Commit 21172d1a by 周志凯

修改vuex modules

1 parent f9ea55c6
import configApi from './configApi'
// 第一种写法
export function fetch(method = 'GET', url, params = null, headers = {}) {
method = method.toLocaleUpperCase();
return new Promise((resolve, reject) => {
uni.request({
url: url,
method: method,
data: params,
header: headers,
success: (res) => {
resolve(res)
},
fail: (err) => {
reject(err);
}
})
})
}
// export function fetch(method = 'GET', url, params = null, headers = {}) {
// method = method.toLocaleUpperCase();
// return new Promise((resolve, reject) => {
// uni.request({
// url: url,
// method: method,
// data: params,
// header: headers,
// success: (res) => {
// resolve(res)
// },
// fail: (err) => {
// reject(err);
// }
// })
// })
// }
// 第二种写法
// 接口基类
const http = (options) => {
const { method = 'get', data, url, headers = {} } = options;
method = method.toLocaleUpperCase();
function fetch(options) {
const { methods, data, url, headers = {} } = options;
return new Promise((resolve, reject) => {
uni.request({
url: url,
method: method,
method: methods,
data: data,
header: headers,
success: (res) => {
......@@ -43,64 +42,65 @@ const http = (options) => {
export default {
// 接口应用层
// 集团列表
loadAccountList({ method, data, headers }) {
return http({
loadAccountList({ data, headers }) {
// console.log(data, headers)
return fetch({
url: configApi.LOAD_ACCOUNT_LIST,
method: method,
methods: 'get',
data: data,
headers: headers
})
},
// 商场列表
loadMallList(method, data, headers) {
return http({
loadMallList(data, headers) {
return fetch({
url: configApi.LOAD_MALL_LIST,
method: method,
methods: 'get',
data: data,
headers: headers
})
},
// 楼层列表
loadFloorList(method, data, headers) {
return http({
loadFloorList(data, headers) {
return fetch({
url: configApi.LOAD_FLOOR_LIST,
method: method,
methods: 'get',
data: data,
headers: headers
})
},
// 店铺列表
loadZoneList(method, data, headers) {
return http({
loadZoneList(data, headers) {
return fetch({
url: configApi.LOAD_ZONE_LIST,
method: method,
methods: 'get',
data: data,
headers: headers
})
},
// 监控点列表
loadGateList(method, data, headers) {
return http({
loadGateList(data, headers) {
return fetch({
url: configApi.LOAD_GATE_LIST,
method: method,
methods: 'get',
data: data,
headers: headers
})
},
// 字典列表
loadDictList(method, data, headers) {
return http({
loadDictList(data, headers) {
return fetch({
url: configApi.LOAD_DICT_LIST,
method: method,
methods: 'get',
data: data,
headers: headers
})
},
// 抓拍记录列表
loadFacerecognitionList(method, data, headers) {
return http({
loadFacerecognitionList(data, headers) {
return fetch({
url: configApi.LOAD_FACERECOGNITION_LIST,
method: method,
methods: 'get',
data: data,
headers: headers
})
......
......@@ -21,6 +21,7 @@ function autoPrefixer(num) {
function getDays(y, m) {
y = Number(y)
m = Number(m)
console.log('m', m)
let endDay = null
switch (m){
case 1:
......@@ -53,14 +54,14 @@ function getDays(y, m) {
}
const yearData = range(START_YEAR, END_YEAR, false, UNIT_YEAR);
const monthData = range(1, 12, false, UNIT_MONTH);
const monthData = range(1, 12, true, UNIT_MONTH);
const hourData = range(0, 23, true, UNIT_HOUR);
const minutesData = range(0, 59, true, UNIT_MINUTES);
const secondsData = range(0, 59, true, UNIT_SECONDS);
console.log(hourData)
console.log(minutesData)
console.log(secondsData)
// console.log(hourData)
// console.log(minutesData)
// console.log(secondsData)
const cascadeMonthData = monthData.map((month) => {
return {
......@@ -124,5 +125,6 @@ const dateAnchor = [
export default {
getDateData() {
return dateData
}
},
START_YEAR
}
\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
......@@ -8,8 +8,7 @@
<div class="picker-title">
<span class="pt-cancel" @click="cancel" :style="{ color: colorCancel }">{{textCancel}}</span>
<span class="pt-submit" @click="confirm" :style="{ color: colorConfirm }">{{textConfirm}}</span>
<!-- <h4 :style="{ color: colorTitle }">{{textTitle}}</h4> -->
<slot></slot>
<h4 :style="{ color: colorTitle }">{{textTitle}}</h4>
</div>
<div class="picker-panel">
<div class="picker-mask-top"></div>
......@@ -114,6 +113,7 @@ export default {
},
computed: {
proxyData () {
return this._dataGetter()
},
proxyAnchor () {
......@@ -139,6 +139,9 @@ export default {
},
_anchorGetter () {
// if(!this.pickerData){
// this.pickerData=this._dataGetter()
// }
let anchor = []
if (this.anchor.length) {
anchor = this.anchor
......@@ -150,7 +153,6 @@ export default {
anchor = this.anchor; break
}
}
anchor = anchor.map((item, i) => {
let index = 0
if (item.index) {
......@@ -170,6 +172,8 @@ export default {
this.display = true
if (!this.wheels.length || this.dataChange) {
this.dataType === DATA_CASCADE && this._updatePickerData()
this.$nextTick(() => {
const wheelWrapper = this.$refs.wheelWrapper
this.pickerData.forEach((item, index) => {
......@@ -177,6 +181,8 @@ export default {
})
this._wheelToAnchor(this.proxyAnchor)
// this.$forceUpdate()
this.dataChange && this._destroyExtraWheels()
this.dataChange = false
})
......@@ -216,7 +222,6 @@ export default {
if (this.dataType !== DATA_CASCADE) {
return
}
this._updatePickerData(0)
const newIndex = this._getCurrentValue()[i].index
if (newIndex !== this.pickerAnchor[i]) {
this.pickerAnchor.splice(i, 1, newIndex)
......@@ -234,14 +239,11 @@ export default {
const value = []
this.wheels.forEach((wheel, i) => {
const j = wheel.getSelectedIndex()
console.log(j)
console.log( this.pickerData)
value.push({
index: j,
value: this.pickerData[i][j]
})
})
console.log(value)
return value
},
......@@ -254,6 +256,7 @@ export default {
this.pickerData.forEach((item, i) => {
this._createWheel(wheelWrapper, i)
})
this._wheelToAnchor(this.proxyAnchor)
this._destroyExtraWheels()
})
......@@ -273,6 +276,7 @@ export default {
},
_updatePickerData (wheelIndex = 0) {
this.pickerAnchor = this._anchorGetter()
let data = [...this.proxyData]
let i = 0
while (data) {
......@@ -281,11 +285,12 @@ export default {
data.forEach((item) => {
wheelData.push(item.value)
})
this.pickerData[i] = wheelData
this.pickerData.splice(i, 1, wheelData)
this.pickerAnchor[i] = wheelIndex === 0
? (this.pickerAnchor[i] < data.length ? this.pickerAnchor[i] || 0 : 0)
: this._reloadWheel(i, wheelData)
}
data = data.length ? data[this.pickerAnchor[i]].children : null
i++
}
......
......@@ -44,28 +44,52 @@
},
created() {
if(!this.checkedGateId) {
this.$store.dispatch('malls/getMallList', {
// this.$store.dispatch('malls/getMallList', {
// data: {
// accountId: this.getStorage('accountId'),
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getMalls', {
data: {
accountId: this.getStorage('accountId'),
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
},
isMultiple: true
}
})
}
},
computed: {
...mapState({
checkedMallId: state => state.malls.checkedMallId,
gateList: state => state.malls.gateList,
checkedGateId: state => state.malls.checkedGateId,
// checkedMallId: state => state.malls.checkedMallId,
// gateList: state => state.malls.gateList,
// checkedGateId: state => state.malls.checkedGateId,
checkedMallId: state => state.conditions.checkedMallId,
gateList: state => state.conditions.storeGateList,
checkedGateId: state => state.conditions.checkedGateId,
}),
},
watch: {
checkedMallId(val) {
this.$store.dispatch('malls/getGateList', {
// this.$store.dispatch('malls/getGateList', {
// data: {
// mallId: val.id,
// status: 1,
// isHasFace: 1,
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getGates', {
data: {
mallId: val.id,
status: 1,
......@@ -73,9 +97,8 @@
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
'Authorization': this.atoken //自定义请求头信息
},
isMultiple: true
})
},
checkedGateId(val) {
......@@ -135,7 +158,8 @@
id: this.cacheList[index].id,
name: this.cacheList[index].name
}
this.$store.dispatch('malls/updateCheckedGate', this.cacheCheckedGateId)
// this.$store.dispatch('malls/updateCheckedGate', this.cacheCheckedGateId)
this.$store.dispatch('conditions/updateCheckedGate', this.cacheCheckedGateId)
uni.reLaunch({
url: `${this.backUrl}?type=${this.analysisLevel}`
})
......
......@@ -44,8 +44,10 @@
},
computed: {
...mapState({
mallList: state => state.malls.list,
checkedMallId: state => state.malls.checkedMallId
// mallList: state => state.malls.list,
// checkedMallId: state => state.malls.checkedMallId,
mallList: state => state.conditions.storeMallList,
checkedMallId: state => state.conditions.checkedMallId
}),
},
watch: {
......@@ -55,15 +57,24 @@
},
created() {
if(!this.checkedMallId) { // 处理刷新获取参数失败
this.$store.dispatch('malls/getMallList', {
// this.$store.dispatch('malls/getMallList', {
// data: {
// accountId: this.getStorage('accountId'),
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getMalls', {
data: {
accountId: this.getStorage('accountId'),
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
},
isMultiple: true
}
})
}
},
......@@ -112,7 +123,20 @@
}
console.log(this.cacheCheckedMallId)
this.$store.dispatch('malls/updateCheckedMall', this.cacheCheckedMallId)
this.$store.dispatch('malls/getGateList', {
// this.$store.dispatch('malls/getGateList', {
// data: {
// mallId: this.cacheCheckedMallId.id,
// status: 1,
// isHasFace: 1,
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/updateCheckedMall', this.cacheCheckedMallId)
this.$store.dispatch('conditions/getGates', {
data: {
mallId: this.cacheCheckedMallId.id,
status: 1,
......@@ -120,9 +144,8 @@
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
'Authorization': this.atoken //自定义请求头信息
},
isMultiple: true
})
uni.reLaunch({
url: `${this.backUrl}?type=${this.analysisLevel}`
......
......@@ -56,14 +56,29 @@
},
computed: {
...mapState({
checkedMallId: state => state.malls.checkedMallId,
gateList: state => state.malls.gateList,
multiCheckedGateId: state => state.malls.multiCheckedGateId
// checkedMallId: state => state.malls.checkedMallId,
// gateList: state => state.malls.gateList,
// multiCheckedGateId: state => state.malls.multiCheckedGateId,
checkedMallId: state => state.conditions.checkedMallId,
gateList: state => state.conditions.storeGateList,
multiCheckedGateId: state => state.conditions.multiCheckedGateId
}),
},
watch: {
checkedMallId(val) {
this.$store.dispatch('malls/getGateList', {
// this.$store.dispatch('malls/getGateList', {
// data: {
// mallId: val.id,
// status: 1,
// isHasFace: 1,
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getGates', {
data: {
mallId: val.id,
status: 1,
......@@ -71,9 +86,8 @@
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
'Authorization': this.atoken //自定义请求头信息
},
isMultiple: true
})
},
multiCheckedGateId: {
......@@ -87,15 +101,24 @@
created() {
console.log('created', this.multiCheckedGateId)
if(!this.multiCheckedGateId.length) {
this.$store.dispatch('malls/getMallList', {
// this.$store.dispatch('malls/getMallList', {
// data: {
// accountId: this.getStorage('accountId'),
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getMalls', {
data: {
accountId: this.getStorage('accountId'),
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
},
isMultiple: true
}
})
}
},
......@@ -134,7 +157,8 @@
});
return;
}
this.$store.dispatch('malls/updateMultiCheckedGate', this.checkedGateIds)
// this.$store.dispatch('malls/updateMultiCheckedGate', this.checkedGateIds)
this.$store.dispatch('conditions/updateMultiCheckedGate', this.checkedGateIds)
uni.reLaunch({
url: `${this.backUrl}?type=${this.analysisLevel}`
})
......
......@@ -58,8 +58,10 @@
},
computed: {
...mapState({
mallList: state => state.malls.list,
multiCheckedMallId: state => state.malls.multiCheckedMallId
// mallList: state => state.malls.list,
// multiCheckedMallId: state => state.malls.multiCheckedMallId,
mallList: state => state.conditions.storeMallList,
multiCheckedMallId: state => state.conditions.multiCheckedMallId
}),
},
watch: {
......@@ -69,15 +71,24 @@
},
created() {
if(!this.multiCheckedMallId) {
this.$store.dispatch('malls/getMallList', {
// this.$store.dispatch('malls/getMallList', {
// data: {
// accountId: this.getStorage('accountId'),
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getMalls', {
data: {
accountId: this.getStorage('accountId'),
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
},
isMultiple: true
}
})
}
},
......@@ -116,7 +127,8 @@
});
return;
}
this.$store.dispatch('malls/updateMultiCheckedMall', this.checkedMallIds)
// this.$store.dispatch('malls/updateMultiCheckedMall', this.checkedMallIds)
this.$store.dispatch('conditions/updateMultiCheckedMall', this.checkedMallIds)
uni.reLaunch({
url: `${this.backUrl}?type=${this.analysisLevel}`
})
......
......@@ -9,7 +9,7 @@
<view class="prefix-elem"></view>
<view class="capture-main">
<view class="empty-capture-item" v-if="captureList.length <= 0">{{ captureList.length > 0 ? '' : '暂无数据' }}</view>
<view class="capture-item" v-for="(item, index) in captureList" :key="item.pic">
<view class="capture-item" v-for="(item, index) in captureList" :key="index">
<view class="capture-image">
<!-- <span class="capture-date">{{ item.counttime }}</span> -->
<!-- <image class="capture-img" ref="imageRef" :src="item.pic" @error="imageError" :lazy-load="true" mode="widthFix"></image> -->
......@@ -110,32 +110,58 @@
},
created() {
if(!this.checkedMallId) { // 处理刷新获取参数失败
this.$store.dispatch('malls/getMallList', {
// this.$store.dispatch('malls/getMallList', {
// data: {
// accountId: this.getStorage('accountId'),
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getMalls', {
data: {
accountId: this.getStorage('accountId'),
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
},
isMultiple: true
}
})
}
if(!this.selectedStartTime || !this.selectedEndTime) {
this.$store.dispatch('malls/getDateData', 15);
// this.$store.dispatch('malls/getDateData', 15);
this.$store.dispatch('conditions/getStartEndDate', 0);
}
},
computed: {
...mapState({
checkedMallId: state => state.malls.checkedMallId,
checkedGateId: state => state.malls.checkedGateId,
selectedStartTime: state => state.malls.startDayTime,
selectedEndTime: state => state.malls.endDayTime
// checkedMallId: state => state.malls.checkedMallId,
// checkedGateId: state => state.malls.checkedGateId,
// selectedStartTime: state => state.malls.startDayTime,
// selectedEndTime: state => state.malls.endDayTime,
checkedMallId: state => state.conditions.checkedMallId,
checkedGateId: state => state.conditions.checkedGateId,
selectedStartTime: state => state.conditions.selectedStartDayTime,
selectedEndTime: state => state.conditions.selectedEndDayTime
})
},
watch: {
checkedMallId(val) {
this.$store.dispatch('malls/getGateList', {
// this.$store.dispatch('malls/getGateList', {
// data: {
// mallId: val.id,
// status: 1,
// isHasFace: 1,
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getGates', {
data: {
mallId: val.id,
status: 1,
......@@ -144,8 +170,7 @@
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
},
isMultiple: true
}
})
this.getCaptureList();
},
......@@ -157,6 +182,21 @@
})
},
getCaptureList() {
// this.captureList = []
// for(let i = 0; i < 60; i++) {
// this.captureList.push({
// show: false,
// loaded: false,
// orderIdx: ++i,
// pic: defaultImg,
// gender: 0,
// personType: 0,
// faceImagePath: this.dealDefaultImg(0),
// age: Math.ceil(Math.random() * 30),
// mood: Math.ceil(Math.random() * 1),
// counttime: '10:10:26'
// })
// }
if(!this.checkedMallId && !this.selectedStartTime && !this.selectedEndTime) return;
// console.log('getCaptureList:', this.checkedMallId, this.checkedGateId)
let atoken = this.getStorage('atoken');
......@@ -165,6 +205,7 @@
uni.showLoading({
title: '加载中'
})
// uni.hideLoading()
uni.request({
url: window.url + '/faceRecognitions',
data: {
......@@ -210,6 +251,7 @@
// item.personType = item.personType == 0 ? '顾客' : '店员'
return item;
})
// this.captureList
setTimeout(() => {
this.load()
}, 100)
......
......@@ -111,19 +111,29 @@
},
created() {
if(!this.selectedMall) {
this.$store.dispatch('malls/getMallList', {
// this.$store.dispatch('malls/getMallList', {
// data: {
// accountId: this.getStorage('accountId'),
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getMalls', {
data: {
accountId: this.getStorage('accountId'),
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
},
isMultiple: true
}
})
}
if(!this.selectedStartTime || !this.selectedEndTime) {
this.$store.dispatch('malls/getDateData', 15);
// this.$store.dispatch('malls/getDateData', 15);
this.$store.dispatch('conditions/getStartEndDate', 0);
}
if(!this.capturePersonType.name) {
this.capturePersonType = {
......@@ -138,8 +148,8 @@
return this.$t("index")
},
...mapState({
selectedMall: state => state.malls.checkedMallId,
selectedGate: state => state.malls.checkedGateId,
// selectedMall: state => state.malls.checkedMallId,
// selectedGate: state => state.malls.checkedGateId,
// dateData: state => state.malls.customTimeData,
// dateStartText: state => state.malls.selectedCustomStartDate,
// dateEndText: state => state.malls.selectedCustomEndDate,
......@@ -147,16 +157,36 @@
// currentEndDate: state => state.malls.pickerCustomEndDate,
//
dateData: state => state.malls.dayDateData,
dateStartText: state => state.malls.startDayTime,
dateEndText: state => state.malls.endDayTime,
currentStartDate: state => state.malls.pickerStartDayDate,
currentEndDate: state => state.malls.pickerEndDayDate
// dateData: state => state.malls.dayDateData,
// dateStartText: state => state.malls.startDayTime,
// dateEndText: state => state.malls.endDayTime,
// currentStartDate: state => state.malls.pickerStartDayDate,
// currentEndDate: state => state.malls.pickerEndDayDate,
selectedMall: state => state.conditions.checkedMallId,
selectedGate: state => state.conditions.checkedGateId,
dateData: state => state.conditions.startEndDateData,
dateStartText: state => state.conditions.selectedStartDayTime,
dateEndText: state => state.conditions.selectedEndDayTime,
currentStartDate: state => state.conditions.startDayAnchor,
currentEndDate: state => state.conditions.endDayAnchor,
})
},
watch: {
selectedMall(val) {
this.$store.dispatch('malls/getGateList', {
// this.$store.dispatch('malls/getGateList', {
// data: {
// mallId: val.id,
// status: 1,
// isHasFace: 1,
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getGates', {
data: {
mallId: val.id,
status: 1,
......@@ -165,8 +195,7 @@
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
},
isMultiple: true
}
})
}
},
......@@ -238,6 +267,7 @@
dateConfirm(item) {
this.startCacheTimeStr = this.formatterTimeToStr(item);
this.startPickerIdx = item;
console.log('item', item)
if(!this.comparsionSize(this.currentEndDate, this.startPickerIdx)) {
uni.showToast({
icon: 'none',
......@@ -247,9 +277,13 @@
// this.startDateHandle()
// }, 500)
} else {
this.$store.dispatch('malls/updateStartEndDate', {
startDate: this.startCacheTimeStr,
startPickerIdx: this.startPickerIdx
// this.$store.dispatch('malls/updateStartEndDate', {
// startDate: this.startCacheTimeStr,
// startPickerIdx: this.startPickerIdx
// })
this.$store.dispatch('conditions/updateStartEndDate', {
startDateText: this.startCacheTimeStr,
startDateAnchor: this.startPickerIdx
})
}
},
......@@ -266,10 +300,15 @@
// }, 500)
return;
} else {
this.$store.dispatch('malls/updateStartEndDate', {
endDate: this.endCacheTimeStr,
endPickerIdx: this.endPickerIdx
// this.$store.dispatch('malls/updateStartEndDate', {
// endDate: this.endCacheTimeStr,
// endPickerIdx: this.endPickerIdx
// })
this.$store.dispatch('conditions/updateStartEndDate', {
endDateText: this.endCacheTimeStr,
endDateAnchor: this.endPickerIdx
})
}
},
comparsionSize(item1, item2) {
......@@ -277,7 +316,8 @@
// console.log('comparsionSize', item1, item2)
let isMoreStart = true;
item1.forEach((val1, idx1) => {
if((val1.value).replace(/[\u4E00-\u9FA5]/g, '') < (item2[idx1].value).replace(/[\u4E00-\u9FA5]/g, '')) {
console.log('comparsionSize', Number((val1.value).replace(/[\u4E00-\u9FA5]/g, ''))<Number((item2[idx1].value).replace(/[\u4E00-\u9FA5]/g, '')))
if(Number((val1.value).replace(/[\u4E00-\u9FA5]/g, '')) < Number((item2[idx1].value).replace(/[\u4E00-\u9FA5]/g, ''))) {
isMoreStart = false;
}
})
......
......@@ -92,19 +92,29 @@
},
created() {
if(!this.selectedMall) { // 处理刷新获取参数失败
this.$store.dispatch('malls/getMallList', {
// this.$store.dispatch('malls/getMallList', {
// data: {
// accountId: this.getStorage('accountId'),
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getMalls', {
data: {
accountId: this.getStorage('accountId'),
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
},
isMultiple: true
}
})
}
if(!this.dateText) {
this.$store.dispatch('malls/getDateData', 15);
// this.$store.dispatch('malls/getDateData', 15);
this.$store.dispatch('conditions/getDayDate')
}
},
computed: {
......@@ -112,17 +122,36 @@
return this.$t("index")
},
...mapState({
selectedMall: state => state.malls.checkedMallId,
multiSelectedMall: state => state.malls.multiCheckedMallId,
multiSelectedGate: state => state.malls.multiCheckedGateId,
dateData: state => state.malls.dayDateData,
dateText: state => state.malls.selectedDayTime,
currentDate: state => state.malls.pickerDayDate
// selectedMall: state => state.malls.checkedMallId,
// multiSelectedMall: state => state.malls.multiCheckedMallId,
// multiSelectedGate: state => state.malls.multiCheckedGateId,
// dateData: state => state.malls.dayDateData,
// dateText: state => state.malls.selectedDayTime,
// currentDate: state => state.malls.pickerDayDate,
selectedMall: state => state.conditions.checkedMallId,
multiSelectedMall: state => state.conditions.multiCheckedMallId,
multiSelectedGate: state => state.conditions.multiCheckedGateId,
dateData: state => state.conditions.dateData,
dateText: state => state.conditions.selectedDayTime,
currentDate: state => state.conditions.dayAnchor
})
},
watch: {
selectedMall(val) {
this.$store.dispatch('malls/getGateList', {
// this.$store.dispatch('malls/getGateList', {
// data: {
// mallId: val.id,
// status: 1,
// isHasFace: 1,
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getGates', {
data: {
mallId: val.id,
status: 1,
......@@ -130,9 +159,8 @@
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
'Authorization': this.atoken //自定义请求头信息
},
isMultiple: true
})
}
},
......@@ -207,9 +235,13 @@
this.formatterTimeToStr(item);
this.cachePickerIdx = item;
if(this.cacheTimeStr && this.cachePickerIdx.length) {
this.$store.dispatch('malls/updateDayDate', {
// this.$store.dispatch('malls/updateDayDate', {
// dayTimeText: this.cacheTimeStr,
// dayPickerIdx: this.cachePickerIdx
// })
this.$store.dispatch('conditions/updateDayDate', {
dayTimeText: this.cacheTimeStr,
dayPickerIdx: this.cachePickerIdx
dayDateAnchor: this.cachePickerIdx
})
}
// console.log(this.cacheTimeStr, this.cachePickerIdx)
......
......@@ -73,23 +73,32 @@
// this.getReportKey(options.analysisLevel)
console.log('onload', options)
this.reportLevel = options.analysisLevel || 'mall';
this.getReportKey(this.reportLevel)
},
created() {
this.accountId = this.getStorage('accountId');
if(!this.checkedMallId) {
this.$store.dispatch('malls/getMallList', {
// this.$store.dispatch('malls/getMallList', {
// data: {
// accountId:this.accountId,
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.atoken //自定义请求头信息
// },
// isMultiple: true
// })
// this.$store.dispatch('malls/getDateData', 15)
this.$store.dispatch('conditions/getMalls', {
data: {
accountId:this.accountId,
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.atoken //自定义请求头信息
},
isMultiple: true
}
})
this.$store.dispatch('malls/getDateData', 15)
this.$store.dispatch('conditions/getDayDate')
}
},
computed: {
......@@ -97,16 +106,33 @@
return this.$t("index")
},
...mapState({
mallList: state => state.malls.list,
checkedMallId: state => state.malls.checkedMallId,
multiCheckedMallId: state => state.malls.multiCheckedMallId,
timeData: state => state.malls.customTimeData,
selectedTime: state => state.malls.selectedDayTime
// mallList: state => state.malls.list,
// checkedMallId: state => state.malls.checkedMallId,
// multiCheckedMallId: state => state.malls.multiCheckedMallId,
// timeData: state => state.malls.customTimeData,
// selectedTime: state => state.malls.selectedDayTime
mallList: state => state.conditions.storeMallList,
checkedMallId: state => state.conditions.checkedMallId,
multiCheckedMallId: state => state.conditions.multiCheckedMallId,
timeData: state => state.conditions.dateData,
selectedTime: state => state.conditions.selectedDayTime
})
},
watch: {
checkedMallId(val) {
this.$store.dispatch('malls/getGateList', {
// this.$store.dispatch('malls/getGateList', {
// data: {
// mallId: val.id,
// status: 1,
// isHasFace: 1,
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.atoken //自定义请求头信息
// },
// isMultiple: true
// })
this.$store.dispatch('conditions/getGates', {
data: {
mallId: val.id,
status: 1,
......@@ -116,7 +142,6 @@
header: {
'Authorization': this.atoken //自定义请求头信息
},
isMultiple: true
})
if(this.reportLevel !== 'mall') {
this.params['orgId'] = val.id;
......
......@@ -39,42 +39,59 @@
}
},
created() {
this.$store.dispatch('malls/getMallList', {
data: {
accountId: this.getStorage('accountId'),
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
},
isMultiple: true
})
this.$store.dispatch('malls/getDateData', 15);
// this.$store.dispatch('malls/getMallList', {
// data: {
// accountId: this.getStorage('accountId'),
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
// this.$store.dispatch('malls/getDateData', 15);
uni.setStorage({
key: 'personType',
data: JSON.stringify({id: 1, name: '全部类型', value: ''})
})
// this.$store.dispatch('conditions/getMalls', {
// data: {
// accountId: this.getStorage('accountId'),
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// }
// })
// this.$store.dispatch('conditions/getDayDate')
// this.$store.dispatch('conditions/getStartEndDate')
// console.log('conditions store', this.malls)
},
computed: {
...mapState({
checkedMallId: state => state.malls.checkedMallId
// checkedMallId: state => state.malls.checkedMallId,
// malls: state => state.conditions.storeMallList
})
},
watch: {
checkedMallId(val) {
this.$store.dispatch('malls/getGateList', {
data: {
mallId: val.id,
status: 1,
isHasFace: 1,
_t:Date.parse(new Date()) / 1000
},
header: {
'Authorization': this.getStorage('atoken') //自定义请求头信息
},
isMultiple: true
})
},
// checkedMallId(val) {
// this.$store.dispatch('malls/getGateList', {
// data: {
// mallId: val.id,
// status: 1,
// isHasFace: 1,
// _t:Date.parse(new Date()) / 1000
// },
// header: {
// 'Authorization': this.getStorage('atoken') //自定义请求头信息
// },
// isMultiple: true
// })
// },
// malls(val) {
// console.log('watch malls', val)
// }
},
methods: {
goReport(url){
......
import Vue from 'vue'
import Vuex from 'vuex'
// import state from './state'
// import mutation from './mutation'
// import getter from './getter'
// import condition from './modules/condition'
import malls from './modules/malls'
//
// import malls from './modules/malls'
import conditions from './modules/condition.js'
Vue.use(Vuex)
//
// const store = new Vuex.Store({
// modules: {
// condition, malls
// },
// state,
// mutation,
// getter
// })
const store = new Vuex.Store({
// state: {
// mallId: '',
// mallList: []
// },
// mutations: {
// mallId(state, newMallId) {
// state.mallId = newMallId;
// },
// mallList(state, newList) {
// state.mallList = newList;
// }
// },
// getters: {
// getMallList(state) {
// return state.mallList;
// }
// },
// actions: {
// getMallList({ commit, state }, params) {
// uni.request({
// url: window.url + "/malls",
// data: params.data,
// header: params.header,
// method: 'GET',
// success: (res) => {
// console.log('store res', res)
// commit('mallList', res.data.data)
// }
// })
// }
// }
state: {},
modules: {
malls
// malls,
conditions
}
})
......
......@@ -17,6 +17,7 @@ const state = {
selectedDayTime: '', // 选中天级日期字符串
dayAnchor: [], // 选中天级日期picker下标
// 开始结束日期
startEndDateData: [], // 开始结束日期数据
selectedStartDayTime: '', // 选中开始日期时间字符串
startDayAnchor: [], // 选中开始日期时间picker下标
selectedEndDayTime: '', // 选中结束日期时间字符串
......@@ -25,22 +26,9 @@ const state = {
const getter = {};
const mutations = {
// 门店/商场
[CONDITIONS.SET_MALLS] (state, mallList) {
state.mallList = mallList;
},
[CONDITIONS.CHECKED_MALL_ID] (state, mallId) {
state.checkedMallId = mallId;
},
[CONDITIONS.CHECKED_MULTI_MALL_ID] (state, multiMallId) {
state.multiCheckedMallId = multiMallId;
},
}
const actions = {
getMalls({ commit }, { data, header }) {
fetch.loadAccountList('get', data, header)
fetch.loadMallList(data, header)
.then(res => {
console.log('actions fetch mallList-=-=-=-=-=->', res)
let result = res.data;
......@@ -68,9 +56,7 @@ const actions = {
})
},
getGates({ commit }, { data, header }) {
fetch.loadGateList({
data, header
})
fetch.loadGateList(data, header)
.then(res => {
console.log('actions fetch gateList-=-=-=-=-=->', res)
let result = res.data;
......@@ -97,13 +83,183 @@ const actions = {
commit(CONDITIONS.CHECKED_MULTI_GATE_ID, multiGateId)
})
},
getDayDate({ commit }) {
console.log('START_YEAR', dateInstance.START_YEAR)
let baseData = dateInstance.getDateData();
// 初始化时间 限定当天
let dayTime = {}
, dayTimeText = ''
, dayAnchor = [];
dayTime = formatterDayTime(new Date());
dayTimeText = `${dayTime['Y']}-${dayTime['M']}-${dayTime['D']}`
dayAnchor = computedAnchor(dayTime, dateInstance.START_YEAR);
commit(CONDITIONS.SET_BASE_DATE_DATA, baseData)
commit(CONDITIONS.SET_SELECTED_DAY_TIME, dayTimeText)
commit(CONDITIONS.SET_DAY_ANCHOR, dayAnchor)
},
getStartEndDate({ commit }, frontDay) {
let dateData = dateInstance.getDateData();
// console.log('getStartEndDate dateInstance', dateInstance)
console.log('getStartEndDate', dateData)
// 初始化开始结束日期
let startDate = null
, endDate = null
, formatterStartDate = null
, formatterEndDate = null
, startDateString = ''
, endDateString = ''
, startDateAnchor = []
, endDateAnchor = [];
endDate = new Date();
startDate = frontTime(endDate, frontDay);
formatterStartDate = formatterDayTime(startDate);
console.log('formatterStartDate', formatterStartDate)
formatterEndDate = formatterDayTime(endDate);
startDateString = `${formatterStartDate['Y']}-${formatterStartDate['M']}-${formatterStartDate['D']}`;
endDateString = `${formatterEndDate['Y']}-${formatterEndDate['M']}-${formatterEndDate['D']}`;
startDateAnchor = computedAnchor(formatterStartDate, dateInstance.START_YEAR);
endDateAnchor = computedAnchor(formatterEndDate, dateInstance.START_YEAR);
console.log('startDateAnchor', startDateAnchor, endDateAnchor)
commit(CONDITIONS.SET_START_END_DATE_DATA, dateData)
commit(CONDITIONS.SET_SELECTED_START_DAY_TIME, startDateString)
commit(CONDITIONS.SET_SELECTED_END_DAY_TIME, endDateString)
commit(CONDITIONS.SET_START_DAY_ANCHOR, startDateAnchor)
commit(CONDITIONS.SET_END_DAY_ANCHOR, endDateAnchor)
},
//=============================更新state操作=============================
updateCheckedMall({ commit }, mallId) {
commit(CONDITIONS.CHECKED_MALL_ID, mallId)
},
updateMultiCheckedMall({ commit }, multiMallId) {
commit(CONDITIONS.CHECKED_MULTI_MALL_ID, multiMallId)
},
updateCheckedGate({ commit }, gateId) {
commit(CONDITIONS.CHECKED_GATE_ID, gateId)
},
updateMultiCheckedGate({ commit }, multiGateId) {
commit(CONDITIONS.CHECKED_MULTI_GATE_ID, multiGateId)
},
updateDayDate({ commit }, { dayTimeText, dayDateAnchor }) {
dayTimeText && commit(CONDITIONS.SET_SELECTED_DAY_TIME, dayTimeText);
dayDateAnchor && commit(CONDITIONS.SET_DAY_ANCHOR, dayDateAnchor);
},
updateStartEndDate({ commit }, { startDateText, endDateText, startDateAnchor, endDateAnchor }) {
startDateText && commit(CONDITIONS.SET_SELECTED_START_DAY_TIME, startDateText)
endDateText && commit(CONDITIONS.SET_SELECTED_END_DAY_TIME, endDateText)
startDateAnchor && commit(CONDITIONS.SET_START_DAY_ANCHOR, startDateAnchor)
endDateAnchor && commit(CONDITIONS.SET_END_DAY_ANCHOR, endDateAnchor)
}
}
const mutations = {
// 门店
[CONDITIONS.SET_MALLS] (state, malls) {
state.storeMallList = malls
},
[CONDITIONS.CHECKED_MALL_ID] (state, mallId) {
state.checkedMallId = mallId
},
[CONDITIONS.CHECKED_MULTI_MALL_ID] (state, multiMallId) {
state.multiCheckedMallId = multiMallId
},
// 出入口
[CONDITIONS.SET_GATES] (state, gates) {
state.storeGateList = gates
},
[CONDITIONS.CHECKED_GATE_ID] (state, gateId) {
state.checkedGateId = gateId
},
[CONDITIONS.CHECKED_MULTI_GATE_ID] (state, multiGateId) {
state.multiCheckedGateId = multiGateId
},
// 日期数据 年月日
[CONDITIONS.SET_BASE_DATE_DATA] (state, dateData) {
state.dateData = dateData
},
// 日级时间
[CONDITIONS.SET_SELECTED_DAY_TIME] (state, dayTimeText) {
state.selectedDayTime = dayTimeText
},
[CONDITIONS.SET_DAY_ANCHOR] (state, dayAnchor) {
state.dayAnchor = dayAnchor
},
// 开始结束日期
[CONDITIONS.SET_START_END_DATE_DATA] (state, startEndDateData) {
state.startEndDateData = startEndDateData;
},
[CONDITIONS.SET_SELECTED_START_DAY_TIME] (state, startDateText) {
state.selectedStartDayTime = startDateText
},
[CONDITIONS.SET_START_DAY_ANCHOR] (state, startDateAnchor) {
state.startDayAnchor = startDateAnchor
},
[CONDITIONS.SET_SELECTED_END_DAY_TIME] (state, endDateText) {
state.selectedEndDayTime = endDateText
},
[CONDITIONS.SET_END_DAY_ANCHOR] (state, endDateAnchor) {
state.endDayAnchor = endDateAnchor
}
}
const conditionList = {
state: state,
getters: getter,
mutations: mutations,
actions: actions
/*
* 格式化日期 年月日
* @param {Object} date
*/
function formatterDayTime(date) {
let baseFormatter = {
Y: date.getFullYear(),
M: date.getMonth() + 1,
D: date.getDate()
}
let resFormatterTime = {};
Object.keys(baseFormatter).forEach(k => {
resFormatterTime[k] = (baseFormatter[k] + '').replace(/(?=\b\d\b)/g, '0')
})
return resFormatterTime;
}
export default conditionList;
\ No newline at end of file
/**
* 计算提前时间
* @param {Object} currentTime
* @param {Number} frontDay
*/
function frontTime(currentTime, frontDay = 15) {
return new Date(currentTime.getTime() - frontDay * 24 * 60 * 60* 1000)
}
/**
* 计算日期下标
* @param {Object} dateObject
* @param {number} dateObject
*/
function computedAnchor(dateObject, startYear) {
let tempDateAnchor = [];
Object.keys(dateObject).forEach(key => {
switch (key){
case 'Y':
tempDateAnchor.push({
index: dateObject[key] - startYear,
value: dateObject[key] + '年'
})
break;
// case '':
default:
tempDateAnchor.push({
index: dateObject[key] - 1,
value: dateObject[key] + (key === 'M' ? '月' : key === 'D' ? '日' : '')
})
break;
}
})
return tempDateAnchor
}
export default {
namespaced: true,
state,
getter,
mutations,
actions
};
\ No newline at end of file
......@@ -34,11 +34,12 @@ export const CONDITIONS = {
CHECKED_GATE_ID: 'checkedGateId',
CHECKED_MULTI_GATE_ID: 'checkedMultiGateId',
// 基础时间
SET_DATEDATA: 'setDateData',
SET_BASEDATEDATA: 'setBaseDateData',
// 天级日期
SET_SELECTED_DAY_TIME: 'setSelectedDayTime',
SET_DAY_ANCHOR: 'setDayAnchor',
// 开始结束日期
SET_START_END_DATE_DATA: 'setStartEndDateData',
SET_SELECTED_START_DAY_TIME: 'setSelectedStartDayTime',
SET_START_DAY_ANCHOR: 'setStartDayAnchor',
SET_SELECTED_END_DAY_TIME: 'setSelectedEndDayTime',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!