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.

go-account.vue 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class='content'>
  3. <view class='content_all'>
  4. <view class="change" @click='change()' v-if='state.isChangeBtn'>切换</view>
  5. <view v-if="state.inputCarNumber">
  6. <view class="car-input">
  7. <view class="title">车牌号</view>
  8. <car-number-input @numberInputResult="carNumber"></car-number-input>
  9. </view>
  10. <u-form :model="form" ref="form1" label-width=180>
  11. <u-form-item label="车牌颜色">
  12. <picker mode="selector" @change="regionConfirmColor" :value="state.indexColor" :range="state.colorList">
  13. <view class="uni-input">{{state.indexColor>=0?state.form.carColor:"请选择"}}</view>
  14. </picker>
  15. </u-form-item>
  16. </u-form>
  17. </view>
  18. <u-form :model="form" ref="form1" label-width=180 v-else>
  19. <u-form-item label="请选择车辆">
  20. <picker mode="selector" @change="regionConfirm" :value="state.index" :range="state.carData">
  21. <view class="uni-input" >{{state.index>=0?state.form.choiceCarVal:"请选择"}}</view>
  22. </picker>
  23. </u-form-item>
  24. <u-form-item label="车牌颜色"><u-input v-model="state.form.carColor" disabled
  25. placeholder='车牌颜色' /></u-form-item>
  26. </u-form>
  27. </view>
  28. <button type="success" class='search' @click='goOpen'>开户</button>
  29. </view>
  30. </template>
  31. <script setup lang="ts">
  32. import { reactive, ref } from "vue";
  33. import { request } from "@/utils/network/request.js";
  34. import { orderList } from "@/utils/network/api.js";
  35. import carNumberInput from "@/components/car-number-input/car-number-input.vue";
  36. import { navTo, msg, hasLogin } from "@/utils/utils";
  37. import { onLoad } from "@dcloudio/uni-app";
  38. import { getItem, StorageKeys } from "@/utils/storage";
  39. import { stringToJson } from "@/utils/network/encryption";
  40. import { vehiclePlateColor } from "@/datas/vehiclePlateColor";
  41. const state = reactive({
  42. indexColor:-1,
  43. index: -1,
  44. carData: [],//车辆数据
  45. colorList: [], //没有注册时车辆颜色
  46. form: {
  47. choiceCarVal: '',
  48. carColor: '',
  49. tel: '',
  50. code: ''
  51. },
  52. vehiclePlate: '', //车牌号
  53. inputCarNumber: false, //是否需要输入车牌号
  54. isChangeBtn: true, //切换按钮是否展示
  55. });
  56. let waitTime = ref(0);
  57. onLoad((option : any) => {
  58. if (!hasLogin()) {
  59. state.isChangeBtn = false;
  60. state.inputCarNumber = true;
  61. }
  62. quanCheckActionTrue();
  63. });
  64. // 选择车牌回调
  65. const regionConfirm = (e : any) => {
  66. // 切割车牌号,获取颜色
  67. console.log("e", e.detail.value,state.carData[e.detail.value].split(' '))
  68. state.index=e.detail.value
  69. state.form.choiceCarVal = state.carData[e.detail.value].split(' ')[0];
  70. state.form.carColor = state.carData[e.detail.value].split(' ')[1]
  71. };
  72. // 选择颜色的回调
  73. const regionConfirmColor = (e : any) => {
  74. console.log(e,state.colorList[e.detail.value])
  75. state.indexColor=e.detail.value
  76. state.form.carColor = state.colorList[e.detail.value]
  77. }
  78. const change = () => {
  79. console.log("11")
  80. state.inputCarNumber = !state.inputCarNumber
  81. state.index=-1
  82. state.indexColor=-1
  83. state.form.choiceCarVal = '';
  84. state.form.carColor = '';
  85. }
  86. const carNumber = (val : any) => {
  87. state.form.choiceCarVal = val;
  88. };
  89. // 去开户页面
  90. const goOpen = () => {
  91. console.log("as", state.form)
  92. if (!state.form.choiceCarVal) {
  93. msg('请选择车辆');
  94. return;
  95. }
  96. navTo(`/subpackage/after-sale/account-recharge/open-account`);
  97. }
  98. const quanCheckActionTrue = () => {
  99. var data = {
  100. opId: getItem(StorageKeys.OpenId),
  101. source: 'WECHAT', //渠道为小程序
  102. tabIndex: '0', //0全部
  103. orderStep: '11', //11 为已完成”
  104. };
  105. const options = {
  106. type: 2,
  107. data: data,
  108. method: "POST",
  109. showLoading: true,
  110. };
  111. request(orderList, options).then((res) => {
  112. let data = stringToJson(res.bizContent).data
  113. // 深拷贝获取全部车牌颜色
  114. let colorArr = JSON.parse(JSON.stringify(vehiclePlateColor))
  115. for (var k = 0; k < colorArr.length; k++) {
  116. state.colorList.push(colorArr[k].color)
  117. }
  118. console.log("state.colorList", state.colorList);
  119. for (var i = 0; i < data.length; i++) {
  120. let strData = '';
  121. strData += data[i].vehiclePlate + " " + getVehiclePlateColor(data[i].vehiclePlateColor);
  122. state.carData.push(strData);
  123. }
  124. console.log("state.carData", state.carData);
  125. })
  126. .catch((err) => {
  127. console.log(err);
  128. });
  129. }
  130. //获取车牌颜色文字
  131. const getVehiclePlateColor = (id : number) => {
  132. const colors = vehiclePlateColor.filter(item => item.id == id);
  133. return colors[0].color
  134. }
  135. </script>
  136. <style scoped>
  137. .content {
  138. background-color: #EEF7F7;
  139. min-height: 100vh;
  140. }
  141. .content_all {
  142. background-color: white;
  143. }
  144. .change {
  145. text-align: right;
  146. padding-right: 20rpx;
  147. font-size: 32rpx;
  148. }
  149. .item {
  150. display: flex;
  151. border-bottom: 2rpx solid rgb(239, 239, 239);
  152. padding: 18rpx 36rpx;
  153. font-size: 32rpx;
  154. align-items: center;
  155. }
  156. /deep/.u-form {
  157. padding: 0 40rpx !important;
  158. }
  159. .btn {
  160. flex: 1;
  161. background: rgb(25, 190, 107);
  162. font-size: 30rpx;
  163. color: white;
  164. z-index: 999;
  165. text-align: center;
  166. border-radius: 10rpx;
  167. }
  168. ::v-deep .u-form-item--right__content__slot {
  169. display: flex;
  170. justify-content: space-between;
  171. }
  172. .title {
  173. margin-top: -32rpx;
  174. font-size: 32rpx;
  175. margin-bottom: 40rpx;
  176. margin-left: 30rpx;
  177. }
  178. .search {
  179. height: 80rpx;
  180. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  181. border-radius: 40rpx;
  182. font-size: 32rpx;
  183. font-weight: 400;
  184. color: #ffffff;
  185. line-height: 80rpx;
  186. margin: 0 30rpx;
  187. margin-top: 70rpx;
  188. }
  189. </style>