information.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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" 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. console.log(data)
  91. } else {
  92. this.title = false
  93. }
  94. } else {
  95. uni.showModal({
  96. content: res.message || '获取失败',
  97. showCancel: false
  98. })
  99. }
  100. })
  101. },
  102. choosePicker() {
  103. // 显示地址选择器
  104. this.$refs.Selector.show();
  105. },
  106. onConfirm(e) {
  107. // 选择地址选择器
  108. this.local = `${e.checkArr[0]}-${e.checkArr[1]}-${e.checkArr[2]}`;
  109. this.address.province = e.checkArr[0];
  110. this.address.city = e.checkArr[1];
  111. this.address.area = e.checkArr[2];
  112. },
  113. save() {
  114. console.log(this.address)
  115. // 保存/修改地址
  116. if (!this.address.username.match(/^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/)) {
  117. // 校验姓名
  118. uni.toast('真实姓名不符合要求');
  119. return;
  120. }
  121. if (!this.address.mobile.match(/^1\d{10}$/)) {
  122. // 校验手机号
  123. uni.toast('手机号码不符合要求');
  124. return;
  125. }
  126. if (!this.local.trim().length) {
  127. // 校验是否选择地区
  128. uni.toast('请选择所在地区');
  129. return;
  130. }
  131. if (!this.address.address.trim().length) {
  132. // 校验是否填写详细地址
  133. uni.toast('详细地址不能为空');
  134. return;
  135. }
  136. const address = {
  137. username: this.address.username,
  138. mobile: this.address.mobile,
  139. province: this.address.province,
  140. city: this.address.city,
  141. area: this.address.area,
  142. address: this.address.address,
  143. };
  144. uni.showLoading({ mask: true });
  145. UpdateAddAddress(address).then(res => {
  146. if (res.code === 200) {
  147. uni.toast('保存成功')
  148. uni.navigateBack()
  149. } else {
  150. uni.showModal({
  151. content: res.message || '提交失败',
  152. showCancel: false
  153. })
  154. }
  155. })
  156. },
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .toptitle {
  162. font-size: 32rpx;
  163. font-weight: bold;
  164. color: #FF0000;
  165. margin-top: 54rpx;
  166. text-align: center;
  167. }
  168. .paybox {
  169. margin: 0 24rpx;
  170. background-color: #fff;
  171. border-radius: 24rpx;
  172. &_title {
  173. display: flex;
  174. align-items: center;
  175. font-size: 36rpx;
  176. font-weight: bold;
  177. color: #333333;
  178. padding: 32rpx 0 0 24rpx;
  179. }
  180. &-input {
  181. font-size: 30rpx;
  182. min-height: 126rpx;
  183. width: 75%;
  184. margin-left: 20rpx;
  185. }
  186. &-top {
  187. min-height: 128rpx;
  188. margin: 0 30rpx;
  189. paybox-sizing: border-paybox;
  190. border-bottom: 2rpx solid #eeeeee;
  191. display: flex;
  192. justify-content: flex-start;
  193. align-items: center;
  194. .title {
  195. font-size: 34rpx;
  196. font-weight: bold;
  197. .star {
  198. color: $base-color;
  199. margin-left: 10rpx;
  200. font-size: 40rpx;
  201. }
  202. }
  203. .picker {
  204. width: 75%;
  205. min-height: 128rpx;
  206. margin-left: 20rpx;
  207. font-size: 30rpx;
  208. .iconfont {
  209. color: #cbcbcb;
  210. }
  211. }
  212. .input_placeholder {
  213. font-size: 30rpx;
  214. color: #cbcbcb;
  215. }
  216. }
  217. &-bottom {
  218. height: 166rpx;
  219. padding: 20rpx 30rpx;
  220. paybox-sizing: border-paybox;
  221. border-bottom: 2rpx solid #eeeeee;
  222. display: flex;
  223. justify-content: flex-start;
  224. align-items: flex-start;
  225. .title {
  226. font-size: 34rpx;
  227. font-weight: bold;
  228. .star {
  229. color: $base-color;
  230. margin-left: 10rpx;
  231. font-size: 40rpx;
  232. }
  233. }
  234. .input_placeholder {
  235. font-size: 30rpx;
  236. color: #cbcbcb;
  237. }
  238. .textpaybox {
  239. height: 166rpx;
  240. .paybox-input {
  241. width: 440rpx;
  242. height: 120rpx;
  243. font-size: 30rpx;
  244. }
  245. }
  246. }
  247. }
  248. .bottom {
  249. position: fixed;
  250. bottom: 0;
  251. width: 100%;
  252. height: 100rpx;
  253. padding: 6rpx 30rpx;
  254. background-color: #fff;
  255. border-top: 1px solid #eeeeee;
  256. &-btn {
  257. color: #fff;
  258. text-align: center;
  259. font-size: 32rpx;
  260. font-weight: bold;
  261. line-height: 88rpx;
  262. height: 88rpx;
  263. background: linear-gradient(90deg, #F30000 0%, #FE4815 100%);
  264. opacity: 1;
  265. border-radius: 44px;
  266. }
  267. }
  268. </style>