orderPlacer.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <view class="">
  3. <view style="padding:30rpx">
  4. <view class="box">
  5. <view class="box-top">
  6. <view class="title">
  7. <text>下单人</text>
  8. <text class="star">*</text>
  9. </view>
  10. <input v-model="buyForm.buy_name" type="text" class="box-input" placeholder-class="input_placeholder"
  11. placeholder="请填写真实姓名" />
  12. </view>
  13. <view class="box-top">
  14. <navigator url="./phone-area" class="phone-area flexB">
  15. <view class="flexS">
  16. <view class="title">
  17. <text class="text">国家/地区</text>
  18. <text class="star">*</text>
  19. </view>
  20. <text class="area">{{areaName}}({{buyForm.buy_code}})</text>
  21. </view>
  22. <text class="icon cuIcon-right"></text>
  23. </navigator>
  24. </view>
  25. <view class="box-top">
  26. <view class="title">
  27. <text>手机号</text>
  28. <text class="star">*</text>
  29. </view>
  30. <input v-model="buyForm.buy_phone" type="number" class="box-input" placeholder-class="input_placeholder"
  31. placeholder="请填写手机号码" maxlength="11" />
  32. </view>
  33. </view>
  34. </view>
  35. <view class="bottom">
  36. <view class="bottom-btn" @tap="save">保存信息</view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. // import {
  42. // _API_AddressAdd,
  43. // _API_AddressUpdata,
  44. // discernAdress
  45. // } from '@/apis/address.js';
  46. import areaList from '@/common/util/phone-area.js'
  47. export default {
  48. data() {
  49. return {
  50. id: '',
  51. message: '',
  52. result: '',
  53. buyForm: {
  54. buy_name: '',
  55. buy_phone: '',
  56. buy_code: '+86', // 手机号地区代码
  57. },
  58. requesting: false,
  59. areaName: '中国大陆', // 手机号地区名称
  60. isMatch: /^[1][3-9]\d{9}$/, //手机号验证
  61. codeList: areaList, //手机号区域选择
  62. };
  63. },
  64. onLoad(option) {
  65. uni.$on('CHOOSEPHONECODE', (name, code, reg, phoneReg) => {
  66. // 监听 chooseArea 事件更新
  67. this.areaName = name; // 修改选择的手机号地区名称
  68. this.buyForm.buy_code = code // 修改选择的手机号地区代码
  69. this.isMatch = phoneReg
  70. })
  71. if (option.data) {
  72. this.buyForm = JSON.parse(decodeURIComponent(option.data))
  73. if (this.buyForm.buy_code) {
  74. let index = this.buyForm.buy_code.indexOf('+')
  75. let code = this.buyForm.buy_code.substring(index + 1)
  76. this.codeList[0].list.map(i => {
  77. if (i.code === Number(code)) {
  78. this.areaName = i.name
  79. this.isMatch = i.phoneReg
  80. }
  81. })
  82. }
  83. }
  84. },
  85. methods: {
  86. save() {
  87. if (this.buyForm.buy_name) {
  88. this.buyForm.buy_name = this.buyForm.buy_name.replace(/\s*/g, '');
  89. }
  90. // 保存/修改地址
  91. if (!this.buyForm.buy_name.match(/^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/)) {
  92. // 校验姓名
  93. uni.showToast({
  94. title: '真实姓名不符合要求',
  95. icon: 'none',
  96. mask: true
  97. });
  98. return;
  99. }
  100. if (!this.buyForm.buy_phone) {
  101. uni.showToast({
  102. title: '手机号码不能为空',
  103. icon: 'none',
  104. mask: true
  105. });
  106. return
  107. }
  108. if (this.isMatch && !this.buyForm.buy_phone.match(this.isMatch)) {
  109. uni.showToast({
  110. title: '手机号所属与区号不一致',
  111. icon: 'none',
  112. mask: true
  113. });
  114. return
  115. }
  116. uni.$emit('orderPlace', this.buyForm)
  117. uni.navigateBack()
  118. }
  119. }
  120. };
  121. </script>
  122. <style>
  123. .input_placeholder {
  124. font-size: 30rpx;
  125. color: #cbcbcb;
  126. }
  127. </style>
  128. <style lang="scss" scoped>
  129. .nav {
  130. padding: 26rpx 20rpx 30rpx 30rpx;
  131. background-color: #fff;
  132. border-radius: 24rpx;
  133. display: flex;
  134. flex-direction: column;
  135. align-items: flex-end;
  136. .discern {
  137. width: 100%;
  138. height: 180rpx;
  139. font-size: 28rpx;
  140. &-placeholder {
  141. color: #c8c8c8;
  142. font-size: 28rpx;
  143. line-height: 44rpx;
  144. }
  145. }
  146. .flex {
  147. display: flex;
  148. view {
  149. width: 128rpx;
  150. height: 64rpx;
  151. font-size: 28rpx;
  152. border-radius: 32rpx;
  153. }
  154. }
  155. &-button {
  156. color: #ffffff;
  157. background: linear-gradient(90deg, #ff232c 0%, #ff571b 100%);
  158. }
  159. &-clearbutton {
  160. background: #fff4f3;
  161. border: 2rpx solid $base-color;
  162. color: $base-color;
  163. margin-right: 15rpx;
  164. }
  165. }
  166. .box {
  167. background-color: #fff;
  168. border-radius: 24rpx;
  169. .phone-area {
  170. width: 100%;
  171. .area {
  172. color: #049E56;
  173. font-weight: bold;
  174. margin-left: 16rpx;
  175. }
  176. .icon {
  177. font-size: 40rpx;
  178. color: #999;
  179. }
  180. }
  181. &-input {
  182. font-size: 30rpx;
  183. min-height: 126rpx;
  184. width: 75%;
  185. margin-left: 20rpx;
  186. }
  187. &-top {
  188. min-height: 128rpx;
  189. margin: 0 30rpx;
  190. box-sizing: border-box;
  191. border-bottom: 2rpx solid #eeeeee;
  192. display: flex;
  193. justify-content: flex-start;
  194. align-items: center;
  195. .title {
  196. font-size: 34rpx;
  197. font-weight: bold;
  198. .star {
  199. color: $base-color;
  200. margin-left: 10rpx;
  201. font-size: 40rpx;
  202. }
  203. }
  204. .picker {
  205. width: 75%;
  206. min-height: 128rpx;
  207. margin-left: 20rpx;
  208. font-size: 30rpx;
  209. .iconfont {
  210. color: #cbcbcb;
  211. }
  212. }
  213. .input_placeholder {
  214. font-size: 30rpx;
  215. color: #cbcbcb;
  216. }
  217. }
  218. &-bottom {
  219. height: 166rpx;
  220. padding: 20rpx 30rpx;
  221. box-sizing: border-box;
  222. border-bottom: 2rpx solid #eeeeee;
  223. display: flex;
  224. justify-content: flex-start;
  225. align-items: flex-start;
  226. .title {
  227. font-size: 34rpx;
  228. font-weight: bold;
  229. .star {
  230. color: $base-color;
  231. margin-left: 10rpx;
  232. font-size: 40rpx;
  233. }
  234. }
  235. .input_placeholder {
  236. font-size: 30rpx;
  237. color: #cbcbcb;
  238. }
  239. .textbox {
  240. height: 166rpx;
  241. .box-input {
  242. width: 440rpx;
  243. height: 120rpx;
  244. font-size: 30rpx;
  245. }
  246. }
  247. }
  248. &-changyong {
  249. height: 110rpx;
  250. padding: 26rpx 20rpx 30rpx 30rpx;
  251. display: flex;
  252. justify-content: space-between;
  253. align-items: center;
  254. .title {
  255. // width: 146rpx;
  256. font-size: 28rpx;
  257. font-weight: 400;
  258. line-height: 29rpx;
  259. color: #585858;
  260. }
  261. .input_placeholder {
  262. font-size: 28rpx;
  263. font-weight: 400;
  264. line-height: 29rpx;
  265. }
  266. .set-used {
  267. margin-right: auto;
  268. color: #ea4a41;
  269. font-size: 30rpx;
  270. }
  271. .set-control {
  272. width: 110rpx;
  273. height: 55rpx;
  274. line-height: 55rpx;
  275. border-radius: 50rpx;
  276. text-align: center;
  277. background: #f8f8f8;
  278. color: #333333;
  279. font-size: 30rpx;
  280. &:nth-last-of-type(1) {
  281. margin-left: 20rpx;
  282. }
  283. &.active {
  284. background: linear-gradient(to right, #f97c55, #f44545) !important;
  285. color: #ffffff !important;
  286. }
  287. }
  288. }
  289. }
  290. .remind {
  291. text-align: center;
  292. color: #fb231f;
  293. font-size: 28rpx;
  294. }
  295. .bottom {
  296. position: fixed;
  297. bottom: 0;
  298. width: 100%;
  299. height: 100rpx;
  300. background-color: #fff;
  301. border-top: 1px solid #eeeeee;
  302. @include flex()
  303. &-btn {
  304. width: 702rpx;
  305. color: #fff;
  306. text-align: center;
  307. font-size: 32rpx;
  308. font-weight: bold;
  309. line-height: 88rpx;
  310. height: 88rpx;
  311. background: linear-gradient(93deg, #ff232c 0%, #ff571b 100%);
  312. opacity: 1;
  313. border-radius: 44px;
  314. }
  315. }
  316. </style>