onLaunch(options) {
this.getUserConfigs()
},
configPromise: null,
userConfigs:null
getUserConfigs() {
if (this.configPromise) {
return this.configPromise;
}
this.configPromise = new Promise(async (resolve, reject) => {
try {
const res = await wechatConfigApi();
this.userConfigs = configs.initData(res);
resolve(this.userConfigs);
console.log('-------------------',this.userConfigs);
} catch (err) {
wx.utils.toast('获取服务器配置获取失败!!!,当前小程序出错了,请重新进入');
reject(err);
}
});
return this.configPromise;
},
async onLoad(options) {
console.log('我是页面onload');
try {
await app.getUserConfigs();
} catch (error) {
wx.utils.toast('配置加载失败:', error)
}
},