upBasic.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <mobile-frame>
  3. <view class="info">
  4. <view class="one">
  5. <uni-forms ref="form" :modelValue="form" :rules="rules" label-width="auto">
  6. <uni-forms-item label="头像" name="logo">
  7. <upload :list="logo" name="logo" :count="1" @uplSuc="uplSuc" @uplDel="uplDel"></upload>
  8. </uni-forms-item>
  9. <uni-forms-item label="真实姓名" name="name">
  10. <uni-easyinput type="text" v-model="form.name" placeholder="请输入真实姓名" />
  11. </uni-forms-item>
  12. <uni-forms-item label="性别" name="gender">
  13. <picker @change="genderChange" name="gender" :value="form.gender" :range="genderList"
  14. range-key="label">
  15. <view class="uni-input">{{form.zhGender||'请选择性别'}}</view>
  16. </picker>
  17. </uni-forms-item>
  18. <uni-forms-item label="生日" name="date">
  19. <picker mode="date" :value="form.date" name="date" :start="startDate" :end="endDate"
  20. @change="bindDateChange">
  21. <view class="uni-input">{{form.date||'请选择日期'}}</view>
  22. </picker>
  23. </uni-forms-item>
  24. <uni-forms-item label="QQ号" name="QQ">
  25. <uni-easyinput type="text" v-model="form.qq" placeholder="请输入QQ号" />
  26. </uni-forms-item>
  27. <uni-forms-item label="昵称" name="Nname">
  28. <uni-easyinput type="text" v-model="form.Nname" placeholder="请输入昵称" />
  29. </uni-forms-item>
  30. </uni-forms>
  31. <view class="btn">
  32. <button type="primary" @click="onSubmit('form')" size="small">提交</button>
  33. <view class="name">提示:为了您的账户安全,建议定期修改密码</view>
  34. </view>
  35. </view>
  36. </view>
  37. </mobile-frame>
  38. </template>
  39. <script>
  40. import upload from '@/components/upload/index.vue';
  41. export default {
  42. components: {
  43. upload
  44. },
  45. data() {
  46. return {
  47. frameStyle: {
  48. useBar: false
  49. },
  50. form: {},
  51. rules: {
  52. name: {
  53. rules: [{
  54. required: true,
  55. errorMessage: '请输入真实姓名',
  56. }]
  57. },
  58. num: {
  59. rules: [{
  60. required: true,
  61. errorMessage: '请输入邮箱验证码',
  62. }]
  63. },
  64. },
  65. genderList: [{
  66. label: '保密',
  67. value: '0'
  68. },
  69. {
  70. label: '男',
  71. value: '1'
  72. },
  73. {
  74. label: '女',
  75. value: '2'
  76. },
  77. ],
  78. logo: []
  79. };
  80. },
  81. onLoad: function(e) {
  82. },
  83. onShow: function() {},
  84. methods: {
  85. toPath(e) {
  86. if (e && e.route) uni.redirectTo({
  87. url: `/${e.route}`
  88. })
  89. },
  90. // 图片上传
  91. uplSuc(e) {
  92. const that = this;
  93. console.log(e);
  94. that.$set(that, `${e.name}`, [...that[e.name], e.data]);
  95. },
  96. // 图片删除
  97. uplDel(e) {
  98. const that = this;
  99. console.log(e);
  100. let data = that[e.name];
  101. let arr = data.filter((i, index) => index != e.data.index);
  102. that.$set(that, `${e.name}`, arr)
  103. },
  104. // 选择性别
  105. genderChange(e) {
  106. const that = this;
  107. let data = that.genderList[e.detail.value];
  108. if (data) {
  109. that.$set(that.form, `gender`, data.value);
  110. that.$set(that.form, `zhGender`, data.label);
  111. }
  112. },
  113. // 选择日期
  114. bindDateChange(e) {
  115. // this.date = e.detail.value
  116. const that = this;
  117. that.$set(that.form, `date`, e.detail.value);
  118. },
  119. // 提交保存
  120. onSubmit() {
  121. const that = this;
  122. let data = that.form;
  123. data.logo = that.logo;
  124. console.log(data);
  125. // this.$refs.form.validate().then(async (res) => {
  126. // let arr;
  127. // if (data._id) {
  128. // arr = await that.$api(``, 'POST', data)
  129. // } else {
  130. // arr = await that.$api(``, 'POST', data)
  131. // }
  132. // if (arr.errcode == '0') {
  133. // uni.showToast({
  134. // title: `维护信息成功`,
  135. // icon: 'success',
  136. // duration: 2000
  137. // });
  138. // that.back()
  139. // } else {
  140. // uni.showToast({
  141. // title: arr.errmsg,
  142. // icon: 'error',
  143. // duration: 2000
  144. // })
  145. // }
  146. // })
  147. },
  148. }
  149. }
  150. </script>
  151. <style lang="scss">
  152. .info {
  153. display: flex;
  154. flex-direction: column;
  155. width: 100vw;
  156. height: 100vh;
  157. .one {
  158. padding: 2vw;
  159. .uni-input {
  160. border: #f1f1ff 1px solid;
  161. padding: 2vw 2vw;
  162. border-radius: 1vw;
  163. }
  164. .btn {
  165. text-align: center;
  166. button {
  167. margin: 0 2vw 2vw 2vw;
  168. background-color: var(--ff0Color);
  169. color: var(--fffColor);
  170. }
  171. .name {
  172. color: var(--f85Color);
  173. font-size: var(--font14Size);
  174. }
  175. }
  176. }
  177. }
  178. .uni-forms-item {
  179. margin-bottom: 6vw !important;
  180. display: flex;
  181. flex-direction: row;
  182. }
  183. </style>