From 5b3f8821f54a7da1934248049321e7977849c0e9 Mon Sep 17 00:00:00 2001
From: xpz2018 <107107461@qq.com>
Date: Thu, 21 Jan 2021 20:26:24 +0800
Subject: [PATCH] no message
---
pages/login/index.js | 70 +++++++++++++++++++++++++++++++++---------
pages/login/index.wxml | 41 ++++++++++++++++---------
2 files changed, 82 insertions(+), 29 deletions(-)
diff --git a/pages/login/index.js b/pages/login/index.js
index a19e08a..3bec633 100644
--- a/pages/login/index.js
+++ b/pages/login/index.js
@@ -1,6 +1,6 @@
//获取应用实例
import Dialog from '../../components/dialog/dialog'
-import { config, postCaptcha, loginCaptcha, loginPwd, verifyCode } from "../api/user"
+import { config, wechatApplet, loginWechat, postCaptcha, loginCaptcha, loginPwd, verifyCode } from "../api/user"
import { sconfig, loginToken, getBaseInfo } from "../api/saas"
const util = require('../../utils/util')
const storage = require('../../utils/storage')
@@ -20,6 +20,7 @@ Page({
captcha: null
},
loging: false,
+ regist: false,
qrPage: null,
metaData: null,
code: null
@@ -37,6 +38,7 @@ Page({
let q = decodeURIComponent(options.q)
this.data.code = q.substring(q.indexOf('?'))
}
+ this.wxLogin()
},
onReady: function () {
wx.getSystemInfo({
@@ -91,20 +93,20 @@ Page({
config.header = { 'Authorization': 'QNT ' + authorization }
loginToken({loginToken: app.globalData.token}).then(result => {
sconfig.header = { 'Authorization': 'QNT ' + result.data }
- wx.redirectTo({ url: '/pages/index/index' })
- // getBaseInfo().then(result => {
- // this.setData({ loging: false})
- // app.userInfo = result.data
- // wx.hideLoading()
- // wx.redirectTo({ url: '/pages/index/index' })
- // }).catch(err => {
- // wx.hideLoading()
- // util.showToast(err)
- // app.globalData.token = null
- // storage.remove('Authorization')
- // config.header = null
- // this.setData({ loging: false})
- // })
+ // wx.redirectTo({ url: '/pages/index/index' })
+ getBaseInfo().then(result => {
+ this.setData({ loging: false})
+ app.userInfo = result.data
+ wx.hideLoading()
+ wx.redirectTo({ url: '/pages/index/index' })
+ }).catch(err => {
+ wx.hideLoading()
+ util.showToast(err)
+ app.globalData.token = null
+ storage.remove('Authorization')
+ config.header = null
+ this.setData({ loging: false})
+ })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
@@ -114,10 +116,47 @@ Page({
this.setData({ loging: false})
})
},
+ wxLogin: function(){
+ wx.login({
+ success: res => {
+ wechatApplet({ authCode: res.code }).then(result => {
+ storage.put('tmpAuthToken', result.data.tmpAuthToken, 98)
+ })
+ }
+ })
+ },
/************************************** 注册流程 ********************************************/
readAgreement: function () {
wx.navigateTo({ url: '/pages/htmls/agreement/index' })
},
+ onGotUserInfo: function (e) {
+ if(this.data.loging){
+ return
+ }
+ this.setData({ loging: true })
+ if(this.data.form.tmpAuthToken){
+ this.registAccount()
+ return
+ }
+ loginWechat({ encryptedData: e.detail.encryptedData, iv: e.detail.iv }).then(result => {
+ storage.put('Authorization', result.data.token)
+ app.globalData.token = result.data.token
+ this.data.form.tmpAuthToken = result.data.tmpAuthToken
+ if(e.currentTarget.id == 'btn-login'){
+ this.registAccount()
+ } else {
+ this.fetchUserInfo()
+ }
+ }).catch(error => {
+ if(error.data && error.data.tmpAuthToken){
+ this.data.form.tmpAuthToken = error.data.tmpAuthToken
+ this.setData({ regist: true, loging: false })
+ } else {
+ this.setData({ loging: false })
+ }
+ util.showToast(error.message)
+ })
+ },
inputFocus: function(e) {
app.globalData.keyboardHeight = e.detail.height
},
@@ -208,6 +247,7 @@ Page({
this.setData({ type: 1, ['form.password']: null, loginEnable: true })
}
},
+
/************************************** 二维码流程 ********************************************/
fetchQrCode: function(code){
wx.showLoading({ title: '处理中', mask: true })
diff --git a/pages/login/index.wxml b/pages/login/index.wxml
index 53ba143..00bf6e9 100644
--- a/pages/login/index.wxml
+++ b/pages/login/index.wxml
@@ -3,47 +3,60 @@
-
+
手机号码
-
+
{{type == 1 ? '验证码' : '密码'}}
-
-
-
+
+
+
{{second}}
-
+
- {{type == 1 ? '密码登录' : '验证码登录'}}
+ {{type == 1 ? '密码登录' : '验证码登录'}}
-
-
- 登录
+
+ 服务协议和隐私政策
+
+ 请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了向你提工厂经营管理、订单结算以及其他业务的相关服务,我们需要获你的个人微信信息,然后验证是你本人在操作。
+ 你可阅读《纸通宝SAAS服务协议》了解详细信息,如你同意,请点击“同意”开始接受我们的服务。
+
+
-
+
- 仅限纸通宝工厂用户使用
+ 仅限纸通宝工厂客户使用
\ No newline at end of file