Browse Source

no message

feature/v1.0
xpz2018 5 years ago
parent
commit
b9cea85338
3 changed files with 23 additions and 20 deletions
  1. 6
      api/user.js
  2. 14
      pages/home/employee/index.js
  3. 23
      pages/login/index.js

6
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 setPassword = (params) => mPost(`/uec/user/set/sign-in-password`, params, config)
const modifyMobile = (params) => mPost(`/uec/user/modify/mobile`, params, config) const modifyMobile = (params) => mPost(`/uec/user/modify/mobile`, params, config)
const updateUserInfo = (params) => mPost('/uec/user/update/user-info', 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 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小程序登录 // /authorize/by-wechat-applet小程序登录
@ -187,5 +188,6 @@ export {
setPassword, setPassword,
modifyMobile, modifyMobile,
verifyCode, verifyCode,
bindingAccount
generateCode,
applyEmplyee
} }

14
pages/home/employee/index.js

@ -1,5 +1,5 @@
// pages/home/employee/index.js // 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 util = require('../../../utils/util')
const app = getApp() const app = getApp()
@ -21,8 +21,8 @@ Page({
*/ */
onLoad: function (options) { onLoad: function (options) {
this.setData({ height: app.globalData.fragmentHeight }) this.setData({ height: app.globalData.fragmentHeight })
wx.showLoading({ title: '加载中', mask: true })
this.fetchMemberList()
// wx.showLoading({ title: '加载中', mask: true })
// this.fetchMemberList()
}, },
fetchMemberList: function(){ fetchMemberList: function(){
getCheckList({enterpriseId: app.accountInfo.enterpriseId}).then(result => { getCheckList({enterpriseId: app.accountInfo.enterpriseId}).then(result => {
@ -135,14 +135,12 @@ Page({
}, },
addEmployee: function(event){ addEmployee: function(event){
wx.showLoading({ title: '加载中', mask: true }) 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 }) this.setData({ showEmbedded: true, base64: result.data })
wx.hideLoading() wx.hideLoading()
}).catch(err => { }).catch(err => {
//异常回调
wx.hideLoading() wx.hideLoading()
util.showToast(err) util.showToast(err)
}) })

23
pages/login/index.js

@ -1,7 +1,7 @@
//获取应用实例 //获取应用实例
import Dialog from '../../components/dialog/dialog' 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 util = require('../../utils/util')
const storage = require('../../utils/storage') const storage = require('../../utils/storage')
const app = getApp() const app = getApp()
@ -24,7 +24,7 @@ Page({
regist: false, regist: false,
metaData: null, metaData: null,
// code: null, // code: null,
code: '?mark=cloudprint&QrCodeRecordId=552611775347036160'
code: '?mark=cloudprint&QrCodeRecordId=552615937199706112'
}, },
/************************************** 初始化登录流程 ********************************************/ /************************************** 初始化登录流程 ********************************************/
onLoad: function (options) { onLoad: function (options) {
@ -89,16 +89,16 @@ Page({
}, },
/************************************** 获取用户信息,进行登录 ********************************************/ /************************************** 获取用户信息,进行登录 ********************************************/
fetchUserInfo: function(authorization){ fetchUserInfo: function(authorization){
// config.header = { 'Authorization': 'QNT ' + authorization }
config.header = { 'Authorization': 'QNT ' + authorization }
// token 切换流程 // token 切换流程
loginToken({loginToken: authorization}).then(result => { loginToken({loginToken: authorization}).then(result => {
sconfig.header = { 'Authorization': 'QNT ' + result.data } sconfig.header = { 'Authorization': 'QNT ' + result.data }
getUserInfo().then(result => { getUserInfo().then(result => {
app.userInfo = result.data app.userInfo = result.data
app.globalData.token = authorization
wx.hideLoading() wx.hideLoading()
if(app.userInfo.enterpriseId){ if(app.userInfo.enterpriseId){
app.globalData.token = authorization
storage.put('Authorization', authorization)
storage.put('Authorization', app.globalData.token)
this.setData({ loging: false}) this.setData({ loging: false})
if(this.data.metaData && app.userInfo.enterpriseId != this.data.metaData.enterpriseId){ if(this.data.metaData && app.userInfo.enterpriseId != this.data.metaData.enterpriseId){
Dialog.alert({ title: '温馨提示', message: '您已经绑定过工厂了,现在就进入?' }).then(() => { Dialog.alert({ title: '温馨提示', message: '您已经绑定过工厂了,现在就进入?' }).then(() => {
@ -109,8 +109,7 @@ Page({
} }
} else if(this.data.metaData){ } else if(this.data.metaData){
// 这里要进行账号的绑定,对工厂进行绑定;或者进行申请操作; // 这里要进行账号的绑定,对工厂进行绑定;或者进行申请操作;
app.globalData.token = authorization
storage.put('Authorization', authorization)
this.setData({ loging: false, metaData: this.data.metaData }) this.setData({ loging: false, metaData: this.data.metaData })
} else { } else {
this.setData({ loging: false}) this.setData({ loging: false})
@ -289,6 +288,7 @@ Page({
if(this.data.metaData.qrPage == '/page/index/yaoqing'){ if(this.data.metaData.qrPage == '/page/index/yaoqing'){
bindingAdmin(this.data.metaData).then(result => { bindingAdmin(this.data.metaData).then(result => {
wx.hideLoading() wx.hideLoading()
storage.put('Authorization', app.globalData.token)
app.userInfo.enterpriseId = this.data.metaData.factoryId app.userInfo.enterpriseId = this.data.metaData.factoryId
app.userInfo.enterpriseName = this.data.metaData.factoryName app.userInfo.enterpriseName = this.data.metaData.factoryName
this.data.metaData = null this.data.metaData = null
@ -299,8 +299,8 @@ Page({
this.setData({loging: false}) this.setData({loging: false})
util.showToast(error) 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 this.data.metaData = null
wx.hideLoading() wx.hideLoading()
this.setData({loging: false}) this.setData({loging: false})
@ -311,6 +311,9 @@ Page({
this.setData({loging: false}) this.setData({loging: false})
util.showToast(error) util.showToast(error)
}) })
} else {
Dialog.alert({ title: '温馨提示', message: '扫码错误,请重新扫码。' }).then(() => {
})
} }
} }
}) })
Loading…
Cancel
Save