增加库存显示

This commit is contained in:
2023-10-27 14:50:28 +08:00
parent 2f788956c6
commit 6cd9823bd8
5 changed files with 276 additions and 412 deletions

View File

@@ -23,25 +23,26 @@
<view class="title">{{ mer_info.name }}</view>
<view class="bom">
<view class="left">
<view>{{ mer_info.address || "暂无商家地址" }}</view>
<view>{{ mer_info.address || '暂无商家地址' }}</view>
<view class="sub"
>距你{{
>距你{{
calculateDistance(
userLocalNum.t,
userLocalNum.l,
Number(mer_info.lat),
Number(mer_info.lon)
)
}}</view
}}
</view
>
</view>
<view class="right">
<view @click="clickMap">
<Locationg3 color="red" size="25" />
<Locationg3 color="red" size="25"/>
<view>导航</view>
</view>
<view @click="clickPhone">
<Find color="red" size="25" />
<Find color="red" size="25"/>
<view>电话</view>
</view>
</view>
@@ -62,30 +63,36 @@
@click="clickTab"
>
<nut-tab-pane
v-for="(item, index) in class_list"
v-for="(item, index) in class_list as any[]"
:title="item.name"
:pane-key="index"
>
<view v-if="good_list.length > 0">
<view
class="list"
v-for="(item, index) in (good_list as any)"
v-for="(item, index) in good_list as any[]"
:key="index"
>
<view class="item">
<img :src="item.cover" />
<img :src="item.cover"/>
<view class="right">
<view class="name">{{ item.name }}</view>
<view class="stock">
库存剩余:{{ item.stock }}
</view>
<view class="bom">
<view class="price"
><text style="font-size: 15px">{{
item.number
}}</text>
>
<text style="font-size: 15px">{{
item.number
}}
</text>
{{
mer_info.bType === 1
? "元"
: "积分"
}}</view
? '元'
: '积分'
}}
</view
>
<nut-button
size="mini"
@@ -97,7 +104,8 @@
1
)
"
>去购买</nut-button
>去购买
</nut-button
>
<nut-button
size="mini"
@@ -109,12 +117,14 @@
2
)
"
>去兑换</nut-button
>去兑换
</nut-button
>
</view>
</view>
</view>
</view></view
</view>
</view
>
<nut-empty v-else description="该分类暂无商品"></nut-empty>
</nut-tab-pane>
@@ -128,41 +138,41 @@
import Taro from '@tarojs/taro'
import {Find, Locationg3} from '@nutui/icons-vue-taro'
import {ref} from 'vue'
import {calculateDistance} from '../../../utils'
import {getGoodList, getMerCategory} from '../../../api/goods'
import {calculateDistance} from '@/utils'
import {getGoodList, getMerCategory} from '@/api/goods'
const swiperList = ref([]);
const swiperList = ref([])
const mer_info = ref<any>({});
const mer_info = ref<any>({})
const value = ref("0");
const value = ref('0')
const userLocalNum = ref({
l: 0,
t: 0,
});
t: 0
})
Taro.useLoad(() => {
Taro.getLocation({
type: "wgs84",
type: 'wgs84',
success: (res) => {
userLocalNum.value.l = res.longitude;
userLocalNum.value.t = res.latitude;
},
});
mer_info.value = Taro.getStorageSync("mer_info");
userLocalNum.value.l = res.longitude
userLocalNum.value.t = res.latitude
}
})
mer_info.value = Taro.getStorageSync('mer_info')
Taro.setNavigationBarTitle({
title: mer_info.value.name,
});
swiperList.value = mer_info.value.img.split(",");
get_class_list();
});
title: mer_info.value.name
})
swiperList.value = mer_info.value.img.split(',')
get_class_list()
})
const clickPhone = () => {
Taro.makePhoneCall({
phoneNumber: mer_info.value.mobile
});
};
})
}
const clickMap = () => {
Taro.openLocation({
@@ -170,50 +180,50 @@ const clickMap = () => {
address: mer_info.value.address,
latitude: Number(mer_info.value.lat),
longitude: Number(mer_info.value.lon),
scale: 18,
});
};
scale: 18
})
}
const class_list = ref<
Array<{
ID?: number;
name?: string;
}>
>([]);
>([])
const get_class_list = async () => {
const res = await getMerCategory({
Bid: mer_info.value.bid,
});
class_list.value = res.data.data || [];
get_good_list(class_list.value[0].ID as number);
};
Bid: mer_info.value.bid
})
class_list.value = res.data.data || []
await get_good_list(class_list.value[0].ID as number)
}
const clickTab = (val: any) => {
get_good_list(class_list.value[val.paneKey].ID as number);
};
get_good_list(class_list.value[val.paneKey].ID as number)
}
const good_list = ref([]);
const good_list = ref([])
const get_good_list = async (id: number) => {
Taro.showLoading({
title: "加载中",
mask: true,
});
title: '加载中',
mask: true
})
const res = await getGoodList({
bid: mer_info.value.bid,
BType: mer_info.value.bType,
class_id: id,
status: 1,
state: 1,
});
good_list.value = res.data.data || [];
Taro.hideLoading();
};
state: 1
})
good_list.value = res.data.data || []
Taro.hideLoading()
}
const toGoodDetails = (id: number, type: number) => {
Taro.navigateTo({
url: `/pages/goods/goods_detail/index?gid=${id}&type=${type}`,
});
};
url: `/pages/goods/goods_detail/index?gid=${id}&type=${type}`
})
}
</script>
<style lang="scss">
@@ -237,6 +247,7 @@ const toGoodDetails = (id: number, type: number) => {
.left {
width: 80%;
.sub {
color: #999;
}
@@ -254,6 +265,7 @@ const toGoodDetails = (id: number, type: number) => {
.good-class {
margin-top: 10px;
.nut-tabs {
height: 100vh;
border-top: #fff 10px solid;
@@ -264,9 +276,10 @@ const toGoodDetails = (id: number, type: number) => {
.item {
display: flex;
margin-bottom: 10px;
img {
width: 140px;
height: 140px;
height: 150px;
border-radius: 10px;
}
@@ -278,6 +291,11 @@ const toGoodDetails = (id: number, type: number) => {
justify-content: center;
// text-align: right;
.stock {
margin-top: 10px;
color: #8f8f8f;
}
.name {
// height: 20px;
font-size: 28px;
@@ -292,7 +310,8 @@ const toGoodDetails = (id: number, type: number) => {
display: flex;
justify-content: space-between;
align-items: flex-end;
margin-top: 10px;
//margin-top: 10px;
.price {
font-size: 20px;
font-weight: bold;