|
|
|
<script>
|
|
|
|
import Define from './common/define.js'
|
|
|
|
import Player from './common/Player.js'
|
|
|
|
import mainPageData from './common/mainPageData.js'
|
|
|
|
export default {
|
|
|
|
onLaunch: function() {
|
|
|
|
|
|
|
|
uni.addInterceptor('request',{
|
|
|
|
invoke(args) {
|
|
|
|
//console.log('interceptor-invoke',args);
|
|
|
|
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';
|
|
|
|
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'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fail(err) {
|
|
|
|
console.log('interceptor-fail',err)
|
|
|
|
uni.showToast({
|
|
|
|
title:'网络出现错误,请稍后再试',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
complete(res) {
|
|
|
|
console.log('interceptor-complete',res)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
mainPageData.getMainPageData();
|
|
|
|
this.LoadPlayerInfoFromStore(Player);
|
|
|
|
},
|
|
|
|
onShow: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
onHide: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
</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;}
|
|
|
|
</style>
|