From 3d04398b7c48194ebd5fd5434817ed8c8efedd96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Dchenxuelian=E2=80=9C?= <“chenxuelian@cjiedata.com”> Date: Mon, 26 Dec 2022 20:16:44 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=88=86=E7=B1=BB=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods-category-search/category-index.vue | 19 +++++++++++++++++-- pages/ideasAndNeeds/ideasAndNeeds.vue | 4 ---- pages/index/index.vue | 11 +++++++++++ service/request.js | 16 +++++++++++++++- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/packageSearch/goods-category-search/category-index.vue b/packageSearch/goods-category-search/category-index.vue index e86bdff..4f2ed21 100644 --- a/packageSearch/goods-category-search/category-index.vue +++ b/packageSearch/goods-category-search/category-index.vue @@ -355,13 +355,15 @@ menuItemHeight: 0, // 左边菜单item的高度 tabCurrent: 0, //分类详情 上架时间, // 左边菜单item的高度 tagCurrent: 0, //分类详情 上架时间 + imgUrl: '' } }, onLoad() { const menuButtonInfo = uni.getMenuButtonBoundingClientRect(); - console.log(menuButtonInfo) this.searchBarTop = menuButtonInfo.top; this.searchBarHeight = menuButtonInfo.height; + this.imgUrl = uni.getStorageSync('img_url') + this.getCategoryList() }, onReady() { let that = this; @@ -448,9 +450,22 @@ }, navigateToSearch() { uni.navigateTo({ - url: '../../search/search' + url: '../search/search' }) }, + getCategoryList() { + this.$apiServe.getCategories().then(res => { + this.categoryList = res.data.data.map((item, index) => { + item.icon = this.imgUrl + item.icon + item.active = false + if(!index) { + item.active = true + } + return item + }) + console.log(this.categoryList) + }).finally(_ => {}) + }, goBack() { uni.navigateBack() }, diff --git a/pages/ideasAndNeeds/ideasAndNeeds.vue b/pages/ideasAndNeeds/ideasAndNeeds.vue index 2de3d0c..d96a6ad 100644 --- a/pages/ideasAndNeeds/ideasAndNeeds.vue +++ b/pages/ideasAndNeeds/ideasAndNeeds.vue @@ -146,10 +146,6 @@ this.tabCurrent = data.index this.needsPublishForm = {} }, - changeCity(data) { - this.needsPublishForm.city = data.data.join('') - console.log('showCityPicker = true') - }, getCityValue(data) { this.showCityPicker = false this.needsPublishForm.city = data.join('/') diff --git a/pages/index/index.vue b/pages/index/index.vue index e703bdf..18cfbbb 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -105,6 +105,7 @@ uni.stopPullDownRefresh() }, onLoad() { + this.getImgUrl() this.$apiServe.getCategories().then(res => { console.log(res) }).finally(_ => {}) @@ -151,6 +152,16 @@ uni.navigateTo({ url: '../../packageSearch/goods-category-search/category-index' }) + }, + getImgUrl() { + this.$apiServe.getImgUrl().then(res => { + console.log(res) + try { + uni.setStorageSync('img_url', res.data.data.img_url); + } catch (e) { + // error + } + }).finally(_ => {}) } } } diff --git a/service/request.js b/service/request.js index d83825f..46ee5e6 100644 --- a/service/request.js +++ b/service/request.js @@ -189,12 +189,26 @@ const apiService = { }) }, // 搜索发现 热搜 - getDiscover(data) { + getDiscover() { const url = `/home/discover` return new Promise((resolve, reject) => { resolve(service.get(url)) }) }, + // 搜索产品 + getProductList(data) { + const url = `/home/product` + return new Promise((resolve, reject) => { + resolve(service.get(url)) + }) + }, + // 图片基本地址 + getImgUrl() { + const url = `/center/cfg?key=img_url` + return new Promise((resolve, reject) => { + resolve(service.get(url)) + }) + }, // 新增 addOutboundOrder(data) { const url = `/api` From 3fd749fd2f524f3111197e4de8135b29b563079e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Dchenxuelian=E2=80=9C?= <“chenxuelian@cjiedata.com”> Date: Mon, 26 Dec 2022 20:27:26 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/request.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/service/request.js b/service/request.js index 689bd2d..d28fbce 100644 --- a/service/request.js +++ b/service/request.js @@ -254,9 +254,7 @@ const apiService = { return new Promise((resolve, reject) => { resolve(service.sm(url, data)) }) - } - uploadImgUrl: serverHost, - imgUrl: serverHost, + }, login: data => { data = Object.assign(data || {}, {}) const url = `/api` From aef226d3ab21e5ba668c5e566508d12c4255000f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Dchenxuelian=E2=80=9C?= <“chenxuelian@cjiedata.com”> Date: Mon, 26 Dec 2022 21:27:22 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=86=E7=B1=BB=E9=A1=B5=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods-category-search/category-index.vue | 357 ++++++++++-------- .../search-products/search-products.vue | 28 +- packageSearch/search/search.vue | 2 +- service/request.js | 37 +- 4 files changed, 221 insertions(+), 203 deletions(-) diff --git a/packageSearch/goods-category-search/category-index.vue b/packageSearch/goods-category-search/category-index.vue index 4f2ed21..bf623dd 100644 --- a/packageSearch/goods-category-search/category-index.vue +++ b/packageSearch/goods-category-search/category-index.vue @@ -10,7 +10,7 @@ + @click="changeSelectedCategory(item, index)"> - - - - - - - - - - - {{item.name}} - - - - - - {{item1.name}} - - - {{item1.describe}} - - - - - - - 发布日期 - {{item1.date}} - - - - - {{ item1.feature }} - - + + + + + + + + + {{item.name}} - - + + + + {{item1.name}} + + + {{item1.describe}} + + + + + + + 发布日期 + {{item1.date}} + + + + + {{ item1.feature }} + + + + @@ -118,7 +114,7 @@ - @@ -223,132 +219,111 @@ } ], selectedCategory: 0, - tabbar: [{ - "name": "蛋糕面包", - "foods": [{ - "name": "牛角面包", - "describe": "法国风味糖皮饼干牛角面包早餐食品", - "image": "/static/category/fl_icon_qb.png", - "date": '2022-12-04', - 'feature': '无防腐剂' - }, - { - "name": "牛角面包", - "describe": "法国风味糖皮饼干牛角面包早餐食品", - "image": "/static/category/fl_icon_qb.png", - "date": '2022-12-04', - 'feature': '无防腐剂' - }, - { - "name": "牛角面包", - "describe": "法国风味糖皮饼干牛角面包早餐食品", - "image": "/static/category/fl_icon_qb.png", - "date": '2022-12-04', - 'feature': '无防腐剂' - }, - { - "name": "牛角面包", - "describe": "法国风味糖皮饼干牛角面包早餐食品", - "image": "", - "date": '2022-12-04', - 'feature': '无防腐剂' - } - ] - }, - { - "name": "糕点卷酥", - "foods": [{ - "name": "牛角面包", - "describe": "法国风味糖皮饼干牛角面包早餐食品", - "image": "/static/category/fl_icon_qb.png", - "date": '2022-12-04', - 'feature': '无防腐剂' - }, - { - "name": "牛角面包", - "describe": "法国风味糖皮饼干牛角面包早餐食品", - "image": "/static/category/fl_icon_qb.png", - "date": '2022-12-04', - 'feature': '无防腐剂' - }, - { - "name": "牛角面包", - "describe": "法国风味糖皮饼干牛角面包早餐食品", - "image": "/static/category/fl_icon_qb.png", - "date": '2022-12-04', - 'feature': '无防腐剂' - } - ] - }, - { - "name": "饼干曲奇", - "foods": [{ - "name": "牛角面包", - "describe": "法国风味糖皮饼干牛角面包早餐食品", - "image": "/static/category/fl_icon_qb.png", - "date": '2022-12-04', - 'feature': '无防腐剂' - }, - { - "name": "牛角面包", - "describe": "法国风味糖皮饼干牛角面包早餐食品", - "image": "/static/category/fl_icon_qb.png", - "date": '2022-12-04', - 'feature': '无防腐剂' - }, - { - "name": "牛角面包", - "describe": "法国风味糖皮饼干牛角面包早餐食品", - "image": "/static/category/fl_icon_qb.png", - "date": '2022-12-04', - 'feature': '无防腐剂' - }, - { - "name": "牛角面包", - "describe": "法国风味糖皮饼干牛角面包早餐食品", - "image": "/static/category/fl_icon_qb.png", - "date": '2022-12-04', - 'feature': '无防腐剂' - } - ] - }, + tabbar: [ + // { + // "name": "蛋糕面包", + // "foods": [{ + // "name": "牛角面包", + // "describe": "法国风味糖皮饼干牛角面包早餐食品", + // "image": "/static/category/fl_icon_qb.png", + // "date": '2022-12-04', + // 'feature': '无防腐剂' + // }, + // { + // "name": "牛角面包", + // "describe": "法国风味糖皮饼干牛角面包早餐食品", + // "image": "/static/category/fl_icon_qb.png", + // "date": '2022-12-04', + // 'feature': '无防腐剂' + // }, + // { + // "name": "牛角面包", + // "describe": "法国风味糖皮饼干牛角面包早餐食品", + // "image": "/static/category/fl_icon_qb.png", + // "date": '2022-12-04', + // 'feature': '无防腐剂' + // }, + // { + // "name": "牛角面包", + // "describe": "法国风味糖皮饼干牛角面包早餐食品", + // "image": "", + // "date": '2022-12-04', + // 'feature': '无防腐剂' + // } + // ] + // }, + // { + // "name": "糕点卷酥", + // "foods": [{ + // "name": "牛角面包", + // "describe": "法国风味糖皮饼干牛角面包早餐食品", + // "image": "/static/category/fl_icon_qb.png", + // "date": '2022-12-04', + // 'feature': '无防腐剂' + // }, + // { + // "name": "牛角面包", + // "describe": "法国风味糖皮饼干牛角面包早餐食品", + // "image": "/static/category/fl_icon_qb.png", + // "date": '2022-12-04', + // 'feature': '无防腐剂' + // }, + // { + // "name": "牛角面包", + // "describe": "法国风味糖皮饼干牛角面包早餐食品", + // "image": "/static/category/fl_icon_qb.png", + // "date": '2022-12-04', + // 'feature': '无防腐剂' + // } + // ] + // }, + // { + // "name": "饼干曲奇", + // "foods": [{ + // "name": "牛角面包", + // "describe": "法国风味糖皮饼干牛角面包早餐食品", + // "image": "/static/category/fl_icon_qb.png", + // "date": '2022-12-04', + // 'feature': '无防腐剂' + // }, + // { + // "name": "牛角面包", + // "describe": "法国风味糖皮饼干牛角面包早餐食品", + // "image": "/static/category/fl_icon_qb.png", + // "date": '2022-12-04', + // 'feature': '无防腐剂' + // }, + // { + // "name": "牛角面包", + // "describe": "法国风味糖皮饼干牛角面包早餐食品", + // "image": "/static/category/fl_icon_qb.png", + // "date": '2022-12-04', + // 'feature': '无防腐剂' + // }, + // { + // "name": "牛角面包", + // "describe": "法国风味糖皮饼干牛角面包早餐食品", + // "image": "/static/category/fl_icon_qb.png", + // "date": '2022-12-04', + // 'feature': '无防腐剂' + // } + // ] + // }, ], + goodsParam: { + sortType: null, + cateId: null, + tagIds: null, + pageSize: 10, + pageNum: 1 + }, + goodsList: [], tabsList: [{ name: '上架时间' }, { name: '点赞量' }], - tagsList: [{ - name: '无添加剂' - }, - { - name: '无添加剂' - }, - { - name: '无添加剂' - }, - { - name: '无添加剂' - }, - { - name: '无添加剂' - }, - { - name: '无添加剂' - }, - { - name: '无添加剂无添加剂' - }, - { - name: '无添加剂' - }, - { - name: '无添加剂' - }, - { - name: '无添加剂无添加剂' - } - ], + tagsList: [], scrollTop: 0, //tab标题的滚动条位置 menuCurrent: 0, // 预设当前项的值 menuHeight: 0, // 左边菜单的高度 @@ -391,7 +366,7 @@ } this.recentRecordList.unshift(param) }, - changeSelectedCategory(index) { + changeSelectedCategory(item, index) { this.$set(this.categoryList, this.selectedCategory, { ...this.categoryList[this.selectedCategory], active: false @@ -401,11 +376,16 @@ active: true }); this.selectedCategory = index + this.tabCurrent = 0 + this.tagCurrent = null + this.menuCurrent = 0 + this.getSeconedCategoryList() this.showMask = false }, changeSelectedTag(index) { this.tagCurrent = index this.featureMask = false + this.getGoodsList() }, // 点击左边的栏目切换 async swichMenu(index) { @@ -418,6 +398,7 @@ } // 将菜单菜单活动item垂直居中 this.scrollTop = index * this.menuItemHeight + this.menuItemHeight / 2 - this.menuHeight / 2; + this.getTagList() }, // 获取一个目标元素的高度 getElRect(elClass, dataVal) { @@ -447,6 +428,7 @@ tabChange(selectTab) { console.log(selectTab) this.tabCurrent = selectTab.index; + this.getGoodsList() }, navigateToSearch() { uni.navigateTo({ @@ -457,13 +439,54 @@ this.$apiServe.getCategories().then(res => { this.categoryList = res.data.data.map((item, index) => { item.icon = this.imgUrl + item.icon - item.active = false - if(!index) { + if (this.selectedCategory && this.selectedCategory === index) { item.active = true + } else if (!this.selectedCategory && !index) { + item.active = true + } else { + item.active = false } return item }) - console.log(this.categoryList) + this.getSeconedCategoryList() + }).finally(_ => {}) + }, + getSeconedCategoryList() { + const data = { + pid: this.categoryList[this.selectedCategory].id + } + this.$apiServe.getCategories(data).then(res => { + this.tabbar = res.data.data.map((item, index) => { + item.icon = this.imgUrl + item.icon + return item + }) + this.getTagList() + }).finally(_ => {}) + }, + getTagList() { + const data = { + pid: this.tabbar[this.menuCurrent].id + } + this.$apiServe.getTags(data).then(res => { + this.tagsList = res.data.data.map((item, index) => { + return item + }) + }).finally(_ => { + this.getGoodsList() + }) + }, + getGoodsList() { + const data = { + ...this.goodsParam, + sortType: this.tabCurrent + 1, + cateId: this.tabbar.length ? this.tabbar[this.menuCurrent].id : null, + tagIds: this.tagsList.length ? this.tagsList[this.tagCurrent].id : null + } + this.$apiServe.getProductList(data).then(res => { + this.goodsList = res.data.data.map((item, index) => { + item.icon = this.imgUrl + item.icon + return item + }) }).finally(_ => {}) }, goBack() { @@ -584,6 +607,7 @@ background: #fff; border: 2rpx solid #fff; border-radius: 25% 0 0 0; + .title { font-size: 32rpx; font-family: PingFangSC-Regular, PingFang SC; @@ -689,7 +713,8 @@ padding: 12rpx; border-radius: 25rpx 0 0 25rpx; line-height: 14rpx; - background: linear-gradient(135deg, #0DB658 0%, #16DD6D 100%);; + background: linear-gradient(135deg, #0DB658 0%, #16DD6D 100%); + ; color: #fff; font-size: 20rpx; width: fit-content; diff --git a/packageSearch/search-products/search-products.vue b/packageSearch/search-products/search-products.vue index 59cc7ed..b05e305 100644 --- a/packageSearch/search-products/search-products.vue +++ b/packageSearch/search-products/search-products.vue @@ -38,18 +38,28 @@ export default { data() { return { - productList: [{ - cover: '/static/products/zhanwei_dg.png', - name: '锅巴', - tag: '无添加剂', - cate_name: '零食铺子', - title: '糯米蟹黄锅巴散装,非油炸绿色健康食品', - pub_time: '2022-12-04' - }, ] + queryParam: { + pageSize: 10, + pageNum: 1 + }, + queryTitle: null, + productList: [] } }, + onLoad(options) { + this.queryTitle = options.title + this.goSearch() + }, methods: { - + goSearch() { + const data = { + ...this.queryParam, + title: this.queryTitle + } + this.$apiServe.getProductList(data).then(res => { + this.productList = res.data.data + }).finally(_ => {}) + } } } diff --git a/packageSearch/search/search.vue b/packageSearch/search/search.vue index 8ecf7e6..a293f37 100644 --- a/packageSearch/search/search.vue +++ b/packageSearch/search/search.vue @@ -83,7 +83,7 @@ // error } uni.navigateTo({ - url: '../search-products/search-products' + url: '../search-products/search-products?title=' + param }) }, goBack() { diff --git a/service/request.js b/service/request.js index d28fbce..22c98d9 100644 --- a/service/request.js +++ b/service/request.js @@ -182,13 +182,6 @@ const apiService = { resolve(service.post(url, data, true)) }) }, - // 获取首页分类 - getCategories() { - const url = `/home/classlist` - return new Promise((resolve, reject) => { - resolve(service.get(url)) - }) - }, // 获取首页轮播图 getBanner(data) { const url = `/home/banner` @@ -238,23 +231,6 @@ const apiService = { resolve(service.get(url, id)) }) }, - - // 解密 - decrypt(data) { - const url = `/api` - return new Promise((resolve, reject) => { - resolve(service.post(url, { - data - })) - }) - }, - // 国密sm4加密 - sm4Encrypt(data) { - const url = `/api` - return new Promise((resolve, reject) => { - resolve(service.sm(url, data)) - }) - }, login: data => { data = Object.assign(data || {}, {}) const url = `/api` @@ -262,11 +238,18 @@ const apiService = { resolve(service.post(url, data, true)) }) }, - // 获取 + // 获取首页分类Tag + getTags(data) { + const url = `/home/tags` + return new Promise((resolve, reject) => { + resolve(service.get(url, data)) + }) + }, + // 获取首页分类 getCategories(data) { const url = `/home/classlist` return new Promise((resolve, reject) => { - resolve(service.get(url)) + resolve(service.get(url, data)) }) }, // 搜索发现 热搜 @@ -280,7 +263,7 @@ const apiService = { getProductList(data) { const url = `/home/product` return new Promise((resolve, reject) => { - resolve(service.get(url)) + resolve(service.get(url, data)) }) }, // 图片基本地址