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