diff --git a/pages/lookup/labelsearch/brand/brandsearch.js b/pages/lookup/labelsearch/brand/brandsearch.js index ccee29e..74087df 100644 --- a/pages/lookup/labelsearch/brand/brandsearch.js +++ b/pages/lookup/labelsearch/brand/brandsearch.js @@ -28,32 +28,32 @@ Page({ }, { id: 1, rank: [{ - title: '全部日期', + name: '全部日期', is: true, month: '', id: '' }, { - title: '一个月内', + name: '一个月内', is: false, month: 1, id: 0 }, { - title: '三个月内', + name: '三个月内', is: false, month: 3, id: 1 }, { - title: '半年内', + name: '半年内', is: false, month: 6, id: 2 }, { - title: '一年内', + name: '一年内', is: false, month: 12, id: 3 }, { - title: '自定义', + name: '自定义', is: false, month: 99, id: 4 @@ -76,7 +76,10 @@ Page({ keyword: '', cdn: getApp().globalData.cdn, searchid: '', - flag: true + flag: true, + beginTime: '', + endTime: '', + datepick: false }, /** * 生命周期函数--监听页面加载 @@ -120,6 +123,8 @@ Page({ http("/reference/listByDay", "post", { pageNum: this.data.page, month: this.data.month, + beginTime:this.data.beginTime?this.data.beginTime + ' 00:00:00':'', + endTime:this.data.endTime?this.data.endTime + ' 00:00:00':'', tagIdList: this.data.tagIdList[0]?this.data.tagIdList:[], brandIdList: [this.data.searchid], keyword: this.data.keyword @@ -160,7 +165,7 @@ Page({ // 点击事件,开始时一定会执行的,先令所有下拉选项先隐藏 const promise = new Promise((res) => { this.setData({ - showOrHide: true + showOrHide: false }) res() }) @@ -224,10 +229,18 @@ Page({ }) this.data.selectItem[1].rank.forEach(el=>{ // console.log(el) - if(el.is){ - this.setData({ - month: el.month - }) + if (el.is) { + if (el.month === 99) { + this.setData({ + datepick: true + }) + } else { + this.setData({ + month: el.month, + beginTime: '', + endTime: '' + }) + } } }) this.data.selectItem[0].rank.forEach(el=>{ @@ -245,6 +258,64 @@ Page({ }) this.getdata() }, + bindDateChange: function (e) { + this.setData({ + beginTime: e.detail.value + }) + }, + bindDateChange2: function (e) { + this.setData({ + endTime: e.detail.value + }) + }, + timeclick(e) { + console.log(e) + if (e.currentTarget.dataset.tu === '1') { + this.setData({ + beginTime: '', + endTime: '', + datepick: false, + 'selectItem[1].rank[5].title': '自定义', + 'selectItem[1].rank[0].is': true, + 'selectItem[1].rank[0].is': false, + 'navItem[1].name': '全部日期' + }) + let e = { + currentTarget:{ + dataset:{ + contant: '全部日期', + id: 0 + } + } + } + this.closeMask(e) + } else { + if (this.data.beginTime === '') { + wx.showToast({ + title: '请输入开始时间', + icon: 'none', + duration: 2000 + }) + } else if (this.data.endTime === '') { + wx.showToast({ + title: '请输入结束时间', + icon: 'none', + duration: 2000 + }) + } else { + this.setData({ + datepick: false, + 'selectItem[1].rank[5].title': this.data.beginTime + ' ~ ' + this.data.endTime, + 'navItem[1].name': this.data.beginTime + ' ~ ' + this.data.endTime, + month: '', + questes: [], + page: 1, + maxpage: 1 + }) + this.getdata() + } + } + }, handleSearch(e){ console.log(e) this.setData({ diff --git a/pages/lookup/labelsearch/tag/tagsearch.js b/pages/lookup/labelsearch/tag/tagsearch.js index ffa9703..52c1ab0 100644 --- a/pages/lookup/labelsearch/tag/tagsearch.js +++ b/pages/lookup/labelsearch/tag/tagsearch.js @@ -22,32 +22,32 @@ Page({ selectItem: [{ id: 0, rank: [{ - title: '全部日期', + name: '全部日期', is: true, month: '', id: '' }, { - title: '一个月内', + name: '一个月内', is: false, month: 1, id: 0 }, { - title: '三个月内', + name: '三个月内', is: false, month: 3, id: 1 }, { - title: '半年内', + name: '半年内', is: false, month: 6, id: 2 }, { - title: '一年内', + name: '一年内', is: false, month: 12, id: 3 }, { - title: '自定义', + name: '自定义', is: false, month: 99, id: 4 @@ -76,7 +76,10 @@ Page({ keyword: '', cdn: getApp().globalData.cdn, tagid: '', - flag:true + flag:true, + beginTime: '', + endTime: '', + datepick: false }, /** * 生命周期函数--监听页面加载 @@ -119,6 +122,8 @@ Page({ http("/reference/listByDay", "post", { pageNum: this.data.page, month: this.data.month, + beginTime:this.data.beginTime?this.data.beginTime + ' 00:00:00':'', + endTime:this.data.endTime?this.data.endTime + ' 00:00:00':'', tagIdList: [this.data.tagid], brandIdList: this.data.brandIdList[0]?this.data.brandIdList:[], keyword: this.data.keyword @@ -159,7 +164,7 @@ Page({ // 点击事件,开始时一定会执行的,先令所有下拉选项先隐藏 const promise = new Promise((res) => { this.setData({ - showOrHide: true + showOrHide: false }) res() }) @@ -223,10 +228,18 @@ Page({ }) this.data.selectItem[0].rank.forEach(el=>{ // console.log(el) - if(el.is){ - this.setData({ - month: el.month - }) + if (el.is) { + if (el.month === 99) { + this.setData({ + datepick: true + }) + } else { + this.setData({ + month: el.month, + beginTime: '', + endTime: '' + }) + } } }) this.data.selectItem[1].rank.forEach(el=>{ @@ -244,6 +257,64 @@ Page({ }) this.getdata() }, + bindDateChange: function (e) { + this.setData({ + beginTime: e.detail.value + }) + }, + bindDateChange2: function (e) { + this.setData({ + endTime: e.detail.value + }) + }, + timeclick(e) { + console.log(e) + if (e.currentTarget.dataset.tu === '1') { + this.setData({ + beginTime: '', + endTime: '', + datepick: false, + 'selectItem[0].rank[5].title': '自定义', + 'selectItem[0].rank[0].is': true, + 'selectItem[0].rank[0].is': false, + 'navItem[0].name': '全部日期' + }) + let e = { + currentTarget:{ + dataset:{ + contant: '全部日期', + id: 0 + } + } + } + this.closeMask(e) + } else { + if (this.data.beginTime === '') { + wx.showToast({ + title: '请输入开始时间', + icon: 'none', + duration: 2000 + }) + } else if (this.data.endTime === '') { + wx.showToast({ + title: '请输入结束时间', + icon: 'none', + duration: 2000 + }) + } else { + this.setData({ + datepick: false, + 'selectItem[0].rank[5].title': this.data.beginTime + ' ~ ' + this.data.endTime, + 'navItem[0].name': this.data.beginTime + ' ~ ' + this.data.endTime, + month: '', + questes: [], + page: 1, + maxpage: 1 + }) + this.getdata() + } + } + }, handleSearch(e){ console.log(e) this.setData({