From 99cc549eb86e4c9f8c976c83e9c307eceaf7c204 Mon Sep 17 00:00:00 2001 From: abson Date: Fri, 25 Feb 2022 09:07:33 +0800 Subject: [PATCH] 测肤 历史档案 --- packageD/pages/AI-test-skin/history_record/history_record.js | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------- packageD/pages/AI-test-skin/history_record/history_record.json | 3 ++- packageD/pages/AI-test-skin/history_record/history_record.wxml | 29 ++++++++++++++++------------- packageD/pages/AI-test-skin/history_record/history_record.wxss | 10 +++++++++- packageD/pages/AI-test-skin/index/aiskin.wxml | 4 ++-- 5 files changed, 116 insertions(+), 70 deletions(-) diff --git a/packageD/pages/AI-test-skin/history_record/history_record.js b/packageD/pages/AI-test-skin/history_record/history_record.js index dac750e..0a97e34 100644 --- a/packageD/pages/AI-test-skin/history_record/history_record.js +++ b/packageD/pages/AI-test-skin/history_record/history_record.js @@ -177,69 +177,102 @@ Page({ return initChart; } }, + history: [], + page: 1, + no_more: 0, + isLoading: 0, + is_get: 0, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + time_sort(data) { + let arr = this.data.history; + for (let i = 0; i < data.length; i++) { + let history = data[i]; + let id = history.id; + let now = new Date(history['addtime'] * 1000); + let year = now.getFullYear(); //年 + let month = (now.getMonth() + 1).toString().padStart(2, 0); //月 + let day = (now.getDate()).toString().padStart(2, 0); //日 + let hour = (now.getHours()).toString().padStart(2, 0); //时 + let minute = (now.getMinutes()).toString().padStart(2, 0); //分 + let history_time = `${year}年${month}月`; + let time = `${year}/${month}/${day} ${hour}:${minute}`; + let time_obj = { + history_time, + time_arr: new Array(), + }; + if (arr.length > 0) { + let index = arr.findIndex(item => { + return item['history_time'] === history_time; + }) + if (index > -1) { + let obj = { + time, + id, + }; + arr[index]['time_arr'].push(obj); + } else { + arr.push(time_obj); + } + } else { + arr.push(time_obj); + } + } + return arr; + }, + + async getHistoryData() { + if (this.data.no_more) return false; + if (this.data.isLoading) return false; + this.data.isLoading = 1; + let history = this.data.history; let url = `/api/weshop/face/storeSkinface/page`; - app.request.promiseGet(url, { + const { data: res } = await request.promiseGet(url, { isShowLoading: true, data: { store_id: setting.stoid, user_id: os.user_id, + page: this.data.page, } - }).then(res => { - console.log('111111111', res); - if (ut.ajax_ok(res)) { - let data = res.data.data.pageData; - let arr = []; - for (let i = 0; i < data.length; i++) { - let history = data[i]; - let id = history.id; - let now = new Date(history['addtime'] * 1000); - let year = now.getFullYear(); //年 - let month = (now.getMonth() + 1).toString().padStart(2, 0); //月 - let day = (now.getDate()).toString().padStart(2, 0); //日 - let hour = (now.getHours()).toString().padStart(2, 0); //时 - let minute = (now.getMinutes()).toString().padStart(2, 0); //分 - let history_time = `${year}年${month}月`; - let time = `${year}/${month}/${day} ${hour}:${minute}`; - let time_obj = { - history_time, - time_arr: new Array(), - }; - if (arr.length > 0) { - let index = arr.findIndex(item => { - return item['history_time'] === history_time; - }) - if (index > -1) { - let obj = { - time, - id, - }; - arr[index]['time_arr'].push(obj); - } else { - arr.push(time_obj); - } - } else { - arr.push(time_obj); - } - } + }); + // initChart.setOption(option); + if (res.code == 0 && res.data.pageData.length > 0) { + history = this.time_sort(res.data.pageData); + this.setData({ + history, + no_more: 0, + isLoading: 0, + is_get: 1, + }) + } else { + if (res.data.page > 1) { + this.setData({ + history, + no_more: 1, + isLoading: 0, + is_get: 1, + }) + } else { this.setData({ - history: arr, + history: [], + is_get: 1, }) - initChart.setOption(option); } - - }) - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + } }, @@ -247,12 +280,12 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { - setTimeout(() => { - - }, 1000); + this.getHistoryData(); }, go_result(e) { - + let id = e.currentTarget.dataset.id; + let url =`/packageD/pages/AI-test-skin/success_result/success_result?id=${id}`; + app.goto(url); }, /** @@ -280,7 +313,8 @@ Page({ * 页面上拉触底事件的处理函数 */ onReachBottom: function () { - + this.data.page++; + this.getHistoryData(); }, /** diff --git a/packageD/pages/AI-test-skin/history_record/history_record.json b/packageD/pages/AI-test-skin/history_record/history_record.json index 3ea23fa..3a9565f 100644 --- a/packageD/pages/AI-test-skin/history_record/history_record.json +++ b/packageD/pages/AI-test-skin/history_record/history_record.json @@ -1,6 +1,7 @@ { "navigationBarTitleText": "历史变化", "usingComponents": { - "ec-canvas": "../../../components/ec-canvas/ec-canvas" + "ec-canvas": "../../../components/ec-canvas/ec-canvas", + "nodata": "/components/nodata/nodata" } } \ No newline at end of file diff --git a/packageD/pages/AI-test-skin/history_record/history_record.wxml b/packageD/pages/AI-test-skin/history_record/history_record.wxml index c0211fa..4fd17de 100644 --- a/packageD/pages/AI-test-skin/history_record/history_record.wxml +++ b/packageD/pages/AI-test-skin/history_record/history_record.wxml @@ -1,22 +1,25 @@ - 历史分析 - - - + + 历史分析 + + + + + + 注:请确保多次拍摄姿态和环境光线一致。拍摄姿态的偏移、环境光线变化或者皮肤状态变化都可能导致分数较大波动。 + - - 注:请确保多次拍摄姿态和环境光线一致。拍摄姿态的偏移、环境光线变化或者皮肤状态变化都可能导致分数较大波动。 - - 历史报告 - + 历史报告 - {{item.time}} - - {{subitem}} - 去查看 + {{item.history_time}} + + {{subitem.time}} + 去查看 + - 没有更多了 - + \ No newline at end of file diff --git a/packageD/pages/AI-test-skin/history_record/history_record.wxss b/packageD/pages/AI-test-skin/history_record/history_record.wxss index a7a41fd..f5d96b0 100644 --- a/packageD/pages/AI-test-skin/history_record/history_record.wxss +++ b/packageD/pages/AI-test-skin/history_record/history_record.wxss @@ -4,10 +4,18 @@ page { height: 100%; } -.mgv5 { +.mgb5 { margin-top: 5%; margin-bottom: 5%; } +.txt-center { + text-align: center; +} +.no-more { + font-size: 24rpx; + line-height: 3; + color: #bbb; +} .content { padding: 5%; diff --git a/packageD/pages/AI-test-skin/index/aiskin.wxml b/packageD/pages/AI-test-skin/index/aiskin.wxml index cf73e9b..deb5f90 100644 --- a/packageD/pages/AI-test-skin/index/aiskin.wxml +++ b/packageD/pages/AI-test-skin/index/aiskin.wxml @@ -1,10 +1,10 @@ - 历史档案 + 历史档案 - + 开始测肤 \ No newline at end of file -- libgit2 0.21.4