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 9.3KB

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