Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

detail.vue 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="top-hint">
  3. <view class="txt">
  4. <image :src="`${$imgUrl}common/icon-tips.png`" mode="aspectFill" class="imgs"></image>
  5. <view>
  6. <text>温馨提示:</text>
  7. <view class="grey-txt">1. ETC挂失业务用于车辆丢失,为确保车主ETC权益,需对ETC设备进行挂失。</view>
  8. <view class="grey-txt">2. 挂失/解挂操作需要4个小时才生效。</view>
  9. </view>
  10. </view>
  11. </view>
  12. <vehicleDetail style="margin-top: -20rpx;" ref="vehicleDetailRef" :vehicleId="state.vehicleId" @getVehicleDetail="getVehicleDetail"></vehicleDetail>
  13. <view class="main-block">
  14. <u-form :model="state.formData" ref="myForm" label-position="left">
  15. <view class="from">
  16. <u-form-item prop="phone">
  17. <view class="from_item" style="background-color: #f7f7f7">
  18. <text><text style="color: red"></text>手机号:</text>
  19. <u-input v-model="state.vehicleInfo.customerTel" :disabled="true" class="input" />
  20. </view>
  21. </u-form-item>
  22. <u-form-item prop="code">
  23. <view class="from_item">
  24. <text><text style="color: red"></text>验证码:</text>
  25. <u-input v-model="state.formData.code" placeholder="请输入验证码" class="input" type="number" />
  26. <view class="hint2">
  27. <view class="green">{{ codeDuration === 0 ? "" : codeDuration }}</view>
  28. <view class="grey" @click="getCode">{{ codeDuration === 0 ? "发送验证码" : "秒后可重发" }}</view>
  29. </view>
  30. </view>
  31. </u-form-item>
  32. </view>
  33. </u-form>
  34. </view>
  35. <view class="action" v-if="state.flag">
  36. <button type="default" class="ui-btn" @click="submit">
  37. {{ state.lossOrUndo ? '卡签挂失' : '解除挂失' }}
  38. </button>
  39. </view>
  40. </template>
  41. <script lang="ts" setup>
  42. import { reactive, ref } from "vue";
  43. import { onLoad, onShow } from "@dcloudio/uni-app";
  44. import { confirm, msg } from "@/utils/utils";
  45. import { sendMessage, cardLossUndo } from '@/utils/network/api.js'
  46. import { requestNew } from "@/utils/network/request.js";
  47. import vehicleDetail from '@/components/vehicle-detail/vehicle-detail.vue'
  48. const state = reactive({
  49. vehicleId: '',
  50. orderInfo: {
  51. },
  52. vehicleInfo: {
  53. customerName: '',
  54. customerIdType: '',
  55. customerIdNum: '',
  56. vehicleId: '',
  57. type: '',
  58. cardId: '',
  59. cardType: '',
  60. cardStatus: '',
  61. cardExpireTime: '',
  62. obuId: '',
  63. obuStatus: '',
  64. obuExpireTime: '',
  65. customerTel: ''
  66. },
  67. renewalStatus: '0',
  68. formData: {
  69. code: '',
  70. },
  71. lossOrUndo: true, // true: 挂失 false: 解挂
  72. flag: false // 是否可以操作挂失与解挂
  73. });
  74. const codeDuration = ref(0);
  75. const vehicleDetailRef = ref(null)
  76. let interval = null;
  77. onLoad(({vehicleId}) => {
  78. if (vehicleId) {
  79. state.vehicleId = decodeURIComponent(vehicleId)
  80. }
  81. });
  82. onShow(() => {
  83. });
  84. const submit = () => {
  85. if (!state.formData.code) {
  86. msg(`请填写验证码`);
  87. return false
  88. }
  89. confirm(`是否确认${state.lossOrUndo ? "卡签挂失" : "解除挂失"}?`, () => {
  90. let params = {
  91. businessType: state.lossOrUndo ? 3 : 6,
  92. cardId: state.vehicleInfo.cardId,
  93. code: state.formData.code,
  94. customerTel: state.vehicleInfo.customerTel,
  95. vehicleId: state.vehicleInfo.vehicleId,
  96. obuId: state.vehicleInfo.obuId
  97. }
  98. let options = {
  99. type: 2,
  100. data: params,
  101. method: "POST",
  102. showLoading: true,
  103. };
  104. requestNew(cardLossUndo, options).then(() => {
  105. msg(`${state.lossOrUndo ? "卡签挂失" : "解除挂失"}成功!`);
  106. vehicleDetailRef.value.updateInfo()
  107. })
  108. })
  109. }
  110. // 获取车辆详情
  111. const getVehicleDetail = (res) => {
  112. state.vehicleInfo = res
  113. if (state.vehicleInfo.cardStatus === 'KGS' || state.vehicleInfo.obuStatus === 'BQGS') {
  114. state.flag = true
  115. state.lossOrUndo = false
  116. } else if (state.vehicleInfo.cardStatus == 'ZC' && state.vehicleInfo.obuStatus == 'ZC') {
  117. state.flag = true
  118. state.lossOrUndo = true
  119. } else {
  120. state.flag = false
  121. }
  122. }
  123. const getCode = () => {
  124. if (codeDuration.value !== 0) {
  125. return;
  126. }
  127. const options = {
  128. type: 2,
  129. data: {
  130. mobile: state.vehicleInfo.customerTel,
  131. businessType: 5
  132. },
  133. method: "POST",
  134. showLoading: true,
  135. };
  136. requestNew(sendMessage, options)
  137. .then(() => {
  138. codeInterval();
  139. msg("验证码发送成功!");
  140. })
  141. .catch((err) => {
  142. console.log(err);
  143. });
  144. }
  145. /* 验证码倒计时 */
  146. const codeInterval = () => {
  147. codeDuration.value = 60;
  148. interval = setInterval(() => {
  149. codeDuration.value--;
  150. if (codeDuration.value === 0) {
  151. if (interval) {
  152. clearInterval(interval);
  153. interval = null;
  154. }
  155. }
  156. }, 1000);
  157. };
  158. </script>
  159. <style lang="scss" scoped>
  160. .main-block {
  161. background-color: white;
  162. margin: 20rpx 30rpx 0 30rpx;
  163. border-radius: 12px;
  164. border: 1px solid #FFFFFF;
  165. padding: 20rpx;
  166. overflow: hidden;
  167. .title {
  168. font-weight: bold;
  169. font-size: 30rpx;
  170. color: #01243A;
  171. margin-bottom: 12rpx;
  172. }
  173. }
  174. .renwal-type{
  175. justify-content: space-around;
  176. }
  177. .action {
  178. position: absolute;
  179. left: 0;
  180. height: 270rpx;
  181. background-color: #fff;
  182. border-radius: 30rpx 30rpx 0 0;
  183. width: 100vw;
  184. display: flex;
  185. align-items: center;
  186. justify-content: space-evenly;
  187. flex-direction: column;
  188. margin-top: 20rpx;
  189. }
  190. .from {
  191. ::v-deep .u-form-item {
  192. padding: 0;
  193. line-height: normal;
  194. .u-form-item__message {
  195. margin-bottom: 12rpx;
  196. }
  197. }
  198. .from_item {
  199. display: flex;
  200. flex-wrap: nowrap;
  201. justify-content: space-between;
  202. align-items: center;
  203. height: 80rpx;
  204. border-bottom: 1rpx solid #dcdcdc;
  205. padding: 0 24rpx;
  206. .btn {
  207. font-size: 24rpx;
  208. font-family: Microsoft YaHei;
  209. font-weight: 400;
  210. color: #ffffff;
  211. background: #00b38b;
  212. border-radius: 10rpx;
  213. padding: 10rpx 15rpx;
  214. }
  215. ::v-deep .input {
  216. text-align: left;
  217. flex: 1;
  218. background: transparent;
  219. input {
  220. text-align: left;
  221. }
  222. }
  223. .hint2{
  224. width: 180rpx;
  225. display: flex;
  226. align-items: center;
  227. }
  228. }
  229. }
  230. </style>