Commit 2111a3e7 by 张立顺

fix 功能回显统一

1 parent 7231537c
// packageIndex/pages/salesSummary/salesSummary.js
import IndexApi from '~/api/index/index'
import { tsFormatTime } from '~/utils/format'
function formatYMDHM(val) {
if (!val) return '-'
const d = new Date(val)
if (isNaN(d.getTime())) return '-'
const yyyy = d.getFullYear()
const MM = String(d.getMonth() + 1).padStart(2, '0')
const DD = String(d.getDate()).padStart(2, '0')
const HH = String(d.getHours()).padStart(2, '0')
const mm = String(d.getMinutes()).padStart(2, '0')
return `${yyyy}-${MM}-${DD} ${HH}:${mm}`
}
// dayjs(infoDetail.expectedOperationDate).format('YYYY-MM-DD')
const app = getApp()
Page({
......@@ -30,8 +41,13 @@ Page({
console.log(res)
res.data = res.data.map(item => ({
...item,
// 保留原字段以兼容其它使用场景
lastFollowUpTime: item.lastFollowUpTime
? tsFormatTime(item.lastFollowUpTime)
? formatYMDHM(item.lastFollowUpTime)
: '-',
// 新增格式化字段,供 WXML 使用
lastFollowUpTimeFormatted: item.lastFollowUpTime
? formatYMDHM(item.lastFollowUpTime)
: '-'
}))
this.setData({
......@@ -82,7 +98,7 @@ Page({
// 跳转查看某个销售人员的潜客/门店数据
goCustomer(e) {
let { item } = e.currentTarget.dataset
app.setTabParams('customerObj', {itemParams: item})
app.setTabParams('customerObj', { itemParams: item })
wx.switchTab({
url: `/pages/tab/customer/customer`
})
......@@ -95,7 +111,9 @@ Page({
// 兼容潜客详情页面参数
target.id = target.potentialCustomerId
wx.navigateTo({
url: `/packageCustomer/pages/potentialDetail/potentialDetail?query=${encodeURIComponent(JSON.stringify(target))}`
url: `/packageCustomer/pages/potentialDetail/potentialDetail?query=${encodeURIComponent(
JSON.stringify(target)
)}`
})
},
......
......@@ -52,7 +52,7 @@
</view>
<view class="item last">
<view class="label">最后跟进</view>
<view class="content">{{item.lastFollowUpTime||'-'}}</view>
<view class="content">{{item.lastFollowUpTimeFormatted||'-'}}</view>
</view>
</view>
</view>
......
// packageIndex/pages/salesSummary/salesSummary.js
import IndexApi from '~/api/index/index'
import { tsFormatTime } from '~/utils/format'
function formatYMDHM(val) {
if (!val) return '-'
const d = new Date(val)
if (isNaN(d.getTime())) return '-'
const yyyy = d.getFullYear()
const MM = String(d.getMonth() + 1).padStart(2, '0')
const DD = String(d.getDate()).padStart(2, '0')
const HH = String(d.getHours()).padStart(2, '0')
const mm = String(d.getMinutes()).padStart(2, '0')
return `${yyyy}-${MM}-${DD} ${HH}:${mm}`
}
Page({
/**
* 页面的初始数据
......@@ -34,18 +46,37 @@ Page({
}
IndexApi.getWarningStores(params).then(res => {
console.log(res, 'res')
let { backstopWarningCount, lostShopWarningCount, lossWarningCount, backstopWarningList = [], lostShopWarningList = [], lossWarningList = [] } =
res.data
let {
backstopWarningCount,
lostShopWarningCount,
lossWarningCount,
backstopWarningList = [],
lostShopWarningList = [],
lossWarningList = []
} = res.data
tabList[0].count = backstopWarningCount || 0
tabList[1].count = lostShopWarningCount || 0
tabList[2].count = lossWarningCount
const mapExpected = arr =>
Array.isArray(arr)
? arr.map(item => ({
...item,
expectedOperationDateFormatted: formatYMDHM(
item.expectedOperationDate
),
signedTimeFormatted: formatYMDHM(item.signedTime)
}))
: []
const _backstop = mapExpected(backstopWarningList)
const _lostShop = mapExpected(lostShopWarningList)
const _loss = mapExpected(lossWarningList)
// list 根据
this.setData({
tabList,
backstopWarningList,
lostShopWarningList,
lossWarningList,
list: backstopWarningList || []
backstopWarningList: _backstop,
lostShopWarningList: _lostShop,
lossWarningList: _loss,
list: _backstop || []
})
})
},
......@@ -91,8 +122,8 @@ Page({
e.detail == 0
? backstopWarningList
: e.detail == 1
? lostShopWarningList
: lossWarningList
? lostShopWarningList
: lossWarningList
this.setData({
activeIndex: e.detail,
list: list || []
......@@ -120,40 +151,40 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) { },
onLoad(options) {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() { },
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() { },
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() { },
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() { },
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() { },
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() { },
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() { }
onShareAppMessage() {}
})
......@@ -28,7 +28,7 @@
</view>
<view class="item">
<view class="label person">签约时间</view>
<view class="content">{{item.signedTime||'-'}}</view>
<view class="content">{{item.signedTimeFormatted||'-'}}</view>
</view>
<view class="item">
<view class="label person">展业时间</view>
......
......@@ -149,7 +149,9 @@ export function centsToyuan(price) {
export function setPrice(price) {
let [num, decimal] = price.toString().split('.')
if (!decimal) decimal = '00'
return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + `.${decimal}`
return (
(num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + `.${decimal}`
)
}
export function deleteSecond(time) {
......@@ -202,23 +204,26 @@ export function tsFormatTime(timestamp, format) {
* 返回值:arg1乘以 arg2的精确结果
**/
export const accMul = (arg1, arg2) => {
if (isNaN(arg1)) {
arg1 = 0;
}
if (isNaN(arg2)) {
arg2 = 0;
}
arg1 = Number(arg1);
arg2 = Number(arg2);
var m = 0,
s1 = arg1.toString(),
s2 = arg2.toString();
try {
m += s1.split(".")[1].length;
} catch (e) { }
try {
m += s2.split(".")[1].length;
} catch (e) { }
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
};
\ No newline at end of file
if (isNaN(arg1)) {
arg1 = 0
}
if (isNaN(arg2)) {
arg2 = 0
}
arg1 = Number(arg1)
arg2 = Number(arg2)
var m = 0,
s1 = arg1.toString(),
s2 = arg2.toString()
try {
m += s1.split('.')[1].length
} catch (e) {}
try {
m += s2.split('.')[1].length
} catch (e) {}
return (
(Number(s1.replace('.', '')) * Number(s2.replace('.', ''))) /
Math.pow(10, m)
)
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!