|
|
|
<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'
|
|
|
|
import SkipData from './common/SkipData.js'
|
|
|
|
/**合同的数据结构*/
|
|
|
|
var agreementData = new SkipData();
|
|
|
|
export default {
|
|
|
|
onLaunch: function() {
|
|
|
|
var self = this;
|
|
|
|
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.$u.toast(msg,4000);
|
|
|
|
self.showToast(msg);
|
|
|
|
}
|
|
|
|
if(code != 0){
|
|
|
|
|
|
|
|
//console.log("code = ",code,args.statusCode);
|
|
|
|
if(args.statusCode == 401){
|
|
|
|
//用户需要登录,跳转到登录界面
|
|
|
|
Player.clear();
|
|
|
|
uni.clearStorageSync();
|
|
|
|
uni.navigateTo({
|
|
|
|
url:'/pages/WxLogin/WxLogin'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fail(err) {
|
|
|
|
console.log('interceptor-fail',err)
|
|
|
|
self.showToast("网络出现错误,请稍后再试");
|
|
|
|
},
|
|
|
|
complete(res) {
|
|
|
|
//console.log('interceptor-complete',res)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.LoadPlayerInfoFromStore(Player);
|
|
|
|
mainPageData.getMainPageData();
|
|
|
|
const updateManager = uni.getUpdateManager();
|
|
|
|
updateManager.onCheckForUpdate(function(res){
|
|
|
|
console.log(res);
|
|
|
|
if(res.hasUpdate){
|
|
|
|
updateManager.onUpdateReady(function(res){
|
|
|
|
uni.showModal({
|
|
|
|
title:'更新提示',
|
|
|
|
content:'新版本已经准备好,是否重启应用?',
|
|
|
|
success(res) {
|
|
|
|
if(res.confirm){
|
|
|
|
updateManager.applyUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onShow: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
onHide: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
globalData:{
|
|
|
|
Define,
|
|
|
|
Player,
|
|
|
|
mainPageData,
|
|
|
|
///合同数据
|
|
|
|
agreementData,
|
|
|
|
///客户数据管理器
|
|
|
|
customermanager,
|
|
|
|
///从其他界面退回到钱包界面的时候是否需要刷新数据,只有在提现界面产生了提现数据时,等地方需要
|
|
|
|
isNeedRefreshWallet : false,
|
|
|
|
///当前正在显示的SkipData,比如【业务动态,品牌风采】
|
|
|
|
showingSkipData : null,
|
|
|
|
///当前正在编辑得客户
|
|
|
|
editingCustomer : null,
|
|
|
|
},
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
showToast(msg){
|
|
|
|
uni.$u.sleep(500).then(()=>{
|
|
|
|
uni.$u.toast(msg);
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
</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>
|