Browse Source

no message

feature/v1.0
xpz2018 5 years ago
parent
commit
a61c0377be
4 changed files with 57 additions and 31 deletions
  1. 79
      pages/login/index.js
  2. 4
      pages/login/index.wxml
  3. 3
      pages/process/index/index.js
  4. 2
      pages/process/index/index.wxml

79
pages/login/index.js

@ -22,7 +22,6 @@ Page({
}, },
loging: false, loging: false,
regist: false, regist: false,
qrPage: null,
metaData: null, metaData: null,
code: null code: null
}, },
@ -89,17 +88,34 @@ Page({
}, },
/************************************** 获取用户信息,进行登录 ********************************************/ /************************************** 获取用户信息,进行登录 ********************************************/
fetchUserInfo: function(authorization){ fetchUserInfo: function(authorization){
app.globalData.token = authorization
storage.put('Authorization', authorization)
config.header = { 'Authorization': 'QNT ' + authorization } config.header = { 'Authorization': 'QNT ' + authorization }
loginToken({loginToken: app.globalData.token}).then(result => {
loginToken({loginToken: authorization}).then(result => {
// token 切换流程
sconfig.header = { 'Authorization': 'QNT ' + result.data } sconfig.header = { 'Authorization': 'QNT ' + result.data }
// wx.redirectTo({ url: '/pages/index/index' })
getBaseInfo().then(result => { getBaseInfo().then(result => {
this.setData({ loging: false})
app.userInfo = result.data app.userInfo = result.data
wx.hideLoading()
wx.redirectTo({ url: '/pages/index/index' })
if(app.userInfo.enterpriseId){
wx.hideLoading()
app.globalData.token = authorization
storage.put('Authorization', authorization)
this.setData({ loging: false})
if(this.data.metaData && app.userInfo.enterpriseId != this.data.metaData.enterpriseId){
Dialog.alert({ title: '温馨提示', message: '您已经绑定过工厂了,现在就进入?' }).then(() => {
wx.redirectTo({ url: '/pages/index/index' })
})
} else {
wx.redirectTo({ url: '/pages/index/index' })
}
} else if(this.data.metaData){
// 这里要进行账号的绑定,对工厂进行绑定;或者进行申请操作;
this.handMetaData()
} else {
wx.hideLoading()
this.setData({ loging: false})
config.header = null
Dialog.alert({ title: '温馨提示', message: '您还不是纸通宝SAAS用户,请联系工厂管理员,或者联系纸通宝客户人员。' }).then(() => {
})
}
}).catch(err => { }).catch(err => {
wx.hideLoading() wx.hideLoading()
if(err.code == 400){ if(err.code == 400){
@ -109,16 +125,11 @@ Page({
util.showToast('请求错误') util.showToast('请求错误')
this.setData({ loging: false}) this.setData({ loging: false})
} }
app.globalData.token = null
storage.remove('Authorization')
config.header = null config.header = null
}) })
}).catch(err => { }).catch(err => {
wx.hideLoading() wx.hideLoading()
util.showToast(err) util.showToast(err)
app.globalData.token = null
storage.remove('Authorization')
config.header = null config.header = null
this.setData({ loging: false}) this.setData({ loging: false})
}) })
@ -141,13 +152,7 @@ Page({
return return
} }
this.setData({ loging: true }) this.setData({ loging: true })
if(this.data.form.tmpAuthToken){
this.registAccount()
return
}
loginWechat({ encryptedData: e.detail.encryptedData, iv: e.detail.iv }).then(result => { 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 this.data.form.tmpAuthToken = result.data.tmpAuthToken
this.fetchUserInfo(result.data.token) this.fetchUserInfo(result.data.token)
}).catch(error => { }).catch(error => {
@ -206,7 +211,6 @@ Page({
this.countDown.start() this.countDown.start()
}).catch(err => { }).catch(err => {
wx.hideLoading() wx.hideLoading()
console.log(err)
util.showToast(err) util.showToast(err)
}) })
}, },
@ -268,16 +272,41 @@ Page({
this.fetchUserInfo(result.data.metaData.token) this.fetchUserInfo(result.data.metaData.token)
} else { } else {
wx.hideLoading() wx.hideLoading()
this.data.metaData = result.data
this.setData({ loging: false}) this.setData({ loging: false})
if(!result.data.message){
result.data.message = '二维码解析失败,请重新扫码'
}
util.showToast(result.data.message)
} }
}).catch(err => { }).catch(err => {
wx.hideLoading() wx.hideLoading()
util.showToast(err)
util.showToast('二维码解析失败,请重新扫码')
this.setData({ loging: false}) this.setData({ loging: false})
}) })
},
handMetaData: function(){
if(this.data.metaData.qrPage == '/page/index/yaoqing'){
bindingAdmin(this.data.metaData).then(result => {
wx.hideLoading()
this.data.metaData = null
app.userInfo.enterpriseId = this.data.metaData.metaData.enterpriseId
app.userInfo.enterpriseName = this.data.metaData.metaData.enterpriseName
this.setData({loging: false})
wx.redirectTo({ url: '/pages/index/index' })
}).catch(error => {
wx.hideLoading()
this.setData({loging: false})
util.showToast(error)
})
} else {
bindingAccount(this.data.metaData).then(result => {
this.data.metaData = null
wx.hideLoading()
this.setData({loging: false})
Dialog.alert({ title: '温馨提示', message: '您的申请已经提交,待管理员审核通过之后在进行登录。' }).then(() => {
})
}).catch(error => {
wx.hideLoading()
this.setData({loging: false})
util.showToast(error)
})
}
} }
}) })

