Compare commits
2 Commits
e9178bdf9c
...
aab7019ae2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aab7019ae2 | ||
|
|
cb11efdc78 |
86
App.vue
86
App.vue
@ -1,49 +1,57 @@
|
||||
<script>
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
export default {
|
||||
onLaunch: function () {
|
||||
console.log('App Launch')
|
||||
},
|
||||
onShow: function () {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function () {
|
||||
console.log('App Hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@import url("static/font/index.css");
|
||||
/*每个页面公共css */
|
||||
:root{
|
||||
--tw-shadow-color: red;
|
||||
--colo-danger: #fb2c36;
|
||||
}
|
||||
.flex{
|
||||
display: flex;
|
||||
}
|
||||
.shadow-sm{
|
||||
@import url("static/font/index.css");
|
||||
|
||||
}
|
||||
.justify-between{
|
||||
justify-content: space-between;
|
||||
}
|
||||
.items-center {
|
||||
align-items: center;
|
||||
}
|
||||
button{
|
||||
background-color: transparent;
|
||||
border: 0 !important;
|
||||
}
|
||||
/*每个页面公共css */
|
||||
:root {
|
||||
--tw-shadow-color: red;
|
||||
--colo-danger: #fb2c36;
|
||||
}
|
||||
|
||||
page{
|
||||
--color-danger: #fb2c36;
|
||||
--color-success: #00c951;
|
||||
--color-warning: #ff6900;
|
||||
--color-primary: #9810fa;
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
||||
--background-linear-gradient: linear-gradient(to right, #ad46ff, #f6339a)
|
||||
.shadow-sm {}
|
||||
|
||||
.justify-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.items-center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: transparent;
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
button::after {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
page {
|
||||
--color-danger: #fb2c36;
|
||||
--color-success: #00c951;
|
||||
--color-warning: #ff6900;
|
||||
--color-primary: #9810fa;
|
||||
|
||||
--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
||||
--background-linear-gradient: linear-gradient(to right, #ad46ff, #f6339a)
|
||||
/* --color-text-primary: # */
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -22,10 +22,7 @@ function request(url, method = 'GET', data = {}) {
|
||||
if (res.data.code) {
|
||||
if (res.data.code == 10103 || res.data.code == 10101) {
|
||||
wx.removeStorageSync('access_token');
|
||||
// wx.navigateTo({
|
||||
// url: '/pages/login/index',
|
||||
// });
|
||||
// reject(res.data);
|
||||
reject({ code: res.data.code, message: 'token expired' });
|
||||
return;
|
||||
}
|
||||
wx.showToast({
|
||||
|
||||
27
pages.json
27
pages.json
@ -13,6 +13,12 @@
|
||||
"navigationBarTitleText": "分销"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/shopClass/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "商品分类"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/create/index",
|
||||
"style": {
|
||||
@ -111,20 +117,15 @@
|
||||
"selectedIconPath": "static/tabBar/homeAct.png",
|
||||
"text": "首页"
|
||||
}, {
|
||||
"pagePath": "pages/distribution/index",
|
||||
"iconPath": "static/tabBar/distribution.png",
|
||||
"selectedIconPath": "static/tabBar/distributionAct.png",
|
||||
"text": "分销"
|
||||
"pagePath": "pages/shopClass/index",
|
||||
"iconPath": "static/tabBar/class.png",
|
||||
"selectedIconPath": "static/tabBar/classAct.png",
|
||||
"text": "分类"
|
||||
}, {
|
||||
"pagePath": "pages/create/index",
|
||||
"iconPath": "static/tabBar/create.png",
|
||||
"selectedIconPath": "static/tabBar/createAct.png",
|
||||
"text": "创建"
|
||||
}, {
|
||||
"pagePath": "pages/subscribe/index",
|
||||
"iconPath": "static/tabBar/subscribe.png",
|
||||
"selectedIconPath": "static/tabBar/subscribeAct.png",
|
||||
"text": "订阅"
|
||||
"pagePath": "pages/shoppingCart/index",
|
||||
"iconPath": "static/tabBar/cart.png",
|
||||
"selectedIconPath": "static/tabBar/cartAct.png",
|
||||
"text": "购物车"
|
||||
}, {
|
||||
"pagePath": "pages/my/index",
|
||||
"iconPath": "static/tabBar/my.png",
|
||||
|
||||
@ -3,24 +3,32 @@
|
||||
<view class="header flex justify-between">
|
||||
<view class="header-left">
|
||||
<image class="icon" src="/static/images/home/icon-1.png"></image>
|
||||
<text>香氛团购</text>
|
||||
<!-- <text>香氛团购</text> -->
|
||||
</view>
|
||||
<view class="header-right flex">
|
||||
<view>
|
||||
<text class="iconfont icon-sousuo">
|
||||
|
||||
</text>
|
||||
<view class="search-trigger" @click="toggleSearch">
|
||||
<text class="iconfont icon-sousuo"></text>
|
||||
</view>
|
||||
<view>
|
||||
<view class="search-slide" :class="{ active: searchVisible }">
|
||||
<input
|
||||
class="search-slide-input"
|
||||
v-model="searchKeyword"
|
||||
placeholder="搜索商品"
|
||||
confirm-type="search"
|
||||
@confirm="handleSearch"
|
||||
/>
|
||||
<view class="search-close" @click.stop="closeSearch">
|
||||
<text class="iconfont icon-guanbi"></text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view>
|
||||
<text class="iconfont icon-aixin">
|
||||
|
||||
</text>
|
||||
</view>
|
||||
<view>
|
||||
<text class="iconfont icon-zhifeiji1">
|
||||
|
||||
</text>
|
||||
</view>
|
||||
</view> -->
|
||||
<button class="icon-btn" open-type="share" data-share-type="app" @click.stop="currentShareItem = null">
|
||||
<text class="iconfont icon-zhifeiji1"></text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="container">
|
||||
@ -37,7 +45,7 @@
|
||||
</view>
|
||||
<view class="search-right flex">
|
||||
<view :class="{ active: searchType2 == 1 }" @click="changeSearch2(1)">
|
||||
<text class="iconfont icon-wanggeshezhi">
|
||||
<text class="iconfont icon-fenlei">
|
||||
|
||||
</text>
|
||||
</view>
|
||||
@ -53,11 +61,11 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="shop-list" v-if="searchType == 1">
|
||||
<view class="shop-item" v-for="(item, index) in shopList" :key="item.id" @click="goShopDetail(item)">
|
||||
<view class="shop-list" :class="{ 'grid-mode': searchType2 == 1 }" v-if="searchType == 1">
|
||||
<view class="shop-item" :class="{ 'grid-card': searchType2 == 1 }" v-for="(item, index) in shopList" :key="item.id" @click="goShopDetail(item)">
|
||||
<view class="shop-image">
|
||||
<image :src="item.main_image_url" mode="aspectFit"></image>
|
||||
<view class="shop-tag flex">
|
||||
<image :src="item.main_image_url" :mode="searchType2 == 1 ? 'aspectFill' : 'aspectFit'"></image>
|
||||
<view class="shop-tag flex" v-if="searchType2 != 1">
|
||||
<view class="tag danger" v-if="item.is_hot_selling == 1">
|
||||
<text class="iconfont icon-tubiaoshangshengqushi"></text>热销
|
||||
</view>
|
||||
@ -65,16 +73,13 @@
|
||||
-30%
|
||||
</view>
|
||||
</view>
|
||||
<view class="grid-share" v-if="searchType2 == 1">
|
||||
<button class="share-btn" open-type="share" :data-item="item" @click.stop="currentShareItem = item">
|
||||
<text class="iconfont icon-zhifeiji1"></text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="shop-container">
|
||||
<!-- <view class="shop-tags flex">
|
||||
<view class="tag">
|
||||
热销
|
||||
</view>
|
||||
<view class="tag">
|
||||
热销
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="shop-container" v-if="searchType2 != 1">
|
||||
<view class="sku-title">
|
||||
{{ item.name }}
|
||||
</view>
|
||||
@ -106,6 +111,19 @@
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="grid-info" v-else>
|
||||
<view class="grid-title">
|
||||
{{ item.name }}
|
||||
</view>
|
||||
<view class="grid-bottom flex justify-between">
|
||||
<view class="grid-price" v-if="item.skus && item.skus.length > 0">
|
||||
¥{{ formatPrice(item.skus[0].price) }}
|
||||
</view>
|
||||
<view class="grid-cart" @click.stop="handleAddToCart(item)">
|
||||
<text class="iconfont icon-gouwuche"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="shop-list" v-if="searchType == 2">
|
||||
@ -219,7 +237,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
searchType: 1,
|
||||
searchType2: 2,
|
||||
searchType2: 1,
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
category_id: '',
|
||||
@ -229,6 +247,8 @@ export default {
|
||||
shopList: '',
|
||||
currentShareItem: null,
|
||||
isLoggedIn: false,
|
||||
searchVisible: false,
|
||||
searchKeyword: '',
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@ -247,12 +267,22 @@ export default {
|
||||
},
|
||||
// 微信小程序分享
|
||||
onShareAppMessage(res) {
|
||||
const item = this.currentShareItem || (res.target && res.target.dataset && res.target.dataset.item) || {};
|
||||
const shareType = res && res.target && res.target.dataset && res.target.dataset.shareType
|
||||
// 菜单或右上角按钮:分享小程序首页
|
||||
if (shareType === 'app' || (res && res.from === 'menu')) {
|
||||
return {
|
||||
title: '香氛团购',
|
||||
// imageUrl: '/static/images/home/icon-1.png',
|
||||
path: '/pages/index/index'
|
||||
}
|
||||
}
|
||||
// 商品卡片分享
|
||||
const item = this.currentShareItem || (res.target && res.target.dataset && res.target.dataset.item) || {}
|
||||
return {
|
||||
title: item.name || '香氛团购',
|
||||
imageUrl: item.main_image_url || '/static/images/home/icon-1.png',
|
||||
path: item.id ? `/pages/shopDetail/index?id=${item.id}` : '/pages/index/index'
|
||||
};
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 检查登录状态
|
||||
@ -278,10 +308,22 @@ export default {
|
||||
|
||||
request(apiUrl, 'get', {
|
||||
page: this.page,
|
||||
page_size: this.page_size
|
||||
page_size: this.page_size,
|
||||
name: this.searchKeyword
|
||||
}).then((res) => {
|
||||
this.shopList = res.list
|
||||
console.log(this.shopList )
|
||||
}).catch((err) => {
|
||||
// token 失效,降级到无需 token 的接口
|
||||
if (err && (err.code == 10101 || err.code == 10103)) {
|
||||
request('xcx/products', 'get', {
|
||||
page: this.page,
|
||||
page_size: this.page_size,
|
||||
name: this.searchKeyword
|
||||
}).then((res) => {
|
||||
this.shopList = res.list
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
async userIsLogin() {
|
||||
@ -300,6 +342,24 @@ export default {
|
||||
changeSearch2(index) {
|
||||
this.searchType2 = index
|
||||
},
|
||||
toggleSearch() {
|
||||
this.searchVisible = !this.searchVisible
|
||||
if (!this.searchVisible) {
|
||||
this.searchKeyword = ''
|
||||
this.page = 1
|
||||
this.getShopList()
|
||||
}
|
||||
},
|
||||
closeSearch() {
|
||||
this.searchVisible = false
|
||||
this.searchKeyword = ''
|
||||
this.page = 1
|
||||
this.getShopList()
|
||||
},
|
||||
handleSearch() {
|
||||
this.page = 1
|
||||
this.getShopList()
|
||||
},
|
||||
async handelLike(row) {
|
||||
this.userIsLogin().then((res) => {
|
||||
request('xcx/product/like', 'post', {
|
||||
@ -420,6 +480,7 @@ export default {
|
||||
}
|
||||
|
||||
.header-right {
|
||||
position: relative;
|
||||
view {
|
||||
box-shadow: none;
|
||||
padding: 10rpx 10rpx;
|
||||
@ -431,6 +492,73 @@ export default {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
}
|
||||
.icon-btn {
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin: 0 0 0 20rpx;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: none;
|
||||
line-height: 1;
|
||||
position: relative;
|
||||
z-index: 30;
|
||||
}
|
||||
.icon-btn::after {
|
||||
border: none !important;
|
||||
}
|
||||
.search-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.search-slide {
|
||||
position: absolute;
|
||||
right: 56rpx; /* 留出分享按钮区域,避免遮挡 */
|
||||
top: 0;
|
||||
height: 72rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
width: 0;
|
||||
opacity: 0;
|
||||
transition: all 0.25s ease;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.search-slide.active {
|
||||
width: 460rpx;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.search-slide-input {
|
||||
flex: 1;
|
||||
height: 72rpx;
|
||||
padding: 0 20rpx;
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.search-close {
|
||||
width: 64rpx;
|
||||
height: 72rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #999;
|
||||
background: #fff;
|
||||
border-radius: 0 12rpx 12rpx 0;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 40rpx 32rpx;
|
||||
@ -498,6 +626,7 @@ export default {
|
||||
margin-top: 60rpx;
|
||||
|
||||
.shop-item {
|
||||
margin-top: 30rpx;
|
||||
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
||||
border-radius: 0 0 36rpx 36rpx;
|
||||
|
||||
@ -574,8 +703,7 @@ export default {
|
||||
flex: 1;
|
||||
border-radius: 12rpx;
|
||||
text-align: center;
|
||||
border: 0;
|
||||
box-shadow: 0 4rpx 8rpx 0 rgb(0 0 0 / 0.05);
|
||||
box-shadow: 0rpx 0rpx 4rpx rgb(0 0 0 / 0.2);
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
font-size: 24rpx;
|
||||
@ -703,6 +831,95 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
.shop-list.grid-mode {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 24rpx;
|
||||
margin-top: 40rpx;
|
||||
|
||||
.shop-item {
|
||||
width: calc(50% - 12rpx);
|
||||
margin-top: 0;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 6rpx 18rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.shop-image image {
|
||||
height: 320rpx;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.shop-container {
|
||||
padding: 32rpx 24rpx;
|
||||
}
|
||||
|
||||
.grid-card {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.grid-share {
|
||||
position: absolute;
|
||||
top: 16rpx;
|
||||
right: 16rpx;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.grid-share .share-btn {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
border-radius: 50%;
|
||||
padding: 0;
|
||||
background: rgba(0,0,0,0.4);
|
||||
color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.grid-info {
|
||||
padding: 20rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 12rpx;
|
||||
}
|
||||
|
||||
.grid-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
color: #333;
|
||||
line-height: 1.4;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.grid-bottom {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.grid-price {
|
||||
font-size: 30rpx;
|
||||
color: #e7000b;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.grid-cart {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: #f3e8ff;
|
||||
color: #9810fa;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 4rpx 10rpx rgba(0,0,0,0.08);
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.sku-group-buying {
|
||||
margin-top: 16rpx;
|
||||
padding: 24rpx;
|
||||
|
||||
@ -159,15 +159,16 @@ export default {
|
||||
try {
|
||||
request('xcx/set_user_info', 'POST', this.form).then(res => {
|
||||
this.showToast('保存成功', 'success');
|
||||
const is_personal_information_complete = uni.getStorageSync('is_personal_information_complete');
|
||||
if (is_personal_information_complete) {
|
||||
wx.navigateBack();
|
||||
} else {
|
||||
uni.setStorageSync('is_personal_information_complete', true);
|
||||
wx.navigateTo({
|
||||
url: `/pages/my/editInfo/index`,
|
||||
});
|
||||
}
|
||||
wx.navigateBack();
|
||||
// const is_personal_information_complete = uni.getStorageSync('is_personal_information_complete');
|
||||
// if (is_personal_information_complete) {
|
||||
// wx.navigateBack();
|
||||
// } else {
|
||||
// uni.setStorageSync('is_personal_information_complete', true);
|
||||
// wx.navigateTo({
|
||||
// url: `/pages/my/editInfo/index`,
|
||||
// });
|
||||
// }
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
@ -309,7 +310,7 @@ export default {
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
height: 92rpx;
|
||||
/* height: 92rpx; */
|
||||
border-radius: 46rpx;
|
||||
font-size: 30rpx;
|
||||
font-weight: 500;
|
||||
|
||||
@ -91,7 +91,7 @@
|
||||
</view>
|
||||
<view class="price-item">
|
||||
<text class="price-label">运费</text>
|
||||
<text class="price-value">包邮</text>
|
||||
<text class="price-value">¥ 0.00</text>
|
||||
</view>
|
||||
<view class="price-item total" v-if="discountAmount > 0">
|
||||
<text class="price-label">优惠</text>
|
||||
|
||||
@ -126,9 +126,9 @@
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view class="empty-block" v-else>
|
||||
<!-- <view class="empty-block" v-else>
|
||||
<text class="placeholder-text">正在加载订单详情...</text>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<view v-if="showReviewModal" class="review-modal">
|
||||
@ -504,7 +504,7 @@ export default {
|
||||
|
||||
<style scoped>
|
||||
.order-detail-page {
|
||||
min-height: 100vh;
|
||||
/* min-height: 100vh; */
|
||||
background-color: #f5f5f5;
|
||||
padding: 32rpx;
|
||||
box-sizing: border-box;
|
||||
@ -584,6 +584,7 @@ export default {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 16rpx;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.label {
|
||||
|
||||
407
pages/shopClass/index.vue
Normal file
407
pages/shopClass/index.vue
Normal file
@ -0,0 +1,407 @@
|
||||
<template>
|
||||
<view class="category-page">
|
||||
<view class="search-bar flex">
|
||||
<input class="search-input" v-model="keyword" placeholder="搜索商品" confirm-type="search"
|
||||
@confirm="handleSearch" />
|
||||
<button class="search-btn" @click="handleSearch">搜索</button>
|
||||
</view>
|
||||
|
||||
<view class="body-wrap">
|
||||
<scroll-view class="side-menu" scroll-y>
|
||||
<view
|
||||
v-for="item in topCategories"
|
||||
:key="item.id"
|
||||
class="side-item"
|
||||
:class="{ active: item.id === activeTopId }"
|
||||
@click="handleTopSelect(item.id)"
|
||||
>
|
||||
<image v-if="item.image_url" class="side-thumb" :src="item.image_url" mode="aspectFill" />
|
||||
<view class="side-text">{{ item.name }}</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<scroll-view class="content" scroll-y @scrolltolower="loadMore">
|
||||
<view class="sub-wrap" v-if="subCategories.length">
|
||||
<view
|
||||
v-for="sub in subCategories"
|
||||
:key="sub.id"
|
||||
class="sub-tag"
|
||||
:class="{ active: sub.id === activeSubId }"
|
||||
@click="handleSubSelect(sub.id)"
|
||||
>
|
||||
{{ sub.name }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="product-list">
|
||||
<view
|
||||
class="product-card shadow"
|
||||
v-for="item in products"
|
||||
:key="item.id"
|
||||
@click="goDetail(item)"
|
||||
>
|
||||
<image class="product-image" :src="item.main_image_url || item.image_url" mode="aspectFill" />
|
||||
<view class="product-info">
|
||||
<view class="title-row">
|
||||
<view class="product-title">{{ item.name }}</view>
|
||||
<view class="hot-tag" v-if="item.is_hot_selling === 1">热销</view>
|
||||
</view>
|
||||
<view class="product-desc">{{ item.description }}</view>
|
||||
<view class="meta-row flex justify-between">
|
||||
<view class="rating">
|
||||
<text class="iconfont icon-xingxing"></text>
|
||||
<text class="rating-num">{{ item.rating || 0 }}</text>
|
||||
<text class="like">· {{ item.like_count || 0 }} 喜欢</text>
|
||||
</view>
|
||||
<view class="price" v-if="item.skus && item.skus.length">
|
||||
<text class="current">¥{{ formatPrice(item.skus[0].price) }}</text>
|
||||
<text class="origin" v-if="item.skus[0].original_price">¥{{ formatPrice(item.skus[0].original_price) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="status" v-if="!products.length && !loading && !catLoading">
|
||||
暂无商品
|
||||
</view>
|
||||
<view class="status" v-if="loading">加载中...</view>
|
||||
<view class="status" v-if="noMore && products.length">没有更多了</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '/api/request'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
keyword: '',
|
||||
topCategories: [],
|
||||
subCategories: [],
|
||||
activeTopId: null,
|
||||
activeSubId: null,
|
||||
products: [],
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
loading: false,
|
||||
catLoading: false,
|
||||
noMore: false
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.initPage()
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.initPage().finally(() => uni.stopPullDownRefresh())
|
||||
},
|
||||
onReachBottom() {
|
||||
this.loadMore()
|
||||
},
|
||||
methods: {
|
||||
async initPage() {
|
||||
this.page = 1
|
||||
this.noMore = false
|
||||
this.products = []
|
||||
await this.fetchTopCategories()
|
||||
},
|
||||
async fetchTopCategories() {
|
||||
this.catLoading = true
|
||||
try {
|
||||
const res = await request('xcx/product/categories', 'GET', { parent_id: 0 })
|
||||
this.topCategories = res.list || []
|
||||
if (this.topCategories.length) {
|
||||
this.activeTopId = this.topCategories[0].id
|
||||
await this.fetchSubCategories(this.activeTopId)
|
||||
} else {
|
||||
this.subCategories = []
|
||||
this.activeTopId = null
|
||||
this.activeSubId = null
|
||||
}
|
||||
} finally {
|
||||
this.catLoading = false
|
||||
}
|
||||
},
|
||||
async fetchSubCategories(parentId) {
|
||||
this.catLoading = true
|
||||
try {
|
||||
const res = await request('xcx/product/categories', 'GET', { parent_id: parentId })
|
||||
this.subCategories = res.list || []
|
||||
this.activeSubId = this.subCategories.length ? this.subCategories[0].id : null
|
||||
} finally {
|
||||
this.catLoading = false
|
||||
this.resetProducts()
|
||||
}
|
||||
},
|
||||
resetProducts() {
|
||||
this.page = 1
|
||||
this.noMore = false
|
||||
this.products = []
|
||||
this.loadProducts(true)
|
||||
},
|
||||
async loadProducts(reset = false) {
|
||||
if (this.loading || this.noMore) return
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {
|
||||
page: this.page,
|
||||
page_size: this.page_size
|
||||
}
|
||||
if (this.activeSubId) {
|
||||
params.category_id = this.activeSubId
|
||||
}
|
||||
if (this.keyword) {
|
||||
params.name = this.keyword.trim()
|
||||
}
|
||||
const res = await request('xcx/products', 'GET', params)
|
||||
const list = res.list || []
|
||||
this.products = reset || this.page === 1 ? list : this.products.concat(list)
|
||||
const total = res.total || 0
|
||||
if (this.products.length >= total || list.length < this.page_size) {
|
||||
this.noMore = true
|
||||
} else {
|
||||
this.page += 1
|
||||
}
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
loadMore() {
|
||||
this.loadProducts()
|
||||
},
|
||||
handleTopSelect(id) {
|
||||
if (id === this.activeTopId) return
|
||||
this.activeTopId = id
|
||||
this.fetchSubCategories(id)
|
||||
},
|
||||
handleSubSelect(id) {
|
||||
if (id === this.activeSubId) return
|
||||
this.activeSubId = id
|
||||
this.resetProducts()
|
||||
},
|
||||
handleSearch() {
|
||||
this.resetProducts()
|
||||
},
|
||||
formatPrice(value) {
|
||||
if (!value) return '0.00'
|
||||
return (value / 100).toFixed(2)
|
||||
},
|
||||
goDetail(item) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/shopDetail/index?id=${item.id}`
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.category-page {
|
||||
min-height: 100vh;
|
||||
background: #f7f7f9;
|
||||
padding: 20rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 12rpx 16rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||
margin-bottom: 16rpx;
|
||||
align-items: center;
|
||||
column-gap: 12rpx;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
height: 72rpx;
|
||||
padding: 0 20rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
background: #f6f6f8;
|
||||
border-radius: 12rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
height: 72rpx;
|
||||
line-height: 72rpx;
|
||||
padding: 0 28rpx;
|
||||
color: #fff;
|
||||
background: linear-gradient(90deg, #ad46ff, #f6339a);
|
||||
border-radius: 12rpx;
|
||||
font-size: 28rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.body-wrap {
|
||||
display: flex;
|
||||
background: #fff;
|
||||
border-radius: 18rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.04);
|
||||
min-height: 70vh;
|
||||
}
|
||||
|
||||
.side-menu {
|
||||
width: 200rpx;
|
||||
background: #fafafa;
|
||||
border-right: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.side-item {
|
||||
padding: 24rpx 16rpx;
|
||||
text-align: center;
|
||||
color: #666;
|
||||
font-size: 28rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.side-item.active {
|
||||
background: #fff;
|
||||
color: #9810fa;
|
||||
font-weight: 600;
|
||||
border-left: 6rpx solid #9810fa;
|
||||
}
|
||||
|
||||
.side-thumb {
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
border-radius: 12rpx;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.side-text {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
padding: 20rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.sub-wrap {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.sub-tag {
|
||||
padding: 10rpx 18rpx;
|
||||
background: #f6f6f8;
|
||||
border-radius: 30rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.sub-tag.active {
|
||||
color: #fff;
|
||||
background: linear-gradient(90deg, #ad46ff, #f6339a);
|
||||
}
|
||||
|
||||
.product-list {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.product-card {
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 100%;
|
||||
height: 320rpx;
|
||||
background: #f7f7f7;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.title-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.product-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
.hot-tag {
|
||||
color: #fb2c36;
|
||||
font-size: 24rpx;
|
||||
background: rgba(251, 44, 54, 0.08);
|
||||
border-radius: 20rpx;
|
||||
padding: 6rpx 14rpx;
|
||||
}
|
||||
|
||||
.product-desc {
|
||||
font-size: 26rpx;
|
||||
color: #777;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.meta-row {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.rating {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.rating .iconfont {
|
||||
color: #ffb400;
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
|
||||
.rating-num {
|
||||
margin-right: 6rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.like {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.price {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.price .current {
|
||||
color: #9810fa;
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
|
||||
.price .origin {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.status {
|
||||
text-align: center;
|
||||
color: #888;
|
||||
padding: 24rpx 0;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
</style>
|
||||
@ -2,20 +2,20 @@
|
||||
<view class="detail-page">
|
||||
<!-- 图片轮播 -->
|
||||
<view class="image-swiper-wrapper">
|
||||
<swiper class="image-swiper" :indicator-dots="true" :autoplay="false" :circular="true"
|
||||
<swiper class="image-swiper" :indicator-dots="true" :autoplay="false"
|
||||
:current="currentImageIndex" @change="onSwiperChange" indicator-color="rgba(0,0,0,0.2)"
|
||||
indicator-active-color="#fff">
|
||||
indicator-active-color="#9810fa" >
|
||||
<swiper-item v-for="(image, index) in productImages" :key="index">
|
||||
<image :src="image" mode="aspectFill" class="swiper-image"></image>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<!-- 左右箭头 -->
|
||||
<view class="swiper-nav prev" @click="prevImage" v-if="productImages.length > 1">
|
||||
<!-- <view class="swiper-nav prev" @click="prevImage" v-if="productImages.length > 1">
|
||||
<text>‹</text>
|
||||
</view>
|
||||
<view class="swiper-nav next" @click="nextImage" v-if="productImages.length > 1">
|
||||
<text>›</text>
|
||||
</view>
|
||||
</view> -->
|
||||
<!-- 分享按钮 -->
|
||||
<view class="share-btn-top">
|
||||
<button class="share-btn-inner-top" open-type="share" :data-item="productInfo" @click.stop="currentShareItem = productInfo">
|
||||
@ -406,8 +406,8 @@ export default {
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// this.productInfo = uni.getStorageSync('product_info');
|
||||
this.loadProductDetail(uni.getStorageSync('product_info'));
|
||||
this.productId = options.id;
|
||||
this.loadProductDetail(this.productId);
|
||||
this.fetchCartSelectedCount();
|
||||
},
|
||||
onShow() {
|
||||
@ -435,7 +435,8 @@ export default {
|
||||
return value.toFixed(2);
|
||||
},
|
||||
// 加载商品详情
|
||||
async loadProductDetail(productInfo) {
|
||||
async loadProductDetail(productId) {
|
||||
const productInfo = await request('xcx/product/' + productId, 'GET');
|
||||
if (!productInfo) {
|
||||
console.warn('商品信息为空');
|
||||
return;
|
||||
|
||||
@ -287,7 +287,7 @@ export default {
|
||||
.cart-page {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
padding-bottom: 120rpx;
|
||||
/* padding-bottom: 120rpx; */
|
||||
}
|
||||
|
||||
/* 购物车列表 */
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
@font-face {
|
||||
font-family: "iconfont"; /* Project id 5057334 */
|
||||
src: url('//at.alicdn.com/t/c/font_5057334_65098frmpc4.woff2?t=1763879647176') format('woff2'),
|
||||
url('//at.alicdn.com/t/c/font_5057334_65098frmpc4.woff?t=1763879647176') format('woff'),
|
||||
url('//at.alicdn.com/t/c/font_5057334_65098frmpc4.ttf?t=1763879647176') format('truetype');
|
||||
src: url('//at.alicdn.com/t/c/font_5057334_cwbx6h5u8j.woff2?t=1765288656880') format('woff2'),
|
||||
url('//at.alicdn.com/t/c/font_5057334_cwbx6h5u8j.woff?t=1765288656880') format('woff'),
|
||||
url('//at.alicdn.com/t/c/font_5057334_cwbx6h5u8j.ttf?t=1765288656880') format('truetype');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
@ -13,6 +13,14 @@
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-guanbi:before {
|
||||
content: "\e620";
|
||||
}
|
||||
|
||||
.icon-fenlei:before {
|
||||
content: "\e638";
|
||||
}
|
||||
|
||||
.icon-gou:before {
|
||||
content: "\e786";
|
||||
}
|
||||
@ -57,6 +65,10 @@
|
||||
content: "\e67e";
|
||||
}
|
||||
|
||||
.icon-gouwuche-copy:before {
|
||||
content: "\11c34";
|
||||
}
|
||||
|
||||
.icon-xingxing:before {
|
||||
content: "\e60a";
|
||||
}
|
||||
|
||||
BIN
static/tabBar/cart.png
Normal file
BIN
static/tabBar/cart.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
static/tabBar/cartAct.png
Normal file
BIN
static/tabBar/cartAct.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
static/tabBar/class.png
Normal file
BIN
static/tabBar/class.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
static/tabBar/classAct.png
Normal file
BIN
static/tabBar/classAct.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Loading…
x
Reference in New Issue
Block a user