Commit ca8f2f7e authored by Morson's avatar Morson

修改token初始化为空问题

parent a84cfc73
...@@ -8,6 +8,8 @@ export default { ...@@ -8,6 +8,8 @@ export default {
uniEnv: process.uniEnv, uniEnv: process.uniEnv,
// 登录凭证 // 登录凭证
token: "", token: "",
// 微信小程序平台编号,空--家维广场,1--自营平台
wxAppNo: 1,
//授权提示 图标 //授权提示 图标
icon_auth_notice: "https://qn-static.banshouhui.com/auth_notice.png", icon_auth_notice: "https://qn-static.banshouhui.com/auth_notice.png",
...@@ -50,16 +52,11 @@ export default { ...@@ -50,16 +52,11 @@ export default {
}, },
onLaunch: function () { onLaunch: function () {
// 应用初始化(全局只触发一次) // 应用初始化(全局只触发一次)
let that = this;
that.globalData.token = util.getToken();
AnalysysAgent.registerSuperProperty("platform", "self-support"); AnalysysAgent.registerSuperProperty("platform", "self-support");
// 应用启动,或从后台进入前台显示
that.autoLogin();
}, },
onShow: function () { onShow: function () {
// 应用启动,或从后台进入前台显示 // 应用启动,或从后台进入前台显示
// this.autoLogin() this.autoLogin()
}, },
onHide: function () { onHide: function () {
// 应用从前台进入后台 // 应用从前台进入后台
...@@ -100,13 +97,12 @@ export default { ...@@ -100,13 +97,12 @@ export default {
if (res.code) { if (res.code) {
let params = { let params = {
code: res.code, code: res.code,
wxAppNo: 1, // 自营平台小程序 wxAppNo: that.globalData.wxAppNo, // 自营平台小程序
}; };
let result = await that.$u.api.loginWechatAuth(params); let result = await that.$u.api.loginWechatAuth(params);
if (result) { if (result) {
if (result.code == 200 && result.data) { if (result.code == 200 && result.data) {
that.setUserData(result.data); that.setUserData(result.data);
that.getBaseInfo(that);
} }
} else { } else {
uni.showModal({ uni.showModal({
...@@ -130,11 +126,9 @@ export default { ...@@ -130,11 +126,9 @@ export default {
if (userInfo && userInfo.token) { if (userInfo && userInfo.token) {
// 如果已经登录则直接获取相关信息 // 如果已经登录则直接获取相关信息
util.setOpenid(userInfo.wxopenid); util.setOpenid(userInfo.wxopenid);
util.setToken(userInfo.token);
this.$u.vuex("vuex_token", userInfo.token); this.$u.vuex("vuex_token", userInfo.token);
uni.setStorageSync("user-info", userInfo); uni.setStorageSync("user-info", userInfo);
} else { } else {
util.setToken("");
this.$u.vuex("vuex_token", ""); this.$u.vuex("vuex_token", "");
} }
}, },
......
...@@ -35,7 +35,7 @@ const install = (Vue, vm) => { ...@@ -35,7 +35,7 @@ const install = (Vue, vm) => {
// 请求拦截,配置Token等参数 // 请求拦截,配置Token等参数
Vue.prototype.$u.http.interceptor.request = (config) => { Vue.prototype.$u.http.interceptor.request = (config) => {
const reg = /\?\w+/; const reg = /\?\w+/;
let token = util.getToken() let token = vm.vuex_token
// if(!token && noLoginUrl.indexOf(config.url)<0){ // if(!token && noLoginUrl.indexOf(config.url)<0){
// toLoginPage() // toLoginPage()
// return false // return false
......
...@@ -134,7 +134,7 @@ export default { ...@@ -134,7 +134,7 @@ export default {
currentLoadStatus: "loading", currentLoadStatus: "loading",
orderList: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}], orderList: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}],
search: { search: {
token: app.globalData.token || "", token: "",
pageNumber: 0, pageNumber: 0,
pageSize: 10, pageSize: 10,
}, },
...@@ -143,7 +143,8 @@ export default { ...@@ -143,7 +143,8 @@ export default {
}, },
watch: { watch: {
vuex_token(val){ vuex_token(val){
console.log(val,'vuex_token---------watch') // 监听token变化,如果更新则重新加载页面数据
this.initSettleInfo()
} }
}, },
computed: { computed: {
...@@ -174,12 +175,8 @@ export default { ...@@ -174,12 +175,8 @@ export default {
this.triggered = false; this.triggered = false;
}, },
onShow() { onShow() {
// console.log(this.vuex_token,'this.vuex_token')
// 每次进入页面都刷新入驻状态 // 每次进入页面都刷新入驻状态
if (app.globalData.token) { if (!this.vuex_token) {
// 初始化入驻信息
this.initSettleInfo();
} else {
// 初始化订单数据 // 初始化订单数据
this.loadOrderList(); this.loadOrderList();
} }
...@@ -220,7 +217,7 @@ export default { ...@@ -220,7 +217,7 @@ export default {
loadOrderList() { loadOrderList() {
let self = this; let self = this;
// 加载订单列表 // 加载订单列表
self.search.token = app.globalData.token; self.search.token = self.vuex_token;
self.$u.api.listByRecommendOrder(self.search).then((res) => { self.$u.api.listByRecommendOrder(self.search).then((res) => {
if (res.code == 200) { if (res.code == 200) {
if (res.data && res.data.length > 0) { if (res.data && res.data.length > 0) {
...@@ -277,7 +274,7 @@ export default { ...@@ -277,7 +274,7 @@ export default {
console.log("-----scroll-------"); console.log("-----scroll-------");
}, },
immediatelyIn() { immediatelyIn() {
if (util.getToken()) { if (this.vuex_token) {
// 0=>'待提交',1=>'待审核',2=>'已通过',3=>'备选',4=>'已驳回',5=>'已签约',6=>'未支付保证金',7=>'已支付保证金',8=>'已通过考试',9=>'待提交' // 0=>'待提交',1=>'待审核',2=>'已通过',3=>'备选',4=>'已驳回',5=>'已签约',6=>'未支付保证金',7=>'已支付保证金',8=>'已通过考试',9=>'待提交'
var pageIndex = 1; var pageIndex = 1;
switch (this.status) { switch (this.status) {
......
...@@ -83,14 +83,13 @@ export default { ...@@ -83,14 +83,13 @@ export default {
let params = { let params = {
nickname: app.globalData.authUserInfo.nickName, nickname: app.globalData.authUserInfo.nickName,
avatar: app.globalData.authUserInfo.avatarUrl, avatar: app.globalData.authUserInfo.avatarUrl,
wxAppNo: 1,
} }
login.appLogin().then(res => { login.appLogin().then(res => {
params.code = res.code params.code = res.code
return login.authorization(params); return login.authorization(params);
}).then(res => { }).then(res => {
uni.hideLoading(); uni.hideLoading();
if (res && util.getToken()) { if (res) {
that.goBackPage() that.goBackPage()
} else { } else {
this.setLoginStatus() this.setLoginStatus()
...@@ -118,14 +117,13 @@ export default { ...@@ -118,14 +117,13 @@ export default {
avatar: app.globalData.authUserInfo.avatarUrl, avatar: app.globalData.authUserInfo.avatarUrl,
encryptedData: e.detail.encryptedData, encryptedData: e.detail.encryptedData,
iv: e.detail.iv, iv: e.detail.iv,
wxAppNo: 1,
} }
login.appLogin().then(res => { login.appLogin().then(res => {
params.code = res.code params.code = res.code
return login.signup(params); return login.signup(params);
}).then(res => { }).then(res => {
uni.hideLoading() uni.hideLoading()
if (res && util.getToken()) { if (res) {
that.goBackPage() that.goBackPage()
} else { } else {
uni.showToast({ uni.showToast({
......
...@@ -80,7 +80,6 @@ ...@@ -80,7 +80,6 @@
}, },
data() { data() {
return { return {
token: app.globalData.token,
baseInfo: { baseInfo: {
name: "", name: "",
id_card_no: "43072219800123456", id_card_no: "43072219800123456",
...@@ -378,7 +377,7 @@ ...@@ -378,7 +377,7 @@
// }, 2000) // }, 2000)
}, },
async goSign() { async goSign() {
const token = app.globalData.token; const token = this.vuex_token;
const settledInfo = this.settledInfo const settledInfo = this.settledInfo
const baseInfo = this.baseInfo const baseInfo = this.baseInfo
const params = { const params = {
......
...@@ -29,6 +29,7 @@ function appLogin() { ...@@ -29,6 +29,7 @@ function appLogin() {
// 小程序授权 // 小程序授权
function authorization(data) { function authorization(data) {
return new Promise(async function (resolve, reject) { return new Promise(async function (resolve, reject) {
data.wxAppNo = app.globalData.wxAppNo
const res = await app.$vm.$u.api.loginWechatAuth(data) const res = await app.$vm.$u.api.loginWechatAuth(data)
if (res) { if (res) {
if (res.code == 200 && res.data) { if (res.code == 200 && res.data) {
...@@ -50,6 +51,7 @@ function authorization(data) { ...@@ -50,6 +51,7 @@ function authorization(data) {
// 小程序注册 // 小程序注册
function signup(data) { function signup(data) {
return new Promise(async function (resolve, reject) { return new Promise(async function (resolve, reject) {
data.wxAppNo = app.globalData.wxAppNo
const res = await app.$vm.$u.api.loginWechatAuth(data) const res = await app.$vm.$u.api.loginWechatAuth(data)
if (res) { if (res) {
if (res.code == 200 && res.data) { if (res.code == 200 && res.data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment