2023-02-18 16:24:17 +08:00
|
|
|
|
// app.js
|
|
|
|
|
|
App({
|
|
|
|
|
|
onLaunch() {
|
|
|
|
|
|
const uid=wx.getStorageSync('uid')
|
|
|
|
|
|
const token=wx.getStorageSync('token')
|
|
|
|
|
|
if(uid){
|
|
|
|
|
|
this.globalData.uid = uid
|
|
|
|
|
|
}
|
|
|
|
|
|
if(token){
|
|
|
|
|
|
this.globalData.token = token
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
globalData: {
|
|
|
|
|
|
userInfo: null,
|
|
|
|
|
|
encryptedData:'',
|
|
|
|
|
|
iv:'',
|
|
|
|
|
|
code:'',
|
|
|
|
|
|
|
2023-03-01 22:50:02 +08:00
|
|
|
|
|
2023-03-18 12:14:55 +08:00
|
|
|
|
url:'http://chengjie.free.idcfengye.com',
|
|
|
|
|
|
// url:'https://35q45673j2.goho.co',
|
2023-03-01 22:50:02 +08:00
|
|
|
|
|
2023-02-18 16:24:17 +08:00
|
|
|
|
|
|
|
|
|
|
phone:'',
|
|
|
|
|
|
uid:'',
|
|
|
|
|
|
sessionKey:'',
|
|
|
|
|
|
version_number:'1.0.0',
|
|
|
|
|
|
// domain:"http://192.168.1.215"
|
|
|
|
|
|
domain:"https://www.zoowoo.net",
|
|
|
|
|
|
domaintwo:"http://106.52.204.179/api"//线上库
|
|
|
|
|
|
},
|
|
|
|
|
|
console:function( msg ){
|
|
|
|
|
|
console.log( msg);
|
|
|
|
|
|
},
|
|
|
|
|
|
tip:function( params ){
|
|
|
|
|
|
var that = this;
|
|
|
|
|
|
var title = params.hasOwnProperty('title')?params['title']:'提示您';
|
|
|
|
|
|
var content = params.hasOwnProperty('content')?params['content']:'';
|
|
|
|
|
|
wx.showModal({
|
|
|
|
|
|
title: title,
|
|
|
|
|
|
content: content,
|
|
|
|
|
|
success: function(res) {
|
|
|
|
|
|
if ( res.confirm ) {//点击确定
|
|
|
|
|
|
if( params.hasOwnProperty('cb_confirm') && typeof( params.cb_confirm ) == "function" ){
|
|
|
|
|
|
params.cb_confirm();
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{//点击否
|
|
|
|
|
|
if( params.hasOwnProperty('cb_cancel') && typeof( params.cb_cancel ) == "function" ){
|
|
|
|
|
|
params.cb_cancel();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
getRequestHeader:function(){
|
|
|
|
|
|
return {
|
|
|
|
|
|
'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
|
|
'Authorization': 'Bearer '+this.getCache( "token" )
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
buildUrl:function( path,params ){
|
|
|
|
|
|
var url = this.globalData.domain + path;
|
|
|
|
|
|
var _paramUrl = "";
|
|
|
|
|
|
if( params ){
|
|
|
|
|
|
_paramUrl = Object.keys( params ).map( function( k ){
|
|
|
|
|
|
return [ encodeURIComponent( k ),encodeURIComponent( params[ k ] ) ].join("=");
|
|
|
|
|
|
}).join("&");
|
|
|
|
|
|
_paramUrl = "?" + _paramUrl;
|
|
|
|
|
|
}
|
|
|
|
|
|
return url + _paramUrl;
|
|
|
|
|
|
},
|
|
|
|
|
|
buildUrltwo:function( path,params ){
|
|
|
|
|
|
var url = this.globalData.domaintwo + path;
|
|
|
|
|
|
var _paramUrl = "";
|
|
|
|
|
|
if( params ){
|
|
|
|
|
|
_paramUrl = Object.keys( params ).map( function( k ){
|
|
|
|
|
|
return [ encodeURIComponent( k ),encodeURIComponent( params[ k ] ) ].join("=");
|
|
|
|
|
|
}).join("&");
|
|
|
|
|
|
_paramUrl = "?" + _paramUrl;
|
|
|
|
|
|
}
|
|
|
|
|
|
return url + _paramUrl;
|
|
|
|
|
|
},
|
|
|
|
|
|
getCache:function( key ){
|
|
|
|
|
|
var value = undefined;
|
|
|
|
|
|
try {
|
|
|
|
|
|
value = wx.getStorageSync( key );
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
}
|
|
|
|
|
|
return value;
|
|
|
|
|
|
},
|
|
|
|
|
|
setCache:function(key,value){
|
|
|
|
|
|
wx.setStorage({
|
|
|
|
|
|
key:key,
|
|
|
|
|
|
data:value
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|