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.

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