Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

verification.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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. console.log("form.damageMode", form.damageMode,form.applyType)
  276. if(form.damageMode==0){
  277. let money=0
  278. if(form.applyType=='EXCHANGE_CARD'){
  279. money=20
  280. }else if(form.applyType=='EXCHANGE_OBU'){
  281. money=130
  282. }else {
  283. money=150
  284. }
  285. uni.showModal({
  286. title: '提示',
  287. content: '费用需要您自理,金额是'+money+'元',
  288. success: function (res) {
  289. if (res.confirm) {
  290. queryCckChangejzCardAction().then(val => {
  291. console.log("val888888", val)
  292. navTo(
  293. `/subpackage/after-sale/replace-equipment/form?orderId=${params.orderId}&&id=${val.id}&&damageMode=${form.damageMode}&&msg=${val.msg}&&cardExpire=${val.cardExpire}&&obuExpire=${val.obuExpire}`
  294. )
  295. })
  296. } else if (res.cancel) {
  297. console.log('用户点击取消');
  298. }
  299. }
  300. });
  301. }else{
  302. queryCckChangejzCardAction().then(val => {
  303. console.log("val888888", val)
  304. navTo(
  305. `/subpackage/after-sale/replace-equipment/form?orderId=${params.orderId}&&id=${val.id}&&damageMode=${form.damageMode}&&msg=${val.msg}&&cardExpire=${val.cardExpire}&&obuExpire=${val.obuExpire}`
  306. )
  307. })
  308. }
  309. };
  310. </script>
  311. <style>
  312. page {
  313. width: 100%;
  314. height: 100%;
  315. display: flex;
  316. flex-direction: column;
  317. background-color: ##eef7f7;
  318. }
  319. </style>
  320. <style lang="scss" scoped>
  321. .radios {
  322. display: flex;
  323. }
  324. .radio-box {
  325. display: flex;
  326. align-items: center;
  327. padding-left: 20rpx;
  328. }
  329. .hint2 {
  330. display: flex;
  331. .green {
  332. font-size: 28rpx;
  333. color: #00b38b;
  334. }
  335. .grey {
  336. font-size: 24rpx;
  337. color: #000000;
  338. margin-left: 16rpx;
  339. }
  340. }
  341. .oderPage {
  342. flex: 1;
  343. width: 100%;
  344. .from1 {
  345. background-color: #fff;
  346. margin-top: 30rpx;
  347. padding: 0 30rpx;
  348. ::v-deep .uni-forms-item {
  349. border-bottom: 1rpx solid #ccc;
  350. padding: 15rpx 0;
  351. margin-bottom: 0;
  352. .uni-forms-item__label {
  353. font-size: 28rpx;
  354. height: 50rpx;
  355. }
  356. .uni-forms-item__content {
  357. display: flex;
  358. }
  359. .uni-easyinput__content-input {
  360. font-size: 28rpx;
  361. height: 50rpx;
  362. }
  363. }
  364. .btn {
  365. line-height: 38rpx;
  366. font-size: 24rpx;
  367. font-family: Microsoft YaHei;
  368. font-weight: 400;
  369. color: #ffffff;
  370. background: #00b38b;
  371. border-radius: 10rpx;
  372. padding: 10rpx 15rpx;
  373. }
  374. }
  375. .from {
  376. background-color: #fff;
  377. margin-top: 30rpx;
  378. padding: 0 30rpx;
  379. ::v-deep .u-form-item {
  380. padding: 0;
  381. line-height: normal;
  382. .u-form-item__message {
  383. margin-bottom: 12rpx;
  384. }
  385. }
  386. .from_item {
  387. display: flex;
  388. flex-wrap: nowrap;
  389. justify-content: space-between;
  390. align-items: center;
  391. height: 80rpx;
  392. border-bottom: 1rpx solid #dcdcdc;
  393. .btn {
  394. font-size: 24rpx;
  395. font-family: Microsoft YaHei;
  396. font-weight: 400;
  397. color: #ffffff;
  398. background: #00b38b;
  399. border-radius: 10rpx;
  400. padding: 10rpx 15rpx;
  401. }
  402. ::v-deep .input {
  403. text-align: left;
  404. flex: 1;
  405. background: transparent;
  406. input {
  407. text-align: left;
  408. }
  409. }
  410. }
  411. .from_item1 {
  412. display: flex;
  413. flex-wrap: nowrap;
  414. flex-direction: column;
  415. justify-content: space-between;
  416. padding: 30rpx;
  417. border-bottom: #dcdcdc 1px solid;
  418. input {
  419. text-align: right;
  420. }
  421. .textarea {
  422. background-color: #f1f1f1;
  423. width: 100%;
  424. border-radius: 20rpx;
  425. margin-top: 10rpx;
  426. text-indent: 1rem;
  427. height: 180rpx;
  428. padding: 20rpx;
  429. box-sizing: border-box;
  430. }
  431. }
  432. }
  433. }
  434. .btn-wrapper {
  435. display: flex;
  436. padding-top: 60rpx;
  437. }
  438. .button::after {
  439. border: none;
  440. }
  441. .default {
  442. height: 80rpx;
  443. background: rgba(0, 179, 139, .1);
  444. border-radius: 40rpx;
  445. font-size: 32rpx;
  446. font-weight: 400;
  447. color: #00B38B;
  448. line-height: 80rpx;
  449. width: 45%;
  450. border: 1px solid #00B38B;
  451. }
  452. .submit {
  453. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  454. height: 80rpx;
  455. line-height: 80rpx;
  456. color: #fff;
  457. border-radius: 100rpx;
  458. font-size: 32rpx;
  459. width: 45%;
  460. }
  461. .upload-img {
  462. margin-top: 10rpx;
  463. }
  464. .please {
  465. font-size: 28rpx;
  466. margin-bottom: 20rpx;
  467. }
  468. .attention {
  469. padding: 20rpx;
  470. font-size: 28rpx;
  471. }
  472. </style>