Commit ca8f2f7e authored by Morson's avatar Morson

修改token初始化为空问题

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