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.
 
 
 
 

534 lines
14 KiB

<script>
import {
VUE_APP_API_URL
} from "@/config";
export default {
onLaunch: function (e) {
var that = this; //获取设备信息
this.setMenuHeight();
this.autoUpdate();
uni.hideTabBar()
},
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,
scene: null, //场景码
},
onShow(e) {
this.globalData.scene = e.scene
// console.log(this.globalData.scene,'this.globalData.scene')
//隐藏系统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: {
sceneInfo(s) {
console.log(s)
var scene = [];
switch (s) {
case 1001:
scene.push(s, "发现栏小程序主入口");
break;
case 1005:
scene.push(s, "顶部搜索框的搜索结果页");
break;
case 1006:
scene.push(s, "发现栏小程序主入口搜索框的搜索结果页");
break;
case 1007:
scene.push(s, "单人聊天会话中的小程序消息卡片");
break;
case 1008:
scene.push(s, "群聊会话中的小程序消息卡片");
break;
case 1011:
scene.push(s, "扫描二维码");
break;
case 1012:
scene.push(s, "长按图片识别二维码");
break;
case 1014:
scene.push(s, "手机相册选取二维码");
break;
case 1017:
scene.push(s, "前往体验版的入口页");
break;
case 1019:
scene.push(s, "微信钱包");
break;
case 1020:
scene.push(s, "公众号profile页相关小程序列表");
break;
case 1022:
scene.push(s, "聊天顶部置顶小程序入口");
break;
case 1023:
scene.push(s, "安卓系统桌面图标");
break;
case 1024:
scene.push(s, "小程序profile页");
break;
case 1025:
scene.push(s, "扫描一维码");
break;
case 1026:
scene.push(s, "附近小程序列表");
break;
case 1027:
scene.push(s, "顶部搜索框搜索结果页“使用过的小程序”列表");
break;
case 1028:
scene.push(s, "我的卡包");
break;
case 1029:
scene.push(s, "卡券详情页");
break;
case 1031:
scene.push(s, "长按图片识别一维码");
break;
case 1032:
scene.push(s, "手机相册选取一维码");
break;
case 1034:
scene.push(s, "微信支付完成页");
break;
case 1035:
scene.push(s, "公众号自定义菜单");
break;
case 1036:
scene.push(s, "App分享消息卡片");
break;
case 1037:
scene.push(s, "小程序打开小程序");
break;
case 1038:
scene.push(s, "从另一个小程序返回");
break;
case 1039:
scene.push(s, "摇电视");
break;
case 1042:
scene.push(s, "添加好友搜索框的搜索结果页");
break;
case 1044:
scene.push(s, "带shareTicket的小程序消息卡片");
break;
case 1047:
scene.push(s, "扫描小程序码");
break;
case 1048:
scene.push(s, "长按图片识别小程序码");
break;
case 1049:
scene.push(s, "手机相册选取小程序码");
break;
case 1052:
scene.push(s, "卡券的适用门店列表");
break;
case 1053:
scene.push(s, "搜一搜的结果页");
break;
case 1054:
scene.push(s, "顶部搜索框小程序快捷入口");
break;
case 1056:
scene.push(s, "音乐播放器菜单");
break;
case 1058:
scene.push(s, "公众号文章");
break;
case 1059:
scene.push(s, "体验版小程序绑定邀请页");
break;
case 1064:
scene.push(s, "微信连Wifi状态栏");
break;
case 1067:
scene.push(s, "公众号文章广告");
break;
case 1068:
scene.push(s, "附近小程序列表广告");
break;
case 1072:
scene.push(s, "二维码收款页面");
break;
case 1073:
scene.push(s, "客服消息列表下发的小程序消息卡片");
break;
case 1074:
scene.push(s, "公众号会话下发的小程序消息卡片");
break;
case 1089:
scene.push(s, "微信聊天主界面下拉");
break;
case 1090:
scene.push(s, "长按小程序右上角菜单唤出最近使用历史");
break;
case 1092:
scene.push(s, "城市服务入口");
break;
default:
scene.push("未知入口");
break;
}
return scene;
},
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 => {
this.globalData.navTopHeight = res.statusBarHeight;
this.globalData.CustomBar = res.statusBarHeight + 45;
this.globalData.systemInfo = res;
let model = res.model;
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)) {
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 {
border-color: #FF5100;
background: #FF5100;
}
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);
}
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);
}
.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>