公司小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.2 KiB

3 years ago
<script>
3 years ago
import Define from './common/define.js'
import Player from './common/Player.js'
import mainPageData from './common/mainPageData.js'
3 years ago
export default {
onLaunch: function() {
3 years ago
uni.addInterceptor('request',{
invoke(args) {
//console.log('interceptor-invoke',args);
3 years ago
args.url = Define.BaseUrl + args.url;
var token = uni.getStorageSync(Define.StoreKeys.WeChatLoginToken);
//args.method = 'POST';
console.log(token);
args.header['content-type'] = 'application/json';
3 years ago
args.header['outsourcing.partner.userapp.token'] = token;
},
success(args) {
//console.log('interceptor-success',args);
var code = args.data.code;
var msg = args.data.msg;
if(msg && msg != ''){
uni.showToast({
title:msg,
});
}
if(code != 0){
//console.log("code = ",code,args.statusCode);
if(args.statusCode == 401){
//用户需要登录,跳转到登录界面
uni.navigateTo({
url:'/pages/WxLogin/WxLogin'
})
}
}
3 years ago
},
fail(err) {
console.log('interceptor-fail',err)
uni.showToast({
title:'网络出现错误,请稍后再试',
});
3 years ago
},
complete(res) {
console.log('interceptor-complete',res)
}
});
mainPageData.getMainPageData();
this.LoadPlayerInfoFromStore(Player);
3 years ago
},
onShow: function() {
},
onHide: function() {
3 years ago
},
globalData:{
Define,
Player,
mainPageData,
},
methods:{
LoadPlayerInfoFromStore(){
var StoreKeys = Define.StoreKeys;
var keys = [
StoreKeys.WeChatLoginToken,
StoreKeys.WeChatGender,
StoreKeys.WeChatHeadUrl,
StoreKeys.WeChatNickName
];
for(let i = 0;i<keys.length;i++){
var k = keys[i];
var info = uni.getStorageSync(k);
if(info){
console.log("从缓存中加载到了属性:",k,info);
Player[k] = info;
}
}
var token = Player.user_token;
if(token && token != ''){
this.$utils.loginWithToken(token,Player);
}
},
3 years ago
},
3 years ago
}
</script>
<style lang="scss">
/*每个页面公共css */
@import "@/uni_modules/uview-ui/index.scss";
@import "common/demo.scss";
.uni-picker-container .uni-picker .uni-picker-action-confirm{color: #d7b57c!important;}
3 years ago
</style>