|
@@ -112,17 +112,13 @@
|
|
|
|
|
|
|
|
<!-- 图书加价弹窗 -->
|
|
<!-- 图书加价弹窗 -->
|
|
|
<UpsellBook ref="upsellRef" @scan="handleScanCode" />
|
|
<UpsellBook ref="upsellRef" @scan="handleScanCode" />
|
|
|
-
|
|
|
|
|
- <!-- 加价分享弹窗 -->
|
|
|
|
|
- <UpsellShare ref="shareRef" @viewRules="handleViewSellRules" />
|
|
|
|
|
<!-- 加价二维码弹窗 -->
|
|
<!-- 加价二维码弹窗 -->
|
|
|
<UpsellQrcode ref="upsellQrcodeRef" />
|
|
<UpsellQrcode ref="upsellQrcodeRef" />
|
|
|
-
|
|
|
|
|
<!-- 加价规则弹窗 -->
|
|
<!-- 加价规则弹窗 -->
|
|
|
<UpsellRules ref="upsellRulesRef" />
|
|
<UpsellRules ref="upsellRulesRef" />
|
|
|
-
|
|
|
|
|
- <!-- 减价分享弹窗 -->
|
|
|
|
|
- <ReduceShare ref="reduceShareRef" @viewRules="handleViewSellRules" />
|
|
|
|
|
|
|
+ <!-- 仅承接加价分享 -->
|
|
|
|
|
+ <ActivityHost ref="activityHost" :enable-reduce="false" @refresh-order="getLastOrder"
|
|
|
|
|
+ @view-rules="handleViewSellRules" />
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -137,11 +133,9 @@
|
|
|
import FirstOrderFreePopup from "./components/FirstOrderFreePopup.vue";
|
|
import FirstOrderFreePopup from "./components/FirstOrderFreePopup.vue";
|
|
|
import UpsellBook from "./components/upsell-book.vue";
|
|
import UpsellBook from "./components/upsell-book.vue";
|
|
|
import UpsellRules from "./components/upsell-rules.vue";
|
|
import UpsellRules from "./components/upsell-rules.vue";
|
|
|
- import UpsellShare from "./components/upsell-share.vue";
|
|
|
|
|
import UpsellQrcode from "./components/upsell-qrcode.vue";
|
|
import UpsellQrcode from "./components/upsell-qrcode.vue";
|
|
|
-import ReduceShare from "./components/reduce-share.vue";
|
|
|
|
|
|
|
+ import ActivityHost from "@/components/activity-host.vue";
|
|
|
import FloatingDrag from "@/components/floating-drag.vue";
|
|
import FloatingDrag from "@/components/floating-drag.vue";
|
|
|
- import { eventBus } from "@/utils/event-bus";
|
|
|
|
|
|
|
|
|
|
const app = getApp();
|
|
const app = getApp();
|
|
|
|
|
|
|
@@ -157,9 +151,8 @@ export default {
|
|
|
FirstOrderFreePopup,
|
|
FirstOrderFreePopup,
|
|
|
UpsellBook,
|
|
UpsellBook,
|
|
|
UpsellRules,
|
|
UpsellRules,
|
|
|
- UpsellShare,
|
|
|
|
|
UpsellQrcode,
|
|
UpsellQrcode,
|
|
|
- ReduceShare,
|
|
|
|
|
|
|
+ ActivityHost,
|
|
|
FloatingDrag,
|
|
FloatingDrag,
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
@@ -181,6 +174,7 @@ export default {
|
|
|
},
|
|
},
|
|
|
shareData: {},
|
|
shareData: {},
|
|
|
deleteBook: {},
|
|
deleteBook: {},
|
|
|
|
|
+ pendingActivityOptions: {},
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
@@ -228,69 +222,18 @@ export default {
|
|
|
},
|
|
},
|
|
|
// 分享配置
|
|
// 分享配置
|
|
|
onShareAppMessage(res) {
|
|
onShareAppMessage(res) {
|
|
|
- if (res.from === "button" && res.target && res.target.dataset && res.target.dataset.shareType === "upsell") {
|
|
|
|
|
- let upsellCode = uni.getStorageSync("upsellCodeShare");
|
|
|
|
|
- console.log(upsellCode, "分享");
|
|
|
|
|
- // 调用分享接口
|
|
|
|
|
- uni.$u.http.get("/token/order/goToShare?upsellCode=" + upsellCode);
|
|
|
|
|
- return {
|
|
|
|
|
- title: "书嗨",
|
|
|
|
|
- path: "/pages/home/index?upsellCode=" + upsellCode,
|
|
|
|
|
- imageUrl: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/share.jpg",
|
|
|
|
|
- desc: "书嗨,专注于书籍交易的平台,提供新书和二手书的买卖服务",
|
|
|
|
|
- };
|
|
|
|
|
- } else if (res.from === "button" && res.target && res.target.dataset && res.target.dataset.shareType === "reduce") {
|
|
|
|
|
- let reduceCode = uni.getStorageSync("reduceCodeShare");
|
|
|
|
|
- if (uni.$u && uni.$u.api && uni.$u.api.goToReduceShareAjax) {
|
|
|
|
|
- uni.$u.api.goToReduceShareAjax({ reduceCode: reduceCode });
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.$u && uni.$u.http && uni.$u.http.get('/token/shop/order/goToShare', { reduceCode: reduceCode });
|
|
|
|
|
- }
|
|
|
|
|
- return {
|
|
|
|
|
- title: "快来帮我减钱买书吧!",
|
|
|
|
|
- path: "/pages/home/index?reduceCode=" + reduceCode,
|
|
|
|
|
- imageUrl: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/share.jpg",
|
|
|
|
|
- desc: "书嗨,专注于书籍交易的平台,提供新书和二手书的买卖服务",
|
|
|
|
|
- };
|
|
|
|
|
- } else {
|
|
|
|
|
- return {
|
|
|
|
|
- title: "书嗨",
|
|
|
|
|
- page: "/pages/home/index",
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return this.$refs.activityHost?.getShareAppMessage(res) || {
|
|
|
|
|
+ title: "书嗨",
|
|
|
|
|
+ page: "/pages/home/index",
|
|
|
|
|
+ };
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 分享到朋友圈
|
|
// 分享到朋友圈
|
|
|
onShareTimeline(res) {
|
|
onShareTimeline(res) {
|
|
|
- if (res.from === "button" && res.target && res.target.dataset && res.target.dataset.shareType === "upsell") {
|
|
|
|
|
- let upsellCode = uni.getStorageSync("upsellCodeShare");
|
|
|
|
|
- // 调用分享接口
|
|
|
|
|
- uni.$u.http.get("/token/order/goToShare?upsellCode=" + upsellCode);
|
|
|
|
|
- return {
|
|
|
|
|
- title: "书嗨",
|
|
|
|
|
- path: "/pages/home/index?upsellCode=" + upsellCode,
|
|
|
|
|
- imageUrl: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/share.jpg",
|
|
|
|
|
- desc: "书嗨,专注于书籍交易的平台,提供新书和二手书的买卖服务",
|
|
|
|
|
- };
|
|
|
|
|
- } else if (res.from === "button" && res.target && res.target.dataset && res.target.dataset.shareType === "reduce") {
|
|
|
|
|
- let reduceCode = uni.getStorageSync("reduceCodeShare");
|
|
|
|
|
- if (uni.$u && uni.$u.api && uni.$u.api.goToReduceShareAjax) {
|
|
|
|
|
- uni.$u.api.goToReduceShareAjax({ reduceCode: reduceCode });
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.$u && uni.$u.http && uni.$u.http.get('/token/shop/order/goToShare', { reduceCode: reduceCode });
|
|
|
|
|
- }
|
|
|
|
|
- return {
|
|
|
|
|
- title: "快来帮我减钱买书吧!",
|
|
|
|
|
- path: "/pages/home/index?reduceCode=" + reduceCode,
|
|
|
|
|
- imageUrl: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/share.jpg",
|
|
|
|
|
- desc: "书嗨,专注于书籍交易的平台,提供新书和二手书的买卖服务",
|
|
|
|
|
- };
|
|
|
|
|
- } else {
|
|
|
|
|
- return {
|
|
|
|
|
- title: "书嗨",
|
|
|
|
|
- page: "/pages/home/index",
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return this.$refs.activityHost?.getShareTimeline(res) || {
|
|
|
|
|
+ title: "书嗨",
|
|
|
|
|
+ page: "/pages/home/index",
|
|
|
|
|
+ };
|
|
|
},
|
|
},
|
|
|
onReady() {
|
|
onReady() {
|
|
|
// 获取屏幕宽度和高度
|
|
// 获取屏幕宽度和高度
|
|
@@ -300,53 +243,31 @@ export default {
|
|
|
this.screenHeight = res.windowHeight;
|
|
this.screenHeight = res.windowHeight;
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ if (this.hasActivityEntryOptions(this.pendingActivityOptions)) {
|
|
|
|
|
+ this.$refs.activityHost?.handlePageOptions(this.pendingActivityOptions, app.globalData.isColdLaunch);
|
|
|
|
|
+ }
|
|
|
|
|
+ this.pendingActivityOptions = {};
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
|
this.$updateCartBadge();
|
|
this.$updateCartBadge();
|
|
|
if (!app.globalData.isColdLaunch) {
|
|
if (!app.globalData.isColdLaunch) {
|
|
|
|
|
+ if (this.hasActivityEntryOptions(this.pendingActivityOptions)) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
let token = uni.getStorageSync("token");
|
|
let token = uni.getStorageSync("token");
|
|
|
if (token) {
|
|
if (token) {
|
|
|
this.getLastOrder();
|
|
this.getLastOrder();
|
|
|
}
|
|
}
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- eventBus.on("loginSuccess", (data) => {
|
|
|
|
|
- console.log(data, "登录成功loginSuccess");
|
|
|
|
|
- this.loginSuccess(data);
|
|
|
|
|
- app.globalData.isColdLaunch = false;
|
|
|
|
|
- });;
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
//针对多次扫码的热启动场景,需要判断是否是冷启动
|
|
//针对多次扫码的热启动场景,需要判断是否是冷启动
|
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
|
console.log(options, app.globalData.isColdLaunch, "onLoad");
|
|
console.log(options, app.globalData.isColdLaunch, "onLoad");
|
|
|
- if (app.globalData.isColdLaunch) return
|
|
|
|
|
-
|
|
|
|
|
- if (options.scene) {
|
|
|
|
|
- let params = {};
|
|
|
|
|
- // 对 scene 进行解码
|
|
|
|
|
- const decodeScene = decodeURIComponent(options.scene);
|
|
|
|
|
- // 拆分参数
|
|
|
|
|
- const paramPairs = decodeScene.split('&');
|
|
|
|
|
- paramPairs.forEach((pair) => {
|
|
|
|
|
- const [key, value] = pair.split('=');
|
|
|
|
|
- params[key] = value;
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- if (params.upsellCode) {
|
|
|
|
|
- this.$refs.shareRef?.open(params.upsellCode);
|
|
|
|
|
- this.getLastOrder();
|
|
|
|
|
- }
|
|
|
|
|
- if (params.reduceCode) {
|
|
|
|
|
- this.$refs.reduceShareRef?.open(params.reduceCode);
|
|
|
|
|
- }
|
|
|
|
|
- } else if (options.upsellCode) {
|
|
|
|
|
- this.$refs.shareRef?.open(options.upsellCode);
|
|
|
|
|
- } else if (options.reduceCode) {
|
|
|
|
|
- this.$refs.reduceShareRef?.open(options.reduceCode);
|
|
|
|
|
- } else {
|
|
|
|
|
- this.getLastOrder();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.pendingActivityOptions = options || {};
|
|
|
},
|
|
},
|
|
|
// #ifdef MP-ALIPAY
|
|
// #ifdef MP-ALIPAY
|
|
|
onPullDownRefresh() {
|
|
onPullDownRefresh() {
|
|
@@ -354,30 +275,21 @@ export default {
|
|
|
},
|
|
},
|
|
|
// #endif
|
|
// #endif
|
|
|
|
|
|
|
|
- //卸载loginSuccess事件
|
|
|
|
|
|
|
+ // 清理活动缓存
|
|
|
onUnload() {
|
|
onUnload() {
|
|
|
uni.removeStorageSync("upsellCode");
|
|
uni.removeStorageSync("upsellCode");
|
|
|
uni.removeStorageSync("reduceCode");
|
|
uni.removeStorageSync("reduceCode");
|
|
|
- eventBus.off("loginSuccess");
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
|
- // 登录成功之后
|
|
|
|
|
- loginSuccess(data) {
|
|
|
|
|
- let upsellCode = uni.getStorageSync("upsellCode");
|
|
|
|
|
- if (upsellCode) {
|
|
|
|
|
- console.log(upsellCode, "登录成功之后助力的 code值:", upsellCode);
|
|
|
|
|
- this.$refs.shareRef?.open(upsellCode);
|
|
|
|
|
- }
|
|
|
|
|
- // 仿照加价助力:优先读取缓存,兼容扫码冷启动参数丢失场景
|
|
|
|
|
- let reduceCode = uni.getStorageSync("reduceCode") || data?.params?.reduceCode;
|
|
|
|
|
- if (reduceCode) {
|
|
|
|
|
- console.log(reduceCode, "登录成功之后助力的 code值:", reduceCode);
|
|
|
|
|
- this.$refs.reduceShareRef?.open(reduceCode);
|
|
|
|
|
- }
|
|
|
|
|
- this.getLastOrder();
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //扫码助力
|
|
|
|
|
+ handleScanCode(data = {}) {
|
|
|
|
|
+ this.$refs.upsellQrcodeRef.open(data);
|
|
|
|
|
+ },
|
|
|
|
|
+ //查看活动规则
|
|
|
|
|
+ handleViewSellRules() {
|
|
|
|
|
+ this.$refs.upsellRulesRef.open();
|
|
|
|
|
+ },
|
|
|
//删除书籍
|
|
//删除书籍
|
|
|
handleDeleteBook(book) {
|
|
handleDeleteBook(book) {
|
|
|
this.deleteBook = book;
|
|
this.deleteBook = book;
|
|
@@ -404,16 +316,6 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- //扫码助力
|
|
|
|
|
- handleScanCode(data = {}) {
|
|
|
|
|
- this.$refs.upsellQrcodeRef.open(data);
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- //查看活动规则
|
|
|
|
|
- handleViewSellRules() {
|
|
|
|
|
- this.$refs.upsellRulesRef.open();
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
handleStart() {
|
|
handleStart() {
|
|
|
this.showPopup = true;
|
|
this.showPopup = true;
|
|
|
},
|
|
},
|
|
@@ -433,6 +335,9 @@ export default {
|
|
|
this.onNext();
|
|
this.onNext();
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ hasActivityEntryOptions(options = {}) {
|
|
|
|
|
+ return !!(options.scene || options.upsellCode || options.reduceCode);
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
//提交
|
|
//提交
|
|
|
onNext() {
|
|
onNext() {
|