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.

383 lines
10 KiB

3 years ago
<script>
import {
VUE_APP_API_URL
} from "@/config";
export default {
onLaunch: function (e) {
var that = this; //获取设备信息
3 years ago
3 years ago
this.setMenuHeight();
this.autoUpdate();
3 years ago
uni.hideTabBar()
3 years ago
},
globalData: {
// baseURL : 'http://192.168.0.110:8092/api/',
baseURL: VUE_APP_API_URL+ '/',
// baseURL : 'https://cloud.api.cyjyyjy.com/api/',
userInfo: null,
navHeight: 0,
navTopHeight: 0,
menuTop: 0,
menuHeight: 0,
CustomBar: 0,
isIphoneX: false,
inviterId: null,
//分享码
systemInfo: null,
},
onShow(e) {
//隐藏系统tabbar
uni.hideTabBar();
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);
this.globalData.inviterId = query.id;
}
} else {
query = e.query;
console.log('query2', query);
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: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
});
}
},
setMenuHeight() {
uni.getSystemInfo({
success: res => {
console.log(res);
this.globalData.navTopHeight = res.statusBarHeight;
this.globalData.CustomBar = res.statusBarHeight + 45;
this.globalData.systemInfo = res;
let model = res.model;
3 years ago
if (/iphone\sx/i.test(model) || /iphone/i.test(model) && /unknown/.test(model) || /iphone\s11/i.test(model) || /iphone\s12/i.test(model) || /iphone\s13/i.test(model)) {
3 years ago
this.globalData.isIphoneX = true;
}
}
});
let menuButtonObj = uni.getMenuButtonBoundingClientRect();
this.globalData.menuTop = menuButtonObj.top; // console.log(menuButtonObj)
this.globalData.menuHeight = menuButtonObj.height;
this.globalData.navHeight = menuButtonObj.height + (menuButtonObj.top - this.globalData.navTopHeight);
},
getInfo() {
this.http('get', 'userinfo').then(res => {
if (res.data.success) {
uni.setStorageSync('userInfo', res.data.data);
var pages = getCurrentPages().pop(); //当前页面
if (pages.getUser) {
pages.getUser();
}
} else {
uni.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000
});
setTimeout(() => {
// uni.navigateTo({
// url: '/pages/login/index'
// });
uni.navigateTo({
url: '/pages/authorization/index'
});
}, 2000);
}
});
},
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) {
// console.log('登陆失效')
// uni.navigateTo({
// url: '/pages/login/index'
// });
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';
view,
scroll-view,
swiper,
button,
input,
textarea,
label,
navigator,
image {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
image{
/* border-radius: 8rpx; */
}
/* layout */
.acea-row-nowrap {
display: flex;
/* 辅助类 */
}
.acea-row {
display: flex;
flex-wrap: wrap;
/* 辅助类 */
}
.acea-row.row-middle,.acea-row-nowrap.row-middle{
align-items: center;
}
.acea-row.row-top,.acea-row-nowrap.row-top {
align-items: flex-start;
}
.acea-row.row-bottom {
align-items: flex-end;
}
.acea-row.row-center,.acea-row-nowrap.row-center {
justify-content: center;
}
.acea-row.row-right,.acea-row-nowrap.row-right {
justify-content: flex-end;
}
.acea-row.row-left,.acea-row-nowrap.row-left {
justify-content: flex-start;
}
.acea-row.row-between,.acea-row-nowrap.row-between {
justify-content: space-between;
}
.acea-row.row-around, .acea-row-nowrap.row-around{
justify-content: space-around;
}
.acea-row.row-column-around,.acea-row-nowrap.row-column-around {
flex-direction: column;
justify-content: space-around;
}
.acea-row.row-column {
flex-direction: column;
}
.acea-row.row-column-between,.acea-row-nowrap.row-column-between {
flex-direction: column;
justify-content: space-between;
}
/* 上下左右垂直居中 */
.acea-row.row-center-wrapper,.acea-row-nowrap.row-center-wrapper {
align-items: center;
justify-content: center;
}
/* 上下两边居中对齐 */
.acea-row.row-between-wrapper,.acea-row-nowrap.row-between-wrapper {
align-items: center;
justify-content: space-between;
}
.line1{
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
width: 100%;
}
.line2{
word-break:break-all;
display:-webkit-box;
-webkit-line-clamp:2;
-webkit-box-orient:vertical;
overflow:hidden;
}
.back-btn{
width: 36rpx;
height: 36rpx;
position: fixed;
left: 40rpx;
text-align: center;
line-height: 36rpx;
z-index: 99;
}
.back-btn image{
width: 100%;
height: 100%;
}
radio .wx-radio-input.wx-radio-input-checked {
3 years ago
border-color: #FF5100;
background: #FF5100;
3 years ago
}
radio .wx-radio-input {
height: 33rpx;
width: 33rpx;
margin-top: -4rpx;
border-radius: 50%;
border: 2rpx solid #999;
background: transparent;
}
radio .wx-radio-input.wx-radio-input-checked::before {
border-radius: 50%; /* 圆角 */
width: 35rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 35rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
line-height: 35rpx;
text-align: center;
font-size: 28rpx; /* 对勾大小 30rpx */
color: #fff; /* 对勾颜色 白色 */
background: #FF5100;
border: 2rpx solid #FF5100;
transform: translate(-50%, -50%) scale(1);
-webkit-transform: translate(-50%, -50%) scale(1);
}
3 years ago
checkbox .wx-checkbox-input.wx-checkbox-input-checked {
border-color: #F99C10;
background: #F99C10;
}
checkbox .wx-checkbox-input {
height: 40rpx;
width: 40rpx;
margin-top: -4rpx;
border-radius: 50%;
border: 2rpx solid #999;
background: transparent;
}
checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
border-radius: 50%; /* 圆角 */
width: 40rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 40rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
line-height: 40rpx;
text-align: center;
font-size: 28rpx; /* 对勾大小 30rpx */
color: #fff; /* 对勾颜色 白色 */
background: #F99C10;
border: 2rpx solid #F99C10;
transform: translate(-50%, -50%) scale(1);
-webkit-transform: translate(-50%, -50%) scale(1);
}
3 years ago
.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: linear-gradient(134deg, #FFA782 0%, #FF6D31 100%);
border-radius: 44rpx;
font-size: 40rpx;
color: #fff;
margin-top: 160rpx;
}
</style>