修复问题
parent
9cf068a1bb
commit
82674b1104
6
.env
6
.env
|
|
@ -2,10 +2,10 @@
|
||||||
SHOPRO_VERSION = v1.8.3
|
SHOPRO_VERSION = v1.8.3
|
||||||
|
|
||||||
# 后端接口 - 正式环境(通过 process.env.NODE_ENV 非 developmentSHOPRO_BASE_URL = http://api-dashboard.yudao.iocoder.cn
|
# 后端接口 - 正式环境(通过 process.env.NODE_ENV 非 developmentSHOPRO_BASE_URL = http://api-dashboard.yudao.iocoder.cn
|
||||||
SHOPRO_BASE_URL = http://100.80.97.101:48080
|
SHOPRO_BASE_URL = http://192.168.10.207:48080
|
||||||
|
|
||||||
# 后端接口 - 测试环境(通过 process.env.NODE_ENV = developmentSHOPRO_DEV_BASE_URL = http://saas.yibeidl.cn
|
# 后端接口 - 测试环境(通过 process.env.NODE_ENV = developmentSHOPRO_DEV_BASE_URL = http://saas.yibeidl.cn
|
||||||
SHOPRO_DEV_BASE_URL = http://100.80.97.101:48080
|
SHOPRO_DEV_BASE_URL = http://192.168.10.207:48080
|
||||||
### SHOPRO_DEV_BASE_URL = http://yunai.natapp1.cc
|
### SHOPRO_DEV_BASE_URL = http://yunai.natapp1.cc
|
||||||
|
|
||||||
# 后端接口前缀(一般不建议调整)
|
# 后端接口前缀(一般不建议调整)
|
||||||
|
|
@ -18,7 +18,7 @@ SHOPRO_WEBSOCKET_PATH = /infra/ws
|
||||||
SHOPRO_DEV_PORT = 48080
|
SHOPRO_DEV_PORT = 48080
|
||||||
|
|
||||||
# 客户端静态资源地址 空=默认使用服务端指定的CDN资源地址前缀 | local=本地 | http(s)://xxx.xxx=自定义静态资源地址前缀SHOPRO_STATIC_URL = https://file.sheepjs.com
|
# 客户端静态资源地址 空=默认使用服务端指定的CDN资源地址前缀 | local=本地 | http(s)://xxx.xxx=自定义静态资源地址前缀SHOPRO_STATIC_URL = https://file.sheepjs.com
|
||||||
SHOPRO_STATIC_URL = http://100.80.97.101
|
SHOPRO_STATIC_URL = http://192.168.10.207
|
||||||
|
|
||||||
# 是否开启直播 1 开启直播 | 0 关闭直播 (小程序官方后台未审核开通直播权限时请勿开启)
|
# 是否开启直播 1 开启直播 | 0 关闭直播 (小程序官方后台未审核开通直播权限时请勿开启)
|
||||||
SHOPRO_MPLIVE_ON = 0
|
SHOPRO_MPLIVE_ON = 0
|
||||||
|
|
|
||||||
|
|
@ -136,13 +136,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 2.1 情况三一:未支付,且轮询次数小于三次,则继续轮询
|
// 2.1 情况三一:未支付,且轮询次数小于三次,则继续轮询
|
||||||
if (state.counter < 3 && state.result === 'unpaid') {
|
if (state.counter < 10 && state.result === 'unpaid') {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getOrderInfo(id);
|
getOrderInfo(id);
|
||||||
}, 1500);
|
}, 1500);
|
||||||
}
|
}
|
||||||
// 2.2 情况二:超过三次检测才判断为支付失败
|
// 2.2 情况二:超过三次检测才判断为支付失败
|
||||||
if (state.counter >= 3) {
|
if (state.counter >= 10) {
|
||||||
state.result = 'failed';
|
state.result = 'failed';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,69 +3,73 @@
|
||||||
<su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose>
|
<su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose>
|
||||||
<view class="model-box">
|
<view class="model-box">
|
||||||
<view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠</view>
|
<view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠</view>
|
||||||
<view class="titleLi">促销</view>
|
<view v-if="state.activityMap.length">
|
||||||
<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
|
<view class="titleLi">促销</view>
|
||||||
<view class="actBox">
|
<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
|
||||||
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
<view class="actBox">
|
||||||
<view class="model-content-tag ss-flex ss-row-center">满减</view>
|
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
||||||
<view class="model-content-title">
|
<view class="model-content-tag ss-flex ss-row-center">满减</view>
|
||||||
<view class="contBu">
|
<view class="model-content-title">
|
||||||
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.reduc"
|
<view class="contBu">
|
||||||
:key="index">满{{fen2yuan(item.discountPrice)}}元减{{fen2yuan(item.limit)}}元;</text>
|
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.reduc"
|
||||||
</view>
|
:key="index">满{{fen2yuan(item.discountPrice)}}元减{{fen2yuan(item.limit)}}元;</text>
|
||||||
<view class="ss-m-b-24 cotBu-txt">
|
</view>
|
||||||
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
<view class="ss-m-b-24 cotBu-txt">
|
||||||
|
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<text class="cicon-forward" />
|
||||||
</view>
|
</view>
|
||||||
<text class="cicon-forward" />
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
<view class="actBox">
|
||||||
<view class="actBox">
|
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
||||||
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
<view class="model-content-tag ss-flex ss-row-center">包邮</view>
|
||||||
<view class="model-content-tag ss-flex ss-row-center">包邮</view>
|
<view class="model-content-title">
|
||||||
<view class="model-content-title">
|
<view class="contBu">
|
||||||
<view class="contBu">
|
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.ship"
|
||||||
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.ship"
|
:key="index" v-show="item.bull">满{{fen2yuan(item.discountPrice)}}元包邮;</text>
|
||||||
:key="index" v-show="item.bull">满{{fen2yuan(item.discountPrice)}}元包邮;</text>
|
</view>
|
||||||
</view>
|
<view class="ss-m-b-24 cotBu-txt">
|
||||||
<view class="ss-m-b-24 cotBu-txt">
|
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
||||||
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<text class="cicon-forward" />
|
||||||
</view>
|
</view>
|
||||||
<text class="cicon-forward" />
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
<view class="actBox">
|
||||||
<view class="actBox">
|
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
||||||
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
<view class="model-content-tag ss-flex ss-row-center">送积分</view>
|
||||||
<view class="model-content-tag ss-flex ss-row-center">送积分</view>
|
<view class="model-content-title">
|
||||||
<view class="model-content-title">
|
<view class="contBu">
|
||||||
<view class="contBu">
|
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.scor"
|
||||||
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.scor"
|
:key="index"
|
||||||
:key="index" v-show="item.bull">满{{fen2yuan(item.discountPrice)}}元送{{item.value}}积分;</text>
|
v-show="item.bull">满{{fen2yuan(item.discountPrice)}}元送{{item.value}}积分;</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="ss-m-b-24 cotBu-txt">
|
<view class="ss-m-b-24 cotBu-txt">
|
||||||
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<text class="cicon-forward" />
|
||||||
</view>
|
</view>
|
||||||
<text class="cicon-forward" />
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
<view class="actBox">
|
||||||
<view class="actBox">
|
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
||||||
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.activityInfo[0])">
|
<view class="model-content-tag ss-flex ss-row-center">送优惠券</view>
|
||||||
<view class="model-content-tag ss-flex ss-row-center">送优惠券</view>
|
<view class="model-content-title">
|
||||||
<view class="model-content-title">
|
<view class="contBu">
|
||||||
<view class="contBu">
|
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.cou"
|
||||||
<text v-for="(item,index) in state.activityMap[state.activityInfo[0]?.id]?.cou"
|
:key="index"
|
||||||
:key="index" v-show="item.bull">满{{fen2yuan(item.discountPrice)}}元送{{item.value}}张优惠券;</text>
|
v-show="item.bull">满{{fen2yuan(item.discountPrice)}}元送{{item.value}}张优惠券;</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="ss-m-b-24 cotBu-txt">
|
<view class="ss-m-b-24 cotBu-txt">
|
||||||
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
{{formatDateRange(state.activityInfo[0]?.startTime,state.activityInfo[0]?.endTime)}}
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<text class="cicon-forward" />
|
||||||
</view>
|
</view>
|
||||||
<text class="cicon-forward" />
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</scroll-view>
|
||||||
</scroll-view>
|
</view>
|
||||||
<view class="titleLi">可领优惠券</view>
|
<view class="titleLi">可领优惠券</view>
|
||||||
<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
|
<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
|
||||||
<view class="actBox" v-for="item in state.couponInfo" :key="item.id">
|
<view class="actBox" v-for="item in state.couponInfo" :key="item.id">
|
||||||
|
|
@ -83,7 +87,7 @@
|
||||||
{{item.name}}
|
{{item.name}}
|
||||||
</view>
|
</view>
|
||||||
<view class="ss-m-b-24 cotBu-txt">
|
<view class="ss-m-b-24 cotBu-txt">
|
||||||
{{item.validityType==1?formatDateRange(item.startTime,item.endTime) : '领取后'+item.fixedStartTerm+'-'+item.fixedEndTerm +'天可用'}}
|
{{item.validityType==1?formatDateRange(item.validStartTime,item.validEndTime) : '领取后'+item.fixedStartTerm+'-'+item.fixedEndTerm +'天可用'}}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="coupon" @click.stop="getBuy(item.id)" v-if="item.canTake">
|
<view class="coupon" @click.stop="getBuy(item.id)" v-if="item.canTake">
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,18 @@
|
||||||
:style="[{ color: titleColor, width: titleWidth ? titleWidth + 'rpx' : '' }]">
|
:style="[{ color: titleColor, width: titleWidth ? titleWidth + 'rpx' : '' }]">
|
||||||
{{ data.title || data.name }}
|
{{ data.title || data.name }}
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 这里是新加的会员价和限时优惠 -->
|
||||||
|
<view class="iconBox" v-if="data.discountPrice || data.vipPrice || data.reward">
|
||||||
|
<view class="card" v-if="iconShow">{{iconShow}}</view>
|
||||||
|
<view class="card2" v-if="data.reward">{{data.reward.rewardActivity}}</view>
|
||||||
|
</view>
|
||||||
|
<!-- 这里是新加的会员价和限时优惠结束 -->
|
||||||
<view v-if="goodsFields.price?.show" class="xs-goods-price font-OPPOSANS"
|
<view v-if="goodsFields.price?.show" class="xs-goods-price font-OPPOSANS"
|
||||||
:style="[{ color: goodsFields.price.color }]">
|
:style="[{ color: goodsFields.price.color }]">
|
||||||
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
|
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
|
||||||
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}
|
<text v-if="iconShow=='限时优惠'">{{fen2yuan(data.discountPrice)}}</text>
|
||||||
|
<text v-else-if="iconShow=='会员价'">{{fen2yuan(data.vipPrice)}}</text>
|
||||||
|
<text v-else>{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -34,10 +42,18 @@
|
||||||
class="sm-goods-title ss-line-1 ss-m-b-16">
|
class="sm-goods-title ss-line-1 ss-m-b-16">
|
||||||
{{ data.title || data.name }}
|
{{ data.title || data.name }}
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 这里是新加的会员价和限时优惠 -->
|
||||||
|
<view class="iconBox" v-if="data.discountPrice || data.vipPrice || data.reward">
|
||||||
|
<view class="card" v-if="iconShow">{{iconShow}}</view>
|
||||||
|
<view class="card2" v-if="data.reward">{{data.reward.rewardActivity}}</view>
|
||||||
|
</view>
|
||||||
|
<!-- 这里是新加的会员价和限时优惠结束 -->
|
||||||
<view v-if="goodsFields.price?.show" class="sm-goods-price font-OPPOSANS"
|
<view v-if="goodsFields.price?.show" class="sm-goods-price font-OPPOSANS"
|
||||||
:style="[{ color: goodsFields.price.color }]">
|
:style="[{ color: goodsFields.price.color }]">
|
||||||
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
|
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
|
||||||
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}
|
<text v-if="iconShow=='限时优惠'">{{fen2yuan(data.discountPrice)}}</text>
|
||||||
|
<text v-else-if="iconShow=='会员价'">{{fen2yuan(data.vipPrice)}}</text>
|
||||||
|
<text v-else>{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -131,6 +147,12 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</slot>
|
</slot>
|
||||||
|
<!-- 这里是新加的会员价和限时优惠 -->
|
||||||
|
<view class="iconBox" v-if="data.discountPrice || data.vipPrice || data.reward">
|
||||||
|
<view class="card" v-if="iconShow">{{iconShow}}</view>
|
||||||
|
<view class="card2" v-if="data.reward">{{data.reward.rewardActivity}}</view>
|
||||||
|
</view>
|
||||||
|
<!-- 这里是新加的会员价和限时优惠结束 -->
|
||||||
<view class="ss-flex ss-col-bottom ss-m-t-10">
|
<view class="ss-flex ss-col-bottom ss-m-t-10">
|
||||||
<view v-if="goodsFields.price?.show"
|
<view v-if="goodsFields.price?.show"
|
||||||
class="lg-goods-price ss-m-r-12 ss-flex ss-col-bottom font-OPPOSANS"
|
class="lg-goods-price ss-m-r-12 ss-flex ss-col-bottom font-OPPOSANS"
|
||||||
|
|
@ -143,7 +165,9 @@
|
||||||
(data.original_price > 0 || data.marketPrice > 0)
|
(data.original_price > 0 || data.marketPrice > 0)
|
||||||
" class="goods-origin-price ss-flex ss-col-bottom font-OPPOSANS" :style="[{ color: originPriceColor }]">
|
" class="goods-origin-price ss-flex ss-col-bottom font-OPPOSANS" :style="[{ color: originPriceColor }]">
|
||||||
<text class="price-unit ss-font-20">{{ priceUnit }}</text>
|
<text class="price-unit ss-font-20">{{ priceUnit }}</text>
|
||||||
<view class="ss-m-l-8">{{ fen2yuan(data.marketPrice) }}</view>
|
<text v-if="iconShow=='限时优惠'">{{fen2yuan(data.discountPrice)}}</text>
|
||||||
|
<text v-else-if="iconShow=='会员价'">{{fen2yuan(data.vipPrice)}}</text>
|
||||||
|
<text v-else>{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="ss-m-t-8 ss-flex ss-col-center ss-flex-wrap">
|
<view class="ss-m-t-8 ss-flex ss-col-center ss-flex-wrap">
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<!-- 规格弹窗 -->
|
<!-- 规格弹窗 -->
|
||||||
<su-popup :show="show" round="10" @close="emits('close')">
|
<su-popup :show="show" round="10" @close="emits('close')">
|
||||||
<!-- SKU 信息 -->
|
<!-- SKU 信息 -->
|
||||||
<view class="ss-modal-box bg-white ss-flex-col">
|
<view class="ss-modal-box bg-white ss-flex-col">
|
||||||
<view class="modal-header ss-flex ss-col-center">
|
<view class="modal-header ss-flex ss-col-center">
|
||||||
<view class="header-left ss-m-r-30">
|
<view class="header-left ss-m-r-30">
|
||||||
|
|
@ -13,8 +13,10 @@
|
||||||
<view class="ss-flex">
|
<view class="ss-flex">
|
||||||
<view class="price-text">
|
<view class="price-text">
|
||||||
{{ fen2yuan( state.selectedSku.price || goodsInfo.price) }}
|
{{ fen2yuan( state.selectedSku.price || goodsInfo.price) }}
|
||||||
<text class="iconBox" v-if="state.selectedSku.type == 6">会员价</text>
|
<text v-if="state.selectedSku.type == 6"><text class="iconBox">会员价</text><text
|
||||||
<text class="iconBox" v-if="state.selectedSku.type == 4">限时优惠</text>
|
class="origin-price-text">{{fen2yuan(state.selectedSku.oldPrice)}}</text></text>
|
||||||
|
<text v-if="state.selectedSku.type == 4"><text class="iconBox">限时优惠</text><text
|
||||||
|
class="origin-price-text">{{fen2yuan(state.selectedSku.oldPrice)}}</text></text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="stock-text ss-m-l-20">
|
<view class="stock-text ss-m-l-20">
|
||||||
|
|
@ -24,7 +26,7 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 属性选择 -->
|
<!-- 属性选择 -->
|
||||||
<view class="modal-content ss-flex-1">
|
<view class="modal-content ss-flex-1">
|
||||||
<scroll-view scroll-y="true" class="modal-content-scroll" @touchmove.stop>
|
<scroll-view scroll-y="true" class="modal-content-scroll" @touchmove.stop>
|
||||||
<view class="sku-item ss-m-b-20" v-for="property in propertyList" :key="property.id">
|
<view class="sku-item ss-m-b-20" v-for="property in propertyList" :key="property.id">
|
||||||
|
|
@ -45,12 +47,12 @@
|
||||||
<view class="buy-num-box ss-flex ss-col-center ss-row-between ss-m-b-40">
|
<view class="buy-num-box ss-flex ss-col-center ss-row-between ss-m-b-40">
|
||||||
<view class="label-text">购买数量</view>
|
<view class="label-text">购买数量</view>
|
||||||
<su-number-box :min="1" :max="state.selectedSku.stock" :step="1"
|
<su-number-box :min="1" :max="state.selectedSku.stock" :step="1"
|
||||||
v-model="state.selectedSku.goods_num" @change="onNumberChange($event)" />
|
v-model="state.selectedSku.goods_num" @change="onNumberChange($event)" />
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 操作区 -->
|
<!-- 操作区 -->
|
||||||
<view class="modal-footer border-top">
|
<view class="modal-footer border-top">
|
||||||
<view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center">
|
<view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center">
|
||||||
<button class="ss-reset-button add-btn ui-Shadow-Main" @tap="onAddCart">加入购物车</button>
|
<button class="ss-reset-button add-btn ui-Shadow-Main" @tap="onAddCart">加入购物车</button>
|
||||||
|
|
@ -62,9 +64,17 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive, watch } from 'vue';
|
import {
|
||||||
|
computed,
|
||||||
|
reactive,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import { formatStock, convertProductPropertyList, fen2yuan } from '@/sheep/hooks/useGoods';
|
import {
|
||||||
|
formatStock,
|
||||||
|
convertProductPropertyList,
|
||||||
|
fen2yuan
|
||||||
|
} from '@/sheep/hooks/useGoods';
|
||||||
|
|
||||||
const emits = defineEmits(['change', 'addCart', 'buy', 'close']);
|
const emits = defineEmits(['change', 'addCart', 'buy', 'close']);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|
@ -84,13 +94,13 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const propertyList = convertProductPropertyList(props.goodsInfo.skus);
|
const propertyList = convertProductPropertyList(props.goodsInfo.skus);
|
||||||
console.log('传递来的sku信息',props.goodsInfo.skus)
|
console.log('传递来的sku信息', props.goodsInfo.skus)
|
||||||
// SKU 列表
|
// SKU 列表
|
||||||
const skuList = computed(() => {
|
const skuList = computed(() => {
|
||||||
let skuPrices = props.goodsInfo.skus;
|
let skuPrices = props.goodsInfo.skus;
|
||||||
for (let price of skuPrices) {
|
for (let price of skuPrices) {
|
||||||
price.value_id_array = price.properties.map((item) => item.valueId)
|
price.value_id_array = price.properties.map((item) => item.valueId)
|
||||||
}
|
}
|
||||||
return skuPrices;
|
return skuPrices;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -98,50 +108,50 @@
|
||||||
() => state.selectedSku,
|
() => state.selectedSku,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
emits('change', newVal);
|
emits('change', newVal);
|
||||||
console.log('选中的sku信息',state.selectedSku)
|
console.log('选中的sku信息', state.selectedSku)
|
||||||
}, {
|
}, {
|
||||||
immediate: true, // 立即执行
|
immediate: true, // 立即执行
|
||||||
deep: true, // 深度监听
|
deep: true, // 深度监听
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// 输入框改变数量
|
// 输入框改变数量
|
||||||
function onNumberChange(e) {
|
function onNumberChange(e) {
|
||||||
if (e === 0) return;
|
if (e === 0) return;
|
||||||
if (state.selectedSku.goods_num === e) return;
|
if (state.selectedSku.goods_num === e) return;
|
||||||
state.selectedSku.goods_num = e;
|
state.selectedSku.goods_num = e;
|
||||||
}
|
|
||||||
|
|
||||||
// 加入购物车
|
|
||||||
function onAddCart() {
|
|
||||||
if (state.selectedSku.id <= 0) {
|
|
||||||
sheep.$helper.toast('请选择规格');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (state.selectedSku.stock <= 0) {
|
|
||||||
sheep.$helper.toast('库存不足');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
emits('addCart', state.selectedSku);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 立即购买
|
// 加入购物车
|
||||||
|
function onAddCart() {
|
||||||
|
if (state.selectedSku.id <= 0) {
|
||||||
|
sheep.$helper.toast('请选择规格');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (state.selectedSku.stock <= 0) {
|
||||||
|
sheep.$helper.toast('库存不足');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emits('addCart', state.selectedSku);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 立即购买
|
||||||
function onBuy() {
|
function onBuy() {
|
||||||
if (state.selectedSku.id <= 0) {
|
if (state.selectedSku.id <= 0) {
|
||||||
sheep.$helper.toast('请选择规格');
|
sheep.$helper.toast('请选择规格');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state.selectedSku.stock <= 0) {
|
if (state.selectedSku.stock <= 0) {
|
||||||
sheep.$helper.toast('库存不足');
|
sheep.$helper.toast('库存不足');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emits('buy', state.selectedSku);
|
emits('buy', state.selectedSku);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 改变禁用状态:计算每个 property 属性值的按钮,是否禁用
|
// 改变禁用状态:计算每个 property 属性值的按钮,是否禁用
|
||||||
function changeDisabled(isChecked = false, propertyId = 0, valueId = 0) {
|
function changeDisabled(isChecked = false, propertyId = 0, valueId = 0) {
|
||||||
let newSkus = []; // 所有可以选择的 sku 数组
|
let newSkus = []; // 所有可以选择的 sku 数组
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
// 情况一:选中 property
|
// 情况一:选中 property
|
||||||
// 获得当前点击选中 property 的、所有可用 SKU
|
// 获得当前点击选中 property 的、所有可用 SKU
|
||||||
|
|
@ -174,18 +184,18 @@
|
||||||
// 循环去除当前已选择的 value 属性值 id
|
// 循环去除当前已选择的 value 属性值 id
|
||||||
state.currentPropertyArray.forEach((currentPropertyId) => {
|
state.currentPropertyArray.forEach((currentPropertyId) => {
|
||||||
if (currentPropertyId.toString() !== '') {
|
if (currentPropertyId.toString() !== '') {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
// currentPropertyId 为空是反选 填充的
|
||||||
|
let index = noChooseValueIds.indexOf(currentPropertyId);
|
||||||
|
if (index >= 0) {
|
||||||
|
// currentPropertyId 存在于 noChooseValueIds
|
||||||
|
noChooseValueIds.splice(index, 1);
|
||||||
}
|
}
|
||||||
// currentPropertyId 为空是反选 填充的
|
|
||||||
let index = noChooseValueIds.indexOf(currentPropertyId);
|
|
||||||
if (index >= 0) {
|
|
||||||
// currentPropertyId 存在于 noChooseValueIds
|
|
||||||
noChooseValueIds.splice(index, 1);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当前已选择的 property 数组
|
// 当前已选择的 property 数组
|
||||||
let choosePropertyIds = [];
|
let choosePropertyIds = [];
|
||||||
if (!isChecked) {
|
if (!isChecked) {
|
||||||
// 当前已选择的 property
|
// 当前已选择的 property
|
||||||
|
|
@ -200,15 +210,16 @@
|
||||||
choosePropertyIds = [propertyId];
|
choosePropertyIds = [propertyId];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let propertyIndex in propertyList) {
|
for (let propertyIndex in propertyList) {
|
||||||
// 当前点击的 property、或者取消选择时候,已选中的 property 不进行处理
|
// 当前点击的 property、或者取消选择时候,已选中的 property 不进行处理
|
||||||
if (choosePropertyIds.indexOf(propertyList[propertyIndex]['id']) >= 0) {
|
if (choosePropertyIds.indexOf(propertyList[propertyIndex]['id']) >= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 如果当前 property id 不存在于有库存的 SKU 中,则禁用
|
// 如果当前 property id 不存在于有库存的 SKU 中,则禁用
|
||||||
for (let valueIndex in propertyList[propertyIndex]['values']) {
|
for (let valueIndex in propertyList[propertyIndex]['values']) {
|
||||||
propertyList[propertyIndex]['values'][valueIndex]['disabled'] =
|
propertyList[propertyIndex]['values'][valueIndex]['disabled'] =
|
||||||
noChooseValueIds.indexOf(propertyList[propertyIndex]['values'][valueIndex]['id']) < 0; // true 禁用 or false 不禁用
|
noChooseValueIds.indexOf(propertyList[propertyIndex]['values'][valueIndex]['id']) <
|
||||||
|
0; // true 禁用 or false 不禁用
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -220,8 +231,8 @@
|
||||||
if (sku.stock <= 0) {
|
if (sku.stock <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let isOk = true;
|
let isOk = true;
|
||||||
state.currentPropertyArray.forEach((propertyId) => {
|
state.currentPropertyArray.forEach((propertyId) => {
|
||||||
// propertyId 不为空,并且,这个 条 sku 没有被选中,则排除
|
// propertyId 不为空,并且,这个 条 sku 没有被选中,则排除
|
||||||
if (propertyId.toString() !== '' && sku.value_id_array.indexOf(propertyId) < 0) {
|
if (propertyId.toString() !== '' && sku.value_id_array.indexOf(propertyId) < 0) {
|
||||||
isOk = false;
|
isOk = false;
|
||||||
|
|
@ -247,7 +258,7 @@
|
||||||
state.currentPropertyArray[propertyId] = valueId;
|
state.currentPropertyArray[propertyId] = valueId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选中的 property 大类
|
// 选中的 property 大类
|
||||||
let choosePropertyId = [];
|
let choosePropertyId = [];
|
||||||
state.currentPropertyArray.forEach((currentPropertyId) => {
|
state.currentPropertyArray.forEach((currentPropertyId) => {
|
||||||
if (currentPropertyId !== '') {
|
if (currentPropertyId !== '') {
|
||||||
|
|
@ -272,7 +283,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
changeDisabled(false);
|
changeDisabled(false);
|
||||||
// TODO 芋艿:待讨论的优化点:1)单规格,要不要默认选中;2)默认要不要选中第一个规格
|
// TODO 芋艿:待讨论的优化点:1)单规格,要不要默认选中;2)默认要不要选中第一个规格
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
@ -406,6 +417,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.iconBox {
|
.iconBox {
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
height: fit-content;
|
height: fit-content;
|
||||||
|
|
@ -415,4 +427,16 @@
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
margin-left: 5rpx;
|
margin-left: 5rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.origin-price-text {
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
text-decoration: line-through;
|
||||||
|
color: $gray-c;
|
||||||
|
font-family: OPPOSANS;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '¥';
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -447,6 +447,7 @@ export function handListPrice(array,array2) {
|
||||||
// 遍历 array 数组并更新 price 和 type
|
// 遍历 array 数组并更新 price 和 type
|
||||||
array.forEach(item => {
|
array.forEach(item => {
|
||||||
if (array2Map[item.id]) {
|
if (array2Map[item.id]) {
|
||||||
|
item.oldPrice = item.price
|
||||||
// 如果在 array2Map 中找到了对应的 skuId(即 id)
|
// 如果在 array2Map 中找到了对应的 skuId(即 id)
|
||||||
item.price = array2Map[item.id].price;
|
item.price = array2Map[item.id].price;
|
||||||
item.type = array2Map[item.id].type;
|
item.type = array2Map[item.id].type;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue