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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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="车牌颜色"><u-input v-model="state.form.carColor" type="select"
  12. :select-open="state.showColor" @click="state.showColor = true"
  13. placeholder='车牌颜色' /></u-form-item>
  14. </u-form>
  15. </view>
  16. <u-form :model="form" ref="form1" label-width=180 v-else>
  17. <u-form-item label="请选择车辆"><u-input v-model="state.form.choiceCarVal" type="select"
  18. :select-open="state.show" @click="state.show = true" placeholder='请选择车辆' /></u-form-item>
  19. <u-form-item label="车牌颜色"><u-input v-model="state.form.carColor" disabled
  20. placeholder='车牌颜色' /></u-form-item>
  21. </u-form>
  22. </view>
  23. <u-picker mode="selector" :range="state.carData" v-model="state.show" @confirm="regionConfirm"></u-picker>
  24. <u-picker mode="selector" :range="state.colorList" v-model="state.showColor"
  25. @confirm="regionConfirmColor"></u-picker>
  26. <button type="success" class='search' @click='goOpen'>开户</button>
  27. </view>
  28. </template>
  29. <script setup lang="ts">
  30. import { reactive, ref } from "vue";
  31. import { request } from "@/utils/network/request.js";
  32. import { sendCode, orderList } from "@/utils/network/api.js";
  33. import carNumberInput from "@/components/car-number-input/car-number-input.vue";
  34. import { navTo, msg, hasLogin } from "@/utils/utils";
  35. import { onLoad } from "@dcloudio/uni-app";
  36. import { getItem, StorageKeys } from "@/utils/storage";
  37. import { stringToJson } from "@/utils/network/encryption";
  38. import { vehiclePlateColor } from "@/datas/vehiclePlateColor";
  39. const state = reactive({
  40. index: 0,
  41. carData: [],//车辆数据
  42. colorList: [], //没有注册时车辆颜色
  43. form: {
  44. choiceCarVal: '',
  45. carColor: '',
  46. tel: '',
  47. code: ''
  48. },
  49. show: false,
  50. vehiclePlate: '', //车牌号
  51. showPhone: false, //是否展示车牌号
  52. inputCarNumber: false, //是否需要输入车牌号
  53. showColor: 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. const getCode = () => {
  65. console.log(123);
  66. if (state.form.tel) {
  67. sendCodeApi()
  68. codeInterval()
  69. } else {
  70. uni.showToast({
  71. title: '请输入手机号',
  72. icon: 'none'
  73. });
  74. }
  75. }
  76. // 发送验证码
  77. const sendCodeApi = (type) => {
  78. //参数说明
  79. let options = {
  80. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  81. data: {
  82. mobile: state.form.tel
  83. }, //请求参数
  84. method: "POST", //提交方式(默认POST)
  85. showLoading: true, //是否显示加载中(默认显示)
  86. };
  87. //调用方式
  88. request(sendCode, options)
  89. .then((res) => {
  90. let data = stringToJson(res.bizContent)
  91. console.log(data, "#################");
  92. if (data.info == "成功.") {
  93. console.log('######################CCCCCCCCCCCCCCCCC');
  94. }
  95. })
  96. .catch((err) => {
  97. console.log(err);
  98. });
  99. }
  100. //倒计时函数
  101. const codeInterval = () => {
  102. waitTime.value = 60
  103. let timer = setInterval(() => {
  104. if (waitTime.value == 1) {
  105. clearInterval(timer)
  106. }
  107. waitTime.value -= 1
  108. }, 1000)
  109. }
  110. const bindPickerChange = (e) => {
  111. state.index = e.detail.value
  112. }
  113. // 选择车牌回调
  114. const regionConfirm = (e : any) => {
  115. // 切割车牌号,获取颜色
  116. console.log("e", state.carData[e].split(' '))
  117. state.form.choiceCarVal = state.carData[e].split(' ')[0];
  118. state.form.carColor = state.carData[e].split(' ')[1]
  119. state.showPhone = true;
  120. };
  121. // 选择颜色的回调
  122. const regionConfirmColor = (e : any) => {
  123. state.form.carColor = state.colorList[e]
  124. }
  125. const change = () => {
  126. console.log("11")
  127. state.inputCarNumber = !state.inputCarNumber
  128. state.form.choiceCarVal = '';
  129. state.form.carColor = '';
  130. }
  131. const carNumber = (val : any) => {
  132. // state.vehiclePlate = val;
  133. state.form.choiceCarVal = val;
  134. };
  135. // 去开户页面
  136. const goOpen = () => {
  137. console.log("as", state.form)
  138. if (!state.form.choiceCarVal) {
  139. msg('请选择车辆');
  140. return;
  141. }
  142. navTo(`/subpackage/after-sale/account-recharge/open-account`);
  143. }
  144. const quanCheckActionTrue = () => {
  145. var data = {
  146. opId: getItem(StorageKeys.OpenId),
  147. source: 'WECHAT', //渠道为小程序
  148. tabIndex: '0', //0全部
  149. orderStep: '11', //11 为已完成”
  150. };
  151. const options = {
  152. type: 2,
  153. data: data,
  154. method: "POST",
  155. showLoading: true,
  156. };
  157. request(orderList, options).then((res) => {
  158. let data = stringToJson(res.bizContent).data
  159. // 深拷贝获取全部车牌颜色
  160. let colorArr = JSON.parse(JSON.stringify(vehiclePlateColor))
  161. for (var k = 0; k < colorArr.length; k++) {
  162. state.colorList.push(colorArr[k].color)
  163. }
  164. console.log("state.colorList", state.colorList);
  165. for (var i = 0; i < data.length; i++) {
  166. let strData = '';
  167. strData += data[i].vehiclePlate + " " + getVehiclePlateColor(data[i].vehiclePlateColor);
  168. state.carData.push(strData);
  169. }
  170. })
  171. .catch((err) => {
  172. console.log(err);
  173. });
  174. }
  175. //获取车牌颜色文字
  176. const getVehiclePlateColor = (id : number) => {
  177. const colors = vehiclePlateColor.filter(item => item.id == id);
  178. return colors[0].color
  179. }
  180. </script>
  181. <style scoped>
  182. .content {
  183. background-color: #EEF7F7;
  184. min-height: 100vh;
  185. }
  186. .content_all {
  187. background-color: white;
  188. }
  189. .change {
  190. text-align: right;
  191. padding-right: 20rpx;
  192. font-size: 32rpx;
  193. }
  194. .item {
  195. display: flex;
  196. border-bottom: 2rpx solid rgb(239, 239, 239);
  197. padding: 18rpx 36rpx;
  198. font-size: 32rpx;
  199. align-items: center;
  200. }
  201. /deep/.u-form {
  202. padding: 0 40rpx !important;
  203. }
  204. .btn {
  205. flex: 1;
  206. background: rgb(25, 190, 107);
  207. font-size: 30rpx;
  208. color: white;
  209. z-index: 999;
  210. text-align: center;
  211. border-radius: 10rpx;
  212. }
  213. ::v-deep .u-form-item--right__content__slot {
  214. display: flex;
  215. justify-content: space-between;
  216. }
  217. .title {
  218. margin-top: -32rpx;
  219. font-size: 32rpx;
  220. margin-bottom: 40rpx;
  221. margin-left: 30rpx;
  222. }
  223. .search {
  224. height: 80rpx;
  225. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  226. border-radius: 40rpx;
  227. font-size: 32rpx;
  228. font-weight: 400;
  229. color: #ffffff;
  230. line-height: 80rpx;
  231. margin: 0 30rpx;
  232. margin-top: 70rpx;
  233. }
  234. </style>