diff --git a/packageSearch/goods-category-search/category-index.vue b/packageSearch/goods-category-search/category-index.vue index e86bdff..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,145 +219,126 @@ } ], 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, // 左边菜单的高度 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; @@ -389,7 +366,7 @@ } this.recentRecordList.unshift(param) }, - changeSelectedCategory(index) { + changeSelectedCategory(item, index) { this.$set(this.categoryList, this.selectedCategory, { ...this.categoryList[this.selectedCategory], active: false @@ -399,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) { @@ -416,6 +398,7 @@ } // 将菜单菜单活动item垂直居中 this.scrollTop = index * this.menuItemHeight + this.menuItemHeight / 2 - this.menuHeight / 2; + this.getTagList() }, // 获取一个目标元素的高度 getElRect(elClass, dataVal) { @@ -445,12 +428,67 @@ tabChange(selectTab) { console.log(selectTab) this.tabCurrent = selectTab.index; + this.getGoodsList() }, 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 + if (this.selectedCategory && this.selectedCategory === index) { + item.active = true + } else if (!this.selectedCategory && !index) { + item.active = true + } else { + item.active = false + } + return item + }) + 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() { uni.navigateBack() }, @@ -569,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; @@ -674,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/pages/ideasAndNeeds/ideasAndNeeds.vue b/pages/ideasAndNeeds/ideasAndNeeds.vue index 7fad0be..d504856 100644 --- a/pages/ideasAndNeeds/ideasAndNeeds.vue +++ b/pages/ideasAndNeeds/ideasAndNeeds.vue @@ -150,10 +150,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 e8e517d..16aa0b5 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -116,6 +116,7 @@ onLoad() { this.getCategories() this.getBanner() + this.getImgUrl() // this.$refs.getProducts.getProducts() }, @@ -170,7 +171,7 @@ }, fail: function(err) { - // 登录授权失败 + // 登录授权失败 // err.code是错误码 } }) @@ -180,6 +181,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 4c07bcc..22c98d9 100644 --- a/service/request.js +++ b/service/request.js @@ -1,3 +1,4 @@ + const serverHost = 'https://pupil.hchyun.com/api' // https://api-ugo-web.itheima.net' function isOutTime(res) { if (res.data.message === '请先登录') { @@ -181,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` @@ -237,23 +231,76 @@ 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` + return new Promise((resolve, reject) => { + 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, 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, data)) + }) + }, + // 图片基本地址 + getImgUrl() { + const url = `/center/cfg?key=img_url` + return new Promise((resolve, reject) => { + resolve(service.get(url)) + }) + }, + // 新增 + addOutboundOrder(data) { + const url = `/api` + return new Promise((resolve, reject) => { + resolve(service.post(url, data)) + }) + }, + // 提交 + deliveryOrderConfirm(data) { + const url = `/api` + return new Promise((resolve, reject) => { + resolve(service.post(url, data)) + }) + }, + // 解密 + 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)) + }) + } } export { apiService,