QuickRegistration.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <template>
  2. <view v-show="show1">
  3. <view class="QuickRegistration">
  4. <view class="view1">
  5. <image class="quick1" src="@/assets/img/quick/1.png"></image>
  6. </view>
  7. <view class="view2">
  8. <view class="view3">
  9. <image class="quick4" @click="close"
  10. src="@/assets/img/quick/4.png"></image>
  11. </view>
  12. <view class="view4">
  13. <image class="quick2" src="@/assets/img/quick/2.png"></image>
  14. <view class="viewbtn" @click="show2=true">
  15. <image class="quick3" src="@/assets/img/quick/3.png"></image>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <u-popup v-model="show2" mode="bottom" border-radius="14" :closeable="true" >
  21. <view>
  22. <ucarkeyboard ref="uKeyboard" mode="car"
  23. style=" z-index: 999;" :style="!keyShow?'display: none':''"
  24. :showTips="true" :confirmBtn="false"
  25. :mask-close-able="false" :tooltip="false" v-model="keyShow" @change="valChange" @backspace="backspace">
  26. <view class="ucarkeyboardView" >
  27. <span >车牌号:{{form.carNumber}}</span>
  28. <span @tap="keyShow=!keyShow" style="
  29. float: right;
  30. padding-right: 10px;
  31. color: #41a863;
  32. ">确定</span>
  33. </view>
  34. </ucarkeyboard>
  35. <view class="QuickRegistrationPopup" >
  36. <view class="popup1">快速注册</view>
  37. <view class="popup2">欢迎来到优电联盟</view>
  38. <view v-show="!keyShow">
  39. <view class="popup3" >
  40. <view class="input">
  41. <u-input :customStyle="customStyle" :clearable="false"
  42. v-model="form.telephone" type="number" placeholder="请输入手机号"
  43. placeholder-style="font-size:16px;color:#ccc;" />
  44. </view>
  45. </view>
  46. <view class="popup4" >未注册的手机号验证后将自动注册</view>
  47. <view class="popup5">验证码</view>
  48. <view class="popup3">
  49. <view class="input">
  50. <u-input :customStyle="customStyle" :clearable="false"
  51. v-model="form.verifyCode" type="number" placeholder="请输入验证码"
  52. placeholder-style="font-size:16px;color:#ccc;" />
  53. <view class="code" :style="isCodeTipsColor ? 'color: #999999;' : ''" @click="getCode">
  54. {{codeTips}}</view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="popup5">车牌号码</view>
  59. <view class="popup6" @tap="keyShowBtn(true)" >
  60. <umessageInput :focus="true"
  61. @selectIndex="getSelectIndex"
  62. :value="form.carNumber" :maxlength="maxlength" :disabled-keyboard="true"></umessageInput>
  63. </view>
  64. <view class="popup7">
  65. <view >
  66. <u-checkbox-group>
  67. <u-checkbox class="tips" active-color="green" v-model="value" shape="circle"
  68. @change="checkboxChange()"></u-checkbox>
  69. </u-checkbox-group>
  70. <span style="font-size: 24rpx;">我已阅读并同意</span>
  71. <span @click="gotoUrl('pages/article/details?code=YHXY')" style="color: #3fbd70;font-size: 24rpx;">《会员协议》</span>和
  72. <span @click="gotoUrl('pages/article/details?code=YSZC')" style="color: #3fbd70;font-size: 24rpx;">《隐私协议》</span>
  73. </view>
  74. </view>
  75. <view class="popup8">
  76. <u-button class="success-btn" shape="circle" type="success" @click="keepCar" >
  77. 完成
  78. </u-button>
  79. </view>
  80. </view>
  81. <u-verification-code :seconds="sendMsgSecond" ref="uCode" @change="codeChange" @end="end" @start="start"
  82. change-text="已发送(Xs)">
  83. </u-verification-code>
  84. </view>
  85. </u-popup>
  86. </view>
  87. </template>
  88. <script>
  89. import umessageInput from '@/components/UmessageInput.vue'
  90. import ucarkeyboard from '@/components/Ucarkeyboard.vue'
  91. import * as loginApi from '@/apis/login.js'
  92. import {
  93. checkPhone,newDate
  94. } from '@/utils'
  95. export default {
  96. name:"QuickRegistration",
  97. components: {
  98. ucarkeyboard,umessageInput
  99. },
  100. props:{
  101. carNum:""
  102. },
  103. data() {
  104. return {
  105. customStyle: {
  106. 'font-size': '28rpx',
  107. 'border-radius': '50px',
  108. 'background-color': 'rgba(237, 240, 239, 1)',
  109. 'text-align':'center'
  110. },
  111. keyShow:false,
  112. show1:true,
  113. show2:false,
  114. selectIndex:-1,
  115. maxlength:8,
  116. value:false,
  117. personInfo: null,
  118. isSendMsgIng: false,
  119. isCodeTipsColor: false,
  120. sendMsgSecond: 60,
  121. codeTips: '',
  122. form: {
  123. telephone: '',
  124. verifyCode: '',
  125. carNumber: '',
  126. defaultFlag: true,
  127. },
  128. };
  129. },
  130. created() {
  131. console.log("1")
  132. this.form.carNumber=this.carNum
  133. var personInfo = this.carhelp.getPersonInfo()
  134. this.personInfo = personInfo
  135. },
  136. mounted() {
  137. },
  138. methods:{
  139. codeChange(text) {
  140. this.codeTips = text;
  141. },
  142. start() {
  143. if (!this.isSendMsgIng) {
  144. uni.showLoading({
  145. title: "加载中",
  146. mask: true,
  147. })
  148. loginApi.getVerifyCode(this.form.telephone).then((response) => {
  149. uni.hideLoading();
  150. this.carhelp.set("getvcodetime", new Date().getTime());
  151. if (!"") {
  152. //倒计时
  153. uni.showToast({
  154. title: "发送成功"
  155. })
  156. } else {
  157. uni.showToast({
  158. title: "您的验证码已经发送[5分钟有效],请勿重复点击"
  159. })
  160. }
  161. }).catch(error => {
  162. uni.showToast({
  163. title: error,
  164. icon: "none"
  165. })
  166. })
  167. }
  168. },
  169. //倒计时
  170. end() {
  171. this.sendMsgSecond = 60;
  172. this.isSendMsgIng = false;
  173. this.isCodeTipsColor = false;
  174. },
  175. // 获取验证码
  176. getCode() {
  177. if (this.$refs.uCode.canGetCode) {} else {
  178. uni.showToast({
  179. title: '倒计时结束后再发送',
  180. icon: "none"
  181. })
  182. return
  183. }
  184. var checkPhoneResult = checkPhone(this.form.telephone);
  185. if (checkPhoneResult !== true) {
  186. uni.showToast({
  187. title: checkPhoneResult,
  188. })
  189. return;
  190. }
  191. this.$refs.uCode.start();
  192. this.isCodeTipsColor = true;
  193. },
  194. keyShowBtn(keyShow){
  195. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  196. console.log(aaa,this.form.carNumber.length)
  197. if((this.form.carNumber.length == 0) && aaa) {
  198. this.$refs.uKeyboard.changeCarInputMode();
  199. }else if(!aaa&&(this.form.carNumber.length > 0)){
  200. this.$refs.uKeyboard.changeCarInputMode();
  201. }
  202. this.keyShow=keyShow;
  203. },
  204. checkboxChange() {
  205. this.value = !this.value;
  206. },
  207. getSelectIndex(i){
  208. // this.selectIndex=i;
  209. // if(i==0){
  210. // var aaa = this.$refs.uKeyboard.changeCarInputValue();
  211. // if( aaa) {
  212. // this.$refs.uKeyboard.changeCarInputMode();
  213. // }
  214. // }
  215. },
  216. // 按键被点击(点击退格键不会触发此事件)
  217. valChange(val) {
  218. if(this.form.carNumber.length>=this.maxlength&&this.selectIndex==-1){
  219. return
  220. }
  221. if(this.selectIndex==-1){
  222. this.form.carNumber += val;
  223. }else{
  224. const replaceStr = (str, index, char) => {
  225. const strAry = str.split('');
  226. if(index<strAry.length){
  227. strAry[index] = char;
  228. }
  229. return strAry.join('');
  230. }
  231. this.form.carNumber=replaceStr(this.form.carNumber,this.selectIndex,val) ;
  232. this.selectIndex=-1;
  233. }
  234. // 将每次按键的值拼接到form.carNumber变量中,注意+=写法
  235. //(this.form.carNumber);
  236. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  237. if((this.form.carNumber.length == 0) && aaa) {
  238. this.$refs.uKeyboard.changeCarInputMode();
  239. }else if(!aaa){
  240. this.$refs.uKeyboard.changeCarInputMode();
  241. }
  242. },
  243. // 退格键被点击
  244. backspace() {
  245. // 删除form.carNumber的最后一个字符
  246. if(this.form.carNumber.length){
  247. if(this.selectIndex==-1){
  248. this.form.carNumber = this.form.carNumber.substr(0, this.form.carNumber.length - 1);
  249. }else{
  250. const replaceStr = (str, index, char) => {
  251. const strAry = str.split('');
  252. if(index<strAry.length){
  253. strAry[index] = char;
  254. }
  255. return strAry.join('');
  256. }
  257. this.form.carNumber=replaceStr(this.form.carNumber,this.selectIndex,'') ;
  258. //this.selectIndex=-1;
  259. }
  260. }
  261. //(this.form.carNumber);
  262. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  263. if(this.form.carNumber.length == 0 && aaa) {
  264. this.$refs.uKeyboard.changeCarInputMode();
  265. }
  266. },
  267. keepCar() {
  268. var checkPhoneResult = checkPhone(this.form.telephone);
  269. if (!this.form.telephone || checkPhoneResult != true) {
  270. uni.showToast({
  271. title: checkPhoneResult,
  272. icon: "none"
  273. })
  274. return;
  275. }
  276. if (!this.form.verifyCode) {
  277. uni.showToast({
  278. title: "请输入验证码",
  279. icon: "none"
  280. })
  281. return
  282. }
  283. //(this.form)
  284. if(this.form.carNumber.length != 8) {
  285. uni.showToast({
  286. title:"请填写新能源车牌"
  287. })
  288. return
  289. }
  290. if (!this.value) {
  291. uni.showToast({
  292. title: "请勾选协议"
  293. })
  294. return
  295. }
  296. //this.form.nickName= this.form.telephone;
  297. if(this.carhelp.getUserInfo().nickname){
  298. this.form.nickName = this.carhelp.getUserInfo().nickname;
  299. this.form.headImg = this.carhelp.getUserInfo().headimgurl;
  300. }
  301. this.form.openId = this.carhelp.getOpenId();
  302. this.form.source = 2 //创建渠道1电单车2电车
  303. uni.showLoading({
  304. title: "加载中",
  305. mask: true,
  306. })
  307. if (this.personInfo && this.personInfo.userType == "1") {
  308. loginApi.validateGuestCode(this.form).then((response) => {
  309. this.loginresponse(response, true)
  310. }).catch(error => {
  311. uni.showToast({
  312. title: error,
  313. icon: "none"
  314. })
  315. })
  316. } else {
  317. loginApi.validateCode(this.form).then((response) => {
  318. this.loginresponse(response)
  319. }).catch(error => {
  320. uni.showToast({
  321. title: error,
  322. icon: "none"
  323. })
  324. })
  325. }
  326. },
  327. loginresponse(response, bl) {
  328. var token = response ? response.data.token : '';
  329. this.carhelp.setToken(token);
  330. this.carhelp.setPersonInfo(response.data.regUser);
  331. this.carhelp.setPersonInfoPlus(response.data);
  332. this.show1=false
  333. this.show2=false
  334. uni.hideLoading()
  335. this.$emit("login",this.form);
  336. },
  337. open(){
  338. },
  339. close() {
  340. // 标记关闭是内部发生的,否则修改了value值,导致watch中对value检测,导致再执行一遍close
  341. // 造成@close事件触发两次
  342. this.show1=false
  343. this.$emit("close");
  344. },
  345. }
  346. }
  347. </script>
  348. <style lang="scss" scoped>
  349. ::v-deep.u-char-item {
  350. width: 60rpx !important;
  351. height: 80rpx !important;
  352. font-size: 36rpx !important;
  353. margin:8rpx !important;
  354. }
  355. .QuickRegistration{
  356. position: fixed;
  357. bottom: 80rpx;
  358. z-index: 1000;
  359. width: 100%;
  360. display: flex;
  361. flex-direction: column;
  362. align-items: center;
  363. .quick1{
  364. width: 240rpx;
  365. height: 190rpx;
  366. position: relative;
  367. bottom: -100rpx;
  368. }
  369. .quick2{
  370. width: 500rpx;
  371. height: 72rpx;
  372. margin-bottom: 26rpx;
  373. }
  374. .quick3{
  375. width: 176rpx;
  376. height: 60rpx;
  377. }
  378. .quick4{
  379. width: 40rpx;
  380. height: 40rpx;
  381. position: fixed;
  382. right: 70rpx;
  383. }
  384. .view4{
  385. display: flex;
  386. align-items: center;
  387. justify-content: center;
  388. flex-direction: column;
  389. }
  390. .view3{
  391. }
  392. .view1{
  393. }
  394. .view2{
  395. background: linear-gradient(180deg, rgba(79,205,145,1) 0%,rgba(30,159,84,1) 100%);
  396. box-shadow: 0px 2px 8px 0px rgba(34, 125, 63, 0.5);
  397. border: 1px solid rgba(79, 205, 145, 1);
  398. border-radius: 12px;
  399. width: 670rpx;
  400. height: 320rpx;
  401. display: flex;
  402. flex-direction: column;
  403. align-items: center;
  404. justify-content: space-between;
  405. padding: 24rpx 0 40rpx 0;
  406. }
  407. .viewbtn{
  408. width: 448rpx;
  409. height: 88rpx;
  410. border-radius: 50px;
  411. background: linear-gradient(180deg, rgba(255,228,0,1) 0%,rgba(255,188,0,1) 100%);
  412. display: flex;
  413. align-items: center;
  414. justify-content: center;
  415. }
  416. }
  417. .QuickRegistrationPopup{
  418. padding: 56rpx;
  419. text-align: center;
  420. .popup1{
  421. color: rgba(16, 16, 16, 1);
  422. font-size: 56rpx;
  423. font-weight: bold;
  424. }
  425. .popup2{
  426. color: rgba(119, 119, 119, 1);
  427. font-size: 36rpx;
  428. margin-bottom: 40rpx;
  429. }
  430. .popup3{
  431. margin-bottom: 24rpx;
  432. .input{
  433. display: flex;
  434. align-items: center;
  435. .code {
  436. top: 7px;
  437. color: rgb(63, 189, 112);
  438. }
  439. }
  440. }
  441. .popup4{
  442. margin-bottom: 40rpx;
  443. color: rgba(102, 102, 102, 1);
  444. font-size: 28rpx;
  445. }
  446. .popup5{
  447. margin-bottom: 16rpx;
  448. color: rgba(16, 16, 16, 1);
  449. font-size: 36rpx;
  450. font-weight: bold;
  451. }
  452. .popup6{
  453. margin-bottom: 40rpx;
  454. }
  455. .popup7{
  456. margin-bottom: 40rpx;
  457. }
  458. .popup8{
  459. }
  460. }
  461. .ucarkeyboardView{
  462. text-align: center;
  463. font-size: 40rpx;
  464. height: 200rpx;
  465. display: flex;
  466. align-items: flex-end;
  467. justify-content: space-between;
  468. }
  469. </style>