index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  1. <template>
  2. <view class="login-wrapper" :style="colorStyle">
  3. <view class="shading">
  4. <!-- <image :src="logoUrl" v-if="logoUrl" /> -->
  5. <image src="@/static/images/logo@2x.png" />
  6. </view>
  7. <view class="whiteBg" v-if="formItem === 1">
  8. <view class="list" v-if="current !== 1">
  9. <form @submit.prevent="submit">
  10. <view class="item">
  11. <view class="acea-row row-middle">
  12. <image src="../static/phone_1.png" style="width: 24rpx; height: 34rpx;"></image>
  13. <input type="text" :placeholder="$t(`输入手机号码`)" v-model="account" maxlength="11" required />
  14. </view>
  15. </view>
  16. <view class="item">
  17. <view class="acea-row row-middle">
  18. <image src="../static/code_1.png" style="width: 28rpx; height: 32rpx;"></image>
  19. <input type="password" :placeholder="$t(`填写登录密码`)" v-model="password" required />
  20. </view>
  21. </view>
  22. </form>
  23. <!-- <navigator class="forgetPwd" hover-class="none" url="/pages/users/retrievePassword/index">
  24. <span class="iconfont icon-wenti"></span>忘记密码
  25. </navigator> -->
  26. </view>
  27. <view class="list" v-if="current !== 0 || appLoginStatus || appleLoginStatus">
  28. <view class="item">
  29. <view class="acea-row row-middle">
  30. <image src="../static/phone_1.png" style="width: 24rpx; height: 34rpx;"></image>
  31. <input type="text" :placeholder="$t(`请输入手机号码`)" v-model="account" maxlength="11" />
  32. </view>
  33. </view>
  34. <view class="item">
  35. <view class="acea-row row-middle">
  36. <image src="../static/code_2.png" style="width: 28rpx; height: 32rpx;"></image>
  37. <input type="text" :placeholder="$t(`请输入验证码`)" maxlength="6" class="codeIput"
  38. v-model="captcha" />
  39. <view class="wrap">
  40. <u-toast ref="uToast"></u-toast>
  41. <u-code :seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange">
  42. </u-code>
  43. <u-button class="code" size="small" shape="circle" @click="getCode" plain>{{
  44. tips
  45. }}
  46. </u-button>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="item" v-if="isShowCode">
  51. <view class="acea-row row-middle">
  52. <image src="../static/code_2.png" style="width: 28rpx; height: 32rpx;"></image>
  53. <input type="text" :placeholder="$t(`请输入验证码`)" class="codeIput" v-model="codeVal" />
  54. <view class="code" @click="again"><img :src="codeUrl" /></view>
  55. </view>
  56. </view>
  57. <view class="item">
  58. <view class="acea-row row-middle">
  59. <image src="../static/code_1.png" style="width: 28rpx; height: 32rpx;"></image>
  60. <input type="password" :placeholder="$t(`请输入登录密码`)" v-model="password" required />
  61. </view>
  62. </view>
  63. <view class="item">
  64. <view class="acea-row row-middle">
  65. <image src="../static/code_1.png" style="width: 28rpx; height: 32rpx;"></image>
  66. <input type="password" :placeholder="$t(`请确认登录密码`)" v-model="passwordConfirm" required />
  67. </view>
  68. </view>
  69. <view class="item">
  70. <view class="acea-row row-middle">
  71. <!-- <image src="@/static/images/contact.png" style="width: 28rpx; height: 32rpx;"></image> -->
  72. <u-icon name="share" color="#b7b5b5"></u-icon>
  73. <input type="text" :placeholder="$t(`邀请码(6KYSYX)`)" v-model="codeInvitation" required />
  74. </view>
  75. </view>
  76. </view>
  77. <view class="protocol">
  78. <checkbox-group @change='ChangeIsDefault'>
  79. <checkbox :class="inAnimation ? 'trembling' : ''" @animationend='inAnimation = false'
  80. :checked="protocol ? true : false" />{{ $t(`已同意`) }} <text class="main-color"
  81. @click="privacy('2.html', '注册协议')">{{ $t(`《注册协议》`) }}</text>
  82. <text class="main-color" @click="privacy('3.html', '商城须知')">{{ $t(`《商城须知》`) }}</text>
  83. <text class="main-color" @click="privacy('1.html', '隐私政策')">{{ $t(`《隐私政策》`) }}</text>
  84. </checkbox-group>
  85. </view>
  86. <view class="logon" @click="loginMobile" v-if="current !== 0">{{ $t(`同意协议注册`) }}</view>
  87. <view class="logon" @click="submit" v-if="current === 0">{{ $t(`同意协议注册`) }}</view>
  88. <!-- #ifndef APP-PLUS -->
  89. <!-- <view class="tips">
  90. <view v-if="current == 0" @click="current = 1">{{ $t(`快速登录`) }}</view>
  91. <view v-if="current == 1" @click="current = 0">{{ $t(`账号登录`) }}</view>
  92. </view> -->
  93. <!-- #endif -->
  94. <!-- #ifdef APP-PLUS -->
  95. <view class="appLogin" v-if="!appLoginStatus && !appleLoginStatus">
  96. <view class="hds">
  97. <span class="line"></span>
  98. <p>{{ $t(`其他方式登录`) }}</p>
  99. <span class="line"></span>
  100. </view>
  101. <view class="btn-wrapper">
  102. <view class="btn wx" @click="wxLogin">
  103. <span class="iconfont icon-s-weixindenglu1"></span>
  104. </view>
  105. <view class="btn mima" v-if="current == 1" @click="current = 0">
  106. <span class="iconfont icon-s-mimadenglu1"></span>
  107. </view>
  108. <view class="btn yanzheng" v-if="current == 0" @click="current = 1">
  109. <span class="iconfont icon-s-yanzhengmadenglu1"></span>
  110. </view>
  111. <view class="apple-btn" @click="appleLogin" v-if="appleShow">
  112. <view class="iconfont icon-s-pingguo"></view>
  113. </view>
  114. </view>
  115. </view>
  116. <!-- #endif -->
  117. </view>
  118. <view class="bottom"></view>
  119. </view>
  120. </template>
  121. <script>
  122. import dayjs from "@/plugin/dayjs/dayjs.min.js";
  123. import sendVerifyCode from "@/mixins/SendVerifyCode";
  124. import {
  125. loginH5,
  126. loginMobile,
  127. registerVerify,
  128. register,
  129. getCodeApi,
  130. getUserInfo,
  131. appleLogin
  132. } from "@/api/user";
  133. import {
  134. postSendValidate,
  135. postUserRegister
  136. } from "@/api/home";
  137. import attrs, {
  138. required,
  139. alpha_num,
  140. chs_phone
  141. } from "@/utils/validate";
  142. import {
  143. getLogo
  144. } from "@/api/public";
  145. // import cookie from "@/utils/store/cookie";
  146. import {
  147. VUE_APP_API_URL
  148. } from "@/utils";
  149. // #ifdef APP-PLUS
  150. import {
  151. wechatAppAuth
  152. } from '@/api/api.js'
  153. // #endif
  154. const BACK_URL = "login_back_url";
  155. import colors from '@/mixins/color.js';
  156. export default {
  157. name: "Login",
  158. mixins: [sendVerifyCode, colors],
  159. data: function () {
  160. return {
  161. tips: '',
  162. seconds: 60,
  163. inAnimation: false,
  164. protocol: false,
  165. navList: [this.$t(`快速登录`), this.$t(`账号登录`)],
  166. current: 1,
  167. account: "",
  168. password: "",
  169. passwordConfirm: "",
  170. codeInvitation: "",
  171. captchaId: "",
  172. captcha: "",
  173. formItem: 1,
  174. type: "login",
  175. logoUrl: "",
  176. keyCode: "",
  177. codeUrl: "",
  178. codeVal: "",
  179. isShowCode: false,
  180. appLoginStatus: false, // 微信登录强制绑定手机号码状态
  181. appUserInfo: null, // 微信登录保存的用户信息
  182. appleLoginStatus: false, // 苹果登录强制绑定手机号码状态
  183. appleUserInfo: null,
  184. appleShow: false, // 苹果登录版本必须要求ios13以上的
  185. keyLock: true
  186. };
  187. },
  188. watch: {
  189. formItem: function (nval, oVal) {
  190. if (nval == 1) {
  191. this.type = 'login'
  192. } else {
  193. this.type = 'register'
  194. }
  195. }
  196. },
  197. onLoad() {
  198. let self = this
  199. uni.getSystemInfo({
  200. success: (res) => {
  201. if (res.platform.toLowerCase() == 'ios' && this.getSystem(res.system)) {
  202. self.appleShow = true
  203. }
  204. }
  205. });
  206. },
  207. mounted: function () {
  208. this.codeInvitation = this.$Cache.get('INVITE_CODE');
  209. // this.getCode();
  210. // this.getLogoImage();
  211. },
  212. methods: {
  213. codeChange(text) {
  214. this.tips = text;
  215. },
  216. end() {
  217. this.keyLock = false
  218. },
  219. start() {
  220. // this.keyLock = !this.keyLock
  221. },
  222. ChangeIsDefault(e) {
  223. this.$set(this, 'protocol', !this.protocol);
  224. },
  225. privacy(type, title) {
  226. uni.navigateTo({
  227. url: "/pages/users/privacy/index?type=" + type + "&title=" + title
  228. })
  229. },
  230. // IOS 版本号判断
  231. getSystem(system) {
  232. let str
  233. system.toLowerCase().indexOf('ios') === -1 ? str = system : str = system.split(' ')[1]
  234. if (str.indexOf('.'))
  235. return str.split('.')[0] >= 13
  236. return str >= 13
  237. },
  238. // 苹果登录
  239. appleLogin() {
  240. let self = this
  241. this.account = ''
  242. this.captcha = ''
  243. if (!self.protocol) {
  244. this.inAnimation = true
  245. return self.$util.Tips({
  246. title: '请先阅读并同意协议'
  247. });
  248. }
  249. uni.showLoading({
  250. title: this.$t(`登录中`)
  251. })
  252. uni.login({
  253. provider: 'apple',
  254. timeout: 10000,
  255. success(loginRes) {
  256. uni.getUserInfo({
  257. provider: 'apple',
  258. success: function (infoRes) {
  259. self.appleUserInfo = infoRes.userInfo
  260. self.appleLoginApi()
  261. },
  262. fail() {
  263. uni.showToast({
  264. title: self.$t(`获取用户信息失败`),
  265. icon: 'none',
  266. duration: 2000
  267. })
  268. },
  269. complete() {
  270. uni.hideLoading()
  271. }
  272. });
  273. },
  274. fail(error) {
  275. console.log(error)
  276. }
  277. })
  278. },
  279. // 苹果登录Api
  280. appleLoginApi() {
  281. let self = this
  282. appleLogin({
  283. openId: self.appleUserInfo.openId,
  284. email: self.appleUserInfo.email || '',
  285. phone: this.account,
  286. captcha: this.captcha
  287. }).then(({
  288. data
  289. }) => {
  290. if (data.isbind) {
  291. uni.showModal({
  292. title: self.$t(`提示`),
  293. content: self.$t(`请绑定手机号后,继续操作`),
  294. showCancel: false,
  295. success: function (res) {
  296. if (res.confirm) {
  297. self.current = 1
  298. self.appleLoginStatus = true
  299. }
  300. }
  301. });
  302. } else {
  303. self.$store.commit("LOGIN", {
  304. 'token': data.token,
  305. 'time': data.expires_time - self.$Cache.time()
  306. });
  307. let backUrl = self.$Cache.get(BACK_URL) || "/pages/index/index";
  308. self.$Cache.clear(BACK_URL);
  309. self.$store.commit("SETUID", data.userInfo.userId);
  310. uni.reLaunch({
  311. url: backUrl
  312. });
  313. }
  314. }).catch(error => {
  315. uni.showModal({
  316. title: self.$t(`提示`),
  317. content: self.$t(`错误信息`) + `${error}`,
  318. success: function (res) {
  319. if (res.confirm) {
  320. console.log(self.$t(`用户点击确定`));
  321. } else if (res.cancel) {
  322. console.log(self.$t(`用户点击取消`));
  323. }
  324. }
  325. });
  326. })
  327. },
  328. // App微信登录
  329. wxLogin() {
  330. let self = this
  331. this.account = ''
  332. this.captcha = ''
  333. if (!self.protocol) {
  334. this.inAnimation = true
  335. return self.$util.Tips({
  336. title: '请先阅读并同意协议'
  337. });
  338. }
  339. uni.showLoading({
  340. title: self.$t(`登录中`)
  341. })
  342. uni.login({
  343. provider: 'weixin',
  344. success: function (loginRes) {
  345. // 获取用户信息
  346. uni.getUserInfo({
  347. provider: 'weixin',
  348. success: function (infoRes) {
  349. self.appUserInfo = infoRes.userInfo
  350. self.wxLoginApi()
  351. },
  352. fail() {
  353. uni.showToast({
  354. title: self.$t(`获取用户信息失败`),
  355. icon: 'none',
  356. duration: 2000
  357. })
  358. },
  359. complete() {
  360. uni.hideLoading()
  361. }
  362. });
  363. },
  364. fail() {
  365. uni.showToast({
  366. title: self.$t(`登录失败`),
  367. icon: 'none',
  368. duration: 2000
  369. })
  370. }
  371. });
  372. },
  373. wxLoginApi() {
  374. let self = this
  375. wechatAppAuth({
  376. userInfo: self.appUserInfo,
  377. phone: this.account,
  378. code: this.captcha
  379. }).then(({
  380. data
  381. }) => {
  382. if (data.isbind) {
  383. uni.showModal({
  384. title: self.$t(`提示`),
  385. content: self.$t(`请绑定手机号后,继续操作`),
  386. showCancel: false,
  387. success: function (res) {
  388. if (res.confirm) {
  389. self.current = 1
  390. self.appLoginStatus = true
  391. }
  392. }
  393. });
  394. } else {
  395. self.$store.commit("LOGIN", {
  396. 'token': data.token,
  397. 'time': data.expires_time - self.$Cache.time()
  398. });
  399. let backUrl = self.$Cache.get(BACK_URL) || "/pages/index/index";
  400. self.$Cache.clear(BACK_URL);
  401. self.$store.commit("SETUID", data.userInfo.userId);
  402. uni.reLaunch({
  403. url: backUrl
  404. });
  405. }
  406. }).catch(error => {
  407. uni.showModal({
  408. title: self.$t(`提示`),
  409. content: self.$t(`错误信息`) + `${error}`,
  410. success: function (res) {
  411. if (res.confirm) {
  412. console.log(self.$t(`用户点击确定`));
  413. } else if (res.cancel) {
  414. console.log(self.$t(`用户点击取消`));
  415. }
  416. }
  417. });
  418. })
  419. },
  420. again() {
  421. this.codeUrl =
  422. VUE_APP_API_URL +
  423. "/sms_captcha?" +
  424. "key=" +
  425. this.keyCode +
  426. Date.parse(new Date());
  427. },
  428. code() {
  429. let that = this
  430. if (!that.protocol) {
  431. this.inAnimation = true
  432. return that.$util.Tips({
  433. title: '请先阅读并同意协议'
  434. });
  435. }
  436. getCodeApi()
  437. .then(res => {
  438. that.keyCode = res.data.key;
  439. that.getCode();
  440. })
  441. .catch(res => {
  442. that.$util.Tips({
  443. title: res
  444. });
  445. });
  446. },
  447. async getLogoImage() {
  448. let that = this;
  449. let logoUrl = "https://demo26.crmeb.net/statics/system_images/login_logo.jpeg"
  450. that.logoUrl = logoUrl;
  451. getLogo(2).then(res => {
  452. that.logoUrl = res.data.logo_url;
  453. });
  454. },
  455. async loginMobile() {
  456. let that = this;
  457. if (!that.account) return that.$util.Tips({
  458. title: that.$t(`请输入手机号码`)
  459. });
  460. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  461. title: that.$t(`请输入正确的手机号码`)
  462. });
  463. if (!that.captcha) return that.$util.Tips({
  464. title: that.$t(`请输入验证码`)
  465. });
  466. if (!/^[\w\d]+$/i.test(that.captcha) || that.captcha.length != 6) return that.$util.Tips({
  467. title: that.$t(`请输入正确的验证码`)
  468. });
  469. if (!that.password) return that.$util.Tips({
  470. title: that.$t(`请输入登录密码`)
  471. });
  472. if (/^([0-9]|[a-z]|[A-Z]){0,6}$/i.test(that.password)) return that.$util.Tips({
  473. title: that.$t(`您输入的密码过于简单`)
  474. });
  475. if (!that.passwordConfirm) return that.$util.Tips({
  476. title: that.$t(`请确认登录密码`)
  477. });
  478. if (that.passwordConfirm != that.password) return that.$util.Tips({
  479. title: that.$t(`确认密码与登录密码不一致,请修正后注册`)
  480. });
  481. if (!that.codeInvitation) return that.$util.Tips({
  482. title: that.$t(`请输入邀请码`)
  483. });
  484. if (!that.protocol) {
  485. this.inAnimation = true
  486. return that.$util.Tips({
  487. title: '请先阅读并同意协议'
  488. });
  489. }
  490. if (that.appLoginStatus) {
  491. that.wxLoginApi()
  492. } else if (that.appleLoginStatus) {
  493. that.appleLoginApi()
  494. } else {
  495. if (this.keyLock) {
  496. this.keyLock = !this.keyLock
  497. } else {
  498. return that.$util.Tips({
  499. title: that.$t(`请勿重复点击`)
  500. });
  501. }
  502. uni.showLoading({
  503. title: that.$t(`注册中`)
  504. });
  505. postUserRegister({
  506. phone: that.account,
  507. captchaCode: that.captcha,
  508. password: that.password,
  509. inviteCode: that.codeInvitation,
  510. captchaId: that.captchaId,
  511. // spread: that.$Cache.get("spread")
  512. })
  513. .then(res => {
  514. uni.hideLoading();
  515. uni.$u.toast('注册成功');
  516. setTimeout(() => {
  517. uni.navigateTo({
  518. url: '/pages/users/wechat_login/index'
  519. })
  520. }, 1500);
  521. // let data = res.data;
  522. // that.$store.commit("LOGIN", {
  523. // 'token': data.token,
  524. // 'time': data.expires_time - this.$Cache.time()
  525. // });
  526. // let backUrl = that.$Cache.get(BACK_URL) || "/pages/index/index";
  527. // that.$Cache.clear(BACK_URL);
  528. // getUserInfo().then(res => {
  529. // this.keyLock = true
  530. // that.$store.commit("SETUID", res.data.userId);
  531. // if (backUrl.indexOf('/pages/users/login/index') !== -1) {
  532. // backUrl = '/pages/index/index';
  533. // }
  534. // uni.reLaunch({
  535. // url: backUrl
  536. // });
  537. // })
  538. })
  539. .catch(res => {
  540. this.keyLock = true
  541. that.$util.Tips({
  542. title: res
  543. });
  544. });
  545. }
  546. },
  547. async register() {
  548. let that = this;
  549. if (!that.protocol) {
  550. this.inAnimation = true
  551. return that.$util.Tips({
  552. title: '请先阅读并同意协议'
  553. });
  554. }
  555. if (!that.account) return that.$util.Tips({
  556. title: that.$t(`请填写手机号码`)
  557. });
  558. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  559. title: that.$t(`请输入正确的手机号码`)
  560. });
  561. if (!that.captcha) return that.$util.Tips({
  562. title: that.$t(`请填写验证码`)
  563. });
  564. if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
  565. title: that.$t(`请输入正确的验证码`)
  566. });
  567. if (!that.password) return that.$util.Tips({
  568. title: that.$t(`请填写密码`)
  569. });
  570. if (/^([0-9]|[a-z]|[A-Z]){0,6}$/i.test(that.password)) return that.$util.Tips({
  571. title: that.$t(`您输入的密码过于简单`)
  572. });
  573. register({
  574. account: that.account,
  575. captcha: that.captcha,
  576. password: that.password,
  577. spread: that.$Cache.get("spread")
  578. })
  579. .then(res => {
  580. that.$util.Tips({
  581. title: res
  582. });
  583. that.formItem = 1;
  584. })
  585. .catch(res => {
  586. that.$util.Tips({
  587. title: res
  588. });
  589. });
  590. },
  591. async getCode() {
  592. let that = this;
  593. if (this.$refs.uCode.canGetCode) {
  594. // 模拟向后端请求验证码
  595. uni.showLoading({
  596. title: '正在获取验证码'
  597. })
  598. if (!that.account) return that.$util.Tips({
  599. title: that.$t(`请填写手机号码`)
  600. });
  601. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  602. title: that.$t(`请输入正确的手机号码`)
  603. });
  604. await postSendValidate({
  605. phone: that.account
  606. })
  607. .then(res => {
  608. uni.hideLoading();
  609. that.captchaId = res.data.id
  610. // 这里此提示会被this.start()方法中的提示覆盖
  611. uni.$u.toast('验证码已发送');
  612. // 通知验证码组件内部开始倒计时
  613. this.$refs.uCode.start();
  614. })
  615. .catch(res => {
  616. that.$util.Tips({
  617. title: res
  618. });
  619. });
  620. } else {
  621. uni.$u.toast('倒计时结束后再发送');
  622. }
  623. // if (!that.protocol) {
  624. // this.inAnimation = true
  625. // return that.$util.Tips({
  626. // title: '请先阅读并同意协议'
  627. // });
  628. // }
  629. },
  630. navTap: function (index) {
  631. this.current = index;
  632. },
  633. async submit() {
  634. let that = this;
  635. if (!that.protocol) {
  636. this.inAnimation = true
  637. return that.$util.Tips({
  638. title: '请先阅读并同意协议'
  639. });
  640. }
  641. if (!that.account) return that.$util.Tips({
  642. title: that.$t(`请填写账号`)
  643. });
  644. if (!/^[\w\d]{5,16}$/i.test(that.account)) return that.$util.Tips({
  645. title: that.$t(`请输入正确的账号`)
  646. });
  647. if (!that.password) return that.$util.Tips({
  648. title: that.$t(`请填写密码`)
  649. });
  650. if (this.keyLock) {
  651. this.keyLock = !this.keyLock
  652. } else {
  653. return that.$util.Tips({
  654. title: that.$t(`请勿重复点击`)
  655. });
  656. }
  657. loginH5({
  658. account: that.account,
  659. password: that.password,
  660. spread: that.$Cache.get("spread")
  661. })
  662. .then(({
  663. data
  664. }) => {
  665. that.$store.commit("LOGIN", {
  666. 'token': data.token,
  667. 'time': data.expires_time - this.$Cache.time()
  668. });
  669. let backUrl = that.$Cache.get(BACK_URL) || "/pages/index/index";
  670. that.$Cache.clear(BACK_URL);
  671. getUserInfo().then(res => {
  672. this.keyLock = true
  673. that.$store.commit("SETUID", res.data.userId);
  674. uni.reLaunch({
  675. url: backUrl
  676. });
  677. }).catch(error => {
  678. this.keyLock = true
  679. })
  680. })
  681. .catch(e => {
  682. this.keyLock = true
  683. that.$util.Tips({
  684. title: e
  685. });
  686. });
  687. }
  688. }
  689. };
  690. </script>
  691. <style>
  692. page {
  693. background: #fff;
  694. }
  695. </style>
  696. <style lang="scss">
  697. .appLogin {
  698. margin-top: 60rpx;
  699. .hds {
  700. display: flex;
  701. justify-content: center;
  702. align-items: center;
  703. font-size: 24rpx;
  704. color: #B4B4B4;
  705. .line {
  706. width: 68rpx;
  707. height: 1rpx;
  708. background: #CCCCCC;
  709. }
  710. p {
  711. margin: 0 20rpx;
  712. }
  713. }
  714. .btn-wrapper {
  715. display: flex;
  716. align-items: center;
  717. justify-content: center;
  718. margin-top: 30rpx;
  719. .btn {
  720. display: flex;
  721. align-items: center;
  722. justify-content: center;
  723. width: 68rpx;
  724. height: 68rpx;
  725. border-radius: 50%;
  726. }
  727. .apple-btn {
  728. display: flex;
  729. align-items: center;
  730. justify-content: center;
  731. width: 68rpx;
  732. height: 68rpx;
  733. border-radius: 50%;
  734. background: #000;
  735. .icon-s-pingguo {
  736. color: #fff;
  737. font-size: 44rpx;
  738. }
  739. }
  740. .iconfont {
  741. font-size: 40rpx;
  742. color: #fff;
  743. }
  744. .wx {
  745. margin-right: 30rpx;
  746. background-color: #61C64F;
  747. }
  748. .mima {
  749. margin-right: 30rpx;
  750. background-color: #28B3E9;
  751. }
  752. .yanzheng {
  753. margin-right: 30rpx;
  754. background-color: #F89C23;
  755. }
  756. }
  757. }
  758. .code img {
  759. width: 100%;
  760. height: 100%;
  761. }
  762. .acea-row.row-middle {
  763. input {
  764. margin-left: 20rpx;
  765. display: block;
  766. }
  767. }
  768. .login-wrapper {
  769. padding: 30rpx;
  770. .shading {
  771. display: flex;
  772. align-items: center;
  773. justify-content: center;
  774. width: 100%;
  775. /* #ifdef APP-VUE */
  776. margin-top: 50rpx;
  777. /* #endif */
  778. /* #ifndef APP-VUE */
  779. margin-top: 20rpx;
  780. /* #endif */
  781. image {
  782. width: 240rpx;
  783. height: 120rpx;
  784. }
  785. }
  786. .whiteBg {
  787. margin-top: 100rpx;
  788. .list {
  789. border-radius: 16rpx;
  790. overflow: hidden;
  791. .item {
  792. border-bottom: 1px solid #F0F0F0;
  793. background: #fff;
  794. .row-middle {
  795. position: relative;
  796. padding: 16rpx 45rpx;
  797. input {
  798. flex: 1;
  799. font-size: 28rpx;
  800. height: 80rpx;
  801. }
  802. .code {
  803. position: absolute;
  804. right: 30rpx;
  805. top: 50%;
  806. color: var(--view-theme);
  807. font-size: 26rpx;
  808. transform: translateY(-50%);
  809. }
  810. }
  811. }
  812. }
  813. .logon {
  814. display: flex;
  815. align-items: center;
  816. justify-content: center;
  817. width: 100%;
  818. height: 86rpx;
  819. margin-top: 80rpx;
  820. background-color: var(--view-theme);
  821. border-radius: 120rpx;
  822. color: #FFFFFF;
  823. font-size: 30rpx;
  824. }
  825. .tips {
  826. margin: 30rpx;
  827. text-align: center;
  828. color: #999;
  829. }
  830. }
  831. }
  832. .protocol {
  833. margin-top: 40rpx;
  834. color: #999999;
  835. font-size: 24rpx;
  836. text-align: center;
  837. bottom: 20rpx;
  838. }
  839. .trembling {
  840. animation: shake 0.6s;
  841. }
  842. .main-color {
  843. color: var(--view-theme);
  844. }
  845. </style>