6
0
Fork 0

select_product

hui.zhou
panliang 2023-02-10 11:46:12 +08:00
parent 61fddda672
commit f4d8058fce
4 changed files with 72 additions and 34 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<view class="rounded-xs box-show" @tap.stop="$u.route('/pages/product_details/index', { skuId: goods.id,showShrough:showShrough })"> <view class="rounded-xs box-show" @tap.stop="handleDetail(goods)">
<!-- <u-image width="100%" height="345rpx" :src="goods.cover" :lazy-load="true"></u-image> --> <!-- <u-image width="100%" height="345rpx" :src="goods.cover" :lazy-load="true"></u-image> -->
<cu-image :borderTopLeftRadius="24" :borderTopRightRadius="24" width="100%" height="345rpx" :src="`${goods.cover}?x-oss-process=image/resize,h_375,m_lfit`" :lazy-load="true"></cu-image> <cu-image :borderTopLeftRadius="24" :borderTopRightRadius="24" width="100%" height="345rpx" :src="`${goods.cover}?x-oss-process=image/resize,h_375,m_lfit`" :lazy-load="true"></cu-image>
<view class="px-base"> <view class="px-base">
@ -50,6 +50,10 @@ export default {
cart:{ cart:{
type:Boolean, type:Boolean,
default:false default:false
},
detail: {
type: Boolean | String,
default: true
} }
}, },
data() { data() {
@ -58,6 +62,18 @@ export default {
methods: { methods: {
onCart(){ onCart(){
this.$emit('cartClick',this.goods) this.$emit('cartClick',this.goods)
},
handleDetail(goods) {
if (this.detail === false) {
this.onCart()
return;
}
let url = '/pages/product_details/index'
let params = { skuId: goods.id, showShrough: this.showShrough }
if (this.detail !== true) {
url = this.detail
}
this.$u.route(url, params)
} }
}, },
}; };

View File

@ -21,41 +21,54 @@
</scroll-view> </scroll-view>
<scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box" @scroll="rightScroll"> <scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box" @scroll="rightScroll">
<view class="page-view"> <view class="page-view">
<view class="class-item" :id="'item' + index" v-for="(item, index) in tabbar" :key="index"> <block v-for="(item, index) in tabbar" :key="index">
<view class="item-title"> <view class="classSel" :id="'item' + index">
<text>{{ item.name }}</text> <view class="class-item" v-for="(item1, index1) in item.children" :key="index1">
</view> <view class="item-title">
<view class="item-container"> <text>{{ item1.name }}</text>
<view class="thumb-box" v-for="(item1, index1) in item.foods" :key="index1" @tap="$u.route('/pageB/select_product/search?category=20')"> </view>
<image class="item-menu-image" :src="item1.icon" mode=""></image> <!-- 广告位 -->
<view class="item-menu-name">{{ item1.name }}</view> <view class="my-20rpx shdow2 h-200rpx" v-if="item1.icon">
</view> <image class="w-full h-full rounded-15rpx " :src="item1.icon" mode="aspectFill"></image>
</view> </view>
</view> <view class="item-container">
</view> <view @click="navigateToList(item2.id)" class="thumb-box" v-for="(item2, index2) in item1.children" :key="index2">
<image v-if="item2.icon" class="item-menu-image" :src="item2.icon" mode=""></image>
<view class="item-menu-name">{{ item2.name }}</view>
</view>
</view>
</view>
</view>
</block>
</view>
</scroll-view> </scroll-view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import classifyData from './classify.data.js';
export default { export default {
data() { data() {
return { return {
mid: '',
scrollTop: 0, //tab scrollTop: 0, //tab
oldScrollTop: 0, oldScrollTop: 0,
current: 0, // current: 0, //
menuHeight: 0, // menuHeight: 0, //
menuItemHeight: 0, // item menuItemHeight: 0, // item
itemId: '', // scroll-viewid itemId: '', // scroll-viewid
tabbar: classifyData, tabbar: [],
menuItemPos: [], menuItemPos: [],
arr: [], arr: [],
scrollRightTop: 0, // scroll-view scrollRightTop: 0, // scroll-view
timer: null, // timer: null, //
}; };
}, },
onLoad() {}, onLoad(e) {
this.mid = e.mid
this.$api.get('/v1/product/categories').then(res => {
this.tabbar = res
})
},
onReady() { onReady() {
this.getMenuItemTop(); this.getMenuItemTop();
}, },
@ -176,6 +189,9 @@ export default {
} }
}, 10); }, 10);
}, },
navigateToList(cid) {
this.$u.route('/pageB/select_product/search', { mid: this.mid, cid: cid })
}
}, },
}; };
</script> </script>

View File

