information.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view style="padding-top: 30rpx;">
  3. <view class="paybox">
  4. <view class="paybox_title">
  5. <image src="../../static/team/user.png" mode="widthFix" style="width: 52rpx;margin-right: 20rpx;" />
  6. 确认收货人信息
  7. </view>
  8. <view class="paybox-top">
  9. <view class="title">
  10. <text>收货人</text>
  11. <text class="star">*</text>
  12. </view>
  13. <input v-model="address.username" type="text" class="paybox-input" placeholder-class="input_placeholder" placeholder="请填写真实姓名" />
  14. </view>
  15. <view class="paybox-top">
  16. <view class="title">
  17. <text>手机号</text>
  18. <text class="star">*</text>
  19. </view>
  20. <input v-model="address.mobile" type="number" class="paybox-input" placeholder-class="input_placeholder" placeholder="请填写手机号码" maxlength="11" />
  21. </view>
  22. <view class="paybox-top">
  23. <view class="title">
  24. <text>省市区</text>
  25. <text class="star">*</text>
  26. </view>
  27. <view class="picker flexB" @tap="choosePicker">
  28. <view :style="{ color: local ? '#333' : '#cbcbcb' }">{{ local ? local : '请选择所在地区' }}</view>
  29. <text class="iconfont iconzhcc_xiangxiajiantou"></text>
  30. </view>
  31. </view>
  32. <view class="paybox-bottom" style="border: none;">
  33. <view class="title">
  34. <text>详细地址</text>
  35. <text class="star">*</text>
  36. </view>
  37. <view class="textpaybox">
  38. <textarea v-model="address.address" type="text" placeholder="请填写详细地址" class="paybox-input" placeholder-class="input_placeholder" />
  39. </view>
  40. </view>
  41. </view>
  42. <view v-if="title" class="toptitle">
  43. 若信息不准确,请手动修改。
  44. </view>
  45. <view class="bottom"><view v-throttle="2000" class="bottom-btn" @click="save">保存地址</view></view>
  46. <w-picker ref="Selector" mode="region" :defaultVal="pickerDefaultVal" themeColor="#F76454" @confirm="onConfirm" />
  47. </view>
  48. </template>
  49. <script>
  50. import WPicker from '@/components/w-picker/w-picker.vue';
  51. import cityData from '@/components/citypicker/city-data/city.js';
  52. import areaData from '@/components/citypicker/city-data/area.js';
  53. import cityPicker from '@/components/citypicker/city-picker.vue';
  54. import provinceData from '@/components/citypicker/city-data/province.js';
  55. import{
  56. GetEnrollUserAddress,
  57. UpdateAddAddress
  58. } from '@/apis/szy.js';
  59. export default {
  60. components: { WPicker, cityPicker },
  61. data() {
  62. return {
  63. local: '',
  64. title: false,
  65. address: {
  66. username: '',
  67. mobile: '',
  68. province: '',
  69. city: '',
  70. area: '',
  71. address: '',
  72. },
  73. pickerDefaultVal: ['河南省', '郑州市', '金水区']
  74. }
  75. },
  76. onLoad() {
  77. this.getAddress()
  78. },
  79. methods: {
  80. // 获取地址信息
  81. getAddress() {
  82. GetEnrollUserAddress().then(res => {
  83. if (res.code === 200) {
  84. if (res.data.province) {
  85. this.address = res.data
  86. const data = res.data
  87. this.local =`${data.province}-${data.city}-${data.area}`
  88. this.pickerDefaultVal = [ data.province, data.city, data.area ]
  89. this.title = true
  90. } else {
  91. this.title = false
  92. }
  93. } else {
  94. uni.showModal({
  95. content: res.message || '获取失败',
  96. showCancel: false
  97. })
  98. }
  99. })
  100. },
  101. choosePicker() {
  102. // 显示地址选择器
  103. this.$refs.Selector.show();
  104. },
  105. onConfirm(e) {
  106. // 选择地址选择器
  107. this.local = `${e.checkArr[0]}-${e.checkArr[1]}-${e.checkArr[2]}`;
  108. this.address.province = e.checkArr[0];
  109. this.address.city = e.checkArr[1];
  110. this.address.area = e.checkArr[2];
  111. },
  112. save() {
  113. console.log(this.address)
  114. // 保存/修改地址
  115. if (!this.address.username.match(/^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/)) {
  116. // 校验姓名
  117. uni.toast('真实姓名不符合要求');
  118. return;
  119. }
  120. if (!this.address.mobile.match(/^1\d{10}$/)) {
  121. // 校验手机号
  122. uni.toast('手机号码不符合要求');
  123. return;
  124. }
  125. if (!this.local.trim().length) {
  126. // 校验是否选择地区
  127. uni.toast('请选择所在地区');
  128. return;
  129. }
  130. if (!this.address.address.trim().length) {
  131. // 校验是否填写详细地址
  132. uni.toast('详细地址不能为空');
  133. return;
  134. }
  135. const address = {
  136. username: this.address.username,
  137. mobile: this.address.mobile,
  138. province: this.address.province,
  139. city: this.address.city,
  140. area: this.address.area,
  141. address: this.address.address,
  142. };
  143. uni.showLoading({ mask: true });
  144. UpdateAddAddress(address).then(res => {
  145. if (res.code === 200) {
  146. uni.toast('保存成功')
  147. } else {
  148. uni.showModal({
  149. content: res.message || '提交失败',
  150. showCancel: false
  151. })
  152. }
  153. })
  154. },
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. .toptitle {
  160. font-size: 32rpx;
  161. font-weight: bold;
  162. color: #FF0000;
  163. margin-top: 54rpx;
  164. text-align: center;
  165. }
  166. .paybox {
  167. margin: 0 24rpx;
  168. background-color: #fff;
  169. border-radius: 24rpx;
  170. &_title {
  171. display: flex;
  172. align-items: center;
  173. font-size: 36rpx;
  174. font-weight: bold;
  175. color: #333333;
  176. padding: 32rpx 0 0 24rpx;
  177. }
  178. &-input {
  179. font-size: 30rpx;
  180. min-height: 126rpx;
  181. width: 75%;
  182. margin-left: 20rpx;
  183. }
  184. &-top {
  185. min-height: 128rpx;
  186. margin: 0 30rpx;
  187. paybox-sizing: border-paybox;
  188. border-bottom: 2rpx solid #eeeeee;
  189. display: flex;
  190. justify-content: flex-start;
  191. align-items: center;
  192. .title {
  193. font-size: 34rpx;
  194. font-weight: bold;
  195. .star {
  196. color: $base-color;
  197. margin-left: 10rpx;
  198. font-size: 40rpx;
  199. }
  200. }
  201. .picker {
  202. width: 75%;
  203. min-height: 128rpx;
  204. margin-left: 20rpx;
  205. font-size: 30rpx;
  206. .iconfont {
  207. color: #cbcbcb;
  208. }
  209. }
  210. .input_placeholder {
  211. font-size: 30rpx;
  212. color: #cbcbcb;
  213. }
  214. }
  215. &-bottom {
  216. height: 166rpx;
  217. padding: 20rpx 30rpx;
  218. paybox-sizing: border-paybox;
  219. border-bottom: 2rpx solid #eeeeee;
  220. display: flex;
  221. justify-content: flex-start;
  222. align-items: flex-start;
  223. .title {
  224. font-size: 34rpx;
  225. font-weight: bold;
  226. .star {
  227. color: $base-color;
  228. margin-left: 10rpx;
  229. font-size: 40rpx;
  230. }
  231. }
  232. .input_placeholder {
  233. font-size: 30rpx;
  234. color: #cbcbcb;
  235. }
  236. .textpaybox {
  237. height: 166rpx;
  238. .paybox-input {
  239. width: 440rpx;
  240. height: 120rpx;
  241. font-size: 30rpx;
  242. }
  243. }
  244. }
  245. }
  246. .bottom {
  247. position: fixed;
  248. bottom: 0;
  249. width: 100%;
  250. height: 100rpx;
  251. padding: 6rpx 30rpx;
  252. background-color: #fff;
  253. border-top: 1px solid #eeeeee;
  254. &-btn {
  255. color: #fff;
  256. text-align: center;
  257. font-size: 32rpx;
  258. font-weight: bold;
  259. line-height: 88rpx;
  260. height: 88rpx;
  261. background: linear-gradient(90deg, #F30000 0%, #FE4815 100%);
  262. opacity: 1;
  263. border-radius: 44px;
  264. }
  265. }
  266. </style>