小程序封装的app方法

本文档介绍了小程序的全局配置App方法,包括初始化数据、网络状态监听、字典信息获取、用户绑定信息获取、更新管理及错误处理。此外,还涉及了页面跳转逻辑和消息红点显示。
摘要由CSDN通过智能技术生成

App({

data: {

/**

* 参数

* author:Dong

*/

isIpx: false,

showBackHome: false,

baseUrl: 'https://test.zhaoshang800.com',

token: '',

appBindPhone: '',

appbindType: '',

cityCode: '440300',

 

//全局策略参数

isProjectListRefresh: false, //项目列表是否需要刷新

projectListSearchKey: '', //项目列表搜索关键字

projectListRentSaleType: 0, //项目列表租赁销售类型

 

isHouseTypeListRefresh: false, //户型列表是否需要刷新

houseTypeListSearchKey: '', //户型列表搜索关键字

houseTypeListRentSaleType: 0, //户型列表租赁销售类型

 

//进来时的页面

pathAndQuery: '/page/index/index'

},

 

onLaunch: function (e) {

let path = e.path;

let query = e.query;

let queryString = "";

for (var item in query) {

queryString += (`${ item}=${ e.query[item]}&`);

}

this.data.pathAndQuery = `/${ path}?${ queryString}`;

//监听网络变化

wx.onNetworkStatusChange(function (res) {

if (res.isConnected==false){

wx.showModal({

title: '提示',

content: '暂无网络',

success: function (res) {

}

})

}

})

 

//使用Promise获取字典信息,若失败,则后台重新获取,连续失败2次停止获取,待1分钟后重新拉取

const _this = this;

const dicArr = ['specialLabel', 'roleType', 'noticeType', 'photoType'];

_this.getDictsAll(dicArr)

.catch(err=>_this.getDictsAll(dicArr)) //失败重新拉取

.catch(err=>{

setTimeout(()=>{

_this.getDictsAll(dicArr) //再次失败隔一分钟拉取

}, 60000);

});

},

onShow: function (options) {

var _this = this;

wx.getSystemInfo({

success: function(res) {

if (res.model.indexOf("iPhone X") > -1) {

_this.data.isIpx = true;

}

}

});

if (wx.canIUse("getUpdateManager")) {

_this.getUpdateManager();

}

if ([1007, 1008, 1011, 1012, 1013, 1025, 1032, 1014, 1036, 1037,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值