Commit 8e13fe0c by chenwq

联调,接口封装改造

1 parent 7a9eea6b
......@@ -80,9 +80,10 @@ class outputApi {
/** 查询门店权益订单数据统计-车险升级活动产值 */
getEquityRevenue(data) {
return api.post({
method: 'scrm.api.busassistant.merchant.equity.statistics',
// method: 'scrm.api.busassistant.merchant.equity.statistics',
method: 'dj.api.smartcarlife.vd.quotation.merchant.statistics',
...data
})
}, false, 'dj')
}
/** 店面汇总-下载海报 */
......
......@@ -30,26 +30,27 @@ const formList = [{
const formObj = {
SC001: [{
label: '总单量',
name: 'totalCount'
}, {
label: '总产值',
name: 'totalAmount',
label: '营业额',
name: 'turnover',
prefix: '¥'
}, {
label: '当月单量',
name: 'monthCount'
label: '推荐客户量',
name: 'customerNum'
}, {
label: '当月产值',
name: 'monthAmount',
prefix: '¥'
label: '成交客户量',
name: 'successNum'
}, {
label: '转化率',
name: 'conversionRate'
label: '融合客单价',
name: 'fuseCustomerPrice',
prefix: '¥'
}, {
label: '单价',
name: 'price',
label: '权益客单价',
name: 'equityCustomerPrice',
prefix: '¥'
}, {
label: '转化率',
name: 'conversionRate',
suffix: '%'
}],
SC002: formList,
SC003: formList
......
......@@ -287,23 +287,30 @@ Page({
* 查询SC001场景值
*/
getEquityRevenue(isFirst = false) {
outputApi.getEquityRevenue({ merchantId: this.data.merchantInfo.merchantId }).then(res => {
// outputApi.getEquityRevenue({ merchantId: this.data.merchantInfo.merchantId }).then(res => {
// outputApi.getEquityRevenue({ merchantIds: [this.data.merchantInfo.merchantId] }).then(res => {
outputApi.getEquityRevenue({ merchantIds: ['44211227'] }).then(res => {
if (res.length) {
var actList = this.data.sceneActivityObj['scene' + this.findSceneIdx('SC001')]
var actCodeList = actList.map(item => item.productCode)
var total = 0
res.forEach(item => {
var idx = actCodeList.findIndex(i => i == item.productCode)
var orderTotal = item.orderTotal
if (item.orderTotal) {
total = (total + Number(item.orderTotal?.totalAmount)).toFixed(2)
item.orderTotal.totalAmount = utils.moneyThreeForTwoThousands(Number(orderTotal.totalAmount).toFixed(2))
item.orderTotal.monthAmount = Number(orderTotal.monthAmount).toFixed(2)
item.orderTotal.price = Number(orderTotal.price).toFixed(2)
}
res.forEach((item, idx) => {
// var idx = actCodeList.findIndex(i => i == item.productCode)
// var orderTotal = item.orderTotal
// if (item.orderTotal) {
// total = (total + Number(item.orderTotal?.totalAmount)).toFixed(2)
// item.orderTotal.totalAmount = utils.moneyThreeForTwoThousands(Number(orderTotal.totalAmount).toFixed(2))
// item.orderTotal.monthAmount = Number(orderTotal.monthAmount).toFixed(2)
// item.orderTotal.price = Number(orderTotal.price).toFixed(2)
// }
item.conversionRate = (item.conversionRate * 100).toFixed(0)
item.turnover = (item.turnover / 100).toFixed(2)
item.fuseCustomerPrice = (item.fuseCustomerPrice / 100).toFixed(2)
item.equityCustomerPrice = (item.equityCustomerPrice / 100).toFixed(2)
total = item.turnover
actList[idx] = {
...actList[idx],
orderTotal: item.orderTotal
orderTotal: res[idx]
}
})
if (!isFirst) {
......
......@@ -47,13 +47,13 @@ Component({
isNum: true
}, {
label: '到店贴膜量',
name: ''
name: 'toShopCount'
}, {
label: '升级订单',
name: ''
name: 'upgradeCount'
}, {
label: '战败订单',
name: ''
name: 'noUpgradeCount'
}, {
label: '转化率',
name: 'conversionRate'
......
......@@ -16,8 +16,8 @@ Component({
*/
data: {
busiOptSceneCode,
// tabActive: 'store',
tabActive: 'business',
tabActive: 'store',
// tabActive: 'business',
formData: {
// 0:全部-1;1:精品升级SC002;2:售后众筹SC004;3:会员权益/升级SC001
busiIdx: 0,
......
......@@ -27,7 +27,7 @@ Component({
},
totalPages: -1,
list: [],
tabActive: 'business',
tabActive: 'store',
// 业务经营汇总
merchantList: [],
formData: {
......@@ -110,7 +110,6 @@ Component({
totalAmount: data.totalAmount,
activityList: []
}
console.log(data, 'data----')
data?.merchantList.forEach(item => {
let _list = item?.merchantActivityRevenueDTO?.statistics || []
_list.forEach(n => {
......@@ -162,16 +161,27 @@ Component({
let params = {
...busiSearchData,
...sortSearchData,
// merchantIds: merchantList.map(item => item.merchantId)
merchantIds: ['44211227', '44211547', '10011000', '44184606', '44209535']
merchantIds: merchantList.map(item => item.merchantId)
// merchantIds: ['44211227', '44211547', '10011000', '44184606', '44209535']
}
console.log(params, 'params--')
outputApi.getBusiStatistics(params).then(res => {
this.resetBusiData()
// console.log(res, '汇总----')
if(isReset) {
this.setData({
busiScrollTop: 0,
triggered: false
})
}
if (formData.sceneCode == 'SC004') {
this.dealCrowdObj(res)
} else {
if(formData.sceneCode == 'SC002') {
res.merchantList.forEach(item => {
item.calUpPrice = Math.round(item.totalSubOrderOrderMoney / item.upgradeCount).toFixed(2)
})
}
this.setData({
busiObj: res,
busiTotalList: res.merchantList || []
......@@ -227,8 +237,12 @@ Component({
var list = this.data.list
list = list.concat(res.list)
list.forEach((item, index) => {
item.scenePriceList = []
item.sceneList.forEach((k, idx) => {
item['scene' + (idx + 1)] = item.sceneList[idx].flag
item.scenePriceList.push({
total: item.sceneList[idx].totalMoney || 0
})
})
item.isOpenScene = item.sceneList.map(item => item.flag).some(item => item == true)
})
......
......@@ -15,7 +15,7 @@
</view>
<!-- 场景内容 -->
<view class="box-content">
<scene-box sceneInfo="{{item}}" hasLockIcon="{{false}}" />
<scene-box sceneInfo="{{item}}" hasLockIcon="{{false}}" scenePriceList="{{item.scenePriceList}}" />
<!-- 通知 -->
<view class="box-bottom">
<view wx:if="{{item.msgList.length}}" class="flex">
......@@ -53,7 +53,7 @@
</view>
</view>
</scroll-view>
<scroll-view wx:if="{{tabActive == 'business'}}" class="client" scroll-y="{{true}}" refresher-enabled="{{true}}" refresher-triggered="{{triggered}}" bindrefresherrefresh="onBindRefresh" lower-threshold='50' scroll-top="{{busiScrollTop}}">
<scroll-view wx:if="{{tabActive == 'business'}}" class="client" scroll-y="{{true}}" refresher-enabled="{{true}}" refresher-triggered="{{triggered}}" bindrefresherrefresh="handleSort" lower-threshold='50' scroll-top="{{busiScrollTop}}">
<view class="client-box">
<!-- 总收益 -->
<view wx:if="{{formData.sceneCode != 'SC004'}}">
......@@ -66,12 +66,18 @@
<!-- 售后众筹 -->
<view wx:if="{{formData.sceneCode == 'SC004'}}">
<output-crowdfund wx:if="{{formData.sceneCode == 'SC004'}}" orderObj="{{crowdOrderObj}}"></output-crowdfund>
<view class="end-txt">
{{ crowdOrderObj.activityList.length ? '到底啦!' : '暂无数据' }}
</view>
</view>
<!-- 0:全部;1:精品升级;3:会员权益/升级 -->
<view wx:else>
<view wx:for="{{busiTotalList}}" wx:key="index">
<busi-card info="{{item}}" sceneCode="{{formData.sceneCode}}"></busi-card>
</view>
<view class="end-txt">
{{busiTotalList.length ? '到底啦!' : '暂无数据'}}
</view>
</view>
</view>
</scroll-view>
......
......@@ -79,35 +79,35 @@ Component({
prefix: '¥',
isNumber: true
}
],
tableHeadList: [
{
label: 'rankIdx',
width: '40rpx'
},
{
label: '业务员',
name: 'shareName'
},
{
label: '转发',
name: 'shareCount'
},
{
label: '浏览',
name: 'browseCount'
},
{
label: '成交',
name: 'dealCount',
width: '92rpx'
},
{
label: '产值',
name: 'totalAmount',
prefix: '¥'
}
]
// tableHeadList: [
// {
// label: 'rankIdx',
// width: '40rpx'
// },
// {
// label: '业务员',
// name: 'shareName'
// },
// {
// label: '转发',
// name: 'shareCount'
// },
// {
// label: '浏览',
// name: 'browseCount'
// },
// {
// label: '成交',
// name: 'dealCount',
// width: '92rpx'
// },
// {
// label: '产值',
// name: 'totalAmount',
// prefix: '¥'
// }
// ]
},
/**
......
import { secretKey, pathEnum, domain, sign } from './http.js'
import { secretKey, djSecretKey, pathEnum, domain, sign } from './http.js'
import { getSessionId } from '~/utils/cache/storageApi'
import network from '~/utils/network'
/**接口 */
class Request {
get(params, returnAll = false) {
return this.request('GET', params, returnAll)
get(params, returnAll = false, requestPath) {
return this.request('GET', params, returnAll, requestPath)
}
post(params, returnAll = false) {
return this.request('POST', params, returnAll)
post(params, returnAll = false, requestPath) {
return this.request('POST', params, returnAll, requestPath)
}
async request(RequestMethods, params, returnAll) {
async request(RequestMethods, params, returnAll, requestPath = 'scrm') {
const type = await network.getNetworkType()
if (type == 'none') return
return new Promise((resolve, reject) => {
......@@ -17,16 +17,16 @@ class Request {
let header =
RequestMethods === 'POST'
? {
'content-type': 'application/x-www-form-urlencoded'
}
'content-type': 'application/x-www-form-urlencoded'
}
: {}
let projectName = params.apiProjectName || this.getRopProject(params.method)
if (!projectName) projectName = this.getRopProject(params.method)
let path = pathEnum[projectName]
if (!path) path = `/rop-scrm-${projectName}/`
params = this.getData(params)
if (!path) path = requestPath == 'scrm' ? `/rop-scrm-${projectName}/` : `/rop-dj-${projectName}/`
params = this.getData(params, requestPath)
wx.request({
url: `${domain}${path}router?method=${params.method}`,
url: `${domain[requestPath]}${path}router?method=${params.method}`,
data: params,
method: RequestMethods,
header,
......@@ -82,16 +82,20 @@ class Request {
})
})
}
getData(params) {
getData(params, requestPath) {
let projectName = params.projectName
if (!projectName) projectName = this.getRopProject(params.method)
else delete params.projectName
let appKey = '48e5e13229b82c1b4e6e8c96151f0637'
let secret = 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
if (secretKey[projectName]) {
if (requestPath == 'scrm' && secretKey[projectName]) {
appKey = secretKey[projectName].appKey
secret = secretKey[projectName].secret
}
if(requestPath == 'dj') {
appKey = djSecretKey.appKey
secret = djSecretKey.secret
}
const sessionId = getSessionId()
let noSignAttr = []
if (!params.sessionId && sessionId) params.sessionId = sessionId
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!