index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878
  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.getCode();
  209. // this.getLogoImage();
  210. },
  211. methods: {
  212. codeChange(text) {
  213. this.tips = text;
  214. },
  215. end() {
  216. this.keyLock = false
  217. },
  218. start() {
  219. // this.keyLock = !this.keyLock
  220. },
  221. ChangeIsDefault(e) {
  222. this.$set(this, 'protocol', !this.protocol);
  223. },
  224. privacy(type, title) {
  225. uni.navigateTo({
  226. url: "/pages/users/privacy/index?type=" + type + "&title=" + title
  227. })
  228. },
  229. // IOS 版本号判断
  230. getSystem(system) {
  231. let str
  232. system.toLowerCase().indexOf('ios') === -1 ? str = system : str = system.split(' ')[1]
  233. if (str.indexOf('.'))
  234. return str.split('.')[0] >= 13
  235. return str >= 13
  236. },
  237. // 苹果登录
  238. appleLogin() {
  239. let self = this
  240. this.account = ''
  241. this.captcha = ''
  242. if (!self.protocol) {
  243. this.inAnimation = true
  244. return self.$util.Tips({
  245. title: '请先阅读并同意协议'
  246. });
  247. }
  248. uni.showLoading({
  249. title: this.$t(`登录中`)
  250. })
  251. uni.login({
  252. provider: 'apple',
  253. timeout: 10000,
  254. success(loginRes) {
  255. uni.getUserInfo({
  256. provider: 'apple',
  257. success: function (infoRes) {
  258. self.appleUserInfo = infoRes.userInfo
  259. self.appleLoginApi()
  260. },
  261. fail() {
  262. uni.showToast({
  263. title: self.$t(`获取用户信息失败`),
  264. icon: 'none',
  265. duration: 2000
  266. })
  267. },
  268. complete() {
  269. uni.hideLoading()
  270. }
  271. });
  272. },
  273. fail(error) {
  274. console.log(error)
  275. }
  276. })
  277. },
  278. // 苹果登录Api
  279. appleLoginApi() {
  280. let self = this
  281. appleLogin({
  282. openId: self.appleUserInfo.openId,
  283. email: self.appleUserInfo.email || '',
  284. phone: this.account,
  285. captcha: this.captcha
  286. }).then(({
  287. data
  288. }) => {
  289. if (data.isbind) {
  290. uni.showModal({
  291. title: self.$t(`提示`),
  292. content: self.$t(`请绑定手机号后,继续操作`),
  293. showCancel: false,
  294. success: function (res) {
  295. if (res.confirm) {
  296. self.current = 1
  297. self.appleLoginStatus = true
  298. }
  299. }
  300. });
  301. } else {
  302. self.$store.commit("LOGIN", {
  303. 'token': data.token,
  304. 'time': data.expires_time - self.$Cache.time()
  305. });
  306. let backUrl = self.$Cache.get(BACK_URL) || "/pages/index/index";
  307. self.$Cache.clear(BACK_URL);
  308. self.$store.commit("SETUID", data.userInfo.userId);
  309. uni.reLaunch({
  310. url: backUrl
  311. });
  312. }
  313. }).catch(error => {
  314. uni.showModal({
  315. title: self.$t(`提示`),
  316. content: self.$t(`错误信息`) + `${error}`,
  317. success: function (res) {
  318. if (res.confirm) {
  319. console.log(self.$t(`用户点击确定`));
  320. } else if (res.cancel) {
  321. console.log(self.$t(`用户点击取消`));
  322. }
  323. }
  324. });
  325. })
  326. },
  327. // App微信登录
  328. wxLogin() {
  329. let self = this
  330. this.account = ''
  331. this.captcha = ''
  332. if (!self.protocol) {
  333. this.inAnimation = true
  334. return self.$util.Tips({
  335. title: '请先阅读并同意协议'
  336. });
  337. }
  338. uni.showLoading({
  339. title: self.$t(`登录中`)
  340. })
  341. uni.login({
  342. provider: 'weixin',
  343. success: function (loginRes) {
  344. // 获取用户信息
  345. uni.getUserInfo({
  346. provider: 'weixin',
  347. success: function (infoRes) {
  348. self.appUserInfo = infoRes.userInfo
  349. self.wxLoginApi()
  350. },
  351. fail() {
  352. uni.showToast({
  353. title: self.$t(`获取用户信息失败`),
  354. icon: 'none',
  355. duration: 2000
  356. })
  357. },
  358. complete() {
  359. uni.hideLoading()
  360. }
  361. });
  362. },
  363. fail() {
  364. uni.showToast({
  365. title: self.$t(`登录失败`),
  366. icon: 'none',
  367. duration: 2000
  368. })
  369. }
  370. });
  371. },
  372. wxLoginApi() {
  373. let self = this
  374. wechatAppAuth({
  375. userInfo: self.appUserInfo,
  376. phone: this.account,
  377. code: this.captcha
  378. }).then(({
  379. data
  380. }) => {
  381. if (data.isbind) {
  382. uni.showModal({
  383. title: self.$t(`提示`),
  384. content: self.$t(`请绑定手机号后,继续操作`),
  385. showCancel: false,
  386. success: function (res) {
  387. if (res.confirm) {
  388. self.current = 1
  389. self.appLoginStatus = true
  390. }
  391. }
  392. });
  393. } else {
  394. self.$store.commit("LOGIN", {
  395. 'token': data.token,
  396. 'time': data.expires_time - self.$Cache.time()
  397. });
  398. let backUrl = self.$Cache.get(BACK_URL) || "/pages/index/index";
  399. self.$Cache.clear(BACK_URL);
  400. self.$store.commit("SETUID", data.userInfo.userId);
  401. uni.reLaunch({
  402. url: backUrl
  403. });
  404. }
  405. }).catch(error => {
  406. uni.showModal({
  407. title: self.$t(`提示`),
  408. content: self.$t(`错误信息`) + `${error}`,
  409. success: function (res) {
  410. if (res.confirm) {
  411. console.log(self.$t(`用户点击确定`));
  412. } else if (res.cancel) {
  413. console.log(self.$t(`用户点击取消`));
  414. }
  415. }
  416. });
  417. })
  418. },
  419. again() {
  420. this.codeUrl =
  421. VUE_APP_API_URL +
  422. "/sms_captcha?" +
  423. "key=" +
  424. this.keyCode +
  425. Date.parse(new Date());
  426. },
  427. code() {
  428. let that = this
  429. if (!that.protocol) {
  430. this.inAnimation = true
  431. return that.$util.Tips({
  432. title: '请先阅读并同意协议'
  433. });
  434. }
  435. getCodeApi()
  436. .then(res => {
  437. that.keyCode = res.data.key;
  438. that.getCode();
  439. })
  440. .catch(res => {
  441. that.$util.Tips({
  442. title: res
  443. });
  444. });
  445. },
  446. async getLogoImage() {
  447. let that = this;
  448. let logoUrl = "https://demo26.crmeb.net/statics/system_images/login_logo.jpeg"
  449. that.logoUrl = logoUrl;
  450. getLogo(2).then(res => {
  451. that.logoUrl = res.data.logo_url;
  452. });
  453. },
  454. async loginMobile() {
  455. let that = this;
  456. if (!that.account) return that.$util.Tips({
  457. title: that.$t(`请输入手机号码`)
  458. });
  459. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  460. title: that.$t(`请输入正确的手机号码`)
  461. });
  462. if (!that.captcha) return that.$util.Tips({
  463. title: that.$t(`请输入验证码`)
  464. });
  465. if (!/^[\w\d]+$/i.test(that.captcha) || that.captcha.length != 6) return that.$util.Tips({
  466. title: that.$t(`请输入正确的验证码`)
  467. });
  468. if (!that.password) return that.$util.Tips({
  469. title: that.$t(`请输入登录密码`)
  470. });
  471. if (/^([0-9]|[a-z]|[A-Z]){0,6}$/i.test(that.password)) return that.$util.Tips({
  472. title: that.$t(`您输入的密码过于简单`)
  473. });
  474. if (!that.passwordConfirm) return that.$util.Tips({
  475. title: that.$t(`请确认登录密码`)
  476. });
  477. if (that.passwordConfirm != that.password) return that.$util.Tips({
  478. title: that.$t(`确认密码与登录密码不一致,请修正后注册`)
  479. });
  480. if (!that.codeInvitation) return that.$util.Tips({
  481. title: that.$t(`请输入邀请码`)
  482. });
  483. if (!that.protocol) {
  484. this.inAnimation = true
  485. return that.$util.Tips({
  486. title: '请先阅读并同意协议'
  487. });
  488. }
  489. if (that.appLoginStatus) {
  490. that.wxLoginApi()
  491. } else if (that.appleLoginStatus) {
  492. that.appleLoginApi()
  493. } else {
  494. if (this.keyLock) {
  495. this.keyLock = !this.keyLock
  496. } else {
  497. return that.$util.Tips({
  498. title: that.$t(`请勿重复点击`)
  499. });
  500. }
  501. uni.showLoading({
  502. title: that.$t(`注册中`)
  503. });
  504. postUserRegister({
  505. phone: that.account,
  506. captchaCode: that.captcha,
  507. password: that.password,
  508. inviteCode: that.codeInvitation,
  509. captchaId: that.captchaId,
  510. // spread: that.$Cache.get("spread")
  511. })
  512. .then(res => {
  513. uni.hideLoading();
  514. uni.$u.toast('注册成功');
  515. setTimeout(() => {
  516. uni.navigateTo({
  517. url: '/pages/users/wechat_login/index'
  518. })
  519. }, 1500);
  520. // let data = res.data;
  521. // that.$store.commit("LOGIN", {
  522. // 'token': data.token,
  523. // 'time': data.expires_time - this.$Cache.time()
  524. // });
  525. // let backUrl = that.$Cache.get(BACK_URL) || "/pages/index/index";
  526. // that.$Cache.clear(BACK_URL);
  527. // getUserInfo().then(res => {
  528. // this.keyLock = true
  529. // that.$store.commit("SETUID", res.data.userId);
  530. // if (backUrl.indexOf('/pages/users/login/index') !== -1) {
  531. // backUrl = '/pages/index/index';
  532. // }
  533. // uni.reLaunch({
  534. // url: backUrl
  535. // });
  536. // })
  537. })
  538. .catch(res => {
  539. this.keyLock = true
  540. that.$util.Tips({
  541. title: res
  542. });
  543. });
  544. }
  545. },
  546. async register() {
  547. let that = this;
  548. if (!that.protocol) {
  549. this.inAnimation = true
  550. return that.$util.Tips({
  551. title: '请先阅读并同意协议'
  552. });
  553. }
  554. if (!that.account) return that.$util.Tips({
  555. title: that.$t(`请填写手机号码`)
  556. });
  557. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  558. title: that.$t(`请输入正确的手机号码`)
  559. });
  560. if (!that.captcha) return that.$util.Tips({
  561. title: that.$t(`请填写验证码`)
  562. });
  563. if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
  564. title: that.$t(`请输入正确的验证码`)
  565. });
  566. if (!that.password) return that.$util.Tips({
  567. title: that.$t(`请填写密码`)
  568. });
  569. if (/^([0-9]|[a-z]|[A-Z]){0,6}$/i.test(that.password)) return that.$util.Tips({
  570. title: that.$t(`您输入的密码过于简单`)
  571. });
  572. register({
  573. account: that.account,
  574. captcha: that.captcha,
  575. password: that.password,
  576. spread: that.$Cache.get("spread")
  577. })
  578. .then(res => {
  579. that.$util.Tips({
  580. title: res
  581. });
  582. that.formItem = 1;
  583. })
  584. .catch(res => {
  585. that.$util.Tips({
  586. title: res
  587. });
  588. });
  589. },
  590. async getCode() {
  591. let that = this;
  592. if (this.$refs.uCode.canGetCode) {
  593. // 模拟向后端请求验证码
  594. uni.showLoading({
  595. title: '正在获取验证码'
  596. })
  597. if (!that.account) return that.$util.Tips({
  598. title: that.$t(`请填写手机号码`)
  599. });
  600. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  601. title: that.$t(`请输入正确的手机号码`)
  602. });
  603. await postSendValidate({
  604. phone: that.account
  605. })
  606. .then(res => {
  607. uni.hideLoading();
  608. that.captchaId = res.data.id
  609. // 这里此提示会被this.start()方法中的提示覆盖
  610. uni.$u.toast('验证码已发送');
  611. // 通知验证码组件内部开始倒计时
  612. this.$refs.uCode.start();
  613. })
  614. .catch(res => {
  615. that.$util.Tips({
  616. title: res
  617. });
  618. });
  619. } else {
  620. uni.$u.toast('倒计时结束后再发送');
  621. }
  622. // if (!that.protocol) {
  623. // this.inAnimation = true
  624. // return that.$util.Tips({
  625. // title: '请先阅读并同意协议'
  626. // });
  627. // }
  628. },
  629. navTap: function (index) {
  630. this.current = index;
  631. },
  632. async submit() {
  633. let that = this;
  634. if (!that.protocol) {
  635. this.inAnimation = true
  636. return that.$util.Tips({
  637. title: '请先阅读并同意协议'
  638. });
  639. }
  640. if (!that.account) return that.$util.Tips({
  641. title: that.$t(`请填写账号`)
  642. });
  643. if (!/^[\w\d]{5,16}$/i.test(that.account)) return that.$util.Tips({
  644. title: that.$t(`请输入正确的账号`)
  645. });
  646. if (!that.password) return that.$util.Tips({
  647. title: that.$t(`请填写密码`)
  648. });
  649. if (this.keyLock) {
  650. this.keyLock = !this.keyLock
  651. } else {
  652. return that.$util.Tips({
  653. title: that.$t(`请勿重复点击`)
  654. });
  655. }
  656. loginH5({
  657. account: that.account,
  658. password: that.password,
  659. spread: that.$Cache.get("spread")
  660. })
  661. .then(({
  662. data
  663. }) => {
  664. that.$store.commit("LOGIN", {
  665. 'token': data.token,
  666. 'time': data.expires_time - this.$Cache.time()
  667. });
  668. let backUrl = that.$Cache.get(BACK_URL) || "/pages/index/index";
  669. that.$Cache.clear(BACK_URL);
  670. getUserInfo().then(res => {
  671. this.keyLock = true
  672. that.$store.commit("SETUID", res.data.userId);
  673. uni.reLaunch({
  674. url: backUrl
  675. });
  676. }).catch(error => {
  677. this.keyLock = true
  678. })
  679. })
  680. .catch(e => {
  681. this.keyLock = true
  682. that.$util.Tips({
  683. title: e
  684. });
  685. });
  686. }
  687. }
  688. };
  689. </script>
  690. <style>
  691. page {
  692. background: #fff;
  693. }
  694. </style>
  695. <style lang="scss">
  696. .appLogin {
  697. margin-top: 60rpx;
  698. .hds {
  699. display: flex;
  700. justify-content: center;
  701. align-items: center;
  702. font-size: 24rpx;
  703. color: #B4B4B4;
  704. .line {
  705. width: 68rpx;
  706. height: 1rpx;
  707. background: #CCCCCC;
  708. }
  709. p {
  710. margin: 0 20rpx;
  711. }
  712. }
  713. .btn-wrapper {
  714. display: flex;
  715. align-items: center;
  716. justify-content: center;
  717. margin-top: 30rpx;
  718. .btn {
  719. display: flex;
  720. align-items: center;
  721. justify-content: center;
  722. width: 68rpx;
  723. height: 68rpx;
  724. border-radius: 50%;
  725. }
  726. .apple-btn {
  727. display: flex;
  728. align-items: center;
  729. justify-content: center;
  730. width: 68rpx;
  731. height: 68rpx;
  732. border-radius: 50%;
  733. background: #000;
  734. .icon-s-pingguo {
  735. color: #fff;
  736. font-size: 44rpx;
  737. }
  738. }
  739. .iconfont {
  740. font-size: 40rpx;
  741. color: #fff;
  742. }
  743. .wx {
  744. margin-right: 30rpx;
  745. background-color: #61C64F;
  746. }
  747. .mima {
  748. margin-right: 30rpx;
  749. background-color: #28B3E9;
  750. }
  751. .yanzheng {
  752. margin-right: 30rpx;
  753. background-color: #F89C23;
  754. }
  755. }
  756. }
  757. .code img {
  758. width: 100%;
  759. height: 100%;
  760. }
  761. .acea-row.row-middle {
  762. input {
  763. margin-left: 20rpx;
  764. display: block;
  765. }
  766. }
  767. .login-wrapper {
  768. padding: 30rpx;
  769. .shading {
  770. display: flex;
  771. align-items: center;
  772. justify-content: center;
  773. width: 100%;
  774. /* #ifdef APP-VUE */
  775. margin-top: 50rpx;
  776. /* #endif */
  777. /* #ifndef APP-VUE */
  778. margin-top: 20rpx;
  779. /* #endif */
  780. image {
  781. width: 240rpx;
  782. height: 120rpx;
  783. }
  784. }
  785. .whiteBg {
  786. margin-top: 100rpx;
  787. .list {
  788. border-radius: 16rpx;
  789. overflow: hidden;
  790. .item {
  791. border-bottom: 1px solid #F0F0F0;
  792. background: #fff;
  793. .row-middle {
  794. position: relative;
  795. padding: 16rpx 45rpx;
  796. input {
  797. flex: 1;
  798. font-size: 28rpx;
  799. height: 80rpx;
  800. }
  801. .code {
  802. position: absolute;
  803. right: 30rpx;
  804. top: 50%;
  805. color: var(--view-theme);
  806. font-size: 26rpx;
  807. transform: translateY(-50%);
  808. }
  809. }
  810. }
  811. }
  812. .logon {
  813. display: flex;
  814. align-items: center;
  815. justify-content: center;
  816. width: 100%;
  817. height: 86rpx;
  818. margin-top: 80rpx;
  819. background-color: var(--view-theme);
  820. border-radius: 120rpx;
  821. color: #FFFFFF;
  822. font-size: 30rpx;
  823. }
  824. .tips {
  825. margin: 30rpx;
  826. text-align: center;
  827. color: #999;
  828. }
  829. }
  830. }
  831. .protocol {
  832. margin-top: 40rpx;
  833. color: #999999;
  834. font-size: 24rpx;
  835. text-align: center;
  836. bottom: 20rpx;
  837. }
  838. .trembling {
  839. animation: shake 0.6s;
  840. }
  841. .main-color {
  842. color: var(--view-theme);
  843. }
  844. </style>