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

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