oil-station/gasStation-uni/App.vue
2024-07-09 10:28:16 +08:00

109 lines
3.1 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script>
export default {
onLaunch: function(e) {
console.log('App Launch')
// #ifdef MP-WEIXIN
uni.setStorageSync("appltType", "WECHAT")
console.log("微信")
//检查是否存在新版本
uni.getUpdateManager().onCheckForUpdate(function(res) {
// 请求完新版本信息的回调
console.log("是否有新版本:" + res.hasUpdate);
if (res.hasUpdate) { //如果有新版本
// 小程序有新版本,会主动触发下载操作(无需开发者触发)
uni.getUpdateManager().onUpdateReady(function() { //当新版本下载完成,会进行回调
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,单击确定重启应用',
showCancel: false,
success: function(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
uni.getUpdateManager().applyUpdate();
}
}
})
})
// 小程序有新版本,会主动触发下载操作(无需开发者触发)
uni.getUpdateManager().onUpdateFailed(function() { //当新版本下载失败,会进行回调
uni.showModal({
title: '提示',
content: '检查到有新版本,但下载失败,请检查网络设置',
showCancel: false,
})
})
}
});
// #endif
// #ifdef MP-ALIPAY
uni.setStorageSync("appltType", "ALIPAY")
console.log("支付宝")
my.canIUse('button.open-type.getAuthorize')
//获取关联普通二维码的码值放到全局变量qrCode中
if (e.query && e.query.qrCode) {
console.log(JSON.stringify(e) + "1.0")
let q = e.query.qrCode;
if (e.query.qrCode) {
let str = q.split("?")[1];
let storeId = "";
let staffId = "";
let userId = "";
let type = "";
let sn = "";
if (str.includes("&")) {
let arr = str.split("&");
arr.forEach(item => {
if (item.includes("storeId")) {
storeId = item.split("=")[1]
} else if (item.includes("staffId")) {
staffId = item.split("=")[1]
} else if (item.includes("userId")) {
userId = item.split("=")[1]
} else if (item.includes("type")) {
type = item.split("=")[1]
} else {
sn = item.split("=")[1]
}
})
} else {
if (str.includes("storeId")) {
storeId = str.split("=")[1]
} else if (str.includes("sn")) {
sn = str.split("=")[1]
}
}
uni.setStorageSync("storeId", storeId)
uni.setStorageSync("sn", sn)
uni.setStorageSync("y_type", type)
uni.setStorageSync("y_userId", userId)
uni.setStorageSync("inviteStaffId", staffId)
// uni.showLoading({
// title:uni.getStorageSync("storeId") + "staffId" + uni.getStorageSync("inviteStaffId")
// })
}
}
// #endif
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
</script>
<style lang="scss">
// /*每个页面公共css */
@import "@/node_modules/uview-ui/index.scss";
.dis {
display: flex;
}
</style>