代码拉取完成,页面将自动刷新
const WXAPI = require('apifm-wxapi')
const AUTH = require('utils/auth')
const CONFIG = require('config')
App({
onLaunch: function () {
WXAPI.init(CONFIG.subDomain)
WXAPI.setMerchantId(CONFIG.merchantId)
// 加载字体
wx.loadFontFace({
global: true,
family: 'LxgwWenKai',
source: 'url("https://ns.s2m.cc/xwwk.ttf")'
})
// 检测新版本
const updateManager = wx.getUpdateManager()
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
// https://www.yuque.com/apifm/nu0f75/dis5tl
WXAPI.queryConfigBatch('mallName,order_remark_msg,order_hx_uids').then(res => {
if (res.code == 0) {
res.data.forEach(config => {
wx.setStorageSync(config.key, config.value);
})
if (this.configLoadOK) {
this.configLoadOK()
}
}
})
},
onShow(e){
// 保存邀请人
if (e && e.query && e.query.inviter_id) {
wx.setStorageSync('referrer', e.query.inviter_id)
if (e.shareTicket) {
wx.getShareInfo({
shareTicket: e.shareTicket,
success: res => {
console.log(res)
console.log({
referrer: e.query.inviter_id,
encryptedData: res.encryptedData,
iv: res.iv
})
wx.login({
success(loginRes) {
if (loginRes.code) {
// https://www.yuque.com/apifm/nu0f75/uthem8
WXAPI.shareGroupGetScore(
loginRes.code,
e.query.inviter_id,
res.encryptedData,
res.iv
).then(_res => {
console.log(_res)
}).catch(err => {
console.error(err)
})
} else {
console.error('登录失败!' + loginRes.errMsg)
}
}
})
}
})
}
}
// 自动登录
AUTH.checkHasLogined().then(isLogined => {
if (!isLogined) {
AUTH.login()
}
})
},
tabbarChange(e, curIndex) {
if (e.detail == curIndex) {
return
}
const pages = [
'/pages/index/index',
'/pages/orders/index',
'/pages/current-order/index',
'/pages/my/index',
]
wx.reLaunch({
url: pages[e.detail]
})
},
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。