@ -41,12 +41,12 @@
<u-waterfall v-model="dataList" ref="uWaterfall"> <u-waterfall v-model="dataList" ref="uWaterfall">
<template v-slot:left="{ leftList }"> <template v-slot:left="{ leftList }">
<view v-for="(item, index) in leftList" :key="index" class="px-rowSm mb-base"> <view v-for="(item, index) in leftList" :key="index" class="px-rowSm mb-base">
<goods-item :goods="item" cart @cartClick="cartClick"></goods-item> <goods-item :goods="item" :detail="false" cart @cartClick="cartClick"></goods-item>
</view> </view>
</template> </template>
<template v-slot:right="{ rightList }"> <template v-slot:right="{ rightList }">
<view v-for="(item, index) in rightList" :key="index" class="px-rowSm mb-base"> <view v-for="(item, index) in rightList" :key="index" class="px-rowSm mb-base">
<goods-item :goods="item" cart @cartClick="cartClick"></goods-item> <goods-item :goods="item" :detail="false" cart @cartClick="cartClick"></goods-item>
</view> </view>
</template> </template>
</u-waterfall> </u-waterfall>
@ -58,7 +58,7 @@
:key="productId" :key="productId"
:loading="loading" :loading="loading"
:specs="specs" :specs="specs"
:sku="detail" :sku="sku"
v-model="show" v-model="show"
:quota-used="number" :quota-used="number"
:show-cart="popupType == 1 || popupType == 0" :show-cart="popupType == 1 || popupType == 0"
@ -66,6 +66,7 @@
:show-confirm="popupType == 3" :show-confirm="popupType == 3"
@add-cart="onAddCart" @add-cart="onAddCart"
@stepper-change="onChangeNumber" @stepper-change="onChangeNumber"
@sku-selected="handleSkuSelect"
> >
</spec-popup> </spec-popup>
@ -84,10 +85,12 @@ export default {
mixins: [MescrollMixin], mixins: [MescrollMixin],
data() { data() {
return { return {
mid: '',// id
category: '',// id
searchText: '',//
sku: {},// sku
key: 0, key: 0,
sort: '', //price sales release_at price -price sort: '', //price sales release_at price -price
searchText: '',
category: '',
loading: false, loading: false,
popupType: 1, popupType: 1,
number: 1, number: 1,
@ -111,17 +114,15 @@ export default {
specs() { specs() {
return this.products?.spu_specs ?? []; return this.products?.spu_specs ?? [];
}, },
detail() {
return this.products?.sku ?? {};
},
height() { height() {
const { windowHeight, statusBarHeight } = this.$u.sys(); const { windowHeight, statusBarHeight } = this.$u.sys();
return windowHeight - statusBarHeight - 44 + 'px'; return windowHeight - statusBarHeight - 44 + 'px';
}, },
}, },
onLoad({ searchText, category }) { onLoad(e) {
this.searchText = searchText; this.searchText = e.keywords;
this.category = category; this.category = e.cid;
this.mid = e.mid;
}, },
methods: { methods: {
Change(e) { Change(e) {
@ -154,6 +155,7 @@ export default {
const resData = await this.$api.get(`/v1/product/products/${this.productId}`); const resData = await this.$api.get(`/v1/product/products/${this.productId}`);
this.products = resData; this.products = resData;
this.skuId = this.products?.sku.id; this.skuId = this.products?.sku.id;
this.sku = this.products?.sku
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} finally { } finally {
@ -169,17 +171,15 @@ export default {
this.loadData(page); this.loadData(page);
}, },
loadData(page) { loadData(page) {
let obj = { let params = {
page: page.num, page: page.num,
per_page: page.size, per_page: page.size,
category: this.category, category: this.category,
keyword: this.searchText, keyword: this.searchText,
sort: this.sort, sort: this.sort,
}; };
this.$api let url = this.mid ? `/v1/store/${this.mid}/product-spus` : `/v1/product/products`
.get(`/v1/product/products`, { this.$api.get(url, { params })
params: obj,
})
.then((res) => { .then((res) => {
this.mescroll.endSuccess(res.data.length); this.mescroll.endSuccess(res.data.length);
if (page.num == 1) this.dataList = []; if (page.num == 1) this.dataList = [];
@ -215,6 +215,12 @@ export default {
this.key++; this.key++;
}); });
}, },
// sku,
handleSkuSelect(e) {
this.$api.get(`/v1/store/${this.mid}/product-sku/${e.sku_id}`).then(res => {
this.sku = res
})
}
}, },
}; };
</script> </script>

View File

@ -5,7 +5,7 @@
线上预约店 线上预约店
</view> </view>
<view class="my-20rpx px-20rpx"> <view class="my-20rpx px-20rpx">
<image @click="$u.route('/pageB/select_product/index', { id: 0 })" mode="widtFix" class="w-full h-250rpx rounded-15rpx" src="/static/images/user/u=2313295534,3451005153&fm=253&fmt=auto&app=138&f=JPEG.webp"></image> <image mode="widtFix" class="w-full h-250rpx rounded-15rpx" src="/static/images/user/u=2313295534,3451005153&fm=253&fmt=auto&app=138&f=JPEG.webp"></image>
</view> </view>
<view class="my-20rpx px-20rpx"> <view class="my-20rpx px-20rpx">
<u-line></u-line> <u-line></u-line>
@ -16,7 +16,7 @@
<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption"> <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
<view class="grid grid-cols-2 gap-x-80rpx pt-20rpx px-80rpx"> <view class="grid grid-cols-2 gap-x-80rpx pt-20rpx px-80rpx">
<view <view
@click="$u.route('/pageB/select_product/index', { id: item.id })" @click="$u.route('/pageB/select_product/index', { mid: item.id })"
class="flex items-center justify-center flex-col mt-40rpx text-30rpx font-extrabold" class="flex items-center justify-center flex-col mt-40rpx text-30rpx font-extrabold"
v-for="(item, index) in dataList" v-for="(item, index) in dataList"
:key="index" :key="index"