<script>
|
import Vue from 'vue'
|
import store from './store/index.js'
|
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
|
import updateCustomBarInfo from './tuniao-ui/libs/function/updateCustomBarInfo.js'
|
export default {
|
onLaunch: function() {
|
setTimeout(() => {
|
// app 检测更新
|
checkUpdate();
|
}, 2000);
|
console.log('App Launch')
|
uni.getPushClientId({
|
success: (res) => {
|
console.log(res.cid);
|
store.commit('$tStore', {
|
name: 'uuid',
|
value: res.cid
|
})
|
|
},
|
fail(err) {
|
console.log(err)
|
}
|
});
|
uni.onPushMessage((res) => {
|
console.log("收到推送消息:",res) //监听推送消息
|
if(res.data){
|
console.log(res.data)
|
uni.createPushMessage(res.data) //收到消息推送,创建系统状态栏及锁屏通 知
|
}
|
})
|
// },
|
console.log(uni.getStorageSync('access_token'));
|
var data = {}
|
data.token = uni.getStorageSync('access_token')
|
var method ='GET'
|
var contentType='application/x-www-form-urlencoded'
|
uni.request({
|
// url: "http://192.168.31.101:8181/Fence/", //接口地址。
|
// url: "http://111.198.60.6:6008/Fence/", //接口地址。
|
// url: "http://123.56.113.213:8081/api/wx/checkLogin", //接口地址。
|
url: "http://39.106.210.13:8090/api/wx/checkLogin", //接口地址。
|
data: data,
|
method: method,
|
header: { //请求头可自定义
|
'Authorization':uni.getStorageSync('access_token'),
|
'content-type': contentType,
|
},
|
timeout:5000,//设置超时时间,默认5秒
|
success: (rep) => { //具体捕获请看自己接口返回的形式
|
console.log(rep);
|
if (rep.data.code!=0) {
|
store.commit('$tStore', {
|
name: 'vuex_is_login',
|
value: false
|
})
|
// uni.reLaunch({
|
// url: '/pages/index/login'
|
// });
|
uni.reLaunch({
|
url: '/pages/index/index'
|
});
|
}else{
|
uni.reLaunch({
|
url: '/pages/index/index'
|
});
|
}
|
|
},
|
fail(error) {
|
console.log(error);
|
// uni.hideLoading();
|
// uni.$u.toast('网络不通');
|
// reject(error)
|
},
|
// complete() {
|
// uni.hideLoading();
|
// }
|
});
|
uni.getSystemInfo({
|
success: function(e) {
|
|
|
console.info('e',e)
|
Vue.prototype.screenHeight = e.screenHeight
|
Vue.prototype.safeBottom = e.safeAreaInsets.bottom
|
|
// #ifndef H5
|
// 获取手机系统版本
|
const system = e.system.toLowerCase()
|
const platform = e.platform.toLowerCase()
|
// 判断是否为ios设备
|
if (platform.indexOf('ios') != -1 && (system.indexOf('ios') != -1 || system.indexOf(
|
'macos') != -1)) {
|
Vue.prototype.SystemPlatform = 'apple'
|
} else if (platform.indexOf('android') != -1 && (system.indexOf('android') != -1)) {
|
Vue.prototype.SystemPlatform = 'android'
|
} else {
|
Vue.prototype.SystemPlatform = 'devtools'
|
}
|
// #endif
|
}
|
})
|
|
// 获取设备的状态栏信息和自定义顶栏信息
|
// store.dispatch('updateCustomBarInfo')
|
updateCustomBarInfo().then((res) => {
|
store.commit('$tStore', {
|
name: 'vuex_status_bar_height',
|
value: res.statusBarHeight
|
})
|
store.commit('$tStore', {
|
name: 'vuex_custom_bar_height',
|
value: res.customBarHeight
|
})
|
})
|
|
// #ifdef MP-WEIXIN
|
//更新检测
|
if (wx.canIUse('getUpdateManager')) {
|
const updateManager = wx.getUpdateManager();
|
updateManager && updateManager.onCheckForUpdate((res) => {
|
if (res.hasUpdate) {
|
updateManager.onUpdateReady(() => {
|
uni.showModal({
|
title: '更新提示',
|
content: '新版本已经准备就绪,是否需要重新启动应用?',
|
success: (res) => {
|
if (res.confirm) {
|
uni.clearStorageSync() // 更新完成后刷新storage的数据
|
updateManager.applyUpdate()
|
}
|
}
|
})
|
})
|
|
updateManager.onUpdateFailed(() => {
|
uni.showModal({
|
title: '已有新版本上线',
|
content: '小程序自动更新失败,请删除该小程序后重新搜索打开哟~~~',
|
showCancel: false
|
})
|
})
|
} else {
|
//没有更新
|
}
|
})
|
} else {
|
uni.showModal({
|
title: '提示',
|
content: '当前微信版本过低,无法使用该功能,请更新到最新的微信后再重试。',
|
showCancel: false
|
})
|
}
|
// #endif
|
},
|
onShow: function() {
|
console.log('App Show')
|
|
},
|
onHide: function() {
|
console.log('App Hide')
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
:root {
|
--main-color--: #40A290;
|
}
|
|
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
|
@import './tuniao-ui/index.scss';
|
@import './tuniao-ui/iconfont.css';
|
|
@import "uview-ui/index.scss";
|
|
.page-title {
|
font-weight: bold;
|
}
|
|
.list-null {
|
width: 100%;
|
height: 100%;
|
padding-top: 30px;
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
}
|
</style>
|