2021-05-13 11:03:32 +08:00
|
|
|
|
|
2021-06-04 18:11:34 +08:00
|
|
|
|
|
2021-05-13 11:03:32 +08:00
|
|
|
|
<script>
|
|
|
|
|
/**
|
|
|
|
|
* vuex管理登录状态,具体可以参考官方登录模板示例
|
|
|
|
|
*/
|
|
|
|
|
import { mapMutations } from "vuex";
|
|
|
|
|
import APPUpdate from "@/plugins/APPUpdate";
|
2021-05-18 16:29:34 +08:00
|
|
|
|
import { getClipboardData } from "@/js_sdk/h5-copy/h5-copy.js";
|
|
|
|
|
import config from "@/config/config";
|
2022-06-02 19:09:57 +08:00
|
|
|
|
import storage from "@/utils/storage";
|
2021-05-13 11:03:32 +08:00
|
|
|
|
// 悬浮球
|
|
|
|
|
|
|
|
|
|
export default {
|
2021-05-18 16:29:34 +08:00
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
config,
|
|
|
|
|
};
|
|
|
|
|
},
|
2021-06-04 18:11:34 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 监听返回
|
|
|
|
|
*/
|
|
|
|
|
onBackPress(e) {
|
|
|
|
|
if (e.from == "backbutton") {
|
|
|
|
|
let routes = getCurrentPages();
|
|
|
|
|
let curRoute = routes[routes.length - 1].options;
|
|
|
|
|
routes.forEach((item) => {
|
|
|
|
|
if (
|
|
|
|
|
item.route == "pages/tabbar/cart/cartList" ||
|
|
|
|
|
item.route.indexOf("pages/product/goods") != -1
|
|
|
|
|
) {
|
|
|
|
|
uni.redirectTo({
|
|
|
|
|
url: item.route,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (curRoute.addId) {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: "/pages/tabbar/cart/cartList",
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
uni.navigateBack();
|
|
|
|
|
}
|
|
|
|
|
return true; //阻止默认返回行为
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-05-13 11:03:32 +08:00
|
|
|
|
methods: {
|
|
|
|
|
...mapMutations(["login"]),
|
|
|
|
|
},
|
|
|
|
|
onLaunch: function () {
|
|
|
|
|
// #ifdef APP-PLUS
|
|
|
|
|
this.checkArguments(); // 检测启动参数
|
2021-06-22 18:12:35 +08:00
|
|
|
|
APPUpdate();
|
|
|
|
|
|
2021-05-13 11:03:32 +08:00
|
|
|
|
// 重点是以下: 一定要监听后台恢复 !一定要
|
|
|
|
|
plus.globalEvent.addEventListener("newintent", (e) => {
|
|
|
|
|
this.checkArguments(); // 检测启动参数
|
|
|
|
|
});
|
|
|
|
|
// #endif
|
2021-07-02 10:52:36 +08:00
|
|
|
|
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
this.applyUpdateWeChat();
|
|
|
|
|
// #endif
|
2021-05-13 11:03:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
2022-04-24 22:41:00 +08:00
|
|
|
|
onShow() {
|
2021-05-18 16:29:34 +08:00
|
|
|
|
// #ifndef H5
|
2022-07-14 14:20:15 +08:00
|
|
|
|
this.getClipboard();
|
|
|
|
|
// #endif
|
2022-04-24 22:41:00 +08:00
|
|
|
|
// #ifdef APP-PLUS
|
2022-06-02 19:09:57 +08:00
|
|
|
|
|
2022-04-24 22:41:00 +08:00
|
|
|
|
if (storage.getShow()) {
|
|
|
|
|
if(uni.getSystemInfoSync().platform == 'ios'){
|
|
|
|
|
this.$u.route("/pages/tabbar/screen/fullScreen");
|
2022-06-02 19:09:57 +08:00
|
|
|
|
|
2022-04-24 22:41:00 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-18 16:29:34 +08:00
|
|
|
|
// #endif
|
|
|
|
|
},
|
2021-05-13 11:03:32 +08:00
|
|
|
|
methods: {
|
2021-07-02 10:52:36 +08:00
|
|
|
|
/**
|
|
|
|
|
* 微信小程序版本提交更新版本 解决缓存问题
|
|
|
|
|
*/
|
|
|
|
|
applyUpdateWeChat() {
|
|
|
|
|
const updateManager = uni.getUpdateManager();
|
|
|
|
|
|
|
|
|
|
updateManager.onCheckForUpdate(function (res) {
|
|
|
|
|
// 请求完新版本信息的回调
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
updateManager.onUpdateReady(function (res) {
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title: "更新提示",
|
|
|
|
|
content: "发现新版本,是否重启应用?",
|
|
|
|
|
success(res) {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
|
|
|
updateManager.applyUpdate();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
updateManager.onUpdateFailed(function (res) {
|
|
|
|
|
// 新的版本下载失败
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2021-05-24 15:49:22 +08:00
|
|
|
|
// TODO 开屏广告 后续优化添加
|
2021-05-13 11:03:32 +08:00
|
|
|
|
launch() {
|
|
|
|
|
try {
|
|
|
|
|
// 获取本地存储中launchFlag标识 开屏广告
|
|
|
|
|
const value = uni.getStorageSync("launchFlag");
|
|
|
|
|
if (!value) {
|
2021-05-24 15:49:22 +08:00
|
|
|
|
// this.$u.route("/pages/index/agreement");
|
2021-05-13 11:03:32 +08:00
|
|
|
|
} else {
|
|
|
|
|
//app启动时打开启动广告页
|
|
|
|
|
var w = plus.webview.open(
|
|
|
|
|
"/hybrid/html/advertise/advertise.html",
|
|
|
|
|
"本地地址",
|
|
|
|
|
{
|
|
|
|
|
top: 0,
|
|
|
|
|
bottom: 0,
|
|
|
|
|
zindex: 999,
|
|
|
|
|
},
|
|
|
|
|
"fade-in",
|
|
|
|
|
500
|
|
|
|
|
);
|
|
|
|
|
//设置定时器,4s后关闭启动广告页
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
plus.webview.close(w);
|
|
|
|
|
APPUpdate();
|
|
|
|
|
}, 3000);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// error
|
|
|
|
|
uni.setStorage({
|
|
|
|
|
key: "launchFlag",
|
|
|
|
|
data: true,
|
|
|
|
|
success: function () {
|
|
|
|
|
console.log("error时存储launchFlag");
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-05-18 16:29:34 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取粘贴板数据
|
|
|
|
|
*/
|
|
|
|
|
async getClipboard() {
|
|
|
|
|
let res = await getClipboardData();
|
2022-07-14 14:20:15 +08:00
|
|
|
|
|
2021-05-18 16:29:34 +08:00
|
|
|
|
/**
|
|
|
|
|
* 解析粘贴板数据
|
|
|
|
|
*/
|
2022-07-14 14:20:15 +08:00
|
|
|
|
|
|
|
|
|
if (res.indexOf(config.shareLink) != -1 && (res!= this.$store.state.shareLink)) {
|
|
|
|
|
this.$store.state.shareLink = res
|
2021-05-18 16:29:34 +08:00
|
|
|
|
uni.showModal({
|
|
|
|
|
title: "提示",
|
|
|
|
|
content: "检测到一个分享链接是否跳转?",
|
|
|
|
|
confirmText: "跳转",
|
|
|
|
|
success: function (callback) {
|
|
|
|
|
if (callback.confirm) {
|
|
|
|
|
const path = res.split(config.shareLink)[1];
|
|
|
|
|
if (path.indexOf("tabbar") != -1) {
|
|
|
|
|
uni.switchTab({
|
|
|
|
|
url: path,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: path,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* h5中打开app获取跳转app的链接并跳转
|
|
|
|
|
*/
|
2021-05-13 11:03:32 +08:00
|
|
|
|
checkArguments() {
|
|
|
|
|
// #ifdef APP-PLUS
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
const args = plus.runtime.arguments;
|
|
|
|
|
if (args) {
|
|
|
|
|
const argsStr = decodeURIComponent(args);
|
|
|
|
|
const path = argsStr.split("//")[1];
|
2021-05-18 16:29:34 +08:00
|
|
|
|
if (path.indexOf("tabbar") != -1) {
|
2021-05-13 11:03:32 +08:00
|
|
|
|
uni.switchTab({
|
|
|
|
|
url: `/${path}`,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: `/${path}`,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// #endif
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
@import "uview-ui/index.scss";
|
2021-08-11 10:28:04 +08:00
|
|
|
|
|
2021-05-13 11:03:32 +08:00
|
|
|
|
// -------适配底部安全区 苹果x系列刘海屏
|
|
|
|
|
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
.mp-iphonex-bottom {
|
|
|
|
|
padding-bottom: constant(safe-area-inset-bottom);
|
|
|
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
|
|
|
box-sizing: content-box;
|
|
|
|
|
height: auto !important;
|
|
|
|
|
padding-top: 10rpx;
|
|
|
|
|
}
|
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
|
|
body {
|
|
|
|
|
background-color: $bg-color;
|
|
|
|
|
}
|
|
|
|
|
/************************ */
|
|
|
|
|
.w200 {
|
|
|
|
|
width: 200rpx !important;
|
|
|
|
|
}
|
|
|
|
|
.flex1 {
|
|
|
|
|
flex: 1; //必须父级设置flex
|
|
|
|
|
}
|
|
|
|
|
</style>
|