Commit f6346fa8 by 李君

优化

1 parent f63b2fbd
......@@ -4,7 +4,6 @@
"index/index2",
"index/me",
"pages/login/index",
"pages/homes/index",
"pages/editPwd/editPwd",
"pages/shopSelect/index"
],
......
......@@ -3,6 +3,7 @@ import {
getAccountTrafficTrend,
getAccountMallRank
} from '../api/shop'
import {getTime} from '../utils/util'
import moment from 'moment'
const App = getApp();
Component({
......@@ -41,6 +42,7 @@ Component({
// maxDate: new Date(2222, 0, 31).getTime(), //自定义时间的结束日期
rankData: [],
indexVal: 'PassengerFlow',
rankType:'1',
indexList: [{
name: '进店客流',
val: 'PassengerFlow'
......@@ -199,6 +201,14 @@ Component({
},500)
})
},
changeMallRank(data){
console.log(data);
this.setData({
rankType:data.target.dataset.name
},()=>{
this.getMallRank()
})
},
// 获取门店排行
getMallRank(){
let startTime = this.data.currentTime,
......@@ -212,15 +222,25 @@ Component({
accountId:wx.getStorageSync('accountId'),
startDate:startTime,
endDate:endTime,
dataIndex:this.data.indexVal
dataIndex:this.data.indexVal,
topN:this.data.rankType==1?'10':99999
}).then(res => {
let rankData = res.data;
let maxVal = Math.max.apply(Math,rankData.map((o)=>{
return o.value
return o.value||0
}))
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({
rankData
......
......@@ -63,7 +63,13 @@
</view> -->
<!-- 门店排行 -->
<view class="keliuliang">
<text class="title_chart">门店排行</text>
<view class="alone_floor">
<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>
<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}}" />
......@@ -75,7 +81,7 @@
<text class="idx color">{{index*1+1+','+item.name}}</text>
</view>
<view class="num color">
{{item.value}}
{{item.dealValue}}
</view>
</view>
<view class="progress progressCustom">
......
......@@ -261,4 +261,10 @@
}
.boxPadding .title_chart{
padding-left: 20rpx;
}
.alone_floor{
display: flex;
}
.alone_btn{
margin-left: auto;
}
\ 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
<!--pages/homes/index.wxml-->
<text>pages/homes/index.wxml</text>
......@@ -98,12 +98,19 @@ function getNowWeek() {
// }
// 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 = {
formatTime,
getMonthStartDate,
getMonthEndDate,
getLocalStorage,
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!