login.vue 15 KB

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