公司小程序
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.

126 lines
3.3 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'
import customermanager from './common/customermanager.js'
3 years ago
import SkipData from './common/SkipData.js'
/**合同的数据结构*/
3 years ago
var agreementData = new SkipData();
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.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 != '' && code != 0){
3 years ago
uni.$u.toast(msg);
}
if(code != 0){
//console.log("code = ",code,args.statusCode);
if(args.statusCode == 401){
//用户需要登录,跳转到登录界面
Player.clear();
3 years ago
uni.clearStorageSync();
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)
3 years ago
}
});
this.LoadPlayerInfoFromStore(Player);
3 years ago
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();
}
}
});
});
}
});
3 years ago
},
onShow: function() {
},
onHide: function() {
3 years ago
},
globalData:{
Define,
Player,
mainPageData,
///合同数据
agreementData,
///客户数据管理器
customermanager,
///从其他界面退回到钱包界面的时候是否需要刷新数据,只有在提现界面产生了提现数据时,等地方需要
isNeedRefreshWallet : false,
///当前正在显示的SkipData,比如【业务动态,品牌风采】
showingSkipData : null,
3 years ago
///当前正在编辑得客户
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);
}
3 years ago
},
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>