login.vue 16 KB

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