Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

verification.vue 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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. <u-radio-group v-model="form.applyTypeName">
  9. <u-radio :customStyle="{ marginBottom: '8px' }" activeColor="#2CE242"
  10. v-for="(item, index) in radiolist1" :key="index" :label="item.disabled"
  11. :name="item.name">
  12. {{ item.name }}
  13. </u-radio>
  14. </u-radio-group>
  15. </view>
  16. </u-form-item>
  17. <u-form-item prop="cardState">
  18. <view class="from_item">
  19. <text><text style="color: red">*</text>设备损坏类型:</text>
  20. <u-radio-group v-model="form.damageModeName">
  21. <u-radio :customStyle="{ marginBottom: '8px' }" activeColor="#2CE242"
  22. v-for="(item, index) in radiolist2" :key="index" :label="item.disabled"
  23. :name="item.name">
  24. {{ item.name }}
  25. </u-radio>
  26. </u-radio-group>
  27. </view>
  28. </u-form-item>
  29. <u-form-item prop="phone">
  30. <view class="from_item" style="background-color: #f7f7f7">
  31. <text><text style="color: red"></text>手机号:</text>
  32. <u-input v-model="form.mobile" :disabled="true" class="input" />
  33. </view>
  34. </u-form-item>
  35. <u-form-item prop="code">
  36. <view class="from_item">
  37. <text><text style="color: red"></text>验证码:</text>
  38. <u-input v-model="form.code" placeholder="请输入验证码" class="input" />
  39. <view class="hint2">
  40. <view class="green">{{ codeDuration === 0 ? "" : codeDuration }}</view>
  41. <view class="grey" @click="getCode">{{
  42. codeDuration === 0 ? "发送验证码" : "秒后可重发"
  43. }}</view>
  44. </view>
  45. </view>
  46. </u-form-item>
  47. </view>
  48. </u-form>
  49. <button class="submit" @click="toPage()">下一步</button>
  50. </view>
  51. </template>
  52. <script setup lang="ts">
  53. import navBar from "./components/nav-bar.vue";
  54. import {
  55. checkStr
  56. } from "@/utils/utils";
  57. import {
  58. ref,
  59. reactive
  60. } from "vue";
  61. import {
  62. navTo
  63. } from "../../utils/utils";
  64. import {
  65. onReady,
  66. onLoad
  67. } from "@dcloudio/uni-app";
  68. import {
  69. request
  70. } from "../../utils/network/request.js";
  71. import {
  72. sendCode,
  73. checkCode,
  74. changeCardApply
  75. } from "@/utils/network/api.js";
  76. import {
  77. stringToJson
  78. } from "@/utils/network/encryption";
  79. import {
  80. msg
  81. } from "@/utils/utils";
  82. // 表单数据
  83. const form = reactive({
  84. damageMode: "",
  85. damageModeName: '人为损坏',
  86. applyType: '',
  87. applyTypeName: '卡',
  88. mobile: "",
  89. code: '',
  90. applyRes: ''
  91. });
  92. //入参
  93. const params = reactive({
  94. cardId: '',
  95. obuId: '',
  96. orderId: ''
  97. });
  98. // 单选数据列表
  99. const radiolist1 = reactive([{
  100. name: "卡",
  101. disabled: false,
  102. },
  103. {
  104. name: "OBU",
  105. disabled: false,
  106. }, {
  107. name: "卡和OBU",
  108. disabled: false,
  109. },
  110. ]);
  111. // 单选数据列表
  112. const radiolist2 = reactive([{
  113. name: "人为损坏",
  114. disabled: false,
  115. },
  116. {
  117. name: "自然损坏",
  118. disabled: false,
  119. }
  120. ]);
  121. // 验证规则
  122. const rules = {
  123. code: [{
  124. required: true,
  125. message: "请输入验证码",
  126. trigger: ["change", "blur"],
  127. }],
  128. };
  129. // 验证提示类型(toast要版本为1.3.5才支持)
  130. const errorType = ["toast"];
  131. // 设置验证规则
  132. const myForm = ref(null);
  133. //倒计时时常
  134. const codeDuration = ref(0);
  135. let interval = null;
  136. /* 验证码倒计时 */
  137. const codeInterval = () => {
  138. codeDuration.value = 60;
  139. interval = setInterval(() => {
  140. codeDuration.value--;
  141. if (codeDuration.value === 0) {
  142. if (interval) {
  143. clearInterval(interval);
  144. interval = null;
  145. }
  146. }
  147. }, 1000);
  148. };
  149. onReady(() => {
  150. myForm.value.setRules(rules);
  151. });
  152. onLoad((option) => {
  153. form.mobile = option.mobile
  154. params.cardId = option.cardId
  155. params.orderId = option.orderId
  156. });
  157. const getCode = () => {
  158. if (codeDuration.value !== 0) {
  159. return;
  160. }
  161. const options = {
  162. type: 2,
  163. data: {
  164. mobile: form.mobile
  165. },
  166. method: "POST",
  167. showLoading: true,
  168. };
  169. request(sendCode, options)
  170. .then((res) => {
  171. codeInterval();
  172. msg("验证码发送成功!");
  173. })
  174. .catch((err) => {
  175. console.log(err);
  176. });
  177. }
  178. //申请
  179. const queryCckChangejzCardAction = () => {
  180. var data = {
  181. orderId: params.orderId,
  182. applyType: form.applyType,
  183. damageMode: form.damageMode //0 --- 人为损坏 1 --- 自然损坏 当为换卡签的时候必传
  184. };
  185. const options = {
  186. type: 2,
  187. data: data,
  188. method: "POST",
  189. showLoading: true,
  190. };
  191. return new Promise(async (resolve, reject) => {
  192. const res = await request(changeCardApply, options);
  193. const data = stringToJson(res.bizContent);
  194. resolve(data);
  195. }).catch((error) => {
  196. reject(error);
  197. });
  198. }
  199. //下一步
  200. const toPage = () => {
  201. myForm.value.validate((valid) => {
  202. if (valid) {
  203. const options = {
  204. type: 2,
  205. data: {
  206. mobile: form.mobile,
  207. code: form.code
  208. },
  209. method: "POST",
  210. showLoading: true,
  211. };
  212. request(checkCode, options)
  213. .then(() => {
  214. if (form.applyTypeName === '卡') {
  215. form.applyType = 'EXCHANGE_CARD'
  216. } else if (form.applyTypeName === 'OBU') {
  217. form.applyType = 'EXCHANGE_OBU'
  218. } else if (form.applyTypeName === '卡和OBU') {
  219. form.applyType = 'EXCHANGE_ALL'
  220. }
  221. if (form.damageModeName === '人为损坏') {
  222. form.damageMode = '0'
  223. } else if (form.damageModeName === '自然损坏') {
  224. form.damageMode = '1'
  225. }
  226. queryCckChangejzCardAction().then(val => {
  227. navTo(
  228. `/after-sale/replace-equipment/form?orderId=${params.orderId}&&id=${val.id}`
  229. )
  230. })
  231. })
  232. .catch((err) => {
  233. console.log(err);
  234. });
  235. } else {
  236. console.log("验证未通过");
  237. }
  238. });
  239. };
  240. </script>
  241. <style>
  242. page {
  243. width: 100%;
  244. height: 100%;
  245. display: flex;
  246. flex-direction: column;
  247. background-color: ##eef7f7;
  248. }
  249. </style>
  250. <style lang="scss" scoped>
  251. .hint2 {
  252. display: flex;
  253. .green {
  254. font-size: 28rpx;
  255. color: #00b38b;
  256. }
  257. .grey {
  258. font-size: 24rpx;
  259. color: #000000;
  260. margin-left: 16rpx;
  261. }
  262. }
  263. .oderPage {
  264. flex: 1;
  265. width: 100%;
  266. .from1 {
  267. background-color: #fff;
  268. margin-top: 30rpx;
  269. padding: 0 30rpx;
  270. ::v-deep .uni-forms-item {
  271. border-bottom: 1rpx solid #ccc;
  272. padding: 15rpx 0;
  273. margin-bottom: 0;
  274. .uni-forms-item__label {
  275. font-size: 28rpx;
  276. height: 50rpx;
  277. }
  278. .uni-forms-item__content {
  279. display: flex;
  280. }
  281. .uni-easyinput__content-input {
  282. font-size: 28rpx;
  283. height: 50rpx;
  284. }
  285. }
  286. .btn {
  287. line-height: 38rpx;
  288. font-size: 24rpx;
  289. font-family: Microsoft YaHei;
  290. font-weight: 400;
  291. color: #ffffff;
  292. background: #00b38b;
  293. border-radius: 10rpx;
  294. padding: 10rpx 15rpx;
  295. }
  296. }
  297. .from {
  298. background-color: #fff;
  299. margin-top: 30rpx;
  300. padding: 0 30rpx;
  301. ::v-deep .u-form-item {
  302. padding: 0;
  303. line-height: normal;
  304. .u-form-item__message {
  305. margin-bottom: 12rpx;
  306. }
  307. }
  308. .from_item {
  309. display: flex;
  310. flex-wrap: nowrap;
  311. justify-content: space-between;
  312. align-items: center;
  313. height: 80rpx;
  314. border-bottom: 1rpx solid #dcdcdc;
  315. .btn {
  316. font-size: 24rpx;
  317. font-family: Microsoft YaHei;
  318. font-weight: 400;
  319. color: #ffffff;
  320. background: #00b38b;
  321. border-radius: 10rpx;
  322. padding: 10rpx 15rpx;
  323. }
  324. ::v-deep .input {
  325. text-align: left;
  326. flex: 1;
  327. input {
  328. text-align: left;
  329. }
  330. }
  331. }
  332. .from_item1 {
  333. display: flex;
  334. flex-wrap: nowrap;
  335. flex-direction: column;
  336. justify-content: space-between;
  337. padding: 30rpx;
  338. border-bottom: #dcdcdc 1px solid;
  339. input {
  340. text-align: right;
  341. }
  342. .textarea {
  343. background-color: #f1f1f1;
  344. width: 100%;
  345. border-radius: 20rpx;
  346. margin-top: 10rpx;
  347. text-indent: 1rem;
  348. height: 180rpx;
  349. padding: 20rpx;
  350. box-sizing: border-box;
  351. }
  352. }
  353. }
  354. }
  355. .submit {
  356. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  357. width: 670rpx;
  358. height: 80rpx;
  359. color: #fff;
  360. border-radius: 100rpx;
  361. position: fixed;
  362. left: 50%;
  363. transform: translate(-50%);
  364. bottom: 60rpx;
  365. font-size: 32rpx;
  366. }
  367. </style>