Commit 9ef9235f by chenwq

汇总-产值

1 parent 08d7928b
......@@ -10,7 +10,7 @@ Component({
type: Object,
value: () => { },
observer(n) {
this.dealStaffList()
n && this.dealStaffList()
}
},
},
......@@ -25,10 +25,10 @@ Component({
name: 'totalNum'
}, {
label: '总订单',
name: 'totalAmount'
name: 'totalOrderCount'
}, {
label: '成交金额',
name: 'totalOrderCount',
name: 'totalAmount',
prefix: '¥'
}],
merchantFormList: [{
......@@ -77,7 +77,7 @@ Component({
methods: {
dealStaffList() {
var list = this.data.orderObj
list && list.activityList.forEach(item => {
list && list.activityList?.forEach(item => {
// 0-未开始;1-活动中;2-已结束
let sliceNum = item.actStatus == 2 ? 3 : 10
item.showStaffList = item.staffList.length > sliceNum ? item.staffList.slice(0, sliceNum) : item.staffList
......
......@@ -74,7 +74,6 @@ Page({
},
setCurActivity() {
console.log(this.data.activityActive)
this.setData({
activityList: JSON.parse(JSON.stringify(this.data.sceneActivityObj['scene' + (this.data.sceneActive)]))
})
......@@ -95,7 +94,6 @@ Page({
['searchForm.scene' + this.data.sceneActive + 'Idx']: res.tapIndex
})
this.data.sceneActive != 4 ? this.getCustomerDetail() : this.getActivityRevenue()
console.log('调接口---')
}
})
},
......@@ -110,24 +108,31 @@ Page({
wx.$router.go('packageOutput.openBusiness', params)
},
getSceneProStatus(sceneCode) {
getSceneProStatus(sceneCode, isFirst = false) {
var params = {
serviceMerchantId: this.data.merchantInfo.pMerchantId,
merchant4sId: this.data.merchantInfo.merchantId,
sceneCode: sceneCode
}
outputApi.getSceneProStatus(params).then(res => {
var proList = res.find(item => item.sceneCode == sceneCode)
// var proList = res.find(item => item.sceneCode == sceneCode)
// 删---
// proList.productList[1].productStatus = 2
this.setData({
['sceneActivityObj.scene' + this.data.sceneActive]: proList.productList
['sceneActivityObj.scene1']: res[0].productList,
['sceneActivityObj.scene2']: res[1].productList,
['sceneActivityObj.scene3']: res[2].productList,
['sceneActivityObj.scene4']: res[3].productList
})
if ([2, 3].includes(+this.data.sceneActive)) {
this.getCustomerDetail()
} else if (this.data.sceneActive == 4) {
this.getActivityRevenue()
} else {
if (isFirst) {
this.getCustomerDetail(isFirst)
this.getActivityRevenue(isFirst)
}
this.setCurActivity()
}
})
......@@ -157,15 +162,14 @@ Page({
/** 1.1和1.2场景产品数据处理
* 调同一个接口,返回两个服务下面的全部产品的数据
*/
getCustomerDetail() {
getCustomerDetail(isFirst = false) {
var params = this.dealSearchTime()
outputApi.getCustomerDetail({ merchantId: this.data.merchantInfo.merchantId, ...params }).then(res => {
var actList = this.data.sceneActivityObj['scene' + this.data.sceneActive]
var actList = this.data.sceneActivityObj['scene' + (isFirst ? 2 : this.data.sceneActive)]
var actCodeList = actList.map(item => item.productCode)
console.log(actCodeList)
var curTotal = 0
var otherTotal = 0
var otherScene = this.data.sceneActive == 2 ? 3 : 2
var otherScene = isFirst ? 2 : (this.data.sceneActive == 2 ? 3 : 2)
res.forEach(item => {
var idx = actCodeList.findIndex(i => i == item.productCode)
if (idx != -1) {
......@@ -184,14 +188,17 @@ Page({
otherTotal = otherTotal + (item.orderTotal?.totalSubOrderOrderMoney || 0)
}
})
if (!isFirst) {
this.setData({
['sceneActivityObj.scene' + this.data.sceneActive]: actList
})
}
// 总金额
this.setData({
['sceneActivityObj.scene' + this.data.sceneActive]: actList,
['scenePriceList[' + (this.data.sceneActive - 1) + '].total']: curTotal,
['scenePriceList[' + (otherScene - 1) + '].total']: otherTotal
['scenePriceList[' + (isFirst ? 1 : (this.data.sceneActive - 1)) + '].total']: curTotal,
['scenePriceList[' + (isFirst ? 2 : (otherScene - 1)) + '].total']: otherTotal
})
console.log(this.data.sceneActivityObj['scene' + this.data.sceneActive])
this.setCurActivity()
!isFirst && this.setCurActivity()
})
},
......@@ -218,13 +225,17 @@ Page({
},
/** 查询场景4的产值 */
getActivityRevenue() {
wx.showLoading()
getActivityRevenue(isFirst = false) {
!isFirst && wx.showLoading()
var params = this.dealSearchStatus()
outputApi.getActivityRevenue({ merchantId: this.data.merchantInfo.merchantId, ...params }).then(res => {
// console.log(res)
// console.log(this.data.sceneActivityObj, '++++++')
var actList = this.data.sceneActivityObj['scene' + this.data.sceneActive]
var actList = this.data.sceneActivityObj['scene' + (isFirst ? 4 : this.data.sceneActive)]
var total = 0
res.forEach(item => {
total = total + item.totalAmount
})
actList.forEach((item, idx) => {
var curItem = res.find(k => k.goodsCategoryCode == item.productCode)
if (curItem) {
......@@ -270,12 +281,19 @@ Page({
}
})
actList[idx].outputData = curItem
} else {
actList[idx].outputData = []
}
})
if (!isFirst) {
this.setData({
['sceneActivityObj.scene' + this.data.sceneActive]: actList
})
}
this.setData({
['sceneActivityObj.scene' + this.data.sceneActive]: actList
['scenePriceList[3].total']: total
})
this.setCurActivity()
!isFirst && this.setCurActivity()
}).finally(() => {
wx.hideLoading()
})
......@@ -295,8 +313,8 @@ Page({
// },
// sceneCodeList: ['SC001', 'SC002', 'SC003', 'SC004']
// })
// this.getSceneProStatus(this.data.sceneCodeList[this.data.sceneActive - 1])
this.getSceneProStatus(this.data.sceneCodeList[this.data.sceneActive - 1])
wx.$router.getData(obj => {
var scene = {}
Object.keys(this.data.sceneObj).forEach(item => {
......@@ -308,7 +326,7 @@ Page({
sceneCodeList: obj.sceneCodeList
})
this.getSceneProStatus(this.data.sceneCodeList[this.data.sceneActive - 1])
this.getSceneProStatus(this.data.sceneCodeList[this.data.sceneActive - 1], true)
})
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!