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.

etc-log-off.vue 6.9KB

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