您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

verification.vue 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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. </view>
  34. </u-form>
  35. <view style="margin: 30rpx;" v-if="state.isPicture">
  36. <view class="please"><text style="color: red">*</text>请上传图片:</view>
  37. <uni-file-picker fileMediatype="image" mode="grid" :limit="9" @select="select"
  38. :image-styles="state.imageStyles" />
  39. </view>
  40. <view class="attention">
  41. <view>注意事项:</view>
  42. <view>1.设备人为损坏时需要支付设备费用;</view>
  43. <view>2.设备自然损坏时:</view>
  44. <view>&nbsp;(1)更换的设备中有设备不在质保期内,需要支付对应的设备费用;</view>
  45. <view>&nbsp;(2)选择自然损坏需要将损坏的设备寄回,不寄回则视为人为损坏,需要支付设备费用;</view>
  46. <view>&nbsp;(3)寄回的设备由专业人员进行检测,检测结果为自然损坏且在质保期内,则免费更换,检测结果为人为损坏则需要支付设备费用;</view>
  47. <view>3.设备费用,卡20元,obu130元。</view>
  48. </view>
  49. <view class="btn-wrapper">
  50. <button class="submit button" v-if="apply.data.status === 'APPLY'||!apply.data.status" @click="toPage()"
  51. type="default">下一步填写资料</button>
  52. </view>
  53. </view>
  54. </template>
  55. <script setup lang="ts">
  56. import navBar from "./components/nav-bar.vue";
  57. import {
  58. checkStr
  59. } from "@/utils/utils";
  60. import {
  61. ref,
  62. reactive
  63. } from "vue";
  64. import {
  65. navTo, uploadFile
  66. } from "@/utils/utils";
  67. import {
  68. onReady,
  69. onLoad,
  70. onShow,
  71. } from "@dcloudio/uni-app";
  72. import {
  73. request
  74. } from "@/utils/network/request.js";
  75. import {
  76. sendCode,
  77. checkCode,
  78. changeCardApply,
  79. changeCardQuery,
  80. } from "@/utils/network/api.js";
  81. import {
  82. stringToJson
  83. } from "@/utils/network/encryption";
  84. import {
  85. msg
  86. } from "@/utils/utils";
  87. const state = reactive({
  88. imageList: [], //图片数据
  89. imageStyles: {
  90. width: 80,
  91. height: 80,
  92. },
  93. isPicture: false, //是否上传图片
  94. })
  95. // 表单数据
  96. const form = reactive({
  97. damageMode: "0",
  98. damageModeName: '人为损坏',
  99. applyType: 'EXCHANGE_CARD',
  100. applyTypeName: '卡',
  101. mobile: "",
  102. code: '',
  103. applyRes: ''
  104. });
  105. const apply = reactive({
  106. data: {
  107. status: undefined,
  108. id: ''
  109. }
  110. });
  111. //入参
  112. const params = reactive({
  113. cardId: '',
  114. obuId: '',
  115. orderId: ''
  116. });
  117. // 单选数据列表
  118. const radiolist1 = reactive([{
  119. name: "卡",
  120. val: "EXCHANGE_CARD",
  121. },
  122. {
  123. name: "OBU",
  124. val: "EXCHANGE_OBU",
  125. }, {
  126. name: "卡和OBU",
  127. val: "EXCHANGE_ALL",
  128. },
  129. ]);
  130. // 单选数据列表
  131. const radiolist2 = reactive([{
  132. name: "人为损坏",
  133. val: "0",
  134. },
  135. {
  136. name: "自然损坏",
  137. val: "1",
  138. }
  139. ]);
  140. // 验证规则
  141. const rules = {
  142. code: [{
  143. required: true,
  144. message: "请输入验证码",
  145. trigger: ["change", "blur"],
  146. }],
  147. };
  148. // 验证提示类型(toast要版本为1.3.5才支持)
  149. const errorType = ["toast"];
  150. // 设置验证规则
  151. const myForm = ref(null);
  152. //倒计时时常
  153. const codeDuration = ref(0);
  154. let interval = null;
  155. /* 验证码倒计时 */
  156. const codeInterval = () => {
  157. codeDuration.value = 60;
  158. interval = setInterval(() => {
  159. codeDuration.value--;
  160. if (codeDuration.value === 0) {
  161. if (interval) {
  162. clearInterval(interval);
  163. interval = null;
  164. }
  165. }
  166. }, 1000);
  167. };
  168. onReady(() => {
  169. myForm.value.setRules(rules);
  170. });
  171. onLoad((option) => {
  172. form.mobile = option.mobile
  173. params.cardId = option.cardId
  174. params.orderId = option.orderId
  175. });
  176. onShow(() => {
  177. changeCardQueryAction()
  178. })
  179. const select = (e) => {
  180. console.log('选择文件:', e)
  181. uploadFile(e.tempFilePaths[0], "", "").then((data) => {
  182. const imgArr = state.imageList
  183. imgArr.push(data)
  184. state.imageList = imgArr;
  185. console.log("data.data.url", state.imageList)
  186. })
  187. }
  188. // 单选
  189. const radioChange = (e : any) => {
  190. console.log(e);
  191. form.applyType = e.detail.value
  192. };
  193. // 单选
  194. const typeChange = (e : any) => {
  195. console.log(e);
  196. form.damageMode = e.detail.value
  197. if (e.detail.value == 1) {
  198. state.isPicture = true
  199. } else {
  200. state.isPicture = false
  201. }
  202. };
  203. const getCode = () => {
  204. if (codeDuration.value !== 0) {
  205. return;
  206. }
  207. const options = {
  208. type: 2,
  209. data: {
  210. mobile: form.mobile
  211. },
  212. method: "POST",
  213. showLoading: true,
  214. };
  215. request(sendCode, options)
  216. .then((res) => {
  217. codeInterval();
  218. msg("验证码发送成功!");
  219. })
  220. .catch((err) => {
  221. console.log(err);
  222. });
  223. }
  224. //查询申请单
  225. const changeCardQueryAction = () => {
  226. var data = {
  227. orderId: params.orderId
  228. };
  229. const options = {
  230. type: 2,
  231. data: data,
  232. method: "POST",
  233. showLoading: true,
  234. };
  235. request(changeCardQuery, options).then((res) => {
  236. const data = stringToJson(res.bizContent);
  237. if (data) {
  238. apply.data = data;
  239. apply.data.status = data.status;
  240. }
  241. })
  242. }
  243. //申请
  244. const queryCckChangejzCardAction = () => {
  245. if (form.damageMode == "1") {
  246. if (state.imageList.length == 0) {
  247. msg('请上传图片');
  248. return;
  249. }
  250. }
  251. var data = {
  252. orderId: params.orderId,
  253. applyType: form.applyType,
  254. damageMode: form.damageMode,//0 --- 人为损坏 1 --- 自然损坏 当为换卡签的时候必传
  255. fileUrl: state.imageList.toString()
  256. };
  257. const options = {
  258. type: 2,
  259. data: data,
  260. method: "POST",
  261. showLoading: true,
  262. };
  263. return new Promise(async (resolve, reject) => {
  264. const res = await request(changeCardApply, options);
  265. var resultData = res.bizContent
  266. console.log("data88888", JSON.parse(resultData))
  267. resolve(JSON.parse(resultData));
  268. }).catch((error) => {
  269. reject(error);
  270. });
  271. }
  272. //下一步
  273. const toPage = () => {
  274. console.log("sdkchkdscn", apply.data)
  275. // if (apply.data.status === 'APPLY') {
  276. // navTo(
  277. // `/subpackage/after-sale/replace-equipment/form?orderId=${params.orderId}&&id=${apply.data.id}`
  278. // )
  279. // } else {
  280. console.log("form.damageMode", form.damageMode)
  281. queryCckChangejzCardAction().then(val => {
  282. console.log("val888888", val)
  283. navTo(
  284. `/subpackage/after-sale/replace-equipment/form?orderId=${params.orderId}&&id=${val.id}&&damageMode=${form.damageMode}&&msg=${val.msg}&&cardExpire=${val.cardExpire}&&obuExpire=${val.obuExpire}`
  285. )
  286. })
  287. // }
  288. };
  289. </script>
  290. <style>
  291. page {
  292. width: 100%;
  293. height: 100%;
  294. display: flex;
  295. flex-direction: column;
  296. background-color: ##eef7f7;
  297. }
  298. </style>
  299. <style lang="scss" scoped>
  300. .radios {
  301. display: flex;
  302. }
  303. .radio-box {
  304. display: flex;
  305. align-items: center;
  306. padding-left: 20rpx;
  307. }
  308. .hint2 {
  309. display: flex;
  310. .green {
  311. font-size: 28rpx;
  312. color: #00b38b;
  313. }
  314. .grey {
  315. font-size: 24rpx;
  316. color: #000000;
  317. margin-left: 16rpx;
  318. }
  319. }
  320. .oderPage {
  321. flex: 1;
  322. width: 100%;
  323. .from1 {
  324. background-color: #fff;
  325. margin-top: 30rpx;
  326. padding: 0 30rpx;
  327. ::v-deep .uni-forms-item {
  328. border-bottom: 1rpx solid #ccc;
  329. padding: 15rpx 0;
  330. margin-bottom: 0;
  331. .uni-forms-item__label {
  332. font-size: 28rpx;
  333. height: 50rpx;
  334. }
  335. .uni-forms-item__content {
  336. display: flex;
  337. }
  338. .uni-easyinput__content-input {
  339. font-size: 28rpx;
  340. height: 50rpx;
  341. }
  342. }
  343. .btn {
  344. line-height: 38rpx;
  345. font-size: 24rpx;
  346. font-family: Microsoft YaHei;
  347. font-weight: 400;
  348. color: #ffffff;
  349. background: #00b38b;
  350. border-radius: 10rpx;
  351. padding: 10rpx 15rpx;
  352. }
  353. }
  354. .from {
  355. background-color: #fff;
  356. margin-top: 30rpx;
  357. padding: 0 30rpx;
  358. ::v-deep .u-form-item {
  359. padding: 0;
  360. line-height: normal;
  361. .u-form-item__message {
  362. margin-bottom: 12rpx;
  363. }
  364. }
  365. .from_item {
  366. display: flex;
  367. flex-wrap: nowrap;
  368. justify-content: space-between;
  369. align-items: center;
  370. height: 80rpx;
  371. border-bottom: 1rpx solid #dcdcdc;
  372. .btn {
  373. font-size: 24rpx;
  374. font-family: Microsoft YaHei;
  375. font-weight: 400;
  376. color: #ffffff;
  377. background: #00b38b;
  378. border-radius: 10rpx;
  379. padding: 10rpx 15rpx;
  380. }
  381. ::v-deep .input {
  382. text-align: left;
  383. flex: 1;
  384. background: transparent;
  385. input {
  386. text-align: left;
  387. }
  388. }
  389. }
  390. .from_item1 {
  391. display: flex;
  392. flex-wrap: nowrap;
  393. flex-direction: column;
  394. justify-content: space-between;
  395. padding: 30rpx;
  396. border-bottom: #dcdcdc 1px solid;
  397. input {
  398. text-align: right;
  399. }
  400. .textarea {
  401. background-color: #f1f1f1;
  402. width: 100%;
  403. border-radius: 20rpx;
  404. margin-top: 10rpx;
  405. text-indent: 1rem;
  406. height: 180rpx;
  407. padding: 20rpx;
  408. box-sizing: border-box;
  409. }
  410. }
  411. }
  412. }
  413. .btn-wrapper {
  414. display: flex;
  415. padding-top: 60rpx;
  416. }
  417. .button::after {
  418. border: none;
  419. }
  420. .default {
  421. height: 80rpx;
  422. background: rgba(0, 179, 139, .1);
  423. border-radius: 40rpx;
  424. font-size: 32rpx;
  425. font-weight: 400;
  426. color: #00B38B;
  427. line-height: 80rpx;
  428. width: 45%;
  429. border: 1px solid #00B38B;
  430. }
  431. .submit {
  432. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  433. height: 80rpx;
  434. line-height: 80rpx;
  435. color: #fff;
  436. border-radius: 100rpx;
  437. font-size: 32rpx;
  438. width: 45%;
  439. }
  440. .upload-img {
  441. margin-top: 10rpx;
  442. }
  443. .please {
  444. font-size: 28rpx;
  445. margin-bottom: 20rpx;
  446. }
  447. .attention {
  448. padding: 20rpx;
  449. font-size: 28rpx;
  450. }
  451. </style>