This commit is contained in:
2024-03-29 14:55:40 +08:00
parent 91af869899
commit 51c708f9fa
10 changed files with 133 additions and 56 deletions

View File

@@ -20,7 +20,7 @@
<grid-view type='masonry' :cross-axis-count='2'>
<view v-for='(item, index) in goodsList' :key='index' class='goods-item'
@click.stop='goPath(`/pages/mall/subs/goods/detail?goodsId=${item.goodsId}`)'>
<image class='goods-image' :src='item.images' />
<image class='goods-image' :src='item.images' />
<text class='goods-name'>{{ item.goodsName }}</text>
<text class='goods-price'>¥{{ item.price }}</text>
<image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart(item)' />
@@ -55,8 +55,7 @@ onLoad(() => {
});
const fetchCategoryList = async () => {
const list = await getCategoryList();
categoryList.value.push(list);
categoryList.value = await getCategoryList();
await changeCategory(0);
};
@@ -80,8 +79,17 @@ const fetchGoodsList = async () => {
};
const randomImageHeight = () => {
// return Math.random() * 100 + 'rpx';
return '300rpx';
const height = getRandomFloatInRange(1, 2) * 200 + 'rpx';
console.log('--------->>>', height);
return height;
};
const getRandomIntegerInRange = (a: number, b: number) => {
return Math.floor(Math.random() * (b - a + 1)) + a;
};
const getRandomFloatInRange = (a: number, b: number) => {
return Math.random() * (b - a) + a;
};
const addShoppingCart = (goodsBean: GoodsBean) => {
@@ -184,7 +192,7 @@ const addShoppingCart = (goodsBean: GoodsBean) => {
.goods-image {
border-radius: 10rpx;
width: 100%;
max-height: 200rpx;
max-height: 300rpx;
}
.goods-name {

View File

@@ -104,6 +104,7 @@ import { assetsUrl } from '@/utils/assets';
import PaymentDialog from '@/components/payment-dialog.vue';
import CouponDialog from '@/pages/mall/subs/components/coupon-dialog.vue';
import { goPath } from '@/utils';
import { orderCreate } from '@/api/goods';
const couponDialogRef = ref();
const paymentDialogRef = ref();
@@ -119,8 +120,36 @@ const showCouponDialog = () => {
couponDialogRef.value.show();
};
const payment = () => {
const payment = async () => {
const params = {
'discount': 0,
'freePrice': 0,
'reducePrice': 0,
'totalPrice': 0,
'integral': 0,
'allowIntegral': 0,
'produceIntegralNumber': 0,
'remark': 'string',
'orderGoods': [
{
'goodsId': 'string',
'goodsCode': 'string',
'goodsNum': 0,
'stockId': 'string',
'originPrice': 0,
'consumePrice': 0,
'discount': 0,
'discountOriginPrice': 0,
'produceIntegral': 0,
'priceModify': [
0
],
'offset': 0
}
]
};
const result = await orderCreate(params);
};
</script>