login.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. <template>
  2. <view class="wrap">
  3. <ujp-navbar :isBack="false" title="" v-if="false">
  4. <view slot="right" v-if="!personInfo&&!member" @click="show3=true"
  5. style=" margin-right: 10px;color:#00B962">游客模式 </view>
  6. </ujp-navbar>
  7. <view class="login">
  8. <view class="login-title">
  9. <h3 ><span style="font-weight: bold;">手机号登录/注册</span>
  10. <span class="login-title-span" v-if="!personInfo&&!member" @click="show3=true" >游客模式</span>
  11. </h3>
  12. <p>欢迎来到{{projectName}}</p>
  13. <p v-if="activityInfo"><span style="color: red;">*</span>正在参加活动<span style="color: #3fbd70;">
  14. <邀请有礼>
  15. </span></p>
  16. </view>
  17. <view class="login-form">
  18. <view class="login-form-item">
  19. <view class="title" style="font-weight: bold;" >手机号</view>
  20. <view class="input">
  21. <u-input :customStyle="customStyle" :placeholderStyle="placeholderStyle"
  22. v-model="form.telephone" type="number" placeholder="请输入手机号"
  23. placeholder-style="font-size:16px;color:#ccc;" />
  24. </view>
  25. <view class="tips"><span style="color: red;">*</span>未注册的手机号验证后将自动注册</view>
  26. <view class="tips" style="color: red;" v-if="branchParameterBl('ud')" >
  27. *原51充电联盟会员使用原手机号登录后可同步您的余额、优惠券等账户信息
  28. </view>
  29. </view>
  30. <view class="login-form-item">
  31. <view class="title" style="font-weight: bold;">验证码</view>
  32. <view class="input">
  33. <u-input :customStyle="customStyle" :placeholderStyle="placeholderStyle"
  34. v-model="form.verifyCode" type="number" placeholder="请输入验证码"
  35. placeholder-style="font-size:16px;color:#ccc;" />
  36. <view class="code" :style="isCodeTipsColor ? 'color: #999999;' : ''" @click="getCode">
  37. {{codeTips}}</view>
  38. </view>
  39. <view style="width: 350px;">
  40. <u-checkbox-group>
  41. <u-checkbox class="tips" active-color="green" v-model="value" shape="circle"
  42. @change="checkboxChange()"></u-checkbox>
  43. </u-checkbox-group>
  44. <span style="font-size: 24rpx;">我已阅读并同意</span>
  45. <span @click="gotoUrl('pages/article/details?code=YHXY')" style="color: #3fbd70;font-size: 24rpx;">《会员协议》</span>和
  46. <span @click="gotoUrl('pages/article/details?code=YSZC')" style="color: #3fbd70;font-size: 24rpx;">《隐私协议》</span>
  47. </view>
  48. </view>
  49. </view>
  50. <u-button :style="[inputStyle]" class="login-btn" type="success" shape="circle" @click="login">登录</u-button>
  51. <u-verification-code :seconds="sendMsgSecond" ref="uCode" @change="codeChange" @end="end" @start="start"
  52. change-text="已发送(Xs)">
  53. </u-verification-code>
  54. </view>
  55. <view class="foot" v-if="!show2">
  56. <span style="color: red;">*</span>我们将使用您的微信昵称及头像,为您补全本平台帐号相关基础信息,请点击下方“<span
  57. style="color: #3fbd70;">使用完整服务</span>”。
  58. </view>
  59. <u-modal v-model="show1" @confirm="gotoGz" cancel-text="暂不关注" confirm-text="前往关注" :show-cancel-button="false"
  60. confirm-color="#53b56b" ref="uModal2" :asyncClose="true">
  61. <view style="padding: 15px;">请先关注<span style=" color: #53b56b;">{{projectName}}</span>公众号,然后进行会员注册</view>
  62. </u-modal>
  63. <u-modal v-model="show3" v-show="!show1" class="showOss" confirm-text="注册会员" cancel-text="先不注册"
  64. :show-title="false" width="650" border-radius="30" title="" :show-cancel-button="false"
  65. :show-confirm-button="false">
  66. <view class="slot-content">
  67. <!-- :show-title="false" -->
  68. <view>
  69. <img src="@/assets/img/Nipic_24385267_20191128181916139081.png" style="width: 100%;"></img>
  70. </view>
  71. <view>
  72. <table class="classtable">
  73. <tr>
  74. <td class="td1">
  75. <img src="@/assets/img/Nipic_vip.png" style="width: 24px;"></img>
  76. <p style="color: #FF9800;line-height: 10px;">会员</p>
  77. </td>
  78. <td class="td2">
  79. <p><span class="dian">·</span>充电最低<span style="color:#4aa461">0.66元</span>/度(含服务费)</p>
  80. <p><span class="dian">·</span>账户充值赠送代金券</p>
  81. <p><span class="dian">·</span>更有<span style="color:#4aa461">会员充电折扣、服务费包月会员资格</span>等超多福利</p>
  82. </td>
  83. </tr>
  84. <tr>
  85. <td style="color: #fff;line-height: 3px;" >.</td>
  86. </tr>
  87. <tr>
  88. <td class="td1">
  89. <img src="@/assets/img/Nipic_youke.png" style="width: 24px;"></img>
  90. <p style="color: rgb(74, 164, 97);line-height: 10px;">游客</p>
  91. </td>
  92. <td class="td2">
  93. <p><span class="dian">·</span>临时车牌快速充电</p>
  94. <p><span class="dian">·</span>无需注册 先付后退</p>
  95. <p><span class="dian">·</span><span style="color:#F44336">不可使用</span>平台各类代金券</p>
  96. </td>
  97. </tr>
  98. </table>
  99. </view>
  100. <view class="btnview">
  101. <!-- <u-button shape="circle" @click="show3=false"
  102. style=" width: 200rpx; background-color: #fff !important; margin: 20rpx;float: left;margin-bottom: 20px; "
  103. szie="mini" type="success" plain>继续充电</u-button> -->
  104. <view class="btnview1">
  105. <u-button shape="circle" style=" float: left; width: 400rpx; margin: 20rpx; "
  106. szie="mini" type="success" @click="show3=false">注册会员</u-button>
  107. </view>
  108. <view class="btnview2" @click="touristConfirm">游客模式</view>
  109. </view>
  110. </view>
  111. </u-modal>
  112. </view>
  113. </template>
  114. <script>
  115. import * as loginApi from '@/apis/login.js'
  116. import * as API from '@/apis/index.js'
  117. import * as API_weixin from '@/apis/weixin.js'
  118. import {
  119. checkPhone,newDate
  120. } from '@/utils'
  121. export default {
  122. data() {
  123. return {
  124. elderMode: false,
  125. customStyle: {
  126. 'font-size': '28rpx'
  127. },
  128. placeholderStyle: "font-size:28rpx",
  129. form: {
  130. telephone: '',
  131. verifyCode: '',
  132. },
  133. activityInfo: null,
  134. isSendMsgIng: false,
  135. isCodeTipsColor: false,
  136. sendMsgSecond: 60,
  137. codeTips: '',
  138. value: false,
  139. code: '',
  140. codeId: '',
  141. projectName: '',
  142. show1: false,
  143. show2: false,
  144. show3: false,
  145. touristBl: false,
  146. personInfo: null,
  147. member: false,
  148. }
  149. },
  150. computed: {
  151. inputStyle() {
  152. let style = {};
  153. if (this.form.telephone) {
  154. style.color = "#fff";
  155. style.backgroundColor = this.$u.color['success'];
  156. }
  157. return style;
  158. }
  159. },
  160. onLoad(op) {
  161. this.projectName = process.car.ProjectName;
  162. if (op.member) {
  163. this.member = true;
  164. }
  165. if (op.jpcode2) {
  166. this.code = op.jpcode2;
  167. }
  168. if (op.codeId) {
  169. this.codeId = op.codeId;
  170. }
  171. if (op.jpcode) {
  172. var str1 = op.jpcode.slice(0, 19);
  173. var str2 = op.jpcode.slice(20, 21);
  174. var str3 = op.jpcode.slice(22);
  175. if (str1 == 'jp_team51_charge_id') {
  176. if (str2 == 'A') {
  177. this.code = str2;
  178. this.codeId = str3;
  179. uni.showToast({
  180. title: "注册后享受充电服务"
  181. })
  182. }
  183. }
  184. }
  185. var obj = this.carhelp.get("friends_invitation")
  186. if (obj) {
  187. if (obj.date + 1000 * 60 * 60 * 24 > new Date().getTime()) {
  188. this.form.inviteId = obj.op.uid
  189. this.form.code = obj.op.icode
  190. this.activityInfo = "true";
  191. }
  192. }
  193. this.personInfo = this.carhelp.getPersonInfo()
  194. if (this.personInfo) {
  195. if (this.personInfo.userType == "1") {
  196. } else {
  197. uni.redirectTo({
  198. url: '/pages/index/index'
  199. })
  200. }
  201. } else {
  202. if (!this.member) {
  203. this.show3 = true
  204. }
  205. }
  206. },
  207. onReady() {
  208. this.elderMode = this.carhelp.get('getElderModeClass') == '长辈模式';
  209. if (this.elderMode)
  210. this.theme('elder')
  211. else
  212. this.theme('standard')
  213. },
  214. onShow() {
  215. this.checkSubscribe()
  216. },
  217. methods: {
  218. touristConfirm() {
  219. uni.showLoading({
  220. title: "加载中",
  221. mask: true,
  222. })
  223. this.form.nickName = this.carhelp.getUserInfo().nickname;
  224. this.form.headImg = this.carhelp.getUserInfo().headimgurl;
  225. this.form.openId = this.carhelp.getOpenId();
  226. this.form.source = 2 //创建渠道1电单车2电车
  227. loginApi.registerGuest(this.form).then((response) => {
  228. this.loginresponse(response,true);
  229. }).catch(error => {
  230. uni.showToast({
  231. title: error,
  232. icon: "none"
  233. })
  234. })
  235. },
  236. gotoGz() {
  237. this.carhelp.setGzDate()
  238. var url = process.car.gzUrl;
  239. window.location.href = url
  240. },
  241. checkSubscribe() {
  242. API_weixin.checkSubscribe({
  243. openId: this.carhelp.getOpenId()
  244. }).then((res) => {
  245. if (res.data == "0") {
  246. this.show1 = true
  247. } else {
  248. //this.init();
  249. this.show1 = false;
  250. this.show2 = true;
  251. //this.carhelp.setGzDate()
  252. }
  253. //setGzDate
  254. }).catch(error => {
  255. uni.showToast({
  256. title: error
  257. })
  258. })
  259. },
  260. theme(type) {
  261. if (type == 'elder') {
  262. document.getElementsByTagName('body')[0].setAttribute('data-theme', type);
  263. let data = {
  264. "font-size": '32rpx',
  265. };
  266. this.customStyle = data;
  267. this.placeholderStyle = "font-size:32rpx"; //data;
  268. } else {
  269. document.getElementsByTagName('body')[0].setAttribute('data-theme', type);
  270. let data = {
  271. "font-size": '28rpx',
  272. };
  273. this.customStyle = data;
  274. this.placeholderStyle = "font-size:28rpx"; //data;
  275. }
  276. },
  277. codeChange(text) {
  278. this.codeTips = text;
  279. },
  280. start() {
  281. if (!this.isSendMsgIng) {
  282. uni.showLoading({
  283. title: "加载中",
  284. mask: true,
  285. })
  286. loginApi.getVerifyCode(this.form.telephone).then((response) => {
  287. uni.hideLoading();
  288. this.carhelp.set("getvcodetime", new Date().getTime());
  289. if (!"") {
  290. //倒计时
  291. uni.showToast({
  292. title: "发送成功"
  293. })
  294. } else {
  295. uni.showToast({
  296. title: "您的验证码已经发送[5分钟有效],请勿重复点击"
  297. })
  298. }
  299. }).catch(error => {
  300. uni.showToast({
  301. title: error,
  302. icon: "none"
  303. })
  304. })
  305. }
  306. },
  307. //倒计时
  308. end() {
  309. this.sendMsgSecond = 60;
  310. this.isSendMsgIng = false;
  311. this.isCodeTipsColor = false;
  312. },
  313. // 获取验证码
  314. getCode() {
  315. if (this.$refs.uCode.canGetCode) {} else {
  316. uni.showToast({
  317. title: '倒计时结束后再发送',
  318. icon: "none"
  319. })
  320. return
  321. }
  322. var checkPhoneResult = checkPhone(this.form.telephone);
  323. if (checkPhoneResult !== true) {
  324. uni.showToast({
  325. title: checkPhoneResult,
  326. })
  327. return;
  328. }
  329. this.$refs.uCode.start();
  330. this.isCodeTipsColor = true;
  331. },
  332. checkboxChange() {
  333. this.value = !this.value;
  334. },
  335. loginresponse(response, bl) {
  336. uni.hideLoading();
  337. var token = response ? response.data.token : '';
  338. this.carhelp.setToken(token);
  339. this.carhelp.setPersonInfo(response.data.regUser);
  340. if (!bl && !response.data.regUser.carId) {
  341. var url = "/pages/login/completeInfo?login=1"
  342. if (this.code == 'A') {
  343. url += "&jpcode=jp_team51_charge_id:A_" + this.codeId
  344. }
  345. uni.redirectTo({
  346. url: url
  347. })
  348. } else if (this.code == 'A') {
  349. var k = API.codeOperation("jp_team51_charge_id:A_" + this.codeId);
  350. if (k) {
  351. uni.redirectTo({
  352. url: k
  353. })
  354. }
  355. }else if(this.code == 'card'){
  356. uni.redirectTo({
  357. url: '/pages/cardBag/cardDetail?id='+ this.codeId
  358. })
  359. }else if (this.code == 'invoice') {
  360. uni.redirectTo({
  361. url: '/pages/MyInvoice/invoiceManagement'
  362. })
  363. }else {
  364. //pages/temporary/anniversary2024
  365. var time1=newDate("2024-05-11")
  366. var time2=newDate("2024-05-18")
  367. var time3=new Date()
  368. if(this.branchParameterBl('ud')&&!bl &&time3>time1&&time3<time2){
  369. uni.redirectTo({
  370. url: '/pages/temporary/anniversary2024'
  371. })
  372. }else{
  373. uni.redirectTo({
  374. url: '/pages/index/index'
  375. })
  376. }
  377. }
  378. },
  379. login() {
  380. // if(!this.show2){
  381. // this.show1=true;
  382. // return
  383. // }
  384. var checkPhoneResult = checkPhone(this.form.telephone);
  385. if (!this.form.telephone || checkPhoneResult != true) {
  386. uni.showToast({
  387. title: checkPhoneResult,
  388. icon: "none"
  389. })
  390. return;
  391. }
  392. if (!this.form.verifyCode) {
  393. uni.showToast({
  394. title: "请输入验证码",
  395. icon: "none"
  396. })
  397. return
  398. }
  399. if (!this.value) {
  400. uni.showToast({
  401. title: "请勾选协议",
  402. icon: "none"
  403. })
  404. return
  405. }
  406. uni.showLoading({
  407. title: "加载中",
  408. mask: true,
  409. })
  410. //this.form.nickName= this.form.telephone;
  411. this.form.nickName = this.carhelp.getUserInfo().nickname;
  412. this.form.headImg = this.carhelp.getUserInfo().headimgurl;
  413. this.form.openId = this.carhelp.getOpenId();
  414. this.form.source = 2 //创建渠道1电单车2电车
  415. if (this.personInfo && this.personInfo.userType == "1") {
  416. loginApi.validateGuestCode(this.form).then((response) => {
  417. this.loginresponse(response, true)
  418. }).catch(error => {
  419. uni.showToast({
  420. title: error,
  421. icon: "none"
  422. })
  423. })
  424. } else {
  425. loginApi.validateCode(this.form).then((response) => {
  426. this.loginresponse(response)
  427. }).catch(error => {
  428. uni.showToast({
  429. title: error,
  430. icon: "none"
  431. })
  432. })
  433. }
  434. }
  435. }
  436. }
  437. </script>
  438. <style>
  439. page {
  440. background-color: #fff;
  441. }
  442. </style>
  443. <style lang="scss" scoped>
  444. .login-title-span{
  445. font-size: 36rpx;
  446. float: right;
  447. color:#00B962
  448. }
  449. .classtable{
  450. margin: 0rpx 40rpx;
  451. .td1{
  452. width: 50rpx;
  453. padding: 12rpx 0;
  454. text-align: center;
  455. img{
  456. width: 48rpx;
  457. height: 48rpx;
  458. }
  459. font-size: 10px;
  460. }
  461. .td2{
  462. padding-left: 16rpx;
  463. font-size: 12px;
  464. line-height: 24px;
  465. .dian{
  466. padding :0 10rpx
  467. }
  468. }
  469. }
  470. .btnview{
  471. display: flex;
  472. flex-direction: column;
  473. align-items: center;
  474. .btnview1{
  475. }
  476. .btnview2{
  477. color:#999999 ;
  478. padding-bottom:38rpx ;
  479. }
  480. }
  481. .foot {
  482. position: fixed;
  483. left: 0;
  484. right: 0;
  485. bottom: 0;
  486. background-color: #fff;
  487. padding: 0 10px;
  488. }
  489. @import "@/_theme.scss";
  490. .all {
  491. @include themeify {
  492. font-size: themed('font-size2');
  493. }
  494. }
  495. /deep/.placeholderStyle {
  496. font-size: themed('font-size2');
  497. }
  498. .wrap {
  499. //background: linear-gradient(#D6EEDC, #F3F4F4);
  500. @include themeify {
  501. font-size: themed('font-size2');
  502. }
  503. /* font-size: 28rpx;*/
  504. .login {
  505. //width: 600rpx;
  506. //
  507. .login-title {
  508. padding: 0 50rpx 0 50rpx;
  509. padding-top: 80rpx;
  510. background: linear-gradient(#D6EEDC, #fff);
  511. text-align: left;
  512. h3 {
  513. @include themeify {
  514. font-size: themed('font-size7');
  515. }
  516. /* font-size: 48rpx;*/
  517. font-weight: normal;
  518. }
  519. p {
  520. margin-top: 4px;
  521. color: #777
  522. }
  523. }
  524. .login-form-item {
  525. margin: 0 50rpx;
  526. width: 600rpx;
  527. margin-top: 40px;
  528. .title {
  529. margin-bottom: 8px;
  530. @include themeify {
  531. font-size: themed('font-size2');
  532. font-weight: themed('fontWeight');
  533. letter-spacing: themed('letterSpacing');
  534. }
  535. }
  536. .input {
  537. border-bottom: 1px solid #f7f7f7;
  538. position: relative;
  539. box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.1);
  540. }
  541. .code {
  542. position: absolute;
  543. right: 0;
  544. top: 7px;
  545. color: rgb(63, 189, 112);
  546. }
  547. .tips {
  548. color: $u-type-info;
  549. margin-top: 12px;
  550. @include themeify {
  551. font-size: themed('font-size1');
  552. }
  553. /* font-size: 12px;*/
  554. span {
  555. color: #3fbd70;
  556. }
  557. }
  558. }
  559. .login-btn {
  560. width: 600rpx;
  561. margin: 0 auto;
  562. margin-top: 40px;
  563. background-color: #a7dbc2;
  564. @include themeify {
  565. font-size: themed('font-size3');
  566. }
  567. }
  568. .alternative {
  569. color: $u-tips-color;
  570. display: flex;
  571. justify-content: space-between;
  572. margin-top: 30rpx;
  573. }
  574. }
  575. }
  576. /deep/.uni-input-placeholder{
  577. color:#ccc
  578. }
  579. .u-checkbox-group{
  580. width: 40rpx;
  581. }
  582. </style>