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

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