login.vue 15 KB

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