From b9cea853382de73b9726f429e387016f050d24dd Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Fri, 29 Jan 2021 19:46:38 +0800 Subject: [PATCH] no message --- api/user.js | 6 ++++-- pages/home/employee/index.js | 14 ++++++-------- pages/login/index.js | 23 +++++++++++++---------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/api/user.js b/api/user.js index ad08194..53cd4b1 100644 --- a/api/user.js +++ b/api/user.js @@ -18,8 +18,9 @@ const postCaptcha = (params) => mPost(`/uec/get/auth-captcha`, params, config) const setPassword = (params) => mPost(`/uec/user/set/sign-in-password`, params, config) const modifyMobile = (params) => mPost(`/uec/user/modify/mobile`, params, config) const updateUserInfo = (params) => mPost('/uec/user/update/user-info', params, config) +const generateCode = (params) => mPost('/uec/generate/qrcode', params, config) const verifyCode = (code, params) => mGet(`/uec/verify/qrcode${code}`, params, config) -const bindingAccount = (params) => mPost(`/uec/apply/to/be/emplyee/of/enterprise`, params, config) +const applyEmplyee = (params) => mPost(`/uec/apply/to/be/emplyee/of/enterprise-department`, params, config) // **************************************************************************************************************************************** // /authorize/by-wechat-applet小程序登录 @@ -187,5 +188,6 @@ export { setPassword, modifyMobile, verifyCode, - bindingAccount + generateCode, + applyEmplyee } \ No newline at end of file diff --git a/pages/home/employee/index.js b/pages/home/employee/index.js index b425f04..db5abfe 100644 --- a/pages/home/employee/index.js +++ b/pages/home/employee/index.js @@ -1,5 +1,5 @@ // pages/home/employee/index.js -import { getCheckList, getEmployeList, auditEmploye, adminEmploye, deleteEmploye, qrcodeEmploye } from "../../../api/user" +import { getCheckList, getEmployeList, auditEmploye, adminEmploye, deleteEmploye, generateCode } from "../../../api/user" const util = require('../../../utils/util') const app = getApp() @@ -21,8 +21,8 @@ Page({ */ onLoad: function (options) { this.setData({ height: app.globalData.fragmentHeight }) - wx.showLoading({ title: '加载中', mask: true }) - this.fetchMemberList() + // wx.showLoading({ title: '加载中', mask: true }) + // this.fetchMemberList() }, fetchMemberList: function(){ getCheckList({enterpriseId: app.accountInfo.enterpriseId}).then(result => { @@ -135,14 +135,12 @@ Page({ }, addEmployee: function(event){ wx.showLoading({ title: '加载中', mask: true }) - const form = { id: 2, action: '/page/index/shenqing' } - form.metaData = { enterpriseId: app.accountInfo.enterpriseId, name: app.accountInfo.enterpriseName } - qrcodeEmploye(form).then(result => { - //成功回调 + const form = { id: 5 } + form.metaData = { factoryId: app.userInfo.enterpriseId, factoryName: app.userInfo.enterpriseName } + generateCode(form).then(result => { this.setData({ showEmbedded: true, base64: result.data }) wx.hideLoading() }).catch(err => { - //异常回调 wx.hideLoading() util.showToast(err) }) diff --git a/pages/login/index.js b/pages/login/index.js index 3d6228a..8b72fb1 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -1,7 +1,7 @@ //获取应用实例 import Dialog from '../../components/dialog/dialog' -import { config, wechatApplet, loginWechat, postCaptcha, loginCaptcha, loginPwd, verifyCode } from "../../api/user" -import { sconfig, loginToken, getUserInfo, getBaseInfo, bindingAdmin, bindingAccount } from "../../api/saas" +import { config, wechatApplet, loginWechat, postCaptcha, loginCaptcha, loginPwd, verifyCode, applyEmplyee } from "../../api/user" +import { sconfig, loginToken, getUserInfo, getBaseInfo, bindingAdmin } from "../../api/saas" const util = require('../../utils/util') const storage = require('../../utils/storage') const app = getApp() @@ -24,7 +24,7 @@ Page({ regist: false, metaData: null, // code: null, - code: '?mark=cloudprint&QrCodeRecordId=552611775347036160' + code: '?mark=cloudprint&QrCodeRecordId=552615937199706112' }, /************************************** 初始化登录流程 ********************************************/ onLoad: function (options) { @@ -89,16 +89,16 @@ Page({ }, /************************************** 获取用户信息,进行登录 ********************************************/ fetchUserInfo: function(authorization){ - // config.header = { 'Authorization': 'QNT ' + authorization } + config.header = { 'Authorization': 'QNT ' + authorization } // token 切换流程 loginToken({loginToken: authorization}).then(result => { sconfig.header = { 'Authorization': 'QNT ' + result.data } getUserInfo().then(result => { app.userInfo = result.data + app.globalData.token = authorization wx.hideLoading() if(app.userInfo.enterpriseId){ - app.globalData.token = authorization - storage.put('Authorization', authorization) + storage.put('Authorization', app.globalData.token) this.setData({ loging: false}) if(this.data.metaData && app.userInfo.enterpriseId != this.data.metaData.enterpriseId){ Dialog.alert({ title: '温馨提示', message: '您已经绑定过工厂了,现在就进入?' }).then(() => { @@ -109,8 +109,7 @@ Page({ } } else if(this.data.metaData){ // 这里要进行账号的绑定,对工厂进行绑定;或者进行申请操作; - app.globalData.token = authorization - storage.put('Authorization', authorization) + this.setData({ loging: false, metaData: this.data.metaData }) } else { this.setData({ loging: false}) @@ -289,6 +288,7 @@ Page({ if(this.data.metaData.qrPage == '/page/index/yaoqing'){ bindingAdmin(this.data.metaData).then(result => { wx.hideLoading() + storage.put('Authorization', app.globalData.token) app.userInfo.enterpriseId = this.data.metaData.factoryId app.userInfo.enterpriseName = this.data.metaData.factoryName this.data.metaData = null @@ -299,8 +299,8 @@ Page({ this.setData({loging: false}) util.showToast(error) }) - } else { - bindingAccount(this.data.metaData).then(result => { + } else if(this.data.metaData.qrPage == '/page/index/shenqing'){ + applyEmplyee(this.data.metaData).then(result => { this.data.metaData = null wx.hideLoading() this.setData({loging: false}) @@ -311,6 +311,9 @@ Page({ this.setData({loging: false}) util.showToast(error) }) + } else { + Dialog.alert({ title: '温馨提示', message: '扫码错误,请重新扫码。' }).then(() => { + }) } } }) \ No newline at end of file