Browse Source

fix time select

voice
刘嘉炜 4 years ago
parent
commit
d6f951e3f5
  1. 10
      src/pages/time_select/date/date.vue
  2. 8
      src/pages/time_select/month/month.vue
  3. 12
      src/pages/time_select/year/year.vue
  4. 43
      src/pages/turnover/turnover.vue

10
src/pages/time_select/date/date.vue

@ -49,8 +49,8 @@ export default {
}
},
onLoad(options){
this.curDay = options.date || ''
this.getRecord();
this.curDay = options.date || '';
this.getRecord(options.store_id || '');
// this.getDateArr({});
},
methods: {
@ -113,11 +113,13 @@ export default {
return _dateArr
},
//
getRecord(){
getRecord(storeID = ''){
util.showLoad();
servers.get({
url: API.turnoverDay,
data: {},
data: {
stadium_id: storeID
},
failMsg: '加载失败!',
})
.then(e=>{

8
src/pages/time_select/month/month.vue

@ -64,7 +64,7 @@ export default {
month: _date[1],
}
this.curMonth = _obj;
this.getServerRecord();
this.getServerRecord(options.store_id || '');
},
methods: {
//
@ -113,11 +113,13 @@ export default {
util.routeTo();
},
//
getServerRecord(){
getServerRecord(storeID = ''){
util.showLoad();
servers.get({
url: API.turnoverMonth,
data: {},
data: {
stadium_id: storeID
},
failMsg: '加载记录失败!',
})
.then(e=>{

12
src/pages/time_select/year/year.vue

@ -25,12 +25,12 @@ export default {
data(){
return {
serverRecord: [], //
curYear: '' //
curYear: '', //
}
},
onLoad(options){
this.curYear = options.date;
this.getServerRecord();
this.curYear = options.date || '';
this.getServerRecord(options.store_id || '');
},
methods: {
selectYear(e){
@ -55,10 +55,12 @@ export default {
});
},
//
getServerRecord(){
getServerRecord(storeID = ''){
servers.get({
url: API.turnoverYear,
data: {},
data: {
stadium_id: storeID
},
failMsg: '加载记录失败!'
})
.then(res=>{

43
src/pages/turnover/turnover.vue

@ -10,7 +10,7 @@
<view>{{pageInfo.name || '-'}}</view>
<!-- <image mode="aspectFit" src="/static/images/icon/arrow_b2.png"></image> -->
</view>
<view class="tts-address" v-else-if="storeList.length ==1">
<view class="tts-address" v-else-if="tabID == 1&&storeList.length ==1">
<view>{{curSelectStore.name || '-'}}</view>
<!-- <image mode="aspectFit" src="/static/images/icon/arrow_b2.png"></image> -->
</view>
@ -98,10 +98,13 @@ export default {
return {
tabID: 0,
timeTabID: 0,
pageInfo: {
calc: {}
},
storeList: [], //
curSelectStore: {}, //
curTime: {
@ -112,25 +115,28 @@ export default {
}
},
onLoad(){
async onLoad(){
let { timeTabID } = this;
let _timeObj = this.getTime();
this.getBrandInfo({
type: timeTabID + 1,
date: _timeObj.date,
});
this.getStoreList();
this.curTime = _timeObj;
let _storeList = await this.getStoreList();
if(_storeList.length == 1)this.tabID = 1;
this.$nextTick(this.refreshPageInfo);
},
methods: {
//
toTimeSelect(type){
let { curTime } = this;
if(type == 0)util.routeTo(`/pages/time_select/date/date?date=${curTime.date || ''}`,'nT');
if(type == 2)util.routeTo(`/pages/time_select/month/month?date=${curTime.month || ''}`,'nT');
if(type == 3)util.routeTo(`/pages/time_select/year/year?date=${curTime.year || ''}`,'nT');
let { curTime, tabID, curSelectStore } = this;
let storeID = '';
if(tabID == 1)storeID = curSelectStore.id;
if(type == 0)util.routeTo(`/pages/time_select/date/date?date=${curTime.date || ''}&store_id=${storeID}`,'nT');
if(type == 2)util.routeTo(`/pages/time_select/month/month?date=${curTime.month || ''}&store_id=${storeID}`,'nT');
if(type == 3)util.routeTo(`/pages/time_select/year/year?date=${curTime.year || ''}&store_id=${storeID}`,'nT');
},
//
refreshPageInfo(){
let { tabID, timeTabID, curSelectStore, curTime } = this;
let _date;
@ -147,14 +153,16 @@ export default {
this.getBrandInfo(_query);
},
//
storeChange(e){
let { storeList } = this;
let { value } = e.detail;
this.curSelectStore = storeList[value];
this.refreshPageInfo();
},
//
timeChange(date){
let { timeTabID, timePickerRange } = this;
let { timeTabID } = this;
if(timeTabID == 0) this.curTime.date = date;
if(timeTabID == 2) this.curTime.month = date;
@ -162,7 +170,7 @@ export default {
this.refreshPageInfo();
},
//
//
getTime(){
let _date = new Date();
let _year = _date.getFullYear();
@ -179,14 +187,16 @@ export default {
this.tabID = type;
this.refreshPageInfo();
},300,300),
timeTabChange: util.debounce(function(type){
this.timeTabID = type;
this.refreshPageInfo();
},300,300),
//
getStoreList(){
let { brandInfo } = this;
servers.get({
return servers.get({
url: API.stadiumList,
data: {
brand_id: brandInfo.brand.id,
@ -194,11 +204,14 @@ export default {
failMsg: '加载店铺列表失败!',
})
.then(res=>{
// let _list = [res.list[0]] || [];
let _list = res.list || [];
this.storeList = _list;
this.curSelectStore = _list[0] || {};
return _list || [];
})
},
getBrandInfo({
date,
type,

Loading…
Cancel
Save