stu_info.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <view class="content">
  3. <view class="" v-if="childList.length>0">
  4. <view class="top_bg">
  5. <view class="title">学员信息</view>
  6. <view class="name">
  7. <picker mode="selector" :range="childList" @change="changeChild" :range-key="'name'">
  8. <view class="name">{{childName}}
  9. <u-icon name="arrow-down-fill" color="#FF8F09" size="30" class="icon"></u-icon>
  10. </view>
  11. </picker>
  12. </view>
  13. </view>
  14. <view class="form">
  15. <u-form :model="form">
  16. <u-form-item label="学员名称:" :label-width="190">
  17. <u-input v-model="form.name" placeholder="学员名称" />
  18. </u-form-item>
  19. <u-form-item label="学员性别:" :label-width="190">
  20. <picker mode="selector" :range="sex" @change="change" :range-key="'name'">
  21. <view>{{name}}</view>
  22. </picker>
  23. </u-form-item>
  24. <u-form-item label="手机号码:" :label-width="190">
  25. <u-input v-model="form.mobile" placeholder="手机号码" />
  26. </u-form-item>
  27. <u-form-item label="出生日期:" :label-width="190">
  28. <picker mode="date" value="YYYY-MM-DD" @change="changeDate">
  29. <view>{{form.birthday}}</view>
  30. </picker>
  31. </u-form-item>
  32. </u-form>
  33. </view>
  34. <view class="bt" @click="submit">
  35. 修改
  36. </view>
  37. </view>
  38. <view class="empty" v-else>
  39. <u-empty text="暂无学生信息" mode="favor"></u-empty>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. form: {
  48. name: '',
  49. gender: 0,
  50. mobile: '',
  51. birthday: '',
  52. shop: '',
  53. },
  54. name: '',
  55. sex: [{
  56. id: 0,
  57. name: '女'
  58. },
  59. {
  60. id: 1,
  61. name: '男'
  62. }
  63. ],
  64. show: false,
  65. nums: [],
  66. childList: [], //学生列表
  67. childName: '', //当前选中的孩子名字
  68. dateShow: false
  69. };
  70. },
  71. onLoad() {
  72. this.getChild()
  73. },
  74. onShow() {
  75. },
  76. methods: {
  77. change(e){
  78. //选择性别
  79. let index=e.detail.value
  80. this.name=this.sex[index].name
  81. this.form.gender=index
  82. },
  83. //选择小孩
  84. changeChild(e) {
  85. let index = e.detail.value
  86. this.form = this.childList[index]
  87. this.childName = this.childList[index].name
  88. },
  89. //选择日期
  90. changeDate(e) {
  91. console.log(e, '选择日期')
  92. this.form.birthday = e.detail.value
  93. },
  94. //获取孩子列表
  95. getChild() {
  96. this.$u.get('/child').then(res => {
  97. console.log(res, 'llll')
  98. this.childList = res.data.data
  99. this.childName = this.childList[0].name
  100. this.form = this.childList[0]
  101. let index=this.form.gender
  102. this.name=this.sex[index].name
  103. console.log(index,this.name)
  104. })
  105. },
  106. //保存修改
  107. submit() {
  108. let data = {
  109. name: this.form.name,
  110. mobile: this.form.mobile,
  111. shop_id: this.form.shop_id,
  112. birthday: this.form.birthday,
  113. gender: this.form.gender,
  114. id: this.form.id
  115. }
  116. this.$u.put('/child', data).then(res => {
  117. console.log(res, '提交成功')
  118. if (res.code == 200) {
  119. uni.showToast({
  120. title: '修改成功',
  121. icon: 'none'
  122. })
  123. setTimeout(function() {
  124. uni.switchTab({
  125. url: './mine'
  126. })
  127. }, 1000)
  128. }
  129. })
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss">
  135. page {
  136. background-color: #FFFFFF;
  137. }
  138. .content {
  139. .empty {
  140. margin-top: 40%;
  141. }
  142. .top_bg {
  143. width: 100%;
  144. height: 235px;
  145. background: url(../../static/info_bg1.png);
  146. text-align: center;
  147. .title {
  148. display: block;
  149. width: 100%;
  150. padding-top: 60px;
  151. font-size: 24px;
  152. font-weight: bold;
  153. color: #FF4600;
  154. }
  155. picker {
  156. height: 50px;
  157. }
  158. .name {
  159. margin-top: 20px;
  160. height: 50px;
  161. line-height: 50px;
  162. font-size: 16px;
  163. font-family: PingFang SC;
  164. font-weight: 400;
  165. color: #333333;
  166. opacity: 1;
  167. .icon {
  168. margin-left: 10px;
  169. }
  170. }
  171. }
  172. .form {
  173. background-color: #FFFFFF;
  174. // margin: 0 20px;
  175. margin-top: -30px;
  176. border-radius: 12px;
  177. padding: 0 20px;
  178. }
  179. .bt {
  180. width: 80%;
  181. margin: 0 auto;
  182. margin-top: 40px;
  183. height: 45px;
  184. line-height: 45px;
  185. text-align: center;
  186. font-size: 16px;
  187. font-family: PingFang SC;
  188. font-weight: bold;
  189. border-radius: 22px;
  190. background: linear-gradient(266deg, #FF3B21 0%, #FF8F09 100%);
  191. color: #FFFFFF;
  192. opacity: 1;
  193. }
  194. }
  195. </style>