|
|
|
<script>
|
|
|
|
import Define from './common/define.js'
|
|
|
|
import Player from './common/Player.js'
|
|
|
|
import mainPageData from './common/mainPageData.js'
|
|
|
|
import customermanager from './common/customermanager.js'
|
|
|
|
/**合同的数据结构*/
|
|
|
|
var agreementData = {
|
|
|
|
inserttime : 0,
|
|
|
|
picurl : '',
|
|
|
|
showtype : 0x02,
|
|
|
|
skipurl : '',
|
|
|
|
sortid : 0,
|
|
|
|
textmsg : '',
|
|
|
|
isAgreed : false,
|
|
|
|
};
|
|
|
|
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.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 != '' && code != 0){
|
|
|
|
uni.showToast({
|
|
|
|
title:msg,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if(code != 0){
|
|
|
|
|
|
|
|
//console.log("code = ",code,args.statusCode);
|
|
|
|
if(args.statusCode == 401){
|
|
|
|
//用户需要登录,跳转到登录界面
|
|
|
|
Player.clear();
|
|
|
|
uni.navigateTo({
|
|
|
|
url:'/pages/WxLogin/WxLogin'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fail(err) {
|
|
|
|
console.log('interceptor-fail',err)
|
|
|
|
uni.showToast({
|
|
|
|
title:'网络出现错误,请稍后再试',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
complete(res) {
|
|
|
|
//console.log('interceptor-complete',res)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.LoadPlayerInfoFromStore(Player);
|
|
|
|
},
|
|
|
|
onShow: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
onHide: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
globalData:{
|
|
|
|
Define,
|
|
|
|
Player,
|
|
|
|
mainPageData,
|
|
|
|
///合同数据
|
|
|
|
agreementData,
|
|
|
|
///客户数据管理器
|
|
|
|
customermanager,
|
|
|
|
},
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
mainPageData.getMainPageData();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
</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>
|