登录 请求顺序 小程序更新提示
This commit is contained in:
41
App.vue
41
App.vue
@@ -1,5 +1,4 @@
|
|||||||
<template>
|
<template>
|
||||||
<button v-show="false" open-type="getPhoneNumber" @getphonenumber="userlogin"> </button>
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
@@ -8,23 +7,47 @@
|
|||||||
uni.cache.set('menuInfo', uni.getMenuButtonBoundingClientRect());
|
uni.cache.set('menuInfo', uni.getMenuButtonBoundingClientRect());
|
||||||
// #endif
|
// #endif
|
||||||
uni.cache.set('NAME', '零点八零');
|
uni.cache.set('NAME', '零点八零');
|
||||||
this.userlogin()
|
|
||||||
},
|
},
|
||||||
onLoad() {},
|
onLoad() {},
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
this.$store.dispatch("HeightActions"); //获取随时获取页面的高度
|
this.$store.dispatch("HeightActions"); //获取随时获取页面的高度
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
// 当向小程序后台请求完新版本信息,会进行回调。res: {hasUpdate: true, version: 1.0.0}
|
||||||
|
const updateManager = uni.getUpdateManager();
|
||||||
|
updateManager.onCheckForUpdate(function(res) {
|
||||||
|
if (res.hasUpdate) { // 有更新
|
||||||
|
uni.showLoading({
|
||||||
|
title: '更新中...'
|
||||||
|
}); // 开始下载前,显示Loading
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 当新版本下载完成,会进行回调
|
||||||
|
updateManager.onUpdateReady(function() {
|
||||||
|
uni.hideLoading(); // 关闭 Loading
|
||||||
|
uni.showModal({ // 弹确认框(强制更新)
|
||||||
|
title: '更新提示',
|
||||||
|
content: '更新完毕,是否重启?',
|
||||||
|
success: function(res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
updateManager.applyUpdate(); // 强制小程序重启并使用新版本。
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
// 当新版本下载失败,会进行回调
|
||||||
|
updateManager.onUpdateFailed(function() {
|
||||||
|
uni.hideLoading(); // 关闭 Loading
|
||||||
|
uni.showToast({
|
||||||
|
title: '更新失败,稍后再试...',
|
||||||
|
icon: "error"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
|
||||||
},
|
},
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
// console.log('App Hide');
|
// console.log('App Hide');
|
||||||
},
|
},
|
||||||
methods: {
|
|
||||||
userlogin() {
|
|
||||||
if (!uni.cache.get('token')) {
|
|
||||||
this.$store.dispatch("loginEvent"); //获取shapid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -104,19 +104,18 @@ async function request(options) {
|
|||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
console.log(options)
|
console.log(options)
|
||||||
if (res.code == -4) {
|
if (res.code == -4) {
|
||||||
// uni.showToast({
|
uni.showToast({
|
||||||
// title: '',
|
title: res.message || res.msg,
|
||||||
// // title: res.message || res.msg,
|
icon: "none",
|
||||||
// icon: "none",
|
success: () => {
|
||||||
// success: () => {
|
// setTimeout(res => {
|
||||||
|
// store.dispatch("loginEvent"); //获取shapid
|
||||||
|
// }, 1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
// setTimeout(res => {
|
// setTimeout(res => {
|
||||||
// store.dispatch("loginEvent"); //获取shapid
|
// store.dispatch("loginEvent"); //获取shapid
|
||||||
// }, 1000)
|
// }, 1000)
|
||||||
// }
|
|
||||||
// })
|
|
||||||
setTimeout(res => {
|
|
||||||
store.dispatch("loginEvent"); //获取shapid
|
|
||||||
}, 1000)
|
|
||||||
} else if (res.code == 482) {
|
} else if (res.code == 482) {
|
||||||
let nowTime = new Date() / 1000 | 0
|
let nowTime = new Date() / 1000 | 0
|
||||||
let offset = parseInt(res.data.message) - parseInt(nowTime);
|
let offset = parseInt(res.data.message) - parseInt(nowTime);
|
||||||
|
|||||||
@@ -112,7 +112,8 @@
|
|||||||
v-for="(item1,index1) in item.products" :key="index1">
|
v-for="(item1,index1) in item.products" :key="index1">
|
||||||
<image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true"
|
<image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true"
|
||||||
@load="imageLoaded(item1,index,index1)"
|
@load="imageLoaded(item1,index,index1)"
|
||||||
:src="`${item1.coverImg}${!item1.imgLoad?'?x-oss-process=image/resize,m_lfit,w_300,h_300':''}`" mode="aspectFill"></image>
|
:src="`${item1.coverImg}${!item1.imgLoad?'?x-oss-process=image/resize,m_lfit,w_300,h_300':''}`"
|
||||||
|
mode="aspectFill"></image>
|
||||||
<!-- <image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true"
|
<!-- <image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true"
|
||||||
:src="`${item1.coverImg}`" mode="aspectFill"></image> -->
|
:src="`${item1.coverImg}`" mode="aspectFill"></image> -->
|
||||||
<image class="goodsImg" src="@/static/1.gif" mode="" v-else :lazy-load="true"></image>
|
<image class="goodsImg" src="@/static/1.gif" mode="" v-else :lazy-load="true"></image>
|
||||||
@@ -389,15 +390,6 @@
|
|||||||
this.$store.getters.is_BarHeight.customBar)
|
this.$store.getters.is_BarHeight.customBar)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onReady() {
|
|
||||||
// setTimeout(() => {
|
|
||||||
// uni.getSystemInfo({
|
|
||||||
// success: (data) => {
|
|
||||||
// this.scrollHeight = data.windowHeight
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }, 100);
|
|
||||||
},
|
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
if (e.q) {
|
if (e.q) {
|
||||||
this.tableCode = this.getQueryString(decodeURIComponent(e.q), 'code')
|
this.tableCode = this.getQueryString(decodeURIComponent(e.q), 'code')
|
||||||
@@ -481,6 +473,7 @@
|
|||||||
* 获取定位
|
* 获取定位
|
||||||
*/
|
*/
|
||||||
getLocation() {
|
getLocation() {
|
||||||
|
try {
|
||||||
uni.getLocation({
|
uni.getLocation({
|
||||||
type: 'wgs84',
|
type: 'wgs84',
|
||||||
success: async (res) => {
|
success: async (res) => {
|
||||||
@@ -502,10 +495,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: async (err) => {
|
fail: async (err) => {
|
||||||
console.log(err, '获取错误') //测试用于app
|
|
||||||
this.productqueryShop();
|
this.productqueryShop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
this.productqueryShop();
|
||||||
|
//TODO handle the exception
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -514,8 +510,10 @@
|
|||||||
async productqueryShop() {
|
async productqueryShop() {
|
||||||
let res = await this.api.productqueryShop({
|
let res = await this.api.productqueryShop({
|
||||||
code: uni.cache.get('tableCode'),
|
code: uni.cache.get('tableCode'),
|
||||||
lng: uni.cache.get('getLocationstorage').lng?uni.cache.get('getLocationstorage').lng:'',
|
lng: uni.cache.get('getLocationstorage').lng ? uni.cache.get('getLocationstorage').lng :
|
||||||
lat: uni.cache.get('getLocationstorage').lat? uni.cache.get('getLocationstorage').lat:'',
|
'',
|
||||||
|
lat: uni.cache.get('getLocationstorage').lat ? uni.cache.get('getLocationstorage').lat :
|
||||||
|
'',
|
||||||
})
|
})
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
uni.cache.set('shopUser', res.data.storeInfo.id)
|
uni.cache.set('shopUser', res.data.storeInfo.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user