wangfukang 1 month ago
parent
commit
4bea17cee4
  1. 6
      package2/myCenter/addGoods.vue
  2. 10
      package2/myCenter/attributeList.vue
  3. 57
      package2/myCenter/goodsList.vue

6
package2/myCenter/addGoods.vue

@ -255,6 +255,8 @@
this.formData.categoryId = this.typeItem.id this.formData.categoryId = this.typeItem.id
this.formData.categoryName = this.typeItem.categoryName this.formData.categoryName = this.typeItem.categoryName
this.syncSelectedCategory() this.syncSelectedCategory()
} else {
this.syncSelectedCategory()
} }
this.formData.shopId = uni.getStorageSync('shopId') this.formData.shopId = uni.getStorageSync('shopId')
}, },
@ -400,7 +402,7 @@
return value !== '' && value !== undefined && value !== null return value !== '' && value !== undefined && value !== null
}, },
hasSelectedTypeItem(item) { hasSelectedTypeItem(item) {
return item && this.hasCategoryValue(item.id) return item && this.hasCategoryValue(item.id) && this.hasCategoryValue(item.categoryName)
}, },
syncSelectedCategory() { syncSelectedCategory() {
if (this.hasCategoryValue(this.formData.categoryId)) { if (this.hasCategoryValue(this.formData.categoryId)) {
@ -891,7 +893,7 @@
goAttributeList(){ goAttributeList(){
this.$refs.addTypeDialog.close() this.$refs.addTypeDialog.close()
uni.navigateTo({ uni.navigateTo({
url: '/package2/myCenter/attributeList' url: '/package2/myCenter/attributeList?from=addGoods'
}) })
}, },
async upLoadFile(path) { async upLoadFile(path) {

10
package2/myCenter/attributeList.vue

@ -331,7 +331,8 @@
attrId:'', attrId:'',
valueEditId:'', valueEditId:'',
isEdieValue:false, isEdieValue:false,
multipleList:[] multipleList:[],
fromPage:''
} }
}, },
computed: { computed: {
@ -354,6 +355,9 @@
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.getGategoryList() this.getGategoryList()
}, },
onLoad(option) {
this.fromPage = option.from || ''
},
methods: { methods: {
editValue(item){ editValue(item){
this.isEdieValue = true this.isEdieValue = true
@ -450,7 +454,9 @@
clickList(item) { clickList(item) {
let pages = getCurrentPages(); let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; let prevPage = pages[pages.length - 2];
prevPage.$vm.typeItem = item if (this.fromPage != 'addGoods') {
prevPage.$vm.typeItem = item
}
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1
}) })

57
package2/myCenter/goodsList.vue

@ -188,14 +188,26 @@
}, },
filters: { filters: {
sliceMsg(val) { sliceMsg(val) {
var name = '' if (!val) return '0'
let priceList = val
if (typeof(val) == 'string') { if (typeof(val) == 'string') {
let newObj = JSON.parse(val) try {
for (let as in newObj) { priceList = JSON.parse(val)
name = newObj[as].specPrice } 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() { onShow() {
@ -353,6 +365,23 @@
url:url 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) { getShareList(type) {
let data = {} let data = {}
@ -377,12 +406,16 @@
pageSize: isRecommend ? '1000' : '10' pageSize: isRecommend ? '1000' : '10'
} }
} }
let that = this
this.tui.request("/app/product/getShareList", "POST", data, false, false).then((res) => { this.tui.request("/app/product/getShareList", "POST", data, false, false).then((res) => {
if (res.code == 200) { if (res.code == 200) {
const records = res.result.records || [] const page = this.normalizeProductPage(res.result)
const goodsList = isRecommend ? records.filter(item => item.isPush == 1) : records const goodsList = (isRecommend ? page.records.filter(item => item.isPush == 1) : page.records).filter(item => item && typeof(item) == 'object').map(item => {
this.pages = isRecommend ? 1 : (res.result.pages || 1) return {
...item,
isShow: false
}
})
this.pages = isRecommend ? 1 : page.pages
if (type == 'search') { if (type == 'search') {
this.shopList = [] this.shopList = []
if (this.pageNum == 1) { if (this.pageNum == 1) {
@ -390,9 +423,6 @@
} else { } else {
this.shopList1 = [...this.shopList1, ...goodsList] this.shopList1 = [...this.shopList1, ...goodsList]
} }
for(let i=0;i<this.shopList1.length;i++){
this.shopList1[i].isShow = false
}
} else { } else {
this.shopList1 = [] this.shopList1 = []
if (this.pageNum == 1) { if (this.pageNum == 1) {
@ -400,9 +430,6 @@
} else { } else {
this.shopList = [...this.shopList, ...goodsList] this.shopList = [...this.shopList, ...goodsList]
} }
for(let i=0;i<this.shopList.length;i++){
this.shopList[i].isShow = false
}
} }
this.status = this.pageNum >= this.pages ? 'nomore' : 'loadmore' this.status = this.pageNum >= this.pages ? 'nomore' : 'loadmore'
} else { } else {

Loading…
Cancel
Save