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.

verification.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. <template>
  2. <view class="oderPage">
  3. <u-form :model="form" ref="myForm" :error-type="errorType">
  4. <view class="from">
  5. <u-form-item prop="cardState">
  6. <view class="from_item">
  7. <text><text style="color: red">*</text>需要更换的设备:</text>
  8. <radio-group @change="radioChange" class="radios">
  9. <block v-for="(item, index) in radiolist1" :key="item.val">
  10. <view class="radio-box">
  11. <radio :value="item.val" :checked="form.applyType == item.val" color="#13e7c1"
  12. style="transform:scale(0.75)" />
  13. <view>{{item.name}}</view>
  14. </view>
  15. </block>
  16. </radio-group>
  17. </view>
  18. </u-form-item>
  19. <u-form-item prop="cardState">
  20. <view class="from_item">
  21. <text><text style="color: red">*</text>设备损坏类型:</text>
  22. <radio-group @change="typeChange" class="radios">
  23. <block v-for="(item, index) in radiolist2" :key="item.val">
  24. <view class="radio-box">
  25. <radio :value="item.val" :checked="form.damageMode == item.val" color="#13e7c1"
  26. style="transform:scale(0.75)" />
  27. <view>{{item.name}}</view>
  28. </view>
  29. </block>
  30. </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. <view style="margin: 30rpx;" v-if="state.isPicture">
  54. <view class="please"><text style="color: red">*</text>请上传图片:</view>
  55. <uni-file-picker fileMediatype="image" mode="grid" :limit="9" @select="select"
  56. :image-styles="state.imageStyles" />
  57. </view>
  58. <view class="btn-wrapper">
  59. <button class="default button" v-if="apply.data.status" @click="changeCardQueryCancleAction()"
  60. type="default">撤回申请</button>
  61. <button class="submit button" v-if="apply.data.status === 'APPLY'||!apply.data.status" @click="toPage()"
  62. type="default">下一步填写资料</button>
  63. </view>
  64. </view>
  65. </template>
  66. <script setup lang="ts">
  67. import navBar from "./components/nav-bar.vue";
  68. import {
  69. checkStr
  70. } from "@/utils/utils";
  71. import {
  72. ref,
  73. reactive
  74. } from "vue";
  75. import {
  76. navTo
  77. } from "@/utils/utils";
  78. import {
  79. onReady,
  80. onLoad,
  81. onShow,
  82. } from "@dcloudio/uni-app";
  83. import {
  84. request
  85. } from "@/utils/network/request.js";
  86. import {
  87. sendCode,
  88. checkCode,
  89. changeCardApply,
  90. changeCardQuery,
  91. changeCardQueryCancle,
  92. fileUpload
  93. } from "@/utils/network/api.js";
  94. import {
  95. stringToJson
  96. } from "@/utils/network/encryption";
  97. import {
  98. msg
  99. } from "@/utils/utils";
  100. import { pathToBase64 } from "@/utils/image-tools/index.js";
  101. const state = reactive({
  102. imageList: [], //图片数据
  103. imageStyles: {
  104. width: 80,
  105. height: 80,
  106. },
  107. isPicture: false, //是否上传图片
  108. })
  109. // 表单数据
  110. const form = reactive({
  111. damageMode: "0",
  112. damageModeName: '人为损坏',
  113. applyType: 'EXCHANGE_CARD',
  114. applyTypeName: '卡',
  115. mobile: "",
  116. code: '',
  117. applyRes: ''
  118. });
  119. const apply = reactive({
  120. data: {
  121. status: undefined,
  122. id: ''
  123. }
  124. });
  125. //入参
  126. const params = reactive({
  127. cardId: '',
  128. obuId: '',
  129. orderId: ''
  130. });
  131. // 单选数据列表
  132. const radiolist1 = reactive([{
  133. name: "卡",
  134. val: "EXCHANGE_CARD",
  135. },
  136. {
  137. name: "OBU",
  138. val: "EXCHANGE_OBU",
  139. }, {
  140. name: "卡和OBU",
  141. val: "EXCHANGE_ALL",
  142. },
  143. ]);
  144. // 单选数据列表
  145. const radiolist2 = reactive([{
  146. name: "人为损坏",
  147. val: "0",
  148. },
  149. {
  150. name: "自然损坏",
  151. val: "1",
  152. }
  153. ]);
  154. // 验证规则
  155. const rules = {
  156. code: [{
  157. required: true,
  158. message: "请输入验证码",
  159. trigger: ["change", "blur"],
  160. }],
  161. };
  162. // 验证提示类型(toast要版本为1.3.5才支持)
  163. const errorType = ["toast"];
  164. // 设置验证规则
  165. const myForm = ref(null);
  166. //倒计时时常
  167. const codeDuration = ref(0);
  168. let interval = null;
  169. /* 验证码倒计时 */
  170. const codeInterval = () => {
  171. codeDuration.value = 60;
  172. interval = setInterval(() => {
  173. codeDuration.value--;
  174. if (codeDuration.value === 0) {
  175. if (interval) {
  176. clearInterval(interval);
  177. interval = null;
  178. }
  179. }
  180. }, 1000);
  181. };
  182. onReady(() => {
  183. myForm.value.setRules(rules);
  184. });
  185. onLoad((option) => {
  186. form.mobile = option.mobile
  187. params.cardId = option.cardId
  188. params.orderId = option.orderId
  189. // changeCardQueryAction().then(val => {
  190. // console.log(val);
  191. // apply.data = val;
  192. // apply.data.status = val.status;
  193. // })
  194. });
  195. onShow(() => {
  196. changeCardQueryAction()
  197. })
  198. const select = (e) => {
  199. console.log('选择文件:', e)
  200. pathToBase64(e.tempFilePaths[0]).then((path) => {
  201. var data = {
  202. fileBase64: path,
  203. };
  204. const options = {
  205. type: 2,
  206. data: data,
  207. method: "POST",
  208. showLoading: true,
  209. };
  210. request(fileUpload, options).then((res) => {
  211. const data = stringToJson(res.bizContent);
  212. const imgArr = state.imageList
  213. imgArr.push(data.data.url)
  214. state.imageList = imgArr;
  215. console.log("data.data.url", state.imageList)
  216. });
  217. })
  218. .catch((error) => { });
  219. }
  220. // 单选
  221. const radioChange = (e : any) => {
  222. console.log(e);
  223. form.applyType = e.detail.value
  224. };
  225. // 单选
  226. const typeChange = (e : any) => {
  227. console.log(e);
  228. form.damageMode = e.detail.value
  229. if (e.detail.value == 1) {
  230. state.isPicture = true
  231. } else {
  232. state.isPicture = false
  233. }
  234. };
  235. const getCode = () => {
  236. if (codeDuration.value !== 0) {
  237. return;
  238. }
  239. const options = {
  240. type: 2,
  241. data: {
  242. mobile: form.mobile
  243. },
  244. method: "POST",
  245. showLoading: true,
  246. };
  247. request(sendCode, options)
  248. .then((res) => {
  249. codeInterval();
  250. msg("验证码发送成功!");
  251. })
  252. .catch((err) => {
  253. console.log(err);
  254. });
  255. }
  256. //查询申请单
  257. const changeCardQueryAction = () => {
  258. var data = {
  259. orderId: params.orderId
  260. };
  261. const options = {
  262. type: 2,
  263. data: data,
  264. method: "POST",
  265. showLoading: true,
  266. };
  267. request(changeCardQuery, options).then((res) => {
  268. const data = stringToJson(res.bizContent);
  269. if (data) {
  270. apply.data = data;
  271. apply.data.status = data.status;
  272. }
  273. })
  274. // return new Promise(async (resolve, reject) => {
  275. // const res = await request(changeCardQuery, options);
  276. // const data = stringToJson(res.bizContent);
  277. // resolve(data);
  278. // }).catch((error) => {
  279. // reject(error);
  280. // });
  281. }
  282. //撤销订单
  283. const changeCardQueryCancleAction = () => {
  284. var data = {
  285. id: apply.data.id,
  286. cancelRes: '取消申请单'
  287. };
  288. const options = {
  289. type: 2,
  290. data: data,
  291. method: "POST",
  292. showLoading: true,
  293. };
  294. return new Promise(async (resolve, reject) => {
  295. const res = await request(changeCardQueryCancle, options);
  296. const data = stringToJson(res.bizContent);
  297. msg('取消申请成功');
  298. uni.navigateBack()
  299. }).catch((error) => {
  300. reject(error);
  301. });
  302. }
  303. //申请
  304. const queryCckChangejzCardAction = () => {
  305. if (form.damageMode == "1") {
  306. if (state.imageList.length == 0) {
  307. msg('请上传图片');
  308. return;
  309. }
  310. }
  311. var data = {
  312. orderId: params.orderId,
  313. applyType: form.applyType,
  314. damageMode: form.damageMode,//0 --- 人为损坏 1 --- 自然损坏 当为换卡签的时候必传
  315. fileUrl: state.imageList.toString()
  316. };
  317. const options = {
  318. type: 2,
  319. data: data,
  320. method: "POST",
  321. showLoading: true,
  322. };
  323. return new Promise(async (resolve, reject) => {
  324. const res = await request(changeCardApply, options);
  325. if (res.bizContent.indexOf("/") !== -1) {
  326. var resultData = stringToJson(res.bizContent);
  327. } else {
  328. var resultData = res.bizContent
  329. }
  330. console.log("data88888", JSON.parse(resultData))
  331. resolve(JSON.parse(resultData));
  332. }).catch((error) => {
  333. reject(error);
  334. });
  335. }
  336. //下一步
  337. const toPage = () => {
  338. // myForm.value.validate((valid) => {
  339. // if (valid) {
  340. // const options = {
  341. // type: 2,
  342. // data: {
  343. // mobile: form.mobile,
  344. // code: form.code
  345. // },
  346. // method: "POST",
  347. // showLoading: true,
  348. // };
  349. // request(checkCode, options)
  350. // .then(() => {
  351. if (apply.data.status === 'APPLY') {
  352. navTo(
  353. `/subpackage/after-sale/replace-equipment/form?orderId=${params.orderId}&&id=${apply.data.id}`
  354. )
  355. } else {
  356. // if (form.applyTypeName === '卡') {
  357. // form.applyType = 'EXCHANGE_CARD'
  358. // } else if (form.applyTypeName === 'OBU') {
  359. // form.applyType = 'EXCHANGE_OBU'
  360. // } else if (form.applyTypeName === '卡和OBU') {
  361. // form.applyType = 'EXCHANGE_ALL'
  362. // }
  363. // if (form.damageModeName === '人为损坏') {
  364. // form.damageMode = '0'
  365. // } else if (form.damageModeName === '自然损坏') {
  366. // form.damageMode = '1'
  367. // }
  368. queryCckChangejzCardAction().then(val => {
  369. console.log("val888888", val.id)
  370. // if(!val.id){
  371. // msg("已存在对应的申请单");
  372. // }else{
  373. navTo(
  374. `/subpackage/after-sale/replace-equipment/form?orderId=${params.orderId}&&id=${val.id}`
  375. )
  376. // }
  377. })
  378. }
  379. // })
  380. // .catch((err) => {
  381. // console.log(err);
  382. // });
  383. // } else {
  384. // console.log("验证未通过");
  385. // }
  386. // });
  387. };
  388. </script>
  389. <style>
  390. page {
  391. width: 100%;
  392. height: 100%;
  393. display: flex;
  394. flex-direction: column;
  395. background-color: ##eef7f7;
  396. }
  397. </style>
  398. <style lang="scss" scoped>
  399. .radios {
  400. display: flex;
  401. }
  402. .radio-box {
  403. display: flex;
  404. align-items: center;
  405. padding-left: 20rpx;
  406. }
  407. .hint2 {
  408. display: flex;
  409. .green {
  410. font-size: 28rpx;
  411. color: #00b38b;
  412. }
  413. .grey {
  414. font-size: 24rpx;
  415. color: #000000;
  416. margin-left: 16rpx;
  417. }
  418. }
  419. .oderPage {
  420. flex: 1;
  421. width: 100%;
  422. .from1 {
  423. background-color: #fff;
  424. margin-top: 30rpx;
  425. padding: 0 30rpx;
  426. ::v-deep .uni-forms-item {
  427. border-bottom: 1rpx solid #ccc;
  428. padding: 15rpx 0;
  429. margin-bottom: 0;
  430. .uni-forms-item__label {
  431. font-size: 28rpx;
  432. height: 50rpx;
  433. }
  434. .uni-forms-item__content {
  435. display: flex;
  436. }
  437. .uni-easyinput__content-input {
  438. font-size: 28rpx;
  439. height: 50rpx;
  440. }
  441. }
  442. .btn {
  443. line-height: 38rpx;
  444. font-size: 24rpx;
  445. font-family: Microsoft YaHei;
  446. font-weight: 400;
  447. color: #ffffff;
  448. background: #00b38b;
  449. border-radius: 10rpx;
  450. padding: 10rpx 15rpx;
  451. }
  452. }
  453. .from {
  454. background-color: #fff;
  455. margin-top: 30rpx;
  456. padding: 0 30rpx;
  457. ::v-deep .u-form-item {
  458. padding: 0;
  459. line-height: normal;
  460. .u-form-item__message {
  461. margin-bottom: 12rpx;
  462. }
  463. }
  464. .from_item {
  465. display: flex;
  466. flex-wrap: nowrap;
  467. justify-content: space-between;
  468. align-items: center;
  469. height: 80rpx;
  470. border-bottom: 1rpx solid #dcdcdc;
  471. .btn {
  472. font-size: 24rpx;
  473. font-family: Microsoft YaHei;
  474. font-weight: 400;
  475. color: #ffffff;
  476. background: #00b38b;
  477. border-radius: 10rpx;
  478. padding: 10rpx 15rpx;
  479. }
  480. ::v-deep .input {
  481. text-align: left;
  482. flex: 1;
  483. background: transparent;
  484. input {
  485. text-align: left;
  486. }
  487. }
  488. }
  489. .from_item1 {
  490. display: flex;
  491. flex-wrap: nowrap;
  492. flex-direction: column;
  493. justify-content: space-between;
  494. padding: 30rpx;
  495. border-bottom: #dcdcdc 1px solid;
  496. input {
  497. text-align: right;
  498. }
  499. .textarea {
  500. background-color: #f1f1f1;
  501. width: 100%;
  502. border-radius: 20rpx;
  503. margin-top: 10rpx;
  504. text-indent: 1rem;
  505. height: 180rpx;
  506. padding: 20rpx;
  507. box-sizing: border-box;
  508. }
  509. }
  510. }
  511. }
  512. .btn-wrapper {
  513. display: flex;
  514. padding-top: 60rpx;
  515. }
  516. .button::after {
  517. border: none;
  518. }
  519. .default {
  520. height: 80rpx;
  521. background: rgba(0, 179, 139, .1);
  522. border-radius: 40rpx;
  523. font-size: 32rpx;
  524. font-weight: 400;
  525. color: #00B38B;
  526. line-height: 80rpx;
  527. width: 45%;
  528. border: 1px solid #00B38B;
  529. }
  530. .submit {
  531. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  532. height: 80rpx;
  533. line-height: 80rpx;
  534. color: #fff;
  535. border-radius: 100rpx;
  536. font-size: 32rpx;
  537. width: 45%;
  538. }
  539. .upload-img {
  540. margin-top: 10rpx;
  541. }
  542. .please {
  543. font-size: 28rpx;
  544. margin-bottom: 20rpx;
  545. }
  546. </style>