people.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="pages">
  3. <view class="" :style="{height: navHeight+'px' }"></view>
  4. <!-- 自定义导航 -->
  5. <view class="navbar-box">
  6. <u-navbar title="信息填写" :safeAreaInsetTop="true" @leftClick="leftClick"></u-navbar>
  7. </view>
  8. <view class="page-wrap">
  9. <view class="form-wrap">
  10. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" labelWidth="120rpx" >
  11. <u-form-item label="姓名" prop="name" borderBottom>
  12. <u--input v-model="form.name" placeholder="与证件名字一致" border="none"></u--input>
  13. </u-form-item>
  14. <u-form-item label="身份证" prop="sfz" borderBottom>
  15. <u--input v-model="form.sfz" placeholder="身份证号码" border="none"></u--input>
  16. </u-form-item>
  17. <u-form-item label="手机号" prop="mobile" borderBottom>
  18. <u--input v-model="form.mobile" placeholder="常用手机号" border="none"></u--input>
  19. </u-form-item>
  20. </u--form>
  21. <view class="set-default u-flex u-row-between">
  22. <view class="left">
  23. <view class="up">设置为默认信息</view>
  24. <view class="down">提醒:每次下单会默认使用该信息</view>
  25. </view>
  26. <view class="right">
  27. <u-switch v-model="form.default" activeValue='1' inactiveValue='0'></u-switch>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="btn-wrap">
  32. <view class="full-btn" @click="submit">保存</view>
  33. <view class="full-btn white" @click="cancel">取消</view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import { systemInfo } from "@/mixin.js";
  40. export default {
  41. mixins:[systemInfo],
  42. data() {
  43. return {
  44. id:'',
  45. type:'',
  46. fromPage:'',
  47. form: {
  48. name: '',
  49. sfz:'',
  50. mobile:'',
  51. default:'0',
  52. },
  53. rules: {
  54. 'name': [
  55. {
  56. type: 'string',
  57. required: true,
  58. message: '请填写姓名',
  59. trigger: ['blur', 'change']
  60. }
  61. ],
  62. 'sfz': [
  63. {
  64. type: 'string',
  65. required: true,
  66. message: '请输入身份证',
  67. trigger: ['blur', 'change']
  68. },
  69. {
  70. validator: (rule, value, callback) => {
  71. // 上面有说,返回true表示校验通过,返回false表示不通过
  72. // this.$u.test.mobile()就是返回true或者false的
  73. return this.$u.test.idCard(value);
  74. },
  75. message: '请输入正确身份证',
  76. // 触发器可以同时用blur和change
  77. trigger: ['change', 'blur'],
  78. }
  79. ],
  80. mobile: [
  81. {
  82. type: 'string',
  83. required: true,
  84. message: '请输入手机号',
  85. trigger: ['blur', 'change']
  86. },
  87. {
  88. validator: (rule, value, callback) => {
  89. // 上面有说,返回true表示校验通过,返回false表示不通过
  90. // this.$u.test.mobile()就是返回true或者false的
  91. return this.$u.test.mobile(value);
  92. },
  93. message: '请输入正确手机号',
  94. // 触发器可以同时用blur和change
  95. trigger: ['change', 'blur'],
  96. }
  97. ],
  98. },
  99. }
  100. },
  101. onLoad(page) {
  102. this.getSystemInfo();
  103. this.type = page.type;
  104. this.fromPage = page.fromPage;
  105. this.id = page.id;
  106. },
  107. onReady() {
  108. this.$refs.uForm.setRules(this.rules)
  109. },
  110. methods: {
  111. leftClick() {
  112. let canNavBack = getCurrentPages();
  113. if(canNavBack && canNavBack.length>1) {
  114. uni.navigateBack({
  115. delta: 1
  116. });
  117. } else {
  118. history.back();
  119. }
  120. },
  121. submit() {
  122. this.$refs.uForm.validate().then(res => {
  123. uni.$u.toast('表单校验失败')
  124. }).catch(errors => {
  125. uni.$u.toast('表单校验失败')
  126. })
  127. },
  128. cancel(){
  129. this.leftClick();
  130. }
  131. }
  132. }
  133. </script>
  134. <style>
  135. page{
  136. background-color: #F4F5F7;
  137. }
  138. </style>
  139. <style lang="scss" scoped>
  140. .form-wrap{
  141. background: #FFFFFF;
  142. box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(226,226,226,0.5);
  143. border-radius: 24rpx;
  144. margin-bottom: 70rpx;
  145. padding: 10rpx 40rpx 24rpx;
  146. }
  147. .set-default{
  148. padding-top: 26rpx;
  149. .up{
  150. font-size: 28rpx;
  151. font-weight: 500;
  152. color: #606060;
  153. line-height: 42rpx;
  154. margin-bottom: 20rpx;
  155. }
  156. .down{
  157. font-size: 24rpx;
  158. font-weight: 400;
  159. color: #7F7F7F;
  160. line-height: 36rpx;
  161. }
  162. }
  163. </style>