diff --git a/App.vue b/App.vue index 5d7defc..0cc4fd6 100644 --- a/App.vue +++ b/App.vue @@ -1,49 +1,57 @@ diff --git a/api/request.js b/api/request.js index ea29477..cd89fe0 100644 --- a/api/request.js +++ b/api/request.js @@ -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({ diff --git a/pages.json b/pages.json index cccdb57..83c3279 100644 --- a/pages.json +++ b/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", diff --git a/pages/index/index.vue b/pages/index/index.vue index 022110b..e7e9c94 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -3,24 +3,32 @@ - 香氛团购 + - - - - + + - + + + + + + + + @@ -37,7 +45,7 @@ - + @@ -53,11 +61,11 @@ - - + + - - + + 热销 @@ -65,16 +73,13 @@ -30% + + + - - + {{ item.name }} @@ -106,6 +111,19 @@ + + + {{ item.name }} + + + + ¥{{ formatPrice(item.skus[0].price) }} + + + + + + @@ -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; diff --git a/pages/my/editInfo/index.vue b/pages/my/editInfo/index.vue index f725c03..6ee7aa0 100644 --- a/pages/my/editInfo/index.vue +++ b/pages/my/editInfo/index.vue @@ -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; diff --git a/pages/order/create.vue b/pages/order/create.vue index 4d22612..d6f0568 100644 --- a/pages/order/create.vue +++ b/pages/order/create.vue @@ -91,7 +91,7 @@ 运费 - 包邮 + ¥ 0.00 优惠 diff --git a/pages/order/detail.vue b/pages/order/detail.vue index 8913254..04e9047 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -126,9 +126,9 @@ - + @@ -504,7 +504,7 @@ export default { \ No newline at end of file diff --git a/pages/shopDetail/index.vue b/pages/shopDetail/index.vue index 4f7c89c..df4f4eb 100644 --- a/pages/shopDetail/index.vue +++ b/pages/shopDetail/index.vue @@ -2,20 +2,20 @@ - + indicator-active-color="#9810fa" > - +