You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

additional-equipment-verification.vue 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <view class="oderPage">
  3. <view v-if="form.receiveMethodName==='邮寄'" class="addr-box">
  4. <view class="addr-box-left">
  5. <view class="text-image">{{form.customerName.charAt(0)}} </view>
  6. <view class="content">
  7. <view class="">
  8. <text class="item1">{{form.customerName}}</text>
  9. <text class="item2">{{form.customerTel}}</text>
  10. <text class="item3">默认</text>
  11. </view>
  12. <view class=""> {{form.area +form.address}}</view>
  13. </view>
  14. </view>
  15. <view class="edit">
  16. <image :src="`${$imgUrl}applyCard/edit.png`" mode=""></image>
  17. </view>
  18. </view>
  19. <u-form :model="form" ref="myForm" :error-type="errorType">
  20. <view class="from">
  21. <u-form-item prop="cardState">
  22. <view class="from_item">
  23. <text><text style="color: red">*</text>是否邮寄:</text>
  24. <u-radio-group v-model="form.receiveMethodName">
  25. <u-radio :customStyle="{ marginBottom: '8px' }" activeColor="#2CE242"
  26. v-for="(item, index) in radiolist1" :key="index" :label="item.disabled"
  27. :name="item.name">
  28. {{ item.name }}
  29. </u-radio>
  30. </u-radio-group>
  31. </view>
  32. </u-form-item>
  33. <u-form-item prop="phone">
  34. <view class="from_item" style="background-color: #f7f7f7">
  35. <text><text style="color: red"></text>手机号:</text>
  36. <u-input v-model="form.mobile" :disabled="true" class="input" />
  37. </view>
  38. </u-form-item>
  39. <u-form-item prop="code">
  40. <view class="from_item">
  41. <text><text style="color: red"></text>验证码:</text>
  42. <u-input v-model="form.code" placeholder="请输入验证码" class="input" />
  43. <view class="hint2">
  44. <view class="green">{{ codeDuration === 0 ? "" : codeDuration }}</view>
  45. <view class="grey" @click="getCode">{{
  46. codeDuration === 0 ? "发送验证码" : "秒后可重发"
  47. }}</view>
  48. </view>
  49. </view>
  50. </u-form-item>
  51. </view>
  52. </u-form>
  53. <button style="margin-top: 50rpx;" class="submit" @click="toPage()">OBU增补申请</button>
  54. </view>
  55. </template>
  56. <script setup lang="ts">
  57. import navBar from "./components/nav-bar.vue";
  58. import {
  59. checkStr
  60. } from "@/utils/utils";
  61. import {
  62. ref,
  63. reactive
  64. } from "vue";
  65. import {
  66. navTo
  67. } from "../../utils/utils";
  68. import {
  69. onReady,
  70. onLoad
  71. } from "@dcloudio/uni-app";
  72. import {
  73. request
  74. } from "../../utils/network/request.js";
  75. import {
  76. getItem,
  77. StorageKeys
  78. } from "@/utils/storage";
  79. import {
  80. sendCode,
  81. checkCode,
  82. addressQuery,
  83. queryOBUAdd,
  84. wechatPayConfigId
  85. } from "@/utils/network/api.js";
  86. import {
  87. stringToJson
  88. } from "@/utils/network/encryption";
  89. import {
  90. msg
  91. } from "@/utils/utils";
  92. // 表单数据
  93. const form = reactive({
  94. receiveMethod: "0",
  95. receiveMethodName: '不邮寄',
  96. customerName: '',
  97. customerTel: '',
  98. mobile: "",
  99. code: '',
  100. address: '',
  101. area: '',
  102. postCode: ''
  103. });
  104. const apply = reactive({
  105. data: {
  106. status: undefined,
  107. id: ''
  108. }
  109. });
  110. //入参
  111. const params = reactive({
  112. cardId: '',
  113. obuId: '',
  114. orderId: ''
  115. });
  116. // 单选数据列表
  117. const radiolist1 = reactive([{
  118. name: "不邮寄",
  119. disabled: false,
  120. },
  121. {
  122. name: "邮寄",
  123. disabled: false,
  124. },
  125. ]);
  126. // 单选数据列表
  127. const radiolist2 = reactive([{
  128. name: "人为损坏",
  129. disabled: false,
  130. },
  131. {
  132. name: "自然损坏",
  133. disabled: false,
  134. }
  135. ]);
  136. // 验证规则
  137. const rules = {
  138. code: [{
  139. required: true,
  140. message: "请输入验证码",
  141. trigger: ["change", "blur"],
  142. }],
  143. };
  144. // 验证提示类型(toast要版本为1.3.5才支持)
  145. const errorType = ["toast"];
  146. // 设置验证规则
  147. const myForm = ref(null);
  148. //倒计时时常
  149. const codeDuration = ref(0);
  150. let interval = null;
  151. const address = reactive({
  152. list: []
  153. }); //地址list
  154. /* 验证码倒计时 */
  155. const codeInterval = () => {
  156. codeDuration.value = 60;
  157. interval = setInterval(() => {
  158. codeDuration.value--;
  159. if (codeDuration.value === 0) {
  160. if (interval) {
  161. clearInterval(interval);
  162. interval = null;
  163. }
  164. }
  165. }, 1000);
  166. };
  167. onReady(() => {
  168. myForm.value.setRules(rules);
  169. });
  170. onLoad((option) => {
  171. form.mobile = option.mobile
  172. params.cardId = option.cardId
  173. params.orderId = option.orderId
  174. getAddressList()
  175. });
  176. const getAddressList = () => {
  177. var data = {
  178. openId: getItem(StorageKeys.OpenId),
  179. };
  180. const options = {
  181. type: 2,
  182. data: data,
  183. method: "POST",
  184. showLoading: true,
  185. };
  186. request(addressQuery, options).then((res) => {
  187. const data = stringToJson(res.bizContent);
  188. address.list = data.data;
  189. if (address.list.length > 0) {
  190. var defaultAddress = address.list[0]
  191. form.customerName = defaultAddress.consignee
  192. form.customerTel = defaultAddress.consigneeTel
  193. form.address = defaultAddress.address
  194. form.area = defaultAddress.region
  195. form.postCode = defaultAddress.postalCode
  196. }
  197. });
  198. };
  199. const getCode = () => {
  200. if (codeDuration.value !== 0) {
  201. return;
  202. }
  203. const options = {
  204. type: 2,
  205. data: {
  206. mobile: form.mobile
  207. },
  208. method: "POST",
  209. showLoading: true,
  210. };
  211. request(sendCode, options)
  212. .then((res) => {
  213. codeInterval();
  214. msg("验证码发送成功!");
  215. })
  216. .catch((err) => {
  217. console.log(err);
  218. });
  219. }
  220. //申请
  221. const queryOBUAddAction = () => {
  222. if (form.receiveMethodName === '不邮寄') {
  223. form.receiveMethod = '0'
  224. } else {
  225. form.receiveMethod = '1'
  226. }
  227. var data = {
  228. orderId: params.orderId,
  229. openId: getItem(StorageKeys.OpenId),
  230. configId: wechatPayConfigId,
  231. receiveMethod: form.receiveMethod,
  232. customerName: form.customerName,
  233. customerTel: form.customerTel,
  234. address: form.address,
  235. area: form.area,
  236. postCode: form.postCode
  237. };
  238. const options = {
  239. type: 2,
  240. data: data,
  241. method: "POST",
  242. showLoading: true,
  243. };
  244. return new Promise(async (resolve, reject) => {
  245. const res = await request(queryOBUAdd, options);
  246. const data = stringToJson(res.bizContent);
  247. resolve(data);
  248. }).catch((error) => {
  249. reject(error);
  250. });
  251. }
  252. //下一步
  253. const toPage = () => {
  254. myForm.value.validate((valid) => {
  255. if (valid) {
  256. const options = {
  257. type: 2,
  258. data: {
  259. mobile: form.mobile,
  260. code: form.code
  261. },
  262. method: "POST",
  263. showLoading: true,
  264. };
  265. request(checkCode, options)
  266. .then(() => {
  267. queryOBUAddAction().then(val => {
  268. navTo(
  269. `/after-sale/additional-equipment/result`
  270. )
  271. })
  272. })
  273. .catch((err) => {
  274. console.log(err);
  275. });
  276. } else {
  277. console.log("验证未通过");
  278. }
  279. });
  280. };
  281. </script>
  282. <style>
  283. page {
  284. width: 100%;
  285. height: 100%;
  286. display: flex;
  287. flex-direction: column;
  288. background-color: ##eef7f7;
  289. }
  290. </style>
  291. <style lang="scss" scoped>
  292. .hint2 {
  293. display: flex;
  294. .green {
  295. font-size: 28rpx;
  296. color: #00b38b;
  297. }
  298. .grey {
  299. font-size: 24rpx;
  300. color: #000000;
  301. margin-left: 16rpx;
  302. }
  303. }
  304. .addr-box {
  305. margin-top: 20rpx;
  306. display: flex;
  307. background: #fff;
  308. padding: 30rpx;
  309. justify-content: space-between;
  310. align-items: center;
  311. .addr-box-left {
  312. display: flex;
  313. .text-image {
  314. width: 68rpx;
  315. height: 68rpx;
  316. background: #00b38b;
  317. border-radius: 50%;
  318. text-align: center;
  319. font-size: 26rpx;
  320. font-family: Microsoft YaHei;
  321. font-weight: 400;
  322. color: #ffffff;
  323. line-height: 68rpx;
  324. margin-right: 30rpx;
  325. }
  326. .content {
  327. view {
  328. font-size: 26rpx;
  329. font-family: Microsoft YaHei;
  330. font-weight: 400;
  331. color: #333333;
  332. .item1 {
  333. font-size: 30rpx;
  334. font-family: Microsoft YaHei;
  335. font-weight: 400;
  336. color: #333333;
  337. }
  338. .item2 {
  339. font-size: 24rpx;
  340. font-family: Microsoft YaHei;
  341. font-weight: 400;
  342. color: #999999;
  343. margin-left: 10rpx;
  344. }
  345. .item3 {
  346. width: 71rpx;
  347. height: 37rpx;
  348. background: #ffffff;
  349. border: 1px solid #ff8000;
  350. border-radius: 6rpx;
  351. font-size: 22rpx;
  352. font-family: Microsoft YaHei;
  353. font-weight: 400;
  354. color: #ff8000;
  355. padding: 3rpx 6rpx;
  356. margin-left: 10rpx;
  357. }
  358. }
  359. }
  360. }
  361. .edit {
  362. image {
  363. width: 50rpx;
  364. height: 50rpx;
  365. }
  366. }
  367. }
  368. .oderPage {
  369. flex: 1;
  370. width: 100%;
  371. .from1 {
  372. background-color: #fff;
  373. margin-top: 30rpx;
  374. padding: 0 30rpx;
  375. ::v-deep .uni-forms-item {
  376. border-bottom: 1rpx solid #ccc;
  377. padding: 15rpx 0;
  378. margin-bottom: 0;
  379. .uni-forms-item__label {
  380. font-size: 28rpx;
  381. height: 50rpx;
  382. }
  383. .uni-forms-item__content {
  384. display: flex;
  385. }
  386. .uni-easyinput__content-input {
  387. font-size: 28rpx;
  388. height: 50rpx;
  389. }
  390. }
  391. .btn {
  392. line-height: 38rpx;
  393. font-size: 24rpx;
  394. font-family: Microsoft YaHei;
  395. font-weight: 400;
  396. color: #ffffff;
  397. background: #00b38b;
  398. border-radius: 10rpx;
  399. padding: 10rpx 15rpx;
  400. }
  401. }
  402. .from {
  403. background-color: #fff;
  404. margin-top: 30rpx;
  405. padding: 0 30rpx;
  406. ::v-deep .u-form-item {
  407. padding: 0;
  408. line-height: normal;
  409. .u-form-item__message {
  410. margin-bottom: 12rpx;
  411. }
  412. }
  413. .from_item {
  414. display: flex;
  415. flex-wrap: nowrap;
  416. justify-content: space-between;
  417. align-items: center;
  418. height: 80rpx;
  419. border-bottom: 1rpx solid #dcdcdc;
  420. .btn {
  421. font-size: 24rpx;
  422. font-family: Microsoft YaHei;
  423. font-weight: 400;
  424. color: #ffffff;
  425. background: #00b38b;
  426. border-radius: 10rpx;
  427. padding: 10rpx 15rpx;
  428. }
  429. ::v-deep .input {
  430. text-align: left;
  431. flex: 1;
  432. input {
  433. text-align: left;
  434. }
  435. }
  436. }
  437. .from_item1 {
  438. display: flex;
  439. flex-wrap: nowrap;
  440. flex-direction: column;
  441. justify-content: space-between;
  442. padding: 30rpx;
  443. border-bottom: #dcdcdc 1px solid;
  444. input {
  445. text-align: right;
  446. }
  447. .textarea {
  448. background-color: #f1f1f1;
  449. width: 100%;
  450. border-radius: 20rpx;
  451. margin-top: 10rpx;
  452. text-indent: 1rem;
  453. height: 180rpx;
  454. padding: 20rpx;
  455. box-sizing: border-box;
  456. }
  457. }
  458. }
  459. }
  460. .submit {
  461. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  462. width: 670rpx;
  463. height: 80rpx;
  464. color: #fff;
  465. border-radius: 100rpx;
  466. font-size: 32rpx;
  467. }
  468. </style>