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