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

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