fix: 🐛 修改商品数量为0时候下单报错问题,修改店铺楼层开关不生效问题

master
lemon橪 2022-12-26 16:28:14 +08:00
parent 9127d61a59
commit 979a1e6b14
2 changed files with 103 additions and 70 deletions

View File

@ -71,7 +71,7 @@
<!-- 正常逻辑 循环出sku --> <!-- 正常逻辑 循环出sku -->
<view <view
v-if="!parentOrder" v-if="!parentOrder"
:class="{ active: spec_val.value == currentSelceted[specIndex] }" :class="{ active: spec_val.value == currentSelected[specIndex] }"
class="skus-view-item" class="skus-view-item"
v-for="(spec_val, spec_index) in spec.values" v-for="(spec_val, spec_index) in spec.values"
:key="spec_index" :key="spec_index"
@ -83,7 +83,7 @@
<!-- 拼团购买仅筛选出当前拼团类型商品 --> <!-- 拼团购买仅筛选出当前拼团类型商品 -->
<view <view
v-if="parentOrder && spec_val.skuId == goodsDetail.id" v-if="parentOrder && spec_val.skuId == goodsDetail.id"
:class="{ active: spec_val.value == currentSelceted[specIndex] }" :class="{ active: spec_val.value == currentSelected[specIndex] }"
class="skus-view-item" class="skus-view-item"
v-for="(spec_val, spec_index) in spec.values" v-for="(spec_val, spec_index) in spec.values"
:key="spec_index" :key="spec_index"
@ -97,7 +97,7 @@
<view class="goods-skus-number flex flex-a-c flex-j-sb"> <view class="goods-skus-number flex flex-a-c flex-j-sb">
<view class="view-class-title">数量</view> <view class="view-class-title">数量</view>
<u-input class="view-class-input" input-align="right" v-model="num" type="number" @blur="numCheck()" @change="numChange()" /> <u-input class="view-class-input" input-align="right" v-model="num" type="number" @blur="numCheck()" />
</view> </view>
</scroll-view> </scroll-view>
<!-- 按钮 --> <!-- 按钮 -->
@ -125,7 +125,7 @@ export default {
buyType: '', // buyType: '', //
parentOrder: '', // - parentOrder: '', // -
formatList: [], formatList: [],
currentSelceted: [], currentSelected: [],
skuList: '', skuList: '',
isClose: false // isClose: false //
}; };
@ -182,7 +182,10 @@ export default {
}, },
watch: { watch: {
num(val) { num(val) {
val == 0 ? this.num = 1 : ''
if (val) { if (val) {
// //
if (val > this.goodsDetail.quantity) { if (val > this.goodsDetail.quantity) {
this.$nextTick(function() { this.$nextTick(function() {
@ -223,20 +226,15 @@ export default {
closeMask() { closeMask() {
this.$emit('closeBuy', false); this.$emit('closeBuy', false);
}, },
numChange() {
if (this.num > this.goodsDetail.quantity) {
alert(1);
this.num = this.goodsDetail.quantity;
}
},
/**点击规格 */ /**点击规格 */
handleClickSpec(val, index, specValue) { handleClickSpec(val, index, specValue) {
this.currentSelceted[index] = specValue.value; this.currentSelected[index] = specValue.value;
let selectedSkuId = this.goodsSpec.find(i => { let selectedSkuId = this.goodsSpec.find(i => {
let matched = true; let matched = true;
let specValues = i.specValues.filter(j => j.specName !== 'images'); let specValues = i.specValues.filter(j => j.specName !== 'images');
for (let n = 0; n < specValues.length; n++) { for (let n = 0; n < specValues.length; n++) {
if (specValues[n].specValue !== this.currentSelceted[n]) { if (specValues[n].specValue !== this.currentSelected[n]) {
matched = false; matched = false;
return; return;
} }
@ -246,7 +244,7 @@ export default {
} }
}); });
if (selectedSkuId?.skuId) { if (selectedSkuId?.skuId) {
this.$set(this.currentSelceted, index, specValue.value); this.$set(this.currentSelected, index, specValue.value);
this.selectSkuList = { this.selectSkuList = {
spec: { spec: {
specName: val.name, specName: val.name,
@ -381,7 +379,7 @@ export default {
item.specValues item.specValues
.filter(i => i.specName !== 'images') .filter(i => i.specName !== 'images')
.forEach((value, _index) => { .forEach((value, _index) => {
this.currentSelceted[_index] = value.specValue; this.currentSelected[_index] = value.specValue;
this.selectName = value.specValue; this.selectName = value.specValue;

View File

@ -79,6 +79,34 @@
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<!-- 基础店铺模式 -->
<div v-if="basePageData">
<u-tabs :list="tabs" :active-color="mainColor" :is-scroll="false" :current="current" @change="changeTab"></u-tabs>
<div class="content" v-if="current == 0">
<u-empty style='margin-top:100rpx' v-if="goodsList.length == 0" class="empty" text='暂无商品信息'></u-empty>
<goodsTemplate v-else :res="goodsList" :storeName="false" />
</div>
<!-- 全部分类 -->
<div class="category" v-if="current == 1">
<div class="category-item" v-for="(item,index) in categoryList" :key="index">
<div class="flex" @click="getCategoryGoodsList(item)">
<div>{{item.labelName}}</div>
<div>
<u-icon color="#999" name="arrow-right"></u-icon>
</div>
</div>
<!-- 分类子级 -->
<div class="child-list" v-if="item.children && item.children.length!=0">
<div class="child" @click="getCategoryGoodsList(child)" :key='i' v-for="(child,i) in item.children">{{child.labelName}}
</div>
</div>
</div>
</div>
</div>
<!-- 楼层装修模式 -->
<div v-if="enablePageData">
<!-- uni 中不能使用 vue component 所以用if判断每个组件 --> <!-- uni 中不能使用 vue component 所以用if判断每个组件 -->
<div v-for="(item, index) in pageData.list" :key="index"> <div v-for="(item, index) in pageData.list" :key="index">
<!-- 搜索栏如果在楼层装修顶部则会自动浮动否则不浮动 --> <!-- 搜索栏如果在楼层装修顶部则会自动浮动否则不浮动 -->
@ -124,6 +152,7 @@
<!-- <integral v-if="item.type == 'integral'" :res="item.options" /> --> <!-- <integral v-if="item.type == 'integral'" :res="item.options" /> -->
<!-- <spike v-if="item.type == 'spike'" :res="item.options" /> --> <!-- <spike v-if="item.type == 'spike'" :res="item.options" /> -->
</div> </div>
</div>
<u-no-network></u-no-network> <u-no-network></u-no-network>
</div> </div>
</view> </view>
@ -147,7 +176,7 @@ import tpl_menu from "@/pages/tabbar/home/template/tpl_menu"; //五列菜单模
import tpl_search from "@/pages/tabbar/home/template/tpl_search"; // import tpl_search from "@/pages/tabbar/home/template/tpl_search"; //
import tpl_group from "@/pages/tabbar/home/template/tpl_group"; // import tpl_group from "@/pages/tabbar/home/template/tpl_group"; //
import tpl_goods from "@/pages/tabbar/home/template/tpl_goods"; // import tpl_goods from "@/pages/tabbar/home/template/tpl_goods"; //
import goodsTemplate from '@/components/m-goods-list/list'
import { getStoreBaseInfo, getStoreCategory } from "@/api/store.js"; import { getStoreBaseInfo, getStoreCategory } from "@/api/store.js";
import { import {
receiveCoupons, receiveCoupons,
@ -192,7 +221,7 @@ export default {
}, },
goodsParams: { goodsParams: {
pageNumber: 1, pageNumber: 1,
pageSize: 50, pageSize: 10,
storeId: "", storeId: "",
}, },
}; };
@ -214,6 +243,7 @@ export default {
flexOne: tpl_flex_one, flexOne: tpl_flex_one,
goods: tpl_goods, goods: tpl_goods,
group: tpl_group, group: tpl_group,
goodsTemplate
// spike: tpl_spike, // spike: tpl_spike,
// joinGroup: tpl_join_group, // joinGroup: tpl_join_group,
// integral: tpl_integral, // integral: tpl_integral,
@ -345,16 +375,21 @@ export default {
let res = await getStoreBaseInfo(this.storeId); let res = await getStoreBaseInfo(this.storeId);
if (res.data.success) { if (res.data.success) {
this.storeInfo = res.data.result; this.storeInfo = res.data.result;
//
this.initPageData();
//
//
this.getGoodsData();
// //
this.getCouponsData(); this.getCouponsData();
if(res.data.result.pageShow == '1'){
//
this.initPageData();
this.enablePageData = true;
}
else{
//
this.getGoodsData();
// //
this.getCategoryData(); this.getCategoryData();
this.basePageData = true;
}
} else { } else {
uni.reLaunch({ uni.reLaunch({
url: "/", url: "/",