From cace1ce69d76fe7f8d694edcf4701d2dcdd24646 Mon Sep 17 00:00:00 2001 From: Enzo <1284707383@qq.com> Date: Fri, 24 Sep 2021 14:07:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=88=97=E8=A1=A8/?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E4=BD=99=E9=A2=9D/=E7=A7=92=E6=9D=80?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/config.js | 2 +- pages/point/detail/detail.vue | 110 ++++++++++++++++++++++++++++++---- pages/shop/seckillList.vue | 106 +++++++++++++++++++++++++------- 3 files changed, 182 insertions(+), 36 deletions(-) diff --git a/common/js/config.js b/common/js/config.js index 8c40c53..4279dca 100644 --- a/common/js/config.js +++ b/common/js/config.js @@ -16,7 +16,7 @@ export default { //https://demo-guojiang-ec-api.guojiang.club/ baseUrl: process.env.NODE_ENV === 'development' ? - 'http://192.168.3.29/' : 'https://v3-ec-admin-dev.guojiang.club/', // 运行时自动替换变量 + 'http://192.168.3.81/' : 'https://v3-ec-admin-dev.guojiang.club/', // 运行时自动替换变量 }, PACKAGES: { activity: false, diff --git a/pages/point/detail/detail.vue b/pages/point/detail/detail.vue index dc2028f..12690d8 100644 --- a/pages/point/detail/detail.vue +++ b/pages/point/detail/detail.vue @@ -8,7 +8,7 @@ - 78326478 + {{point_data.point}} 兑换礼品 @@ -31,15 +31,24 @@ - - - {{ index % 2 ? '-250' : '+80' }} - 2021-09-01 18:27:58 - - - 商城内消费 - - + + + + {{ index % 2 ? '-250' : '+80' }} + 2021-09-01 18:27:58 + + + 商城内消费 + + + + + {{ loadingText }} + + + @@ -48,15 +57,92 @@ export default { data(){ return { - date: '' + date: '', + point_data: '', + list: [], + page: 1, + isPage: true, + loadingClass: true, + loadingText: '正在加载中', + scrollH: 0, + nav_height: 0, + isRefresher: true, + pageSize: 10 + } + }, + computed: { + autoHeight(){ + return `calc(${this.scrollH}px - ${this.nav_height}px - 660rpx)`; } }, onLoad(){ - + let info = uni.getSystemInfoSync(); + this.scrollH = info.screenHeight; + this.getPointNum(); + this.getPointList(); }, methods: { dateChange(event){ this.date = event.detail.value; + }, + getPointNum(){ + this.$http.get({ + api: 'api/users/point', + header: { + Authorization: this.$cookieStorage.get('user_token') + } + }).then(res => { + this.point_data = res.data.data + console.log(this.point_data) + }) + }, + // 页面触底,加载下一页 + onScrolltolower(){ + if(this.isPage){ + this.page = this.page + 1; + this.getMyActivity(); + } + }, + // 下拉刷新处理 + refreshFn(options){ + this.page = 1; + this.isPage = true; + this.loadingClass = true; + this.list = [] + this.loadingText = '正在加载中'; + this.getPointList(options); + }, + // scroll-view 下拉刷新 + onRefresherrefresh(){ + this.isRefresher = true; + this.refreshFn({type: 'scrollRefresh'}); + }, + getPointList(options = {}){ + this.$http.get({ + api: 'api/users/point/list', + header: { + Authorization: this.$cookieStorage.get('user_token') + } + }).then(res => { + console.log("----", res); + let isPage = this.page < res.data.meta.pagination.total_pages?true:false; + this.isPage = isPage; + if(!isPage) { + this.loadingClass = false; + this.loadingText = '没有更多数据啦~'; + } + if(options.type == 'pageRefresh') { + uni.stopPullDownRefresh(); + }else if(options.type == 'scrollRefresh') { + this.isRefresher = false; + } + if(this.page == 1) { + this.list = res.data.data; + }else { + this.list.push(...res.data.data); + } + + }) } } } diff --git a/pages/shop/seckillList.vue b/pages/shop/seckillList.vue index db9c390..39747e2 100644 --- a/pages/shop/seckillList.vue +++ b/pages/shop/seckillList.vue @@ -1,29 +1,38 @@ @@ -32,19 +41,71 @@ export default { data(){ return { - list: [] + list: [], + page: 1, + isPage: true, + loadingClass: true, + loadingText: '正在加载中', + scrollH: 0, + nav_height: 0, + isRefresher: true, + pageSize: 10 + } + }, + computed: { + autoHeight(){ + return `calc(${this.scrollH}px - ${this.nav_height}px - 180rpx)`; } }, onLoad(){ + let info = uni.getSystemInfoSync(); + this.scrollH = info.screenHeight; this.getSeckillList(); }, methods: { - getSeckillList(){ + // 页面触底,加载下一页 + onScrolltolower(){ + if(this.isPage){ + this.page = this.page + 1; + this.getMyActivity(); + } + }, + // 下拉刷新处理 + refreshFn(options){ + this.page = 1; + this.isPage = true; + this.loadingClass = true; + this.list = [] + this.loadingText = '正在加载中'; + this.getSeckillList(options); + }, + // scroll-view 下拉刷新 + onRefresherrefresh(){ + this.isRefresher = true; + this.refreshFn({type: 'scrollRefresh'}); + }, + getSeckillList(options = {}){ this.$http.get({ api: 'api/seckill/all' }).then(res => { console.log("----", res); - this.list = res.data.data; + let isPage = this.page < res.data.meta.pagination.total_pages?true:false; + this.isPage = isPage; + if(!isPage) { + this.loadingClass = false; + this.loadingText = '没有更多数据啦~'; + } + if(options.type == 'pageRefresh') { + uni.stopPullDownRefresh(); + }else if(options.type == 'scrollRefresh') { + this.isRefresher = false; + } + if(this.page == 1) { + this.list = res.data.data; + }else { + this.list.push(...res.data.data); + } + }) } } @@ -112,7 +173,7 @@ } .desc{ width: 281rpx; - height: 35rpx; + height: max-content; border-radius: 3rpx; background-color: #E9F2F2; font-size: 24rpx; @@ -120,7 +181,6 @@ display: flex; justify-content: center; align-items: center; - margin-top: 10rpx; } .price>text:nth-child(1){ font-size: 36rpx; From f67b1f177186d213f608ebb9c97890dd7fd9f561 Mon Sep 17 00:00:00 2001 From: Enzo <1284707383@qq.com> Date: Fri, 24 Sep 2021 17:39:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/point/detail/detail.vue | 41 ++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/pages/point/detail/detail.vue b/pages/point/detail/detail.vue index 12690d8..9408e09 100644 --- a/pages/point/detail/detail.vue +++ b/pages/point/detail/detail.vue @@ -26,7 +26,7 @@ 积分变动明细 - {{ date || '2021-09-01' }} + {{ date || nowDate }} @@ -35,11 +35,11 @@ @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh"> - {{ index % 2 ? '-250' : '+80' }} - 2021-09-01 18:27:58 + {{ item.value }} + {{item.created_at}} - 商城内消费 + {{item.note}} @@ -58,6 +58,7 @@ data(){ return { date: '', + nowDate: '', point_data: '', list: [], page: 1, @@ -78,12 +79,17 @@ onLoad(){ let info = uni.getSystemInfoSync(); this.scrollH = info.screenHeight; + var date1 = new Date(); + var date2 = new Date(date1); + date2.setDate(date1.getDate()); + this.nowDate = this.$shared.recordTime(date2, '-', 'date') this.getPointNum(); this.getPointList(); }, methods: { dateChange(event){ this.date = event.detail.value; + this.getPointList(); }, getPointNum(){ this.$http.get({ @@ -100,7 +106,7 @@ onScrolltolower(){ if(this.isPage){ this.page = this.page + 1; - this.getMyActivity(); + this.getPointList(); } }, // 下拉刷新处理 @@ -110,7 +116,7 @@ this.loadingClass = true; this.list = [] this.loadingText = '正在加载中'; - this.getPointList(options); + this.getPointList(options); }, // scroll-view 下拉刷新 onRefresherrefresh(){ @@ -120,6 +126,9 @@ getPointList(options = {}){ this.$http.get({ api: 'api/users/point/list', + data: { + day: this.date || this.nowDate + }, header: { Authorization: this.$cookieStorage.get('user_token') } @@ -137,9 +146,25 @@ this.isRefresher = false; } if(this.page == 1) { - this.list = res.data.data; + let list = res.data.data; + list.forEach((item,index) => { + if(item.value.indexOf('-') != -1) { + this.$set(item,'ifNegative',true) + }else { + this.$set(item,'ifNegative',false) + } + }) + this.list = list; }else { - this.list.push(...res.data.data); + let list = res.data.data; + list.forEach((item,index) => { + if(item.value.indexOf('-') != -1) { + this.$set(item,'ifNegative',true) + }else { + this.$set(item,'ifNegative',false) + } + }) + this.list.push(...list); } })