選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

etc-log-off.vue 6.9KB

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