This commit is contained in:
1173117610@qq.com 2026-05-14 13:40:17 +08:00
parent da8d437cbb
commit bdc742934a
1 changed files with 48 additions and 37 deletions

View File

@ -363,35 +363,42 @@
// (使 itemid son_category) // (使 itemid son_category)
this.getSimilarProducts(d.itemid, d.son_category); this.getSimilarProducts(d.itemid, d.son_category);
// /
this.fetchTaoWord();
} }
} }
}); });
}, },
fetchTaoWord() { fetchTaoWord(callback) {
if (!this.product.taobaoId) return; if (!this.product.taobaoId) return;
uni.showLoading({ title: '加载中...', mask: true });
uni.request({ uni.request({
url: 'https://api.cmspro.haodanku.com/taobao/getTaoWord', url: 'https://v2.api.haodanku.com/ratesurl',
method: 'POST', method: 'POST',
header: { header: {
'content-type': 'application/x-www-form-urlencoded' 'content-type': 'application/x-www-form-urlencoded'
}, },
data: { data: {
domain: 'cms.baimajiayuanjiankang.com',
itemid: this.product.taobaoId, itemid: this.product.taobaoId,
activityid: this.product.activityId || '',
title: this.product.title || '', title: this.product.title || '',
relation_id: '2887601176', get_taoword: 1,
cid: 'YsWZ21tx' pid: 'mm_284380119_1881450385_111415850448',
tb_name: 'michuan2018',
relation_id: '2864040832',
apikey: '5417B681C5EA'
}, },
success: (res) => { success: (res) => {
uni.hideLoading();
const body = res.data || {}; const body = res.data || {};
if (body.code === 200 && body.data) { if (body.code === 1 && body.data) {
this.product.taoCode = body.data.tao_code || ''; this.product.taoCode = body.data.taoword || '';
this.product.spreadUrl = body.data.spread_url || ''; this.product.couponUrl = body.data.coupon_click_url || '';
this.product.couponUrl = body.data.coupon_url || ''; if (callback) callback();
} else {
uni.showToast({ title: body.msg || '获取失败', icon: 'none' });
} }
},
fail: () => {
uni.hideLoading();
uni.showToast({ title: '网络错误', icon: 'none' });
} }
}); });
}, },
@ -420,37 +427,41 @@
uni.navigateBack(); uni.navigateBack();
}, },
copyTaoWord() { copyTaoWord() {
if (!this.product.taoCode) { this.fetchTaoWord(() => {
uni.showToast({ title: '口令加载中,请稍候', icon: 'none' }); if (!this.product.taoCode) {
return; uni.showToast({ title: '暂无口令', icon: 'none' });
} return;
uni.setClipboardData({
data: this.product.taoCode,
success: () => {
uni.showToast({ title: '淘口令已复制', icon: 'success' });
},
fail: () => {
uni.showToast({ title: '复制失败', icon: 'none' });
} }
uni.setClipboardData({
data: this.product.taoCode,
success: () => {
uni.showToast({ title: '淘口令已复制', icon: 'success' });
},
fail: () => {
uni.showToast({ title: '复制失败', icon: 'none' });
}
});
}); });
}, },
goBuy() { goBuy() {
const url = this.product.couponUrl; this.fetchTaoWord(() => {
if (!url) { const url = this.product.couponUrl;
uni.showToast({ title: '链接加载中,请稍候', icon: 'none' }); if (!url) {
return; uni.showToast({ title: '暂无领券链接', icon: 'none' });
} return;
// #ifdef H5
window.location.href = url;
// #endif
// #ifndef H5
uni.setClipboardData({
data: url,
success: () => {
uni.showToast({ title: '链接已复制,请到浏览器打开', icon: 'none' });
} }
// #ifdef H5
window.location.href = url;
// #endif
// #ifndef H5
uni.setClipboardData({
data: url,
success: () => {
uni.showToast({ title: '链接已复制,请到浏览器打开', icon: 'none' });
}
});
// #endif
}); });
// #endif
}, },
handleScroll(e) { handleScroll(e) {
const scrollTop = e.detail.scrollTop; const scrollTop = e.detail.scrollTop;