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.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) {

10
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
})

57
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.shopList1.length;i++){
this.shopList1[i].isShow = false
}
} else {
this.shopList1 = []
if (this.pageNum == 1) {
@ -400,9 +430,6 @@
} else {
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'
} else {

Loading…
Cancel
Save