Commit 21172d1a by 周志凯

修改vuex modules

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