Commit ecbaa823 by Jaxon

style: 格式化

1 parent 825f7520
import api from '~/api/index/index'
import dayjs from 'dayjs'
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/'
import api from "~/api/index/index";
import dayjs from "dayjs";
const IMG_URL = "https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/";
Page({
/**
* 页面的初始数据
*/
data: {
/**
* 页面的初始数据
*/
data: {
IMG_URL,
navBarHeight: 84,
navStyle: 'background-color: rgba(0,0,0,0);',
navTitleStyle: 'font-weight: 600; font- size: 32rpx; color: #000;',
navStyle: "background-color: rgba(0,0,0,0);",
navTitleStyle: "font-weight: 600; font- size: 32rpx; color: #000;",
userInfo: {},
staticList: [{
label: '驻店人员',
width: '208',
key: 'staffCount',
background: 'linear-gradient(90deg, #42CCCF 0%, #36D9A5 100%)'
}, {
label: '门店数量',
width: '192',
key: 'shopCount',
background: 'linear-gradient(90deg, #5E69FF 0%, #4079FF 100%)'
}, {
label: '总产值',
key: 'totalValue',
background: 'linear-gradient(90deg, #3D76FC 0%, #4DA6FF 100%)'
}],
tabList: [{
text: '每日任务'
}, {
text: '本周任务'
}, {
text: '月度任务'
}, {
text: '专项任务'
}],
staticList: [
{
label: "驻店人员",
width: "208",
key: "staffCount",
background: "linear-gradient(90deg, #42CCCF 0%, #36D9A5 100%)",
},
{
label: "门店数量",
width: "192",
key: "shopCount",
background: "linear-gradient(90deg, #5E69FF 0%, #4079FF 100%)",
},
{
label: "总产值",
key: "totalValue",
background: "linear-gradient(90deg, #3D76FC 0%, #4DA6FF 100%)",
},
],
tabList: [
{
text: "每日任务",
},
{
text: "本周任务",
},
{
text: "月度任务",
},
{
text: "专项任务",
},
],
tabIndex: 0,
statusMap: {
0: {name: '待完成', color: '#2C66F7', background: '#2c66f71a'},
1: {name: '进行中', color: '#FF9D0A', background: '#ff9d0a1a'},
2: {name: '已完成', color: '#35C376', background: '#35c3761a'},
0: { name: "待完成", color: "#2C66F7", background: "#2c66f71a" },
1: { name: "进行中", color: "#FF9D0A", background: "#ff9d0a1a" },
2: { name: "已完成", color: "#35C376", background: "#35c3761a" },
},
missionMap: {
3: {name: '录音复盘'},
5: {name: '人员带教'},
0: {name: '督导日报'},
1: {name: '本周复盘'},
2: {name: '督导月度计划'},
4: {name: '专项任务'},
3: { name: "录音复盘" },
5: { name: "人员带教" },
0: { name: "督导日报" },
1: { name: "本周复盘" },
2: { name: "督导月度计划" },
4: { name: "专项任务" },
},
list: [],
scrollTop: 0
},
onTabItemTap(e) {
// 点击埋点
wx.$track.setTrackData(0, 'supervisor_index_page', {}, '')
},
navbarReady(e) {
let navBarHeight = e.detail.height
this.setData({
navBarHeight
})
scrollTop: 0,
},
onTabItemTap(e) {
// 点击埋点
wx.$track.setTrackData(0, "supervisor_index_page", {}, "");
},
navbarReady(e) {
let navBarHeight = e.detail.height;
this.setData({
navBarHeight,
});
},
onScroll(e) {
this.setData({
scrollTop: e.detail.scrollTop
})
const {navBarHeight} = this.data
const query = wx.createSelectorQuery().in(this)
query.select('.data-container').boundingClientRect()
query.exec(res => {
scrollTop: e.detail.scrollTop,
});
const { navBarHeight } = this.data;
const query = wx.createSelectorQuery().in(this);
query.select(".data-container").boundingClientRect();
query.exec((res) => {
this.setData({
isSticky: res[0].top <= navBarHeight
})
})
isSticky: res[0].top <= navBarHeight,
});
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let userInfo = wx.$util.getUserInfo()
this.setData({userInfo})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let userInfo = wx.$util.getUserInfo();
this.setData({ userInfo });
},
/**
* 生命周期函数--监听页面显示
*/
onShow () {
this.getStaticData()
this.setData({
list: [],
pageNum: 1,
flag: false,
nothing: false
}, () => {
this.getList(true)
})
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.getStaticData();
this.setData(
{
list: [],
pageNum: 1,
flag: false,
nothing: false,
},
() => {
this.getList(true);
},
);
},
formatThousands (v) {
const s = String(v)
if (!s) return s
const isNeg = s[0] === '-'
const raw = isNeg ? s.slice(1) : s
const [intPart, decPart] = raw.split('.')
const intFmt = String(intPart || '0').replace(/\B(?=(\d{3})+(?!\d))/g, ',')
const res = decPart ? `${intFmt}.${decPart}` : intFmt
return isNeg ? `-${res}` : res
formatThousands(v) {
const s = String(v);
if (!s) return s;
const isNeg = s[0] === "-";
const raw = isNeg ? s.slice(1) : s;
const [intPart, decPart] = raw.split(".");
const intFmt = String(intPart || "0").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
const res = decPart ? `${intFmt}.${decPart}` : intFmt;
return isNeg ? `-${res}` : res;
},
getStaticData() {
api.getSupervisorStaticData({}).then(res => {
let { code, data, message } = res
api.getSupervisorStaticData({}).then((res) => {
let { code, data, message } = res;
if (code == 0) {
data.staffCount = (data.staffCount ?? '') === '' ? '-' : this.formatThousands(data.staffCount)
data.shopCount = (data.shopCount ?? '') === '' ? '-' : this.formatThousands(data.shopCount)
data.totalValue = (data.totalValue ?? '') === '' ? '-' : this.formatThousands(data.totalValue)
this.setData({staticData: data})
data.staffCount = (data.staffCount ?? "") === "" ? "-" : this.formatThousands(data.staffCount);
data.shopCount = (data.shopCount ?? "") === "" ? "-" : this.formatThousands(data.shopCount);
data.totalValue = (data.totalValue ?? "") === "" ? "-" : this.formatThousands(data.totalValue);
this.setData({ staticData: data });
} else {
wx.$util.showToast(message)
wx.$util.showToast(message);
}
})
});
},
tabClick(e) {
let eventCode = ['supervisor_dayTask_tab', 'supervisor_weeklyTask_tab', 'supervisor_monthlyTask_tab', 'supervisor_specificTask_tab']
let eventCode = ["supervisor_dayTask_tab", "supervisor_weeklyTask_tab", "supervisor_monthlyTask_tab", "supervisor_specificTask_tab"];
// 点击埋点
wx.$track.setTrackData(0, eventCode[e.detail], {}, '')
wx.$track.setTrackData(0, eventCode[e.detail], {}, "");
this.setData({
tabIndex: e.detail
})
tabIndex: e.detail,
});
},
jump(e) {
const { target } = e.currentTarget.dataset
const { target } = e.currentTarget.dataset;
const pageUrl = {
3: '/packageIndex/pages/recordingReview/recordingReview',
5: '/packageCrew/pages/mentoring/mentoring',
0: '/packageIndex/pages/dailySupervisionReport/dailySupervisionReport',
1: '/packageIndex/pages/weeklyReview/weeklyReview',
2: '/packageIndex/pages/monthlyPlan/monthlyPlan',
4: '/packageIndex/pages/specialTask/specialTask'
}
3: "/packageIndex/pages/recordingReview/recordingReview",
5: "/packageCrew/pages/mentoring/mentoring",
0: "/packageIndex/pages/dailySupervisionReport/dailySupervisionReport",
1: "/packageIndex/pages/weeklyReview/weeklyReview",
2: "/packageIndex/pages/monthlyPlan/monthlyPlan",
4: "/packageIndex/pages/specialTask/specialTask",
};
const eventCode = {
3: {view: 'supervisor_recording_view', execute: 'supervisor_recording_execute'},
5: {view: 'supervisor_mentoring_view', execute: 'supervisor_mentoring_execute'},
0: {view: 'supervisor_report_view', execute: 'supervisor_report_execute'},
1: {view: 'supervisor_weeklyReview_view', execute: 'supervisor_weeklyReview_execute'},
2: {view: 'supervisor_monthlyPlan_view', execute: 'supervisor_monthlyPlan_execute'},
4: {view: 'supervisor_specificTask_view', execute: 'supervisor_specificTask_execute'},
}
let status = target.taskStatus != 2 ? 'execute' : 'view'
console.log(eventCode[target.taskType][status])
wx.$track.setTrackData(0, eventCode[target.taskType][status], {}, '')
3: { view: "supervisor_recording_view", execute: "supervisor_recording_execute" },
5: { view: "supervisor_mentoring_view", execute: "supervisor_mentoring_execute" },
0: { view: "supervisor_report_view", execute: "supervisor_report_execute" },
1: { view: "supervisor_weeklyReview_view", execute: "supervisor_weeklyReview_execute" },
2: { view: "supervisor_monthlyPlan_view", execute: "supervisor_monthlyPlan_execute" },
4: { view: "supervisor_specificTask_view", execute: "supervisor_specificTask_execute" },
};
let status = target.taskStatus != 2 ? "execute" : "view";
console.log(eventCode[target.taskType][status]);
wx.$track.setTrackData(0, eventCode[target.taskType][status], {}, "");
wx.navigateTo({
url: `${pageUrl[target.taskType]}?taskStatus=${target.taskStatus}&id=${target.id}`,
})
});
},
search(e) {
this.setData({
list: [],
pageNum: 1,
flag: false,
nothing: false,
startStr: e.detail.startDay?.replace(/\//g, '-'),
endStr: e.detail.endDay?.replace(/\//g, '-')
}, () => {
this.getList(true)
})
this.setData(
{
list: [],
pageNum: 1,
flag: false,
nothing: false,
startStr: e.detail.startDay?.replace(/\//g, "-"),
endStr: e.detail.endDay?.replace(/\//g, "-"),
},
() => {
this.getList(true);
},
);
},
scrollonReachBottom() {
this.getList()
},
this.getList();
},
// 获取列表数据
getList(repload) {
let { pageNum, nothing, startStr, endStr, tabIndex, topBoxHeight, scrollTop } = this.data
if (nothing) return
const taskList = [[0, 3, 5], [1], [2], [4]]
wx.$util.showLoading()
let params = {
taskTypeList: taskList[tabIndex],
startDate: startStr,
endDate: endStr,
pageNum,
pageSize: 10
}
api.getMissionList(params).then(res => {
wx.$util.hideLoading()
let total = 0
let list = []
let {
code,
data,
message
} = res
data?.list?.forEach(val => {
val.updatedDate = val.updatedDate ? dayjs(val.updatedDate).format('YYYY-MM-DD HH:mm:ss') : ''
val.createTime = val.createTime ? dayjs(val.createTime).format('YYYY-MM-DD HH:mm:ss') : ''
})
if (code == 0) {
list = data.list
total = data.total
} else {
wx.$util.showToast(message)
}
if (total != 0) {
this.setData({
[`list[${pageNum - 1}]`]: list
})
getList(repload) {
let { pageNum, nothing, startStr, endStr, tabIndex, topBoxHeight, scrollTop } = this.data;
if (nothing) return;
const taskList = [[0, 3, 5], [1], [2], [4]];
wx.$util.showLoading();
let params = {
taskTypeList: taskList[tabIndex],
startDate: startStr,
endDate: endStr,
pageNum,
pageSize: 10,
};
api.getMissionList(params).then((res) => {
wx.$util.hideLoading();
let total = 0;
let list = [];
let { code, data, message } = res;
data?.list?.forEach((val) => {
val.updatedDate = val.updatedDate ? dayjs(val.updatedDate).format("YYYY-MM-DD HH:mm:ss") : "";
val.createTime = val.createTime ? dayjs(val.createTime).format("YYYY-MM-DD HH:mm:ss") : "";
});
if (code == 0) {
list = data.list;
total = data.total;
} else {
wx.$util.showToast(message);
}
if (total != 0) {
this.setData({
[`list[${pageNum - 1}]`]: list,
});
}
// if (repload) {
// const query = wx.createSelectorQuery().in(this)
......@@ -230,35 +240,33 @@ Page({
// }
// })
// }
this.setData({
total,
flag: true,
triggered: false,
pageNum: pageNum + 1,
nothing: pageNum == data?.pages
})
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
this.setData({
total,
flag: true,
triggered: false,
pageNum: pageNum + 1,
nothing: pageNum == data?.pages,
});
});
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {},
onShareTimeline: function () {}
})
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {},
onShareTimeline: function () {},
});
<!--pages/tab/index/index.wxml-->
<navigation-bar bindnavbarReady="navbarReady"
class="navigation-header"
navStyle="background-color:{{isSticky ? '#FFFFFF' : 'transparent'}};box-shadow:none;">
navStyle="background-color:{{ isSticky ? '#FFFFFF' : 'transparent' }};box-shadow:none;">
<view class="page-title">
工作台
</view>
</navigation-bar>
<view class="bg" wx:if="{{!isSticky}}"></view>
<scroll-view class="container" scroll-y enable-back-to-top
scroll-top="{{setScrollTop}}"
bind:scroll="onScroll"
bindrefresherrefresh="search"
bindscrolltolower="scrollonReachBottom"
enhanced="{{true}}"
show-scrollbar="{{false}}" style="padding-top: {{navBarHeight}}px;">
<view class="bg" wx:if="{{ !isSticky }}"></view>
<scroll-view class="container"
scroll-y
enable-back-to-top
scroll-top="{{ setScrollTop }}"
bind:scroll="onScroll"
bind:refresherrefresh="search"
bind:scrolltolower="scrollonReachBottom"
enhanced="{{ true }}"
show-scrollbar="{{ false }}"
style="padding-top: {{ navBarHeight }}px;">
<view class="top-box">
<view class="user-info">
<image src="{{IMG_URL}}default-avatar.png" />
<view>督导{{userInfo.name}}</view>
<image src="{{ IMG_URL }}default-avatar.png" />
<view>
督导{{ userInfo.name }}
</view>
</view>
<view class="static-info">
<view class="static-item" style="flex: {{item.width}}rpx 0 0;background: {{item.background}};" wx:for="{{staticList}}" wx:key="index">
<view class="label">{{item.label}}</view>
<view class="value">{{staticData[item.key]}}</view>
<view class="static-item"
style="flex: {{ item.width }}rpx 0 0;background: {{ item.background }};"
wx:for="{{ staticList }}"
wx:key="index">
<view class="label">
{{ item.label }}
</view>
<view class="value">
{{ staticData[item.key] }}
</view>
</view>
</view>
</view>
<view class="data-container">
<view class="sticky-box {{isSticky ? 'is-sticky' : ''}}">
<view class="sticky-box {{ isSticky ? 'is-sticky' : '' }}">
<view class="tab-box">
<tab-bar tabList="{{ tabList }}" bindclick="tabClick" activeIndex="{{ tabIndex }}" />
<tab-bar tabList="{{ tabList }}"
bindclick="tabClick"
activeIndex="{{ tabIndex }}" />
</view>
<view class="date">
<date-screen tabSelected="{{tabIndex}}" isSticky="{{isSticky}}" bind:search="search"></date-screen>
<date-screen tabSelected="{{ tabIndex }}"
isSticky="{{ isSticky }}"
bind:search="search"></date-screen>
</view>
<view class="number">
共{{ total || 0 }}条任务
</view>
<view class="number">共{{total || 0}}条任务</view>
</view>
<view class="content-box">
<view class="list">
<block wx:if="{{ list.length > 0 }}">
<block wx:for="{{ list }}" wx:for-item="val" wx:for-index="sIndex" wx:key="sIndex">
<block wx:for="{{val}}" wx:key="index">
<view class="item content">
<!-- 顶部状态和标题 -->
<view class="item-top">
<view
class="status text-center"
style="color: {{statusMap[item.taskStatus].color}}; background-color: {{statusMap[item.taskStatus].background}};"
>
{{statusMap[item.taskStatus].name}}
</view>
<view class="name" wx:if="{{item.taskType != 4}}">
{{missionMap[item.taskType].name}}
<text wx:if="{{item.taskType == 5}}">-{{item.storeManagerName || '-'}}</text>
</view>
<view class="name" wx:else>{{item.merchantName || '-'}}</view>
<block wx:if="{{ list.length > 0 }}">
<block wx:for="{{ list }}"
wx:for-item="val"
wx:for-index="sIndex"
wx:key="sIndex">
<block wx:for="{{ val }}" wx:key="index">
<view class="item content">
<!-- 顶部状态和标题 -->
<view class="item-top">
<view class="status text-center"
style="color: {{ statusMap[item.taskStatus].color }}; background-color: {{ statusMap[item.taskStatus].background }};">
{{ statusMap[item.taskStatus].name }}
</view>
<view class="name" wx:if="{{ item.taskType != 4 }}">
{{ missionMap[item.taskType].name }}<text wx:if="{{ item.taskType == 5 }}">-{{ item.storeManagerName || '-' }}</text>
</view>
<view wx:if="{{(item.taskType == 0 || item.taskType == 1 || item.taskType == 2) && item.taskStatus == 2}}" class="list-item">
<image class="icon" src="{{IMG_URL}}task-icon.png" mode="" />
<view class="label">{{['日报内容:', '复盘内容:', '月度计划:'][item.taskType]}}</view>
<view class="text-hide">{{item.taskContext || '-'}}</view>
<view class="name" wx:else>
{{ item.merchantName || '-' }}
</view>
<block wx:if="{{item.taskType == 4}}">
<view class="list-item">
<image class="icon" src="{{IMG_URL}}matter-icon.png" mode="" />
<view class="label">事项描述:</view>
<view class="text-hide">{{item.taskDesc || '-'}}</view>
</view>
<view wx:if="{{ (item.taskType == 0 || item.taskType == 1 || item.taskType == 2) && item.taskStatus == 2 }}"
class="list-item">
<image class="icon"
src="{{ IMG_URL }}task-icon.png"
mode="" />
<view class="label">
{{ ['日报内容:', '复盘内容:', '月度计划:'][item.taskType] }}
</view>
<view class="text-hide">
{{ item.taskContext || '-' }}
</view>
</view>
<block wx:if="{{ item.taskType == 4 }}">
<view class="list-item">
<image class="icon"
src="{{ IMG_URL }}matter-icon.png"
mode="" />
<view class="label">
事项描述:
</view>
<view wx:if="{{item.taskStatus == 2}}" class="list-item">
<image class="icon" src="{{IMG_URL}}task-icon.png" mode="" />
<view class="label">专项任务:</view>
<view class="text-hide">{{item.taskContext || '-'}}</view>
<view class="text-hide">
{{ item.taskDesc || '-' }}
</view>
<view wx:else class="list-item">
<image class="icon" src="{{IMG_URL}}time-icon.png" mode="" />
<view class="label">创建时间:</view>
<view>{{item.createTime || '-'}}</view>
</view>
<view wx:if="{{ item.taskStatus == 2 }}" class="list-item">
<image class="icon"
src="{{ IMG_URL }}task-icon.png"
mode="" />
<view class="label">
专项任务:
</view>
<view class="text-hide">
{{ item.taskContext || '-' }}
</view>
</block>
<view wx:if="{{item.taskType != 4 || (item.taskType == 4 && item.taskStatus == 2)}}" class="list-item">
<image class="icon" src="{{IMG_URL}}time-icon.png" mode="" />
<view class="label">完成时间:</view>
<view>{{item.updatedDate || '-'}}</view>
</view>
<view wx:if="{{item.taskType == 3}}" class="list-item">
<view class="progress">
<view class="progress-line"></view>
<view
class="progress-item"
style="width: {{ (item.audioReviewCompletedCount / item.audioReviewTotalCount * 100) + '%' }}"
></view>
<view class="num">{{item.audioReviewCompletedCount + '/' + item.audioReviewTotalCount}}</view>
<view wx:else class="list-item">
<image class="icon"
src="{{ IMG_URL }}time-icon.png"
mode="" />
<view class="label">
创建时间:
</view>
<view>
{{ item.createTime || '-' }}
</view>
</view>
</block>
<view wx:if="{{ item.taskType != 4 || (item.taskType == 4 && item.taskStatus == 2) }}"
class="list-item">
<image class="icon"
src="{{ IMG_URL }}time-icon.png"
mode="" />
<view class="label">
完成时间:
</view>
<!-- 底部按钮 -->
<view class="btn-box">
<view
bindtap="jump"
data-target="{{item}}"
class="btn {{item.taskStatus == 2 ? '' : 'primary'}}"
>
{{item.taskStatus == 2 ? '查看' : '去执行'}}
<view>
{{ item.updatedDate || '-' }}
</view>
</view>
<view wx:if="{{ item.taskType == 3 }}" class="list-item">
<view class="progress">
<view class="progress-line"></view>
<view class="progress-item"
style="width: {{ (item.audioReviewCompletedCount / item.audioReviewTotalCount * 100) + '%' }}"></view>
<view class="num">
{{ item.audioReviewCompletedCount + '/' + item.audioReviewTotalCount }}
</view>
</view>
</view>
</block>
<!-- 底部按钮 -->
<view class="btn-box">
<view bindtap="jump"
data-target="{{ item }}"
class="btn {{ item.taskStatus == 2 ? '' : 'primary' }}">
{{ item.taskStatus == 2 ? '查看' : '去执行' }}
</view>
</view>
</view>
</block>
<block wx:if="{{ nothing }}">
<view class="list-nothing">到底了~</view>
</block>
</block>
<block wx:else>
<empty-data />
</block>
</block>
<block wx:if="{{ nothing }}">
<view class="list-nothing">
到底了~
</view>
</block>
</block>
<block wx:else>
<empty-data />
</block>
</view>
</view>
</view>
</scroll-view>
\ No newline at end of file
</scroll-view>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!