4
pages/login/index.wxml

@ -37,10 +37,6 @@
<text class="text-df">请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了向你提工厂经营管理、订单结算以及其他业务的相关服务,我们需要获你的个人微信信息,然后验证是你本人在操作。你可阅读</text><text class="text-blue" bindtap="readAgreement">《纸通宝SAAS服务协议》</text>了解详细信息,如你同意,请点击“同意”开始接受我们的服务。 <text class="text-df">请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了向你提工厂经营管理、订单结算以及其他业务的相关服务,我们需要获你的个人微信信息,然后验证是你本人在操作。你可阅读</text><text class="text-blue" bindtap="readAgreement">《纸通宝SAAS服务协议》</text>了解详细信息,如你同意,请点击“同意”开始接受我们的服务。
</view> </view>
</view> </view>
<!-- <view style="margin-top:20rpx;padding:40rpx 80rpx">
<van-button block type="info" loading="{{loging}}" loading-text="登录中..." disabled="{{loginEnable}}" open-type="getUserInfo"
bind:getuserinfo="onGotUserInfo">登录</van-button>
</view> -->
<view style="margin-top:20rpx;padding:40rpx 80rpx"> <view style="margin-top:20rpx;padding:40rpx 80rpx">
<van-button block type="info" loading="{{loging}}" loading-text="登录中..." disabled="{{loginEnable}}" <van-button block type="info" loading="{{loging}}" loading-text="登录中..." disabled="{{loginEnable}}"

3
pages/process/index/index.js

@ -12,6 +12,7 @@ Component({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
userInfo: app.userInfo,
height: app.globalData.safeFragmentHeight, height: app.globalData.safeFragmentHeight,
tabList: [ tabList: [
{ status: 1, badge: 2, name: '定价', icon: '/assets/image/icon_pricing.png' }, { status: 1, badge: 2, name: '定价', icon: '/assets/image/icon_pricing.png' },
@ -24,7 +25,7 @@ Component({
lifetimes: { lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名 // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () { attached: function () {
this.setData({ height: app.globalData.safeFragmentHeight - 100 })
this.setData({userInfo: app.userInfo, height: app.globalData.safeFragmentHeight - 100 })
event.on('EventMessage', this, this.onEvent) event.on('EventMessage', this, this.onEvent)
}, },
detached: function () { detached: function () {

2
pages/process/index/index.wxml

@ -7,7 +7,7 @@
<view style="height:250rpx;background-color:#008AFF;border-radius: 0rpx 0rpx 12rpx 12rpx;"> <view style="height:250rpx;background-color:#008AFF;border-radius: 0rpx 0rpx 12rpx 12rpx;">
<view class="flex flex-center" style="padding:32rpx 28rpx;justify-content: flex-start"> <view class="flex flex-center" style="padding:32rpx 28rpx;justify-content: flex-start">
<image style="width:100rpx;height:100rpx" src="/assets/image/icon_logo.png"></image> <image style="width:100rpx;height:100rpx" src="/assets/image/icon_logo.png"></image>
<view class="text-xxl text-bold" style="color:white;margin-left:32rpx">钟落潭打包厂</view>
<view class="text-xxl text-bold" style="color:white;margin-left:32rpx">{{userInfo.enterpriseName}}</view>
</view> </view>
</view> </view>

Loading…
Cancel
Save