|
|
@@ -8,6 +8,7 @@ let codeInter: number = 0;
|
|
|
let setInter: number = 0
|
|
|
import { baseurl, captcha } from '../../config'
|
|
|
import { getAuthCodeImpl, phoneLoginImpl } from "../../service/impl/hwUser.impl";
|
|
|
+import { getPrivacySetting } from "../../utils/util";
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
@@ -158,70 +159,75 @@ Page({
|
|
|
* @code {string} 验证码
|
|
|
* @register_from {注册来源} 0 小程序 1 APP 2 后台
|
|
|
*/
|
|
|
- submit() {
|
|
|
- // 首先判断是否可以登陆
|
|
|
- const status = this.data.canLogin;
|
|
|
- if (status) {
|
|
|
- phoneLoginImpl({
|
|
|
- phone: this.data.phone,
|
|
|
- code: this.data.code,
|
|
|
- register_from: 0
|
|
|
- }).then(res => {
|
|
|
- if (res.errCode === 0) {
|
|
|
- // 请求成功 存入userID和userToken 并根据来源跳转不同的页面 后台账号跳转首页
|
|
|
- wx.setStorage({
|
|
|
- key: 'userId',
|
|
|
- data: res.data.userInfo.id,
|
|
|
- success: () => {
|
|
|
- wx.setStorage({
|
|
|
- key: 'userToken',
|
|
|
- data: res.data.userInfo.userToken,
|
|
|
- success: () => {
|
|
|
- wx.setStorageSync('userInfo', res.data.userInfo)
|
|
|
- wx.setStorageSync('firstLogin', true)
|
|
|
- if (!wx.getStorageInfoSync().keys.length) {
|
|
|
- wx.setStorageSync('hasClear', true)
|
|
|
- }
|
|
|
- // 提交是否登录信息
|
|
|
- if (res.data.userInfo.isDemonstrate) {
|
|
|
- wx.reLaunch({
|
|
|
- url: '/pages/index/index'
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.reLaunch({
|
|
|
- url: '/pages/my-order/my-order'
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- let content = ''
|
|
|
- if (!this.data.isCheck) {
|
|
|
- content = '请勾选用用户协议与隐私政策'
|
|
|
- }
|
|
|
- if (!this.data.code) {
|
|
|
- content = '请填写验证码'
|
|
|
- }
|
|
|
- if (!this.data.phone || !app.globalData.phone_zz.test(this.data.phone)) {
|
|
|
- content = '电话号码格式错误'
|
|
|
- }
|
|
|
- wx.showModal({
|
|
|
- title: '登录失败',
|
|
|
- content,
|
|
|
- showCancel: false,
|
|
|
- confirmColor: '#31364C',
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
+ submit() {
|
|
|
+ // 首先判断是否可以登陆
|
|
|
+ const status = this.data.canLogin;
|
|
|
+ getPrivacySetting().then(data => {
|
|
|
+ if (data.needAuthorization) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (status) {
|
|
|
+ phoneLoginImpl({
|
|
|
+ phone: this.data.phone,
|
|
|
+ code: this.data.code,
|
|
|
+ register_from: 0
|
|
|
+ }).then(res => {
|
|
|
+ if (res.errCode === 0) {
|
|
|
+ // 请求成功 存入userID和userToken 并根据来源跳转不同的页面 后台账号跳转首页
|
|
|
+ wx.setStorage({
|
|
|
+ key: 'userId',
|
|
|
+ data: res.data.userInfo.id,
|
|
|
+ success: () => {
|
|
|
+ wx.setStorage({
|
|
|
+ key: 'userToken',
|
|
|
+ data: res.data.userInfo.userToken,
|
|
|
+ success: () => {
|
|
|
+ wx.setStorageSync('userInfo', res.data.userInfo)
|
|
|
+ wx.setStorageSync('firstLogin', true)
|
|
|
+ if (!wx.getStorageInfoSync().keys.length) {
|
|
|
+ wx.setStorageSync('hasClear', true)
|
|
|
+ }
|
|
|
+ // 提交是否登录信息
|
|
|
+ if (res.data.userInfo.isDemonstrate) {
|
|
|
+ wx.reLaunch({
|
|
|
+ url: '/pages/index/index'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.reLaunch({
|
|
|
+ url: '/pages/my-order/my-order'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let content = ''
|
|
|
+ if (!this.data.isCheck) {
|
|
|
+ content = '请勾选用用户协议与隐私政策'
|
|
|
+ }
|
|
|
+ if (!this.data.code) {
|
|
|
+ content = '请填写验证码'
|
|
|
+ }
|
|
|
+ if (!this.data.phone || !app.globalData.phone_zz.test(this.data.phone)) {
|
|
|
+ content = '电话号码格式错误'
|
|
|
+ }
|
|
|
+ wx.showModal({
|
|
|
+ title: '登录失败',
|
|
|
+ content,
|
|
|
+ showCancel: false,
|
|
|
+ confirmColor: '#31364C',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
- this.options = options;
|
|
|
+ this.options = options;
|
|
|
},
|
|
|
|
|
|
/**
|