diff --git a/api/cloud_warehouse.js b/api/cloud_warehouse.js index f3726de..87e43cc 100644 --- a/api/cloud_warehouse.js +++ b/api/cloud_warehouse.js @@ -26,4 +26,12 @@ export function getProportion(data) { */ export function goodsList(data) { return request.get("product/spu/merchant/" + data.mer_id, data); +} + +/** + * 里海云仓商品列表 + * @param + */ +export function getStorageList(data) { + return request.get("product/spu/lst", data); } \ No newline at end of file diff --git a/pages/cloud_warehouse/big_classification/index.vue b/pages/cloud_warehouse/big_classification/index.vue index 6889762..7dae72f 100644 --- a/pages/cloud_warehouse/big_classification/index.vue +++ b/pages/cloud_warehouse/big_classification/index.vue @@ -38,7 +38,10 @@ } from "@/api/cloud_warehouse.js"; import { getCategoryListLevel - } from '@/api/requesta.js' + } from '@/api/requesta.js'; + import { + ENV + } from "@/config/app.js"; export default { data() { return { @@ -62,9 +65,7 @@ uni.showLoading({ title: "加载中..." }) - getCategoryListLevel({ - type: 2 - }).then(res => { + getCategory(ENV == 'prod' ? 259 : 244).then(res => { uni.hideLoading(); this.list = res.data; }).catch(() => { @@ -81,10 +82,16 @@ // 小分类 goSmallType(e) { - uni.setStorageSync("market_type_parent", e); - uni.navigateTo({ - url: `/pages/cloud_warehouse/small_classification/index?type_id=${this.type_id}&townName=${this.town_name}&street_id=${this.street_id}` - }) + if (e.children) { + uni.setStorageSync("market_type_parent", e); + uni.navigateTo({ + url: `/pages/cloud_warehouse/small_classification/index` + }) + } else { + this.$util.Tips({ + title: "暂无商品!" + }); + } } } } diff --git a/pages/cloud_warehouse/small_classification/index.vue b/pages/cloud_warehouse/small_classification/index.vue index 7c12fff..341fcad 100644 --- a/pages/cloud_warehouse/small_classification/index.vue +++ b/pages/cloud_warehouse/small_classification/index.vue @@ -5,22 +5,16 @@ - - + + - + - - {{street||'定位中'}} - - @@ -35,13 +29,12 @@ {{item.cate_name}} + :class="{'left-panel_item_active':storeParam.mer_cate_id == item.store_category_id}">{{item.cate_name}} - @@ -73,7 +66,7 @@ - + 1 {{item.product.store_name}} {{item.product.store_info}} @@ -186,7 +179,8 @@ Toast } from '../../../libs/uniApi'; import { - getProportion + getProportion, + getStorageList } from "@/api/cloud_warehouse.js"; const app = getApp(); export default { @@ -255,7 +249,8 @@ type_id: '', street_id: '', is_recommend: false, // 是否为推荐的参数 - deduction_rate: '' + deduction_rate: '', + mer_cate_id: '' }, storeKey: 0, storeScroll: true, @@ -290,34 +285,24 @@ }; }, async onLoad(options) { - this.street_id = options.street_id - this.street = options.townName this.product_type = options.product_type ?? 0 if (this.$store.state.storage?.location?.lat) { this.latitude = this.$store.state.storage.location.lat; this.longitude = this.$store.state.storage.location.long; } - if (options.street_id != undefined) { - this.storeParam.street_id = options.street_id - } + this.credit_buy = options.credit_buy - this.storeParam.type_id = options.type_id - this.storeParam.type_id = options.type_id && options.type_id.split(',').toString() || '' this.storeParam.category_id = options.cate_id && options.cate_id.split(',').toString() || '' this.storeList = []; this.showLoading = true; - await this.getCloundShop(); - if (this.mer_location == 1) { - this.selfLocation() - } - this.getStoreType(); - this.Area() // 左侧 // 初始化查询第一个 const sideMenuType = uni.getStorageSync("market_type_parent"); this.sideMenuType = sideMenuType; if (sideMenuType && sideMenuType.children && sideMenuType.children.length > 0) - this.storeParam.category_id = this.sideMenuType.children[0].store_category_id; + this.storeParam.mer_cate_id = this.sideMenuType.children[0].store_category_id; + // 初始化 + this.getStoreList(); //初始化左侧类型高度 this.initHeight(); @@ -347,33 +332,6 @@ }, mapGetters(['viewColor', 'keyColor'])), }, methods: { - async getCloundShop() { - const { - data - } = await getCategoryListLevel({ - type: 2 - }) - this.cloudList = data; - this.cloudList.unshift({ - cate_name: '全部', - children: [], - pic: "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/de2be202312151001024597.png", - store_category_id: -1 - }) - this.cloudList.forEach((item) => { - item.children.unshift({ - cate_name: '全部', - store_category_id: item.store_category_id, - }); - }) - this.merchant = this.cloudList[0]; - this.merchantTow = this.merchant?.children[0]; - this.storeParam.category_id = this.merchantTow.store_category_id; - return null; - }, - selectLocation() { - this.isSelectPlace ? this.showPicker = true : '' - }, confirm(e) { this.showPicker = false this.$emit('selectPlce', e) @@ -387,6 +345,7 @@ this.street_id = e.value[1].code this.getStoreList() }, + changeHandler(e) { const { columnIndex, @@ -403,27 +362,7 @@ }); } }, - Area() { - getArea({ - city_code: 510500 - }).then(res => { - this.$refs.uPicker.setColumnValues(0, res.data); - this.Street(res.data[0]['code']); - }); - }, - Street(code) { - getStreet({ - area_code: code - }).then(res => { - this.$refs.uPicker.setColumnValues(1, res.data); - }); - }, - - onInputConfirm() { - this.showSerch = false - this.searchSubmit() - }, // 对象转数组 objToArr(data) { let obj = Object.keys(data).sort(); @@ -443,186 +382,6 @@ }) }, - // 获取商户分类 - getClassfication: function() { - let temp = [] - merClassifly() - .then(res => { - temp = res.data.map(item => { - return { - ...item, - check: false - } - }) - if (this.storeParam.category_id.length > 0) { - this.storeParam.category_id.forEach((ids, index) => { - temp.forEach(el => { - if (ids == el.category_id) { - el.check = true - } - }) - }) - } - this.merList = temp - }) - .catch(res => { - this.$util.Tips({ - title: res - }); - }); - }, - - // 获取店铺类型 - getStoreType: function() { - let temp = [] - getStoreTypeApi().then(res => { - res.data.forEach(item => { - if (item.mer_type_id == this.storeParam.type_id) { - temp.push({ - ...item, - check: true - }) - } - }) - this.storeTypeArr = temp - }) - .catch(res => { - this.$util.Tips({ - title: res - }); - }); - }, - /** 打开地图**/ - showMaoLocation(lat, long) { - if (!lat || !long) return this.$util.Tips({ - title: '请设置允许商城访问您的位置!' - }); - //#ifdef H5 - if (this.$wechat.isWeixin() === true) { - this.$wechat.seeLocation({ - latitude: Number(lat), - longitude: Number(long), - name: '当前位置', - address: this.location_address - }).then(res => { - // console.log('success'); - }) - } else { - //#endif - uni.openLocation({ - latitude: parseFloat(lat), - longitude: parseFloat(long), - name: '当前位置', - address: this.location_address, - scale: 8, - success: function(res) { - // console.log(res) - }, - }); - // #ifdef H5 - } - //#endif - }, - showStoreLocation(item) { - if (!item.lat || !item.long) return this.$util.Tips({ - title: '请设置允许商城访问您的位置!' - }); - //#ifdef H5 - if (this.$wechat.isWeixin() === true) { - this.$wechat.seeLocation({ - latitude: Number(item.lat), - longitude: Number(item.long), - name: item.mer_name, - address: item.mer_address ? item.mer_address : '', - }).then(res => { - // console.log('success'); - }) - } else { - //#endif - uni.openLocation({ - latitude: parseFloat(item.lat), - longitude: parseFloat(item.long), - scale: 8, - name: item.mer_name, - address: item.mer_address ? item.mer_address : '', - success: function(res) { - // console.log(res) - }, - }); - // #ifdef H5 - } - //#endif - }, - selfLocation() { - let self = this - if (uni.getStorageSync('RejectTarget')) { - this.getStoreList(); - return; - } - if (this.$store?.state?.storage?.location?.lat) { - this.latitude = this.$store?.state?.storage?.location?.lat; - this.longitude = this.$store?.state?.storage?.location?.long; - getGeocoder({ - lat: this.latitude, - long: this.longitude - }).then(res => { - // console.log(res) - this.detaile_address = res.data.address; - this.location_address = res.data.address; - this.recommend_address = res.data.address.length > 4 ? res.data.address - .slice(0, 4) + '...' : - res.data.address; - this.getStoreList(); - }).catch(err => { - uni.showToast({ - title: err, - icon: 'none' - }) - this.getStoreList(); - }) - } else uni.getLocation({ - type: 'wgs84', - success: (res) => { - res = wgsToGcj(res); - console.log('定位'); - let latitude, longitude; - latitude = res.latitude.toString(); - longitude = res.longitude.toString(); - this.latitude = res.latitude.toFixed(6); - this.longitude = res.longitude.toFixed(6); - this.$store.commit('setLocation', { - lat: res.latitude.toFixed(6), - long: res.longitude.toFixed(6), - }); - getGeocoder({ - lat: latitude, - long: longitude - }).then(res => { - // console.log(res) - this.detaile_address = res.data.address; - this.location_address = res.data.address; - this.recommend_address = res.data.address.length > 4 ? res.data.address - .slice(0, 4) + '...' : - res.data.address - this.getStoreList(); - }).catch(err => { - uni.showToast({ - title: err, - icon: 'none' - }) - this.getStoreList(); - }) - }, - fail: (res) => { - uni.showToast({ - title: res, - icon: 'none', - duration: 1000 - }); - this.getStoreList(); - }, - }); - }, // 进店 goStore(id) { if (this.storeParam.type_id == 12) { @@ -637,6 +396,7 @@ } } }, + // 搜索 searchSubmit: function() { this.$set(this.storeParam, 'keyword', this.storeParam.keyword); @@ -664,9 +424,9 @@ // 点击商品二级分类 changeMerchantTow(item) { this.merchantTow = item; - this.storeParam.category_id = this.merchantTow.store_category_id; + this.storeParam.mer_cate_id = this.merchantTow.store_category_id; this.storeParam.page = 1; - this.getStoreList() + this.getStoreList('') }, // 商品列表 @@ -678,17 +438,15 @@ this.goodsList = []; } let query = { - street_code: this.street_id, + mer_id: ENV == 'prod' ? 259 : 244, order: this.storeParam.order, keyword: this.storeParam.keyword, page: this.storeParam.page, - location: this.latitude + ',' + this.longitude, - deduction_rate: this.storeParam.deduction_rate + deduction_rate: this.storeParam.deduction_rate, + mer_cate_id: this.storeParam.mer_cate_id } - if (this.storeParam.category_id == -1) null; - else if (!this.merchantTow.pid) query.cate_pid = this.storeParam.category_id; // 全部是查询一级分类pid - else query.category_id = this.storeParam.category_id; // 否则查询二级分类 - townCloud(query).then(res => { + + getStorageList(query).then(res => { this.goodsList = [...this.goodsList, ...res.data.list] this.showLoading = false this.goodsList.forEach(item => { @@ -729,15 +487,18 @@ this.goodsNum = res.data[0].count }) }, + // 点击商品 clickProduct(data) { this.$refs.shortPopupRef.setDatas(data, this.goodsNum); this.$refs.shortPopupRef.open(); }, + // 点击全部 showAllRef() { this.$refs.allRef.open(); }, + changeAllRef(e) { this.allShow = e.show; }, @@ -749,30 +510,8 @@ // 获取规格名称 getSkuName(item) { - return Object.keys(item.sku).join('/') || null; - }, - - // 选择位置 - changeMap() { - uni.navigateTo({ - url: `/pages/select_address/select_address_n`, - success: () => { - uni.$once('changeAddress', (e) => { - this.street_id = e.street.code; - this.storeParam.street_id = this.street_id; - this.street = e.street.name; - if (e.longitude) { - this.longitude = e.longitude; - this.latitude = e.latitude; - this.$store.commit('setLocation', { - lat: e.latitude, - long: e.longitude, - }); - } - this.getStoreList(); - }) - } - }) + if (item.sku) + return Object.keys(item.sku).join('/') || null; }, // 比例 @@ -788,7 +527,6 @@ mer_id: ENV == 'prod' ? '259' : '244' }).then(res => { this.propotionData = res.data; - console.log(this.propotionData); }) },