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)
this.getSimilarProducts(d.itemid, d.son_category);
// /
this.fetchTaoWord();
}
}
});
},
fetchTaoWord() {
fetchTaoWord(callback) {
if (!this.product.taobaoId) return;
uni.showLoading({ title: '加载中...', mask: true });
uni.request({
url: 'https://api.cmspro.haodanku.com/taobao/getTaoWord',
url: 'https://v2.api.haodanku.com/ratesurl',
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
data: {
domain: 'cms.baimajiayuanjiankang.com',
itemid: this.product.taobaoId,
activityid: this.product.activityId || '',
title: this.product.title || '',
relation_id: '2887601176',
cid: 'YsWZ21tx'
get_taoword: 1,
pid: 'mm_284380119_1881450385_111415850448',
tb_name: 'michuan2018',
relation_id: '2864040832',
apikey: '5417B681C5EA'
},
success: (res) => {
uni.hideLoading();
const body = res.data || {};
if (body.code === 200 && body.data) {
this.product.taoCode = body.data.tao_code || '';
this.product.spreadUrl = body.data.spread_url || '';
this.product.couponUrl = body.data.coupon_url || '';
if (body.code === 1 && body.data) {
this.product.taoCode = body.data.taoword || '';
this.product.couponUrl = body.data.coupon_click_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();
},
copyTaoWord() {
if (!this.product.taoCode) {
uni.showToast({ title: '口令加载中,请稍候', icon: 'none' });
return;
}
uni.setClipboardData({
data: this.product.taoCode,
success: () => {
uni.showToast({ title: '淘口令已复制', icon: 'success' });
},
fail: () => {
uni.showToast({ title: '复制失败', icon: 'none' });
this.fetchTaoWord(() => {
if (!this.product.taoCode) {
uni.showToast({ title: '暂无口令', icon: 'none' });
return;
}
uni.setClipboardData({
data: this.product.taoCode,
success: () => {
uni.showToast({ title: '淘口令已复制', icon: 'success' });
},
fail: () => {
uni.showToast({ title: '复制失败', icon: 'none' });
}
});
});
},
goBuy() {
const url = this.product.couponUrl;
if (!url) {
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' });
this.fetchTaoWord(() => {
const url = this.product.couponUrl;
if (!url) {
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' });
}
});
// #endif
});
// #endif
},
handleScroll(e) {
const scrollTop = e.detail.scrollTop;