login.vue 15 KB

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