diff --git a/package2/myCenter/addGoods.vue b/package2/myCenter/addGoods.vue index b76c634..49d7138 100644 --- a/package2/myCenter/addGoods.vue +++ b/package2/myCenter/addGoods.vue @@ -255,6 +255,8 @@ this.formData.categoryId = this.typeItem.id this.formData.categoryName = this.typeItem.categoryName this.syncSelectedCategory() + } else { + this.syncSelectedCategory() } this.formData.shopId = uni.getStorageSync('shopId') }, @@ -400,7 +402,7 @@ return value !== '' && value !== undefined && value !== null }, hasSelectedTypeItem(item) { - return item && this.hasCategoryValue(item.id) + return item && this.hasCategoryValue(item.id) && this.hasCategoryValue(item.categoryName) }, syncSelectedCategory() { if (this.hasCategoryValue(this.formData.categoryId)) { @@ -891,7 +893,7 @@ goAttributeList(){ this.$refs.addTypeDialog.close() uni.navigateTo({ - url: '/package2/myCenter/attributeList' + url: '/package2/myCenter/attributeList?from=addGoods' }) }, async upLoadFile(path) { diff --git a/package2/myCenter/attributeList.vue b/package2/myCenter/attributeList.vue index 4de8029..d3a2a3d 100644 --- a/package2/myCenter/attributeList.vue +++ b/package2/myCenter/attributeList.vue @@ -331,7 +331,8 @@ attrId:'', valueEditId:'', isEdieValue:false, - multipleList:[] + multipleList:[], + fromPage:'' } }, computed: { @@ -354,6 +355,9 @@ this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() this.getGategoryList() }, + onLoad(option) { + this.fromPage = option.from || '' + }, methods: { editValue(item){ this.isEdieValue = true @@ -450,7 +454,9 @@ clickList(item) { let pages = getCurrentPages(); let prevPage = pages[pages.length - 2]; - prevPage.$vm.typeItem = item + if (this.fromPage != 'addGoods') { + prevPage.$vm.typeItem = item + } uni.navigateBack({ delta: 1 }) diff --git a/package2/myCenter/goodsList.vue b/package2/myCenter/goodsList.vue index c90efd9..b33bfca 100644 --- a/package2/myCenter/goodsList.vue +++ b/package2/myCenter/goodsList.vue @@ -188,14 +188,26 @@ }, filters: { sliceMsg(val) { - var name = '' + if (!val) return '0' + let priceList = val if (typeof(val) == 'string') { - let newObj = JSON.parse(val) - for (let as in newObj) { - name = newObj[as].specPrice + try { + priceList = JSON.parse(val) + } catch (e) { + return '0' } } - return name; + if (Array.isArray(priceList)) { + const firstPrice = priceList[0] || {} + return firstPrice.specPrice != null && firstPrice.specPrice !== '' ? firstPrice.specPrice : '0' + } + if (typeof(priceList) == 'object') { + for (let as in priceList) { + const item = priceList[as] || {} + return item.specPrice != null && item.specPrice !== '' ? item.specPrice : '0' + } + } + return '0'; }, }, onShow() { @@ -353,6 +365,23 @@ url:url }) }, + normalizeProductPage(result) { + let page = result || {} + if (page.data && typeof(page.data) == 'object') { + page = page.data + } + if (Array.isArray(page)) { + return { + records: page, + pages: 1 + } + } + const records = page.records || page.list || page.content || page.rows || [] + return { + records: Array.isArray(records) ? records : [], + pages: page.pages || page.totalPage || page.totalPages || 1 + } + }, //点击分类获取商品列表 getShareList(type) { let data = {} @@ -377,12 +406,16 @@ pageSize: isRecommend ? '1000' : '10' } } - let that = this this.tui.request("/app/product/getShareList", "POST", data, false, false).then((res) => { if (res.code == 200) { - const records = res.result.records || [] - const goodsList = isRecommend ? records.filter(item => item.isPush == 1) : records - this.pages = isRecommend ? 1 : (res.result.pages || 1) + const page = this.normalizeProductPage(res.result) + const goodsList = (isRecommend ? page.records.filter(item => item.isPush == 1) : page.records).filter(item => item && typeof(item) == 'object').map(item => { + return { + ...item, + isShow: false + } + }) + this.pages = isRecommend ? 1 : page.pages if (type == 'search') { this.shopList = [] if (this.pageNum == 1) { @@ -390,9 +423,6 @@ } else { this.shopList1 = [...this.shopList1, ...goodsList] } - for(let i=0;i= this.pages ? 'nomore' : 'loadmore' } else {