1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- // app.js
- App({
-
- "permission": {
- "scope.userLocation": {
- "desc": "你的位置信息将用于地图展示"
- }
- },
- "requiredPrivateInfos": ["getLocation"],
- onLaunch() {
- // 初始化路由跟踪
- if (typeof this.globalData === 'undefined') {
- this.globalData = {}
- }
- this.globalData.route = 'pages/index/index'
- },
- onLaunch: function () {
- var userInfo=wx.getStorageSync('userInfo');
- if(userInfo){
- this.globalData.userInfo=userInfo
- }
- },
- globalData:{
- userInfo:null,
- apiBaseUrl: wx.getSystemInfoSync().platform === 'devtools' ?
- 'http://localhost:8000' :
- 'https://api.yourdomain.com',
- debugMode: true,
- },
- initUserInfo:function(res,localInfo){
- var info={
- token:res.token,
- phone:res.phone,
- id:res.id,
- nickName:localInfo.nickName,
- avatarUrl:localInfo.avatarUrl,
- };
- this.globalData.userInfo=info;
- wx.setStorageSync('userInfo', info)
- },
- delUserInfo:function(){
- this.globalData.userInfo=null;
- wx.removeStorageSync('userInfo');
- }
- })
|