Commit f6346fa8 by 李君

优化

1 parent f63b2fbd
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
"index/index2", "index/index2",
"index/me", "index/me",
"pages/login/index", "pages/login/index",
"pages/homes/index",
"pages/editPwd/editPwd", "pages/editPwd/editPwd",
"pages/shopSelect/index" "pages/shopSelect/index"
], ],
......
...@@ -3,6 +3,7 @@ import { ...@@ -3,6 +3,7 @@ import {
getAccountTrafficTrend, getAccountTrafficTrend,
getAccountMallRank getAccountMallRank
} from '../api/shop' } from '../api/shop'
import {getTime} from '../utils/util'
import moment from 'moment' import moment from 'moment'
const App = getApp(); const App = getApp();
Component({ Component({
...@@ -41,6 +42,7 @@ Component({ ...@@ -41,6 +42,7 @@ Component({
// maxDate: new Date(2222, 0, 31).getTime(), //自定义时间的结束日期 // maxDate: new Date(2222, 0, 31).getTime(), //自定义时间的结束日期
rankData: [], rankData: [],
indexVal: 'PassengerFlow', indexVal: 'PassengerFlow',
rankType:'1',
indexList: [{ indexList: [{
name: '进店客流', name: '进店客流',
val: 'PassengerFlow' val: 'PassengerFlow'
...@@ -199,6 +201,14 @@ Component({ ...@@ -199,6 +201,14 @@ Component({
},500) },500)
}) })
}, },
changeMallRank(data){
console.log(data);
this.setData({
rankType:data.target.dataset.name
},()=>{
this.getMallRank()
})
},
// 获取门店排行 // 获取门店排行
getMallRank(){ getMallRank(){
let startTime = this.data.currentTime, let startTime = this.data.currentTime,
...@@ -212,15 +222,25 @@ Component({ ...@@ -212,15 +222,25 @@ Component({
accountId:wx.getStorageSync('accountId'), accountId:wx.getStorageSync('accountId'),
startDate:startTime, startDate:startTime,
endDate:endTime, endDate:endTime,
dataIndex:this.data.indexVal dataIndex:this.data.indexVal,
topN:this.data.rankType==1?'10':99999
}).then(res => { }).then(res => {
let rankData = res.data; let rankData = res.data;
let maxVal = Math.max.apply(Math,rankData.map((o)=>{ let maxVal = Math.max.apply(Math,rankData.map((o)=>{
return o.value return o.value||0
})) }))
rankData.forEach(item=>{ rankData.forEach(item=>{
item.value = this.toThousands(item.value) // 进店率和深逛率加%
item.percentage = parseInt(item.value*100/maxVal); if(this.data.indexVal=='IntoStoreRate' || this.data.indexVal=='DeepShoppingRate'){
item.dealValue = item.value?item.value + '%':'--'
}else if(this.data.indexVal=='AvgResidenceTime'){
// 停留时间转换
item.dealValue = item.value?getTime(item.value):'--'
}else{
item.dealValue = item.value?this.toThousands(item.value):'--'
}
item.percentage = item.value?parseInt(item.value*100/maxVal):0;
}) })
this.setData({ this.setData({
rankData rankData
......
...@@ -63,7 +63,13 @@ ...@@ -63,7 +63,13 @@
</view> --> </view> -->
<!-- 门店排行 --> <!-- 门店排行 -->
<view class="keliuliang"> <view class="keliuliang">
<view class="alone_floor">
<text class="title_chart">门店排行</text> <text class="title_chart">门店排行</text>
<view class="alone_btn">
<van-button bindtap="changeMallRank" data-name="1" size="mini" plain type="{{rankType==1?'info':'default'}}">TOP10</van-button>
<van-button plain bindtap="changeMallRank" data-name="2" size="mini" type="{{rankType==2?'info':'default'}}">全部</van-button>
</view>
</view>
<view style="margin-top:20rpx"></view> <view style="margin-top:20rpx"></view>
<van-grid class="indexList" column-num="4" gutter='{{5}}'> <van-grid class="indexList" column-num="4" gutter='{{5}}'>
<van-grid-item bindtap="clickIndex" data-val="{{item.val}}" custom-class="desc_info" content-class="{{indexVal==item.val?'desc_content_active':'desc_content'}}" text-class="{{indexVal==item.val?'desc_text_active':'desc_text'}}" text="{{item.name}}" wx:for="{{ indexList }}" wx:for-item="item" wx:key="{{item.val}}" /> <van-grid-item bindtap="clickIndex" data-val="{{item.val}}" custom-class="desc_info" content-class="{{indexVal==item.val?'desc_content_active':'desc_content'}}" text-class="{{indexVal==item.val?'desc_text_active':'desc_text'}}" text="{{item.name}}" wx:for="{{ indexList }}" wx:for-item="item" wx:key="{{item.val}}" />
...@@ -75,7 +81,7 @@ ...@@ -75,7 +81,7 @@
<text class="idx color">{{index*1+1+','+item.name}}</text> <text class="idx color">{{index*1+1+','+item.name}}</text>
</view> </view>
<view class="num color"> <view class="num color">
{{item.value}} {{item.dealValue}}
</view> </view>
</view> </view>
<view class="progress progressCustom"> <view class="progress progressCustom">
......
...@@ -262,3 +262,9 @@ ...@@ -262,3 +262,9 @@
.boxPadding .title_chart{ .boxPadding .title_chart{
padding-left: 20rpx; padding-left: 20rpx;
} }
.alone_floor{
display: flex;
}
.alone_btn{
margin-left: auto;
}
\ No newline at end of file \ No newline at end of file
// pages/homes/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
<!--pages/homes/index.wxml-->
<text>pages/homes/index.wxml</text>
...@@ -98,12 +98,19 @@ function getNowWeek() { ...@@ -98,12 +98,19 @@ function getNowWeek() {
// } // }
// return rom + ',' + to // return rom + ',' + to
} }
function numFormat(val){
return val>9?val:("0"+val)
}
function getTime(seconds){
if(isNaN(seconds))return seconds;
return numFormat(parseInt(seconds/3600))+':'+numFormat(parseInt(seconds%3600/60))+':'+numFormat(parseInt(seconds%60));
}
module.exports = { module.exports = {
formatTime, formatTime,
getMonthStartDate, getMonthStartDate,
getMonthEndDate, getMonthEndDate,
getLocalStorage, getLocalStorage,
dealTimer, dealTimer,
getNowWeek getNowWeek,
getTime
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!