diff --git a/App.vue b/App.vue
index 8600157..df138ce 100644
--- a/App.vue
+++ b/App.vue
@@ -1,5 +1,8 @@
+
\ No newline at end of file
diff --git a/components/detail-preview-popup/detail-preview-popup.vue b/components/detail-preview-popup/detail-preview-popup.vue
index 2e36608..0fc720a 100644
--- a/components/detail-preview-popup/detail-preview-popup.vue
+++ b/components/detail-preview-popup/detail-preview-popup.vue
@@ -103,10 +103,24 @@ export default {
this.innerProductType = this.productType;
this.innerProbability = this.probability;
this.innerExtraInfo = this.extraInfo;
+
+ // 监听全局预览事件
+ uni.$on('global-preview-event', this.handleGlobalEvent);
+ },
+ beforeDestroy() {
+ // 组件销毁前移除事件监听
+ uni.$off('global-preview-event', this.handleGlobalEvent);
},
methods: {
+ // 处理全局预览事件
+ handleGlobalEvent(options) {
+ console.log('收到全局预览事件', options);
+ this.setPreviewData(options);
+ },
+
// 设置预览数据并打开弹窗
setPreviewData(data) {
+ console.log('设置预览数据', data);
if (!data) return;
// 更新内部数据
@@ -123,17 +137,27 @@ export default {
// 打开弹窗
open() {
- console.log('尝试打开弹窗');
+ console.log('尝试打开弹窗', this.$refs.popup);
this.visible = true;
// 使用nextTick确保DOM更新后再打开弹窗
this.$nextTick(() => {
console.log('DOM已更新,准备打开弹窗');
if (this.$refs.popup) {
- this.$refs.popup.open();
- console.log('弹窗已打开');
+ // 小程序环境下需要额外延迟
+ setTimeout(() => {
+ this.$refs.popup.open();
+ console.log('弹窗已打开');
+ }, 50);
} else {
console.error('popup ref不存在,请检查组件是否正确挂载');
+ // 延迟后再次尝试
+ setTimeout(() => {
+ if (this.$refs.popup) {
+ this.$refs.popup.open();
+ console.log('弹窗已打开(延迟尝试)');
+ }
+ }, 300);
}
});
},
diff --git a/components/detail-preview-popup/index.js b/components/detail-preview-popup/index.js
new file mode 100644
index 0000000..4737d19
--- /dev/null
+++ b/components/detail-preview-popup/index.js
@@ -0,0 +1,73 @@
+import Vue from 'vue'
+
+/**
+ * 全局商品预览弹窗方法
+ * @param {Object} options 预览参数
+ * @param {String} options.title 商品标题
+ * @param {String} options.imgUrl 商品图片地址
+ * @param {String} options.tipTitle 商品标签
+ * @param {String} options.productType 商品类型
+ * @param {String} options.probability 商品概率
+ * @param {Array} options.extraInfo 额外信息
+ * @returns {Promise} 返回Promise
+ */
+const preview = function(options = {}) {
+ return new Promise((resolve) => {
+ // 获取当前页面
+ const pages = getCurrentPages();
+ const currentPage = pages[pages.length - 1];
+
+ // 尝试获取全局预览组件
+ let previewComponent = null;
+
+ // 尝试在App.vue中找到全局组件
+ try {
+ const app = getApp();
+ if (app.$vm && app.$vm.$children) {
+ // 在App.vue的子组件中查找
+ for (const child of app.$vm.$children) {
+ if (child.$options.name === 'DetailPreviewPopup') {
+ previewComponent = child;
+ break;
+ }
+ }
+ }
+ } catch (e) {
+ console.error('获取全局组件失败', e);
+ }
+
+ // 如果没找到全局组件,尝试在当前页面找
+ if (!previewComponent && currentPage && currentPage.$vm) {
+ try {
+ // 查找页面中的预览组件
+ const pageVm = currentPage.$vm;
+ for (const child of pageVm.$children) {
+ if (child.$options.name === 'DetailPreviewPopup') {
+ previewComponent = child;
+ break;
+ }
+ }
+ } catch (e) {
+ console.error('获取页面组件失败', e);
+ }
+ }
+
+ // 如果还是没找到组件,发送全局事件
+ if (!previewComponent) {
+ console.log('未找到组件实例,发送全局事件');
+ uni.$emit('global-preview-event', options);
+ setTimeout(() => resolve(), 500);
+ return;
+ }
+
+ // 使用找到的组件
+ console.log('找到预览组件,直接调用');
+ previewComponent.setPreviewData(options);
+ setTimeout(() => resolve(previewComponent), 300);
+ });
+};
+
+// 挂载到Vue原型上
+Vue.prototype.$preview = preview;
+
+export default preview;
\ No newline at end of file
diff --git a/package/index/leitai.vue b/package/index/leitai.vue
index 2972fe5..2157341 100644
--- a/package/index/leitai.vue
+++ b/package/index/leitai.vue
@@ -699,7 +699,7 @@ export default {
if (type == 1) {
url = "orderbuy";
- if (!uni.getStorageSync("_agree_buy_notice") && !fromNotice) {
+ if (this.$refs.buyNotice.getIsShow()&& !fromNotice) {
this.$refs.buyNotice.getRule(6);
return;
}
diff --git a/package/index/lian-ji.vue b/package/index/lian-ji.vue
index d630918..b99c89a 100644
--- a/package/index/lian-ji.vue
+++ b/package/index/lian-ji.vue
@@ -757,7 +757,7 @@
}
}
- if (!uni.getStorageSync('_agree_buy_notice') && !fromNotice) {
+ if (this.$refs.buyNotice.getIsShow() && !fromNotice) {
this.$refs.buyNotice.getRule(6)
return
}
diff --git a/pages/shouye/detail.vue b/pages/shouye/detail.vue
index 827c242..d8521db 100644
--- a/pages/shouye/detail.vue
+++ b/pages/shouye/detail.vue
@@ -3,62 +3,37 @@
-->
-
+
{{ $c.detailPageTitle((pageData && pageData.goods) || "") }}
-
@@ -327,11 +226,7 @@
-
+
@@ -351,11 +246,7 @@
-
+
@@ -372,11 +263,7 @@
-
+
@@ -389,11 +276,7 @@
-
+
@@ -409,10 +292,7 @@
-
+
确认支付
{{
pageData.goods.type == 5
@@ -423,16 +303,9 @@
-
-
-
+
+
+
@@ -446,35 +319,21 @@
{{ item.goodslist_title }}
-
+
-
+
去发货
-
+
继续抽
@@ -488,7 +347,6 @@
-
@@ -614,16 +472,17 @@ export default {
methods: {
previewDetail(item) {
console.log(item);
- // 使用新的setPreviewData方法而不是直接修改props
- if (this.$refs.localPreviewPopup) {
- this.$refs.localPreviewPopup.setPreviewData({
- title: item.title,
- imgUrl: item.imgurl,
- tipTitle: item.shang_info ? item.shang_info.title : '',
- productType: this.optData.type_text,
- probability: item.pro
- });
- }
+
+ // 使用全局方法调用预览弹窗
+ this.$preview({
+ title: item.title,
+ imgUrl: item.imgurl,
+ tipTitle: item.shang_info ? item.shang_info.title : '',
+ productType: this.optData.type_text,
+ probability: item.pro
+ }).then(() => {
+ console.log('预览弹窗打开成功');
+ });
},
resetSec() {
@@ -717,7 +576,7 @@ export default {
if (type == 1) {
url = "orderbuy";
- if (!uni.getStorageSync("_agree_buy_notice") && !fromNotice) {
+ if (this.$refs.buyNotice.getIsShow() && !fromNotice) {
this.$refs.buyNotice.getRule(6);
return;
}
@@ -735,7 +594,6 @@ export default {
use_money_is: this.useMoney ? 1 : 2,
use_integral_is: this.useIntegral ? 1 : 2,
coupon_id: (this.couponData && this.couponData.id) || "",
- // ad_id: uni.getStorageSync('_ad_id')
};
if (this.pageData.goods.type == 5) {
@@ -978,7 +836,7 @@ export default {
z-index: 100;
height: 44px;
- > view {
+ >view {
// font-family: YouSheBiaoTiHei;
font-weight: 400;
font-size: 50rpx;
@@ -1025,26 +883,26 @@ export default {
bottom: 390rpx;
z-index: 2;
- > image:nth-of-type(1) {
+ >image:nth-of-type(1) {
width: 46rpx;
height: 46rpx;
border: 2rpx solid #ffffff;
border-radius: 50rpx;
}
- > image:nth-of-type(2) {
+ >image:nth-of-type(2) {
width: 144rpx;
height: 68rpx;
}
- > view:nth-of-type(1) {
+ >view:nth-of-type(1) {
width: 140rpx;
font-weight: 400;
font-size: 28rpx;
color: #ffffff;
}
- > view:nth-of-type(2) {
+ >view:nth-of-type(2) {
font-weight: 400;
font-size: 24rpx;
color: #ffffff;
@@ -1060,13 +918,13 @@ export default {
transform: translateX(-50%);
bottom: 78rpx;
- > text:nth-child(2n + 1) {
+ >text:nth-child(2n + 1) {
font-weight: 400;
font-size: 16rpx;
color: #333333;
}
- > text:nth-child(2) {
+ >text:nth-child(2) {
font-weight: 700;
font-size: 24rpx;
color: #333333;
@@ -1088,7 +946,7 @@ export default {
bottom: 0;
z-index: 1;
- > image {
+ >image {
width: 100%;
height: 100%;
}
@@ -1103,7 +961,7 @@ export default {
bottom: 0;
z-index: 1;
- > image {
+ >image {
width: 100%;
height: 100%;
}
@@ -1117,7 +975,7 @@ export default {
right: 160rpx;
bottom: 0;
- > image {
+ >image {
width: 100%;
height: 100%;
}
@@ -1131,7 +989,7 @@ export default {
right: 0;
bottom: 0;
- > image {
+ >image {
width: 100%;
height: 100%;
}
@@ -1147,8 +1005,8 @@ export default {
padding: 24rpx 30rpx;
width: 750rpx;
- > view:nth-child(2n + 1) {
- > view:nth-child(1) {
+ >view:nth-child(2n + 1) {
+ >view:nth-child(1) {
width: 74rpx;
height: 56rpx;
background: #f5f5f5;
@@ -1156,7 +1014,7 @@ export default {
// border: 2rpx solid #000000;
}
- > view:nth-child(2) {
+ >view:nth-child(2) {
margin-top: 8rpx;
font-weight: 400;
font-size: 20rpx;
@@ -1165,29 +1023,29 @@ export default {
}
}
- > view:nth-child(2) {
+ >view:nth-child(2) {
width: 420rpx;
- > view:nth-child(1) {
+ >view:nth-child(1) {
width: 420rpx;
height: 14rpx;
border-radius: 40rpx;
- > text {
+ >text {
height: 14rpx;
border-radius: 40rpx;
background: #cdf022;
}
}
- > view:nth-child(2) {
+ >view:nth-child(2) {
padding: 14rpx 30rpx 0;
font-weight: 400;
font-size: 24rpx;
color: #999999;
- > view {
- > text {
+ >view {
+ >text {
font-family: YouSheBiaoTiHei;
font-weight: 400;
font-size: 36rpx;
@@ -1277,7 +1135,7 @@ export default {
background: rgba(0, 0, 0, 0.6);
border-radius: 24rpx;
- > image {
+ >image {
width: 86rpx;
height: 156rpx;
}
@@ -1354,7 +1212,7 @@ export default {
height: 68rpx;
position: relative;
- > view {
+ >view {
white-space: nowrap;
font-family: YouSheBiaoTiHei;
font-weight: 400;
@@ -1486,8 +1344,7 @@ export default {
color: #333333;
}
- .hang1 {
- }
+ .hang1 {}
.type {
font-size: 20rpx;
@@ -1630,11 +1487,11 @@ export default {
font-weight: 500;
color: #cdef27;
- > text:nth-child(1) {
+ >text:nth-child(1) {
font-size: 28rpx;
}
- > text:nth-child(2) {
+ >text:nth-child(2) {
font-size: 36rpx;
}
}
@@ -1678,7 +1535,7 @@ export default {
background: #d8d8d8;
border-radius: 16rpx 16rpx 0rpx 0rpx;
- > image {
+ >image {
width: 180rpx;
height: 180rpx;
border-radius: 16rpx 16rpx 0rpx 0rpx;
@@ -1691,8 +1548,7 @@ export default {
z-index: 2;
width: 68rpx;
height: 32rpx;
- background: url($imgurl + "common/chouLabel.png") no-repeat 0 0 /
- 100% 100%;
+ background: url($imgurl + "common/chouLabel.png") no-repeat 0 0 / 100% 100%;
font-weight: 400;
font-size: 14rpx;
color: #ffffff;
@@ -1743,11 +1599,11 @@ export default {
font-size: 24rpx;
}
- > view:nth-child(1) {
+ >view:nth-child(1) {
color: #333333;
}
- > view:nth-child(2) {
+ >view:nth-child(2) {
color: #333333;
}
}
diff --git a/pages/shouye/detail_wuxian.vue b/pages/shouye/detail_wuxian.vue
index b6b7388..fa61a74 100644
--- a/pages/shouye/detail_wuxian.vue
+++ b/pages/shouye/detail_wuxian.vue
@@ -853,7 +853,7 @@
if (type == 1) {
url = 'infinite_orderbuy'
- if (!uni.getStorageSync('_agree_buy_notice') && !fromNotice) {
+ if (this.$refs.buyNotice.getIsShow() && !fromNotice) {
this.$refs.buyNotice.getRule(6)
return
}