Merge remote-tracking branch '鹿泉/lu_quan_dev' into lu_quan_dev

# Conflicts:
#	subPageC/Ai/index.vue
lu_quan_dev
Tuzki 8 months ago
commit f1779aaab6
  1. 66
      subPageC/Ai/index.vue

@ -59,6 +59,7 @@
mapState, mapState,
mapMutations mapMutations
} from "vuex"; } from "vuex";
import store from "@/store/index.js";
export default { export default {
components: { components: {
ZeroMarkdownView ZeroMarkdownView
@ -116,6 +117,7 @@
openid: undefined, openid: undefined,
appid: undefined, appid: undefined,
}, },
nowUserId:null
} }
}, },
onUnload() { onUnload() {
@ -126,19 +128,46 @@
this.outWs() this.outWs()
}, },
onShow() { onShow() {
const userInfo = uni.getStorageSync("userInfo"); const userInfo = uni.getStorageSync('userInfo');
const extConfig = uni.getAccountInfoSync().miniProgram; const refreshTokenValue = userInfo.refreshToken;
let appId = extConfig.appId if (!refreshTokenValue){
store.commit('setUserInfo', null)
this.param.openid = userInfo.openid uni.removeStorageSync('userInfo');
this.param.appid = appId setTimeout(() => {
uni.navigateBack({ delta: 1 })
this.$Request.get(this.$config.getHomestayOrderList, this.param, null, null, false, true).then((res) => { }, 1500)
this.getUserInfo() uni.showToast({
this.connectWs() title: '登录过期,请重新登录',
}).catch(err=>{ icon: 'none',
console.log(err) mask: true
}); })
}else{
this.$Request.post(this.$config.refreshToken, { refreshToken: refreshTokenValue }, 'application/json', null, false, false)
.then(response => {
console.log('response',response)
const newAccessToken = response.data.accessToken;
const newRefreshToken = response.data.refreshToken;
userInfo.accessToken = newAccessToken;
userInfo.refreshToken = newRefreshToken;
store.commit('setUserInfo', userInfo)
this.Token = newAccessToken
this.nowUserId = response.data.userId
this.getUserInfo(response.data.userId)
})
.catch(error => {
store.commit('setUserInfo', null)
uni.removeStorageSync('userInfo');
setTimeout(() => {
uni.navigateBack({ delta: 1 })
}, 1500)
uni.showToast({
title: '登录过期,请重新登录',
icon: 'none',
mask: true
})
});
}
}, },
created: function() { created: function() {
const res = uni.getSystemInfoSync(); const res = uni.getSystemInfoSync();
@ -148,15 +177,15 @@
}, },
methods: { methods: {
// //
getUserInfo() { getUserInfo(userId) {
this.querUserInfo = { this.querUserInfo = {
"message": "", "message": "",
"dialogId": "", "dialogId": "",
"identity": this.generateRandomString(8), "identity": this.generateRandomString(8),
"userId": this.userInfo.userId "userId": userId
}; };
console.log(this.querUserInfo) console.log('querUserInfo',this.querUserInfo)
this.Token = this.userInfo.accessToken; this.connectWs()
}, },
// websocket // websocket
connectWs() { connectWs() {
@ -275,7 +304,8 @@
// //
sendMsg() { sendMsg() {
const $this = this const $this = this
this.getUserInfo() console.log('$this.nowUserId',$this.nowUserId)
this.getUserInfo($this.nowUserId)
this.list.push({ this.list.push({
content: this.content, content: this.content,
userType: 'friend', userType: 'friend',

Loading…
Cancel
Save