Commit 2111a3e7 by 张立顺

fix 功能回显统一

1 parent 7231537c
// packageIndex/pages/salesSummary/salesSummary.js // packageIndex/pages/salesSummary/salesSummary.js
import IndexApi from '~/api/index/index' 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') // dayjs(infoDetail.expectedOperationDate).format('YYYY-MM-DD')
const app = getApp() const app = getApp()
Page({ Page({
...@@ -30,8 +41,13 @@ Page({ ...@@ -30,8 +41,13 @@ Page({
console.log(res) console.log(res)
res.data = res.data.map(item => ({ res.data = res.data.map(item => ({
...item, ...item,
// 保留原字段以兼容其它使用场景
lastFollowUpTime: item.lastFollowUpTime lastFollowUpTime: item.lastFollowUpTime
? tsFormatTime(item.lastFollowUpTime) ? formatYMDHM(item.lastFollowUpTime)
: '-',
// 新增格式化字段,供 WXML 使用
lastFollowUpTimeFormatted: item.lastFollowUpTime
? formatYMDHM(item.lastFollowUpTime)
: '-' : '-'
})) }))
this.setData({ this.setData({
...@@ -82,7 +98,7 @@ Page({ ...@@ -82,7 +98,7 @@ Page({
// 跳转查看某个销售人员的潜客/门店数据 // 跳转查看某个销售人员的潜客/门店数据
goCustomer(e) { goCustomer(e) {
let { item } = e.currentTarget.dataset let { item } = e.currentTarget.dataset
app.setTabParams('customerObj', {itemParams: item}) app.setTabParams('customerObj', { itemParams: item })
wx.switchTab({ wx.switchTab({
url: `/pages/tab/customer/customer` url: `/pages/tab/customer/customer`
}) })
...@@ -95,7 +111,9 @@ Page({ ...@@ -95,7 +111,9 @@ Page({
// 兼容潜客详情页面参数 // 兼容潜客详情页面参数
target.id = target.potentialCustomerId target.id = target.potentialCustomerId
wx.navigateTo({ 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 @@ ...@@ -52,7 +52,7 @@
</view> </view>
<view class="item last"> <view class="item last">
<view class="label">最后跟进</view> <view class="label">最后跟进</view>
<view class="content">{{item.lastFollowUpTime||'-'}}</view> <view class="content">{{item.lastFollowUpTimeFormatted||'-'}}</view>
</view> </view>
</view> </view>
</view> </view>
......
// packageIndex/pages/salesSummary/salesSummary.js // packageIndex/pages/salesSummary/salesSummary.js
import IndexApi from '~/api/index/index' import IndexApi from '~/api/index/index'
import { tsFormatTime } from '~/utils/format' 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({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -34,18 +46,37 @@ Page({ ...@@ -34,18 +46,37 @@ Page({
} }
IndexApi.getWarningStores(params).then(res => { IndexApi.getWarningStores(params).then(res => {
console.log(res, 'res') console.log(res, 'res')
let { backstopWarningCount, lostShopWarningCount, lossWarningCount, backstopWarningList = [], lostShopWarningList = [], lossWarningList = [] } = let {
res.data backstopWarningCount,
lostShopWarningCount,
lossWarningCount,
backstopWarningList = [],
lostShopWarningList = [],
lossWarningList = []
} = res.data
tabList[0].count = backstopWarningCount || 0 tabList[0].count = backstopWarningCount || 0
tabList[1].count = lostShopWarningCount || 0 tabList[1].count = lostShopWarningCount || 0
tabList[2].count = lossWarningCount 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 根据 // list 根据
this.setData({ this.setData({
tabList, tabList,
backstopWarningList, backstopWarningList: _backstop,
lostShopWarningList, lostShopWarningList: _lostShop,
lossWarningList, lossWarningList: _loss,
list: backstopWarningList || [] list: _backstop || []
}) })
}) })
}, },
...@@ -120,40 +151,40 @@ Page({ ...@@ -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 @@ ...@@ -28,7 +28,7 @@
</view> </view>
<view class="item"> <view class="item">
<view class="label person">签约时间</view> <view class="label person">签约时间</view>
<view class="content">{{item.signedTime||'-'}}</view> <view class="content">{{item.signedTimeFormatted||'-'}}</view>
</view> </view>
<view class="item"> <view class="item">
<view class="label person">展业时间</view> <view class="label person">展业时间</view>
......
...@@ -149,7 +149,9 @@ export function centsToyuan(price) { ...@@ -149,7 +149,9 @@ export function centsToyuan(price) {
export function setPrice(price) { export function setPrice(price) {
let [num, decimal] = price.toString().split('.') let [num, decimal] = price.toString().split('.')
if (!decimal) decimal = '00' 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) { export function deleteSecond(time) {
...@@ -203,22 +205,25 @@ export function tsFormatTime(timestamp, format) { ...@@ -203,22 +205,25 @@ export function tsFormatTime(timestamp, format) {
**/ **/
export const accMul = (arg1, arg2) => { export const accMul = (arg1, arg2) => {
if (isNaN(arg1)) { if (isNaN(arg1)) {
arg1 = 0; arg1 = 0
} }
if (isNaN(arg2)) { if (isNaN(arg2)) {
arg2 = 0; arg2 = 0
} }
arg1 = Number(arg1); arg1 = Number(arg1)
arg2 = Number(arg2); arg2 = Number(arg2)
var m = 0, var m = 0,
s1 = arg1.toString(), s1 = arg1.toString(),
s2 = arg2.toString(); s2 = arg2.toString()
try { try {
m += s1.split(".")[1].length; m += s1.split('.')[1].length
} catch (e) { } } catch (e) {}
try { 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 \ No newline at end of file
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!