From f3fb56445c3d8e15ecd9e5d1b31bca13e85ac1fe Mon Sep 17 00:00:00 2001 From: Tuisku Date: Fri, 1 Jul 2022 11:45:03 +0800 Subject: [PATCH] 1.0.2 --- pages/user/subpage/newest/newest.js | 176 +++++++++++++++++++------- pages/user/subpage/newest/newest.wxml | 19 ++- pages/user/subpage/newest/newest.wxss | 18 +++ pages/user/subpage/quest/quest.js | 103 +++++++++++++-- pages/user/subpage/quest/quest.wxml | 20 ++- pages/user/subpage/quest/quest.wxss | 18 +++ 6 files changed, 293 insertions(+), 61 deletions(-) diff --git a/pages/user/subpage/newest/newest.js b/pages/user/subpage/newest/newest.js index f756f44..a3a21ea 100644 --- a/pages/user/subpage/newest/newest.js +++ b/pages/user/subpage/newest/newest.js @@ -34,23 +34,33 @@ Page({ rank: [{ name: '全部日期', is: true, - month:'' + month: '', + id: '' }, { name: '一个月内', is: false, - month:1 + month: 1, + id: 0 }, { name: '三个月内', is: false, - month:3 + month: 3, + id: 1 }, { name: '半年内', is: false, - month:6 + month: 6, + id: 2 }, { name: '一年内', is: false, - month:12 + month: 12, + id: 3 + }, { + name: '自定义', + is: false, + month: 99, + id: 4 }] }, { id: 2, @@ -75,7 +85,10 @@ Page({ brandIdList: [], keyword: '', cdn: getApp().globalData.cdn, - flag: true + flag: true, + beginTime: '', + endTime: '', + datepick: false }, /** * 生命周期函数--监听页面加载 @@ -126,14 +139,16 @@ Page({ http("/userReference/list", "post", { pageNum: this.data.page, month: this.data.month, - tagIdList: this.data.tagIdList[0]?this.data.tagIdList:[], - brandIdList: this.data.brandIdList[0]?this.data.brandIdList:[], + 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.brandIdList[0] ? this.data.brandIdList : [], keyword: this.data.keyword }).then(res => { let arr = [] res.data.records.forEach(el => { el.referenceList.forEach(e => { - e.isCollected=true + e.isCollected = true arr.push(e) }) }) @@ -167,7 +182,7 @@ Page({ // 点击事件,开始时一定会执行的,先令所有下拉选项先隐藏 const promise = new Promise((res) => { this.setData({ - showOrHide: true + showOrHide: false }) res() }) @@ -229,25 +244,33 @@ Page({ navItem, selectedItem }) - this.data.selectItem[1].rank.forEach(el=>{ + 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=>{ + this.data.selectItem[0].rank.forEach(el => { // console.log(el) - if(el.is){ + if (el.is) { this.setData({ 'tagIdList[0]': el.id }) } }) - this.data.selectItem[2].rank.forEach(el=>{ + this.data.selectItem[2].rank.forEach(el => { // console.log(el) - if(el.is){ + if (el.is) { this.setData({ 'brandIdList[0]': el.id }) @@ -260,13 +283,71 @@ Page({ }) this.getdata() }, - handleSearch(e){ + 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({ keyword: e.detail, listdata: [], - max:1, - page:1 + max: 1, + page: 1 }) this.getdata() }, @@ -281,13 +362,12 @@ Page({ let c = 'listdata[' + a + '].referenceList[' + b + '].choose' // console.log(e.currentTarget.dataset.data) this.setData({ - [c] : !this.data.listdata[a].referenceList[b].choose + [c]: !this.data.listdata[a].referenceList[b].choose }) let flag = true for (let i = 0; i < this.data.listdata[a].referenceList.length; i++) { - if (this.data.listdata[a].referenceList[i].choose) { - } else { + if (this.data.listdata[a].referenceList[i].choose) {} else { flag = false } } @@ -319,19 +399,19 @@ Page({ batch() { let arr = [] this.data.listdata.forEach(el => { - el.referenceList.forEach(e=> { + el.referenceList.forEach(e => { // console.log(e.choose) - if(e.choose){ + if (e.choose) { arr.push(e) } }) }) return arr }, - add () { + add() { let arr = this.batch() let b = [] - arr.forEach(el=>{ + arr.forEach(el => { b.push(el.id) }) if (b.length === 0) { @@ -339,8 +419,8 @@ Page({ title: '请选择', icon: 'none', duration: 1000 - }) - return 0 + }) + return 0 } http("/userReference/addGroup", "post", { referenceIdList: b @@ -350,7 +430,7 @@ Page({ icon: 'none', duration: 2000 }).then(res => { - if (re.code === 200){ + if (re.code === 200) { this.setData({ listdata: [], page: 1 @@ -360,10 +440,10 @@ Page({ }) }) }, - del () { + del() { let arr = this.batch() let b = [] - arr.forEach(el=>{ + arr.forEach(el => { b.push(el.id) }) if (b.length === 0) { @@ -371,8 +451,8 @@ Page({ title: '请选择', icon: 'none', duration: 1000 - }) - return 0 + }) + return 0 } http("/userReference/delGroup", "post", { referenceIdList: b @@ -382,7 +462,7 @@ Page({ icon: 'none', duration: 2000 }).then(res => { - if (re.code === 200){ + if (re.code === 200) { this.setData({ listdata: [], page: 1 @@ -392,10 +472,10 @@ Page({ }) }) }, - batchdown(){ + batchdown() { let arr = this.batch() let b = [] - arr.forEach(el=>{ + arr.forEach(el => { b.push(el.fileUrl) }) if (b.length === 0) { @@ -403,14 +483,14 @@ Page({ title: '请选择', icon: 'none', duration: 1000 - }) - return 0 + }) + return 0 } - b.forEach(el=>{ + b.forEach(el => { this.downloadfile(el) }) }, - downloadfile(url){ + downloadfile(url) { wx.showLoading({ title: '正在下载', mask: true @@ -418,7 +498,7 @@ Page({ console.log(this.data.cdn + url) //下载文件,生成临时地址 wx.downloadFile({ - url: this.data.cdn + url, + url: this.data.cdn + url, success(res) { console.log(res) //保存到本地 @@ -426,12 +506,12 @@ Page({ tempFilePath: res.tempFilePath, success: function (res) { console.log(res) - console.log('保存到本地',res) + console.log('保存到本地', res) wx.saveVideoToPhotosAlbum({ filePath: res.savedFilePath, - complete(res){ + complete(res) { wx.hideLoading(); - console.log('保存到相册',res) + console.log('保存到相册', res) } }) }, @@ -439,7 +519,7 @@ Page({ wx.hideLoading(); console.log('保存失败:', err) }, - complete(res){ + complete(res) { wx.hideLoading(); console.log(res) } diff --git a/pages/user/subpage/newest/newest.wxml b/pages/user/subpage/newest/newest.wxml index bfabd2b..e96112a 100644 --- a/pages/user/subpage/newest/newest.wxml +++ b/pages/user/subpage/newest/newest.wxml @@ -27,4 +27,21 @@ - \ No newline at end of file + + + + + + + 开始时间: {{beginTime}} + + + + + 结束时间: {{endTime}} + + + + + + \ No newline at end of file diff --git a/pages/user/subpage/newest/newest.wxss b/pages/user/subpage/newest/newest.wxss index f6fae28..6458ad5 100644 --- a/pages/user/subpage/newest/newest.wxss +++ b/pages/user/subpage/newest/newest.wxss @@ -269,4 +269,22 @@ .getmore{ margin: 20rpx; +} + +.mask-content { + background-color: white; + border-radius: 8rpx; + width: 500rpx; + /* height: 250rpx; */ + padding: 32rpx; +} + +.picker { + /* width: 622rpx; */ + /* height: 80rpx; */ + padding: 24rpx; + background: #F9F9F9; + border-radius: 8rpx; + display: flex; + align-items: center; } \ No newline at end of file diff --git a/pages/user/subpage/quest/quest.js b/pages/user/subpage/quest/quest.js index 9a5f43d..8c3bd60 100644 --- a/pages/user/subpage/quest/quest.js +++ b/pages/user/subpage/quest/quest.js @@ -56,23 +56,33 @@ Page({ rank: [{ title: '全部日期', is: true, - month: '' + month: '', + id: '' }, { title: '一个月内', is: false, - month: 1 + month: 1, + id: 0 }, { title: '三个月内', is: false, - month: 3 + month: 3, + id: 1 }, { title: '半年内', is: false, - month: 6 + month: 6, + id: 2 }, { title: '一年内', is: false, - month: 12 + month: 12, + id: 3 + }, { + title: '自定义', + is: false, + month: 99, + id: 4 }] }, { id: 3, @@ -96,7 +106,10 @@ Page({ month: '', tagIdList: [], brandIdList: [], - keyword: '' + keyword: '', + beginTime: '', + endTime: '', + datepick: false }, /** @@ -153,6 +166,8 @@ Page({ pageNum: this.data.page, status: this.data.status, 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.brandIdList[0]?this.data.brandIdList:[], keyword: this.data.keyword @@ -184,7 +199,7 @@ Page({ // 点击事件,开始时一定会执行的,先令所有下拉选项先隐藏 const promise = new Promise((res) => { this.setData({ - showOrHide: true + showOrHide: false }) res() }) @@ -250,10 +265,18 @@ Page({ }) this.data.selectItem[2].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=>{ @@ -287,6 +310,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[2].rank[5].title': '自定义', + 'selectItem[2].rank[0].is': true, + 'selectItem[2].rank[0].is': false, + 'navItem[2].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[2].rank[5].title': this.data.beginTime + ' ~ ' + this.data.endTime, + 'navItem[2].name': this.data.beginTime + ' ~ ' + this.data.endTime, + month: '', + questes: [], + page: 1, + maxpage: 1 + }) + this.getdata() + } + } + }, /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/pages/user/subpage/quest/quest.wxml b/pages/user/subpage/quest/quest.wxml index 4558d27..87347f1 100644 --- a/pages/user/subpage/quest/quest.wxml +++ b/pages/user/subpage/quest/quest.wxml @@ -8,6 +8,7 @@ {{item.name}} + @@ -46,4 +47,21 @@ - \ No newline at end of file + + + + + + + 开始时间: {{beginTime}} + + + + + 结束时间: {{endTime}} + + + + + + diff --git a/pages/user/subpage/quest/quest.wxss b/pages/user/subpage/quest/quest.wxss index 9da6755..b67d936 100644 --- a/pages/user/subpage/quest/quest.wxss +++ b/pages/user/subpage/quest/quest.wxss @@ -224,4 +224,22 @@ .main { background-color: #F9F9F9; min-height: 100vh; +} + +.mask-content { + background-color: white; + border-radius: 8rpx; + width: 500rpx; + /* height: 250rpx; */ + padding: 32rpx; +} + +.picker { + /* width: 622rpx; */ + /* height: 80rpx; */ + padding: 24rpx; + background: #F9F9F9; + border-radius: 8rpx; + display: flex; + align-items: center; } \ No newline at end of file