分类 存
This commit is contained in:
parent
239191fbe3
commit
cc8d4be07f
BIN
public/img/nocart.png
Normal file
BIN
public/img/nocart.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 827 B |
71
src/App.vue
71
src/App.vue
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<router-view v-slot="{ Component, route }">
|
<router-view v-slot="{ Component, route }">
|
||||||
<keep-alive :include="cacheList">
|
<keep-alive :include="cacheList">
|
||||||
<component :is="Component" :key="route.name" />
|
<component :is="Component" :key="route.name" @updateShare="updateShare" />
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
</router-view>
|
</router-view>
|
||||||
</template>
|
</template>
|
||||||
@ -15,17 +15,32 @@ export default {
|
|||||||
return routes.filter(r => r.meta.cache).map(r => r.name)
|
return routes.filter(r => r.meta.cache).map(r => r.name)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
wechatShareInfo: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
$route(to, from) {
|
$route(to, from) {
|
||||||
const title = to.meta.title || ''
|
const title = to.meta.title || ''
|
||||||
this.updateTitle(title)
|
this.updateTitle(title)
|
||||||
|
this.updateShare(undefined, undefined, undefined)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.init()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
init() {
|
||||||
|
this.$post('/v1/client/HWxinfoClient/share', { url: location.href }).then(data => {
|
||||||
|
this.wechatShareInfo = data
|
||||||
|
}).finally(() => {
|
||||||
|
this.updateShare()
|
||||||
|
})
|
||||||
|
},
|
||||||
updateTitle(title) {
|
updateTitle(title) {
|
||||||
document.title = title
|
document.title = title
|
||||||
if (this.$isWechat()) {
|
if (this.$isWechat()) {
|
||||||
// 微信安卓需要用 iframe 触发标题更新
|
|
||||||
const iframe = document.createElement('iframe')
|
const iframe = document.createElement('iframe')
|
||||||
iframe.style.display = 'none'
|
iframe.style.display = 'none'
|
||||||
iframe.src = 'https://www.baidu.com/favicon.ico?' + Date.now()
|
iframe.src = 'https://www.baidu.com/favicon.ico?' + Date.now()
|
||||||
@ -39,32 +54,34 @@ export default {
|
|||||||
},
|
},
|
||||||
updateShare(title, desc, imgUrl) {
|
updateShare(title, desc, imgUrl) {
|
||||||
if (wx && this.$isWechat()) {
|
if (wx && this.$isWechat()) {
|
||||||
// this.$CommonAPI.Post('GetJSSDKConfig', location.href).then(data => {
|
this.$post('/v1/client/HWxinfoClient/share', { url: location.href }).then(data => {
|
||||||
let shareinfo = {
|
let shareinfo = {
|
||||||
title: title || '泰古润' || this.wechatShareInfo.ShareTitle,
|
title: title || this.wechatShareInfo.ShareTitle || '泰古润',
|
||||||
desc: desc || '汇聚平凡梦想,共创美好未来' || this.wechatShareInfo.ShareContent,
|
desc: desc || this.wechatShareInfo.ShareContent || '汇聚平凡梦想,共创美好未来',
|
||||||
imgUrl: this.$file(imgUrl || this.wechatShareInfo.ShareLogo),
|
imgUrl: this.$file(imgUrl || this.wechatShareInfo.ShareLogo || '/img/logo.png'),
|
||||||
link: this.$getShareLink(),
|
link: this.$getShareLink(),
|
||||||
};
|
};
|
||||||
if (this.$isWechatMini())
|
if (this.$isWechatMini())
|
||||||
wx.miniProgram.postMessage({ data: { share: shareinfo } });
|
wx.miniProgram.postMessage({ data: { share: shareinfo } });
|
||||||
data.jsApiList.push('wx-open-launch-weapp');
|
data.jsApiList.push('wx-open-launch-weapp');
|
||||||
data.openTagList = ['wx-open-launch-weapp'];
|
data.openTagList = ['wx-open-launch-weapp'];
|
||||||
wx.config(data);
|
wx.config({
|
||||||
wx.ready(() => {
|
debug: false,
|
||||||
wx.updateAppMessageShareData(shareinfo);
|
appId: data.appid,
|
||||||
wx.updateTimelineShareData(shareinfo);
|
timestamp: data.timestamp,
|
||||||
if (location.hash == '#/Weapp') {
|
nonceStr: data.noncestr,
|
||||||
document.addEventListener('WeixinOpenTagsError', function (e) {
|
signature: data.signature,
|
||||||
alert(e.detail.errMsg); // 无法使用开放标签的错误原因,需回退兼容。仅无法使用开放标签,JS-SDK其他功能不受影响
|
jsApiList: data.jsApiList,
|
||||||
});
|
openTagList: data.openTagList
|
||||||
}
|
});
|
||||||
|
wx.ready(() => {
|
||||||
|
wx.updateAppMessageShareData(shareinfo);
|
||||||
|
wx.updateTimelineShareData(shareinfo);
|
||||||
|
});
|
||||||
|
wx.error((e) => {
|
||||||
|
console.error('wx.error', e);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
wx.error((e) => {
|
|
||||||
if (location.hash == '#/Weapp')
|
|
||||||
alert(JSON.stringify(e));
|
|
||||||
});
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -178,7 +178,7 @@ const routes = [
|
|||||||
path: '/TradeList',
|
path: '/TradeList',
|
||||||
name: 'TradeList',
|
name: 'TradeList',
|
||||||
component: () => import('./views/Trade/TradeList.vue'),
|
component: () => import('./views/Trade/TradeList.vue'),
|
||||||
meta: { title: '订单列表' }
|
meta: { title: '订单列表', cache: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/Pay',
|
path: '/Pay',
|
||||||
|
|||||||
@ -780,7 +780,7 @@ img {
|
|||||||
.van-tab {
|
.van-tab {
|
||||||
height: 10.13vw;
|
height: 10.13vw;
|
||||||
background-color: #ededed;
|
background-color: #ededed;
|
||||||
font-size: 4vw;
|
font-size: 3.67vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.van-tab--active {
|
.van-tab--active {
|
||||||
@ -2239,6 +2239,12 @@ img {
|
|||||||
color: #303030;
|
color: #303030;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
|
.overhide {
|
||||||
|
width: 70vw;
|
||||||
|
overflow: hidden;
|
||||||
|
.text-hide(1);
|
||||||
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
width: 3.73vw;
|
width: 3.73vw;
|
||||||
height: 2.93vw;
|
height: 2.93vw;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<BasePage :title="data.name || '产品详情'" :back="back">
|
<BasePage :title="data.name || '产品详情'">
|
||||||
<div class="goodsdetails">
|
<div class="goodsdetails">
|
||||||
<div class="t">
|
<div class="t">
|
||||||
<img :src="$file(data.img)" alt="">
|
<img :src="$file(data.img)" alt="">
|
||||||
@ -62,7 +62,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="spec_box" @click="showArea = true">
|
<div class="spec_box" @click="showArea = true">
|
||||||
<img src="/img/spec.png" alt="">
|
<img style="height: 3.47vw;" src="/img/nocart.png" alt="">
|
||||||
<span>不支持发货区域:</span>
|
<span>不支持发货区域:</span>
|
||||||
<span
|
<span
|
||||||
style="color: #999999;max-width: 43vw;width: 43vw;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
style="color: #999999;max-width: 43vw;width: 43vw;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||||
@ -73,7 +73,7 @@
|
|||||||
|
|
||||||
<div class="spec_box" @click="showSpecs = true">
|
<div class="spec_box" @click="showSpecs = true">
|
||||||
<img src="/img/spec.png" alt="">
|
<img src="/img/spec.png" alt="">
|
||||||
<span>{{ selectedSku }}</span>
|
<span class="overhide">{{ selectedSku }}</span>
|
||||||
<van-icon class="r" name="arrow"></van-icon>
|
<van-icon class="r" name="arrow"></van-icon>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -263,16 +263,25 @@ export default {
|
|||||||
if (mainSku) {
|
if (mainSku) {
|
||||||
this.tempSku = { ...mainSku, Qty: 1 };
|
this.tempSku = { ...mainSku, Qty: 1 };
|
||||||
this.selectedSku = "已选:" + mainSku.skuname;
|
this.selectedSku = "已选:" + mainSku.skuname;
|
||||||
// 根据skuname设置默认选中规格,拆分规格名匹配对应分类
|
// 根据skuname设置默认选中规格,skuname用逗号分隔
|
||||||
const skuParts = mainSku.skuname.split('-').filter(Boolean);
|
const skuParts = mainSku.skuname.split(',').filter(Boolean);
|
||||||
this.specSelect.forEach((spec, specIndex) => {
|
this.specSelect.forEach((spec) => {
|
||||||
|
const specIndex = this.specSelect.findIndex(s => s.name === spec.name);
|
||||||
|
// 优先从skuname匹配,匹配不到则默认选中第一个子选项
|
||||||
if (skuParts[specIndex]) {
|
if (skuParts[specIndex]) {
|
||||||
const child = spec.children?.find(c => skuParts[specIndex].includes(c.name));
|
const child = spec.children?.find(c => skuParts[specIndex].includes(c.name));
|
||||||
if (child) {
|
if (child) {
|
||||||
this.selectedSpecs[spec.name] = child.name;
|
this.selectedSpecs[spec.name] = child.name;
|
||||||
|
} else if (spec.children?.length > 0) {
|
||||||
|
this.selectedSpecs[spec.name] = spec.children[0].name;
|
||||||
}
|
}
|
||||||
|
} else if (spec.children?.length > 0) {
|
||||||
|
// skuname没有对应分类时,默认选中第一个
|
||||||
|
this.selectedSpecs[spec.name] = spec.children[0].name;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// 调用refreshSku确保tempSku包含正确的skuid等信息
|
||||||
|
this.refreshSku();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectSpec(specName, specValue) {
|
selectSpec(specName, specValue) {
|
||||||
@ -284,9 +293,10 @@ export default {
|
|||||||
if (specKeys.length === 0) return;
|
if (specKeys.length === 0) return;
|
||||||
|
|
||||||
let matchedSku = this.specCombinations.find(combo => {
|
let matchedSku = this.specCombinations.find(combo => {
|
||||||
const skuParts = combo.skuname.split('-').filter(Boolean);
|
const skuParts = combo.skuname.split(',').filter(Boolean);
|
||||||
return specKeys.every((key, specIndex) => {
|
return specKeys.every((key) => {
|
||||||
const selectedVal = this.selectedSpecs[key];
|
const selectedVal = this.selectedSpecs[key];
|
||||||
|
const specIndex = this.specSelect.findIndex(s => s.name === key);
|
||||||
return skuParts[specIndex]?.includes(selectedVal);
|
return skuParts[specIndex]?.includes(selectedVal);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -331,7 +341,7 @@ export default {
|
|||||||
this.$showFailToast("该规格库存不足,无法购买");
|
this.$showFailToast("该规格库存不足,无法购买");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$navigate(`/TradeConfirm?id=${this.data.id}&skuid=${this.tempSku.skuid}&buynums=${this.tempSku.Qty}`);
|
this.$navigate(`/TradeConfirm?id=${this.data.id}&skuname=${encodeURIComponent(this.tempSku.skuname)}&buynums=${this.tempSku.Qty}`);
|
||||||
},
|
},
|
||||||
beforeShare() {
|
beforeShare() {
|
||||||
this.showShare = true;
|
this.showShare = true;
|
||||||
|
|||||||
@ -191,13 +191,13 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
loadProduct() {
|
loadProduct() {
|
||||||
const id = this.$route.query.id;
|
const id = this.$route.query.id;
|
||||||
const skuid = this.$route.query.skuid;
|
const skuname = decodeURIComponent(this.$route.query.skuname || '');
|
||||||
this.$get(`/v1/client/EProsClient/${id}`).then(res => {
|
this.$get(`/v1/client/EProsClient/${id}`).then(res => {
|
||||||
const data = res.data;
|
const data = res.data;
|
||||||
// 从规格组合中找到匹配的SKU
|
// 从规格组合中找到匹配的SKU
|
||||||
let sku = null;
|
let sku = null;
|
||||||
if (skuid && data.specCombinations) {
|
if (skuname && data.specCombinations) {
|
||||||
sku = data.specCombinations.find(s => String(s.skuid) === String(skuid));
|
sku = data.specCombinations.find(s => s.skuname === skuname);
|
||||||
}
|
}
|
||||||
if (!sku && data.specCombinations?.length) {
|
if (!sku && data.specCombinations?.length) {
|
||||||
sku = data.specCombinations[0];
|
sku = data.specCombinations[0];
|
||||||
@ -209,7 +209,7 @@ export default {
|
|||||||
saleprice: sku?.saleprice || data.saleprice,
|
saleprice: sku?.saleprice || data.saleprice,
|
||||||
originalprice: sku?.originalprice || data.originalprice,
|
originalprice: sku?.originalprice || data.originalprice,
|
||||||
skuid: sku?.skuid,
|
skuid: sku?.skuid,
|
||||||
skuname: sku?.skuname || '默认规格',
|
skuname: sku?.skuname || skuname || '默认规格',
|
||||||
buynums: parseInt(this.$route.query.buynums) || 1,
|
buynums: parseInt(this.$route.query.buynums) || 1,
|
||||||
typename: data.typename || '商品',
|
typename: data.typename || '商品',
|
||||||
expressprice: data.expressprice || 0,
|
expressprice: data.expressprice || 0,
|
||||||
|
|||||||
@ -132,7 +132,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
back() {
|
back() {
|
||||||
this.$navigate('/TradeList');
|
window.history.back();
|
||||||
},
|
},
|
||||||
async loadData() {
|
async loadData() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -130,7 +130,11 @@ export default {
|
|||||||
{
|
{
|
||||||
"value": 4,
|
"value": 4,
|
||||||
"label": "买单订单"
|
"label": "买单订单"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"value": 5,
|
||||||
|
"label": "积分订单"
|
||||||
|
},
|
||||||
],
|
],
|
||||||
_initializing: true,
|
_initializing: true,
|
||||||
logisticsVisible: false,
|
logisticsVisible: false,
|
||||||
@ -222,7 +226,7 @@ export default {
|
|||||||
this.$showSuccessToast('确认收货成功')
|
this.$showSuccessToast('确认收货成功')
|
||||||
this.$refs.baseList?.refresh()
|
this.$refs.baseList?.refresh()
|
||||||
})
|
})
|
||||||
.catch(err => this.$showFailToast(err.message || '操作失败'))
|
.catch()
|
||||||
},
|
},
|
||||||
|
|
||||||
// 取消订单
|
// 取消订单
|
||||||
@ -233,7 +237,7 @@ export default {
|
|||||||
this.$showSuccessToast('取消订单成功')
|
this.$showSuccessToast('取消订单成功')
|
||||||
this.$refs.baseList?.refresh()
|
this.$refs.baseList?.refresh()
|
||||||
})
|
})
|
||||||
.catch(err => this.$showFailToast(err.message || '取消失败'))
|
.catch()
|
||||||
},
|
},
|
||||||
|
|
||||||
// 显示物流信息
|
// 显示物流信息
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user