You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
onLaunch(options) {
|
|
|
|
|
uni.hideTabBar()
|
|
|
|
|
const Pages = options.path;
|
|
|
|
|
|
|
|
|
|
// 白名单
|
|
|
|
|
const WHITE = [
|
|
|
|
|
"pages/login/login",
|
|
|
|
|
"pages/register/index",
|
|
|
|
|
"pages/register/registerSuccess",
|
|
|
|
|
"pages/login/authInfo",
|
|
|
|
|
"pages/login/forgotPassword"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const value = uni.getStorageSync("token");
|
|
|
|
|
console.log("App Launch");
|
|
|
|
|
if ((!value) && (WHITE.indexOf(Pages) < 0)) {
|
|
|
|
|
uni.redirectTo({
|
|
|
|
|
url: "/pages/login/login",
|
|
|
|
|
});
|
|
|
|
|
return false
|
|
|
|
|
} else {
|
|
|
|
|
const userInfo = uni.getStorageSync("userinfo");
|
|
|
|
|
if (userInfo) {
|
|
|
|
|
// 处理用户数据
|
|
|
|
|
this.$store.dispatch("changeTabbar", userInfo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
this.timer=setInterval(()=>{
|
|
|
|
|
this.updatePosition()
|
|
|
|
|
},10000)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
data(){
|
|
|
|
|
return {
|
|
|
|
|
timer:null,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
updatePosition() {
|
|
|
|
|
const userInfo = uni.getStorageSync("userinfo");
|
|
|
|
|
if (this.$store.state.dataType == 4) {
|
|
|
|
|
uni.getLocation({
|
|
|
|
|
type: 'wgs84',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
let query = {
|
|
|
|
|
id: userInfo.user_id,
|
|
|
|
|
// "addressLon": res.longitude,
|
|
|
|
|
// "addressLat": res.latitude
|
|
|
|
|
"addressLon": 120.4732160947301,
|
|
|
|
|
"addressLat": 36.17767397801995
|
|
|
|
|
}
|
|
|
|
|
this.$u.api.updatePosition(query).then(res => {
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
this.error = err;
|
|
|
|
|
console.error('定位失败:', err);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
onHide () {
|
|
|
|
|
clearInterval(this.timer);
|
|
|
|
|
console.log("App Hide");
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
@import "@/uni_modules/uview-ui/index.scss";
|
|
|
|
|
@import "@/static/scss/index.scss";
|
|
|
|
|
|
|
|
|
|
/*每个页面公共css */
|
|
|
|
|
page {
|
|
|
|
|
background: #fff;
|
|
|
|
|
}
|
|
|
|
|
</style>
|