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.

233 lines
6.6 KiB

3 years ago
<script>
import {
VUE_APP_API_URL
} from "@/config";
import Vue from 'vue'
3 years ago
export default {
onLaunch: function (e) {
var that = this; //获取设备信息
this.setAppInfo();
3 years ago
this.autoUpdate();
// uni.hideTabBar()
3 years ago
},
globalData: {
baseURL: VUE_APP_API_URL+ '/',
userInfo: null,
isIphoneX: false,
inviterId: null,
//分享码
systemInfo: null,
scene: null, //场景码
3 years ago
},
onShow(e) {
this.globalData.scene = e.scene
3 years ago
//隐藏系统tabbar
// uni.hideTabBar();
3 years ago
var query = {};
if (e.query.q) {
//通过扫码进来获取二维码上的参数并存入storage
let urlSpread = e.query.q;
if (urlSpread) {
if (urlSpread.indexOf('?') != -1) {
// 通过扫桌面二维码进来
urlSpread = urlSpread.split("?")[1].replace(/=/g, ":").replace(/&/g, ",").split(",").map((item, index) => {
item = item.split(":");
return `"${item[0]}":"${item[1]}"`;
}).join(",");
query = JSON.parse("{" + urlSpread + "}");
}
// console.log('query1', query);
3 years ago
this.globalData.inviterId = query.id;
}
} else {
query = e.query;
// console.log('query2', query);
3 years ago
this.globalData.inviterId = query.id;
}
},
methods: {
autoUpdate: function () {
// console.log(new Date());
var self = this; // 获取小程序更新机制兼容
if (uni.canIUse('getUpdateManager')) {
const updateManager = uni.getUpdateManager(); //1. 检查小程序是否有新版本发布
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
if (res.hasUpdate) {
//2. 小程序有新版本,则静默下载新版本,做好更新准备
updateManager.onUpdateReady(function () {
console.log(new Date());
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
if (res.confirm) {
//3. 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
}
});
});
updateManager.onUpdateFailed(function () {
// 新的版本下载失败
uni.showModal({
title: '已经有新版本了哟~',
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
});
});
}
});
} else {
// 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
uni.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
});
}
},
// 获取系统栏高度
async setAppInfo() {
let that = this
return new Promise((resolve, reject) => {
uni.getSystemInfo({
success: function (e) {
Vue.prototype.StatusBar = e.statusBarHeight
// #ifdef H5
Vue.prototype.CustomBar = e.statusBarHeight + 45
// #endif
3 years ago
// #ifdef APP-PLUS
if (e.platform == 'android') {
Vue.prototype.CustomBar = e.statusBarHeight + 50
} else {
Vue.prototype.CustomBar = e.statusBarHeight + 45
}
// #endif
3 years ago
// #ifdef MP-WEIXIN
let custom = wx.getMenuButtonBoundingClientRect()
Vue.prototype.Custom = custom
Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight
// #endif
},
})
})
3 years ago
},
3 years ago
http(mathods, url, params) {
var that = this;
var header = {
'content-type': 'application/json',
'version': '2.0',
'Authorization': 'Bearer ' + uni.getStorageSync('login_status') || ''
};
return new Promise((resolve, reject) => {
uni.showLoading({
title: "正在加载中..."
});
uni.request({
url: this.globalData.baseURL + url,
//请求地址
method: mathods,
//请求方法
header: header,
data: params || {},
//请求参数
success: res => {
uni.hideLoading(); // console.log(res)
//判断token是否过期 res.data.code == 40001
if (!res.data.success && res.data.status == 401) {
var pages = getCurrentPages().pop(); //当前页面
console.log(pages.$page.fullPath)
uni.setStorageSync('redirect',pages.$page.fullPath) //当前路由存起来,用于登录后自动跳转
uni.navigateTo({
url: '/pages/authorization/index'
});
}
resolve(res); //成功执行方法,参数值为res.data,直接将返回的数据传入
},
fail: function () {
//请求失败
uni.hideLoading();
uni.showToast({
title: '服务器错误,请稍后再试!',
icon: 'none'
});
reject(err);
}
});
});
},
}
};
</script>
<style lang="scss" scoped>
@import "uview-ui/index.scss";
</style>
<style lang="less">
/**app.wxss**/
@import './assets/iconfont/iconfont.css';
@import './assets/css/base.less';
@import './assets/css/reset.less';
@import './assets/css/style.less';
radio .wx-radio-input.wx-radio-input-checked,
checkbox .wx-checkbox-input.wx-checkbox-input-checked
{
border-color: #1d1d1d;
background: #1d1d1d;
3 years ago
}
radio .wx-radio-input {
height: 32rpx;
width: 32rpx;
margin-top: -4rpx !important;
3 years ago
border-radius: 50%;
border: 2rpx solid #999;
background: transparent;
}
radio .wx-radio-input.wx-radio-input-checked::before,
checkbox .wx-checkbox-input.wx-checkbox-input-checked::before{
3 years ago
border-radius: 50%; /* 圆角 */
width: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 32rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
line-height: 32rpx;
3 years ago
text-align: center;
font-size: 26rpx; /* 对勾大小 30rpx */
3 years ago
color: #fff; /* 对勾颜色 白色 */
background: #1d1d1d;
border: 2rpx solid #1d1d1d;
3 years ago
transform: translate(-50%, -50%) scale(1);
-webkit-transform: translate(-50%, -50%) scale(1);
}
.no-list{
display: flex;
flex-direction: column;
align-items: center;
font-size: 46rpx;
color: #D8D8D8;
font-weight: 500;
padding-top: 20%;
}
.no-list image{
width: 536rpx;
height: 490rpx;
}
.no-list .to-btn{
width: 458rpx;
height: 88rpx;
line-height: 88rpx;
text-align: center;
background: #000;
3 years ago
border-radius: 44rpx;
font-size: 40rpx;
color: #fff;
margin-top: 160rpx;
}
</style>