第一次提交
This commit is contained in:
94
app.js
Normal file
94
app.js
Normal file
@@ -0,0 +1,94 @@
|
||||
// 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:'',
|
||||
|
||||
url:'http://chengjie468.gnway.cc',
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user