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

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