Commit 99cc549eb86e4c9f8c976c83e9c307eceaf7c204

Authored by abson
1 parent deacd713

测肤 历史档案

packageD/pages/AI-test-skin/history_record/history_record.js
... ... @@ -177,69 +177,102 @@ Page({
177 177 return initChart;
178 178 }
179 179 },
  180 + history: [],
  181 + page: 1,
  182 + no_more: 0,
  183 + isLoading: 0,
  184 + is_get: 0,
180 185 },
181 186  
182 187 /**
183 188 * 生命周期函数--监听页面加载
184 189 */
185 190 onLoad: function (options) {
  191 +
  192 + },
  193 +
  194 + /**
  195 + * 生命周期函数--监听页面初次渲染完成
  196 + */
  197 + onReady: function () {
  198 +
  199 + },
  200 +
  201 + time_sort(data) {
  202 + let arr = this.data.history;
  203 + for (let i = 0; i < data.length; i++) {
  204 + let history = data[i];
  205 + let id = history.id;
  206 + let now = new Date(history['addtime'] * 1000);
  207 + let year = now.getFullYear(); //年
  208 + let month = (now.getMonth() + 1).toString().padStart(2, 0); //月
  209 + let day = (now.getDate()).toString().padStart(2, 0); //日
  210 + let hour = (now.getHours()).toString().padStart(2, 0); //时
  211 + let minute = (now.getMinutes()).toString().padStart(2, 0); //分
  212 + let history_time = `${year}年${month}月`;
  213 + let time = `${year}/${month}/${day} ${hour}:${minute}`;
  214 + let time_obj = {
  215 + history_time,
  216 + time_arr: new Array(),
  217 + };
  218 + if (arr.length > 0) {
  219 + let index = arr.findIndex(item => {
  220 + return item['history_time'] === history_time;
  221 + })
  222 + if (index > -1) {
  223 + let obj = {
  224 + time,
  225 + id,
  226 + };
  227 + arr[index]['time_arr'].push(obj);
  228 + } else {
  229 + arr.push(time_obj);
  230 + }
  231 + } else {
  232 + arr.push(time_obj);
  233 + }
  234 + }
  235 + return arr;
  236 + },
  237 +
  238 + async getHistoryData() {
  239 + if (this.data.no_more) return false;
  240 + if (this.data.isLoading) return false;
  241 + this.data.isLoading = 1;
  242 + let history = this.data.history;
186 243 let url = `/api/weshop/face/storeSkinface/page`;
187   - app.request.promiseGet(url, {
  244 + const { data: res } = await request.promiseGet(url, {
188 245 isShowLoading: true,
189 246 data: {
190 247 store_id: setting.stoid,
191 248 user_id: os.user_id,
  249 + page: this.data.page,
192 250 }
193   - }).then(res => {
194   - console.log('111111111', res);
195   - if (ut.ajax_ok(res)) {
196   - let data = res.data.data.pageData;
197   - let arr = [];
198   - for (let i = 0; i < data.length; i++) {
199   - let history = data[i];
200   - let id = history.id;
201   - let now = new Date(history['addtime'] * 1000);
202   - let year = now.getFullYear(); //年
203   - let month = (now.getMonth() + 1).toString().padStart(2, 0); //月
204   - let day = (now.getDate()).toString().padStart(2, 0); //日
205   - let hour = (now.getHours()).toString().padStart(2, 0); //时
206   - let minute = (now.getMinutes()).toString().padStart(2, 0); //分
207   - let history_time = `${year}年${month}月`;
208   - let time = `${year}/${month}/${day} ${hour}:${minute}`;
209   - let time_obj = {
210   - history_time,
211   - time_arr: new Array(),
212   - };
213   - if (arr.length > 0) {
214   - let index = arr.findIndex(item => {
215   - return item['history_time'] === history_time;
216   - })
217   - if (index > -1) {
218   - let obj = {
219   - time,
220   - id,
221   - };
222   - arr[index]['time_arr'].push(obj);
223   - } else {
224   - arr.push(time_obj);
225   - }
226   - } else {
227   - arr.push(time_obj);
228   - }
229   - }
  251 + });
  252 + // initChart.setOption(option);
  253 + if (res.code == 0 && res.data.pageData.length > 0) {
  254 + history = this.time_sort(res.data.pageData);
  255 + this.setData({
  256 + history,
  257 + no_more: 0,
  258 + isLoading: 0,
  259 + is_get: 1,
  260 + })
  261 + } else {
  262 + if (res.data.page > 1) {
  263 + this.setData({
  264 + history,
  265 + no_more: 1,
  266 + isLoading: 0,
  267 + is_get: 1,
  268 + })
  269 + } else {
230 270 this.setData({
231   - history: arr,
  271 + history: [],
  272 + is_get: 1,
232 273 })
233   - initChart.setOption(option);
234 274 }
235   -
236   - })
237   - },
238   -
239   - /**
240   - * 生命周期函数--监听页面初次渲染完成
241   - */
242   - onReady: function () {
  275 + }
243 276  
244 277 },
245 278  
... ... @@ -247,12 +280,12 @@ Page({
247 280 * 生命周期函数--监听页面显示
248 281 */
249 282 onShow: function () {
250   - setTimeout(() => {
251   -
252   - }, 1000);
  283 + this.getHistoryData();
253 284 },
254 285 go_result(e) {
255   -
  286 + let id = e.currentTarget.dataset.id;
  287 + let url =`/packageD/pages/AI-test-skin/success_result/success_result?id=${id}`;
  288 + app.goto(url);
256 289 },
257 290  
258 291 /**
... ... @@ -280,7 +313,8 @@ Page({
280 313 * 页面上拉触底事件的处理函数
281 314 */
282 315 onReachBottom: function () {
283   -
  316 + this.data.page++;
  317 + this.getHistoryData();
284 318 },
285 319  
286 320 /**
... ...
packageD/pages/AI-test-skin/history_record/history_record.json
1 1 {
2 2 "navigationBarTitleText": "历史变化",
3 3 "usingComponents": {
4   - "ec-canvas": "../../../components/ec-canvas/ec-canvas"
  4 + "ec-canvas": "../../../components/ec-canvas/ec-canvas",
  5 + "nodata": "/components/nodata/nodata"
5 6 }
6 7 }
7 8 \ No newline at end of file
... ...
packageD/pages/AI-test-skin/history_record/history_record.wxml
1 1 <view class="content">
2   - <view style="margin-bottom: 5%;">历史分析</view>
3   - <view class="echarts" style="border-radius: 30rpx;">
4   - <view class="tubiao">
5   - <ec-canvas id="mychart" canvas-id="mychart-bar" ec="{{ec}}"></ec-canvas>
  2 + <view style="display: none;">
  3 + <view style="margin-bottom: 5%;">历史分析</view>
  4 + <view class="echarts" style="border-radius: 30rpx;">
  5 + <view class="tubiao">
  6 + <ec-canvas id="mychart" canvas-id="mychart-bar" ec="{{ec}}"></ec-canvas>
  7 + </view>
  8 + <text class="fs24" style="position:absolute;bottom:25px;color: #333;">
  9 + 注:请确保多次拍摄姿态和环境光线一致。拍摄姿态的偏移、环境光线变化或者皮肤状态变化都可能导致分数较大波动。
  10 + </text>
6 11 </view>
7   - <text class="fs24" style="position:absolute;bottom:25px;color: #333;">
8   - 注:请确保多次拍摄姿态和环境光线一致。拍摄姿态的偏移、环境光线变化或者皮肤状态变化都可能导致分数较大波动。
9   - </text>
10 12 </view>
11   - <view class="mgv5">历史报告</view>
12   -
  13 + <view class="mgb5">历史报告</view>
13 14 <view class="history_list">
14 15 <view class="history_list_month" wx:for="{{history}}">
15   - <view style="color:#333;font-size:26rpx;margin-top: 30rpx">{{item.time}}</view>
16   - <view class="souce" wx:for="{{item.time_arr}}" wx:for-item="subitem" wx:for-index="subindex" wx:key="subindex">
17   - <view style="font-weight: 600;">{{subitem}}</view>
18   - <view style="color: #9b9b9b;" bindtap="go_result">去查看<text style="font-size: 24rpx;" class="iconfont icon-arrow_right"></text></view>
  16 + <view style="color:#333;font-size:26rpx;margin-top: 30rpx">{{item.history_time}}</view>
  17 + <view class="souce" wx:for="{{item.time_arr}}" wx:for-item="subitem" bindtap="go_result" data-id="{{subitem.id}}" wx:for-index="subindex" wx:key="subindex">
  18 + <view style="font-weight: 600;">{{subitem.time}}</view>
  19 + <view style="color: #9b9b9b;" >去查看<text style="font-size: 24rpx;" class="iconfont icon-arrow_right"></text></view>
19 20 </view>
20 21 </view>
21 22 </view>
  23 + <view class="no-more txt-center" wx:if="{{history.length > 0 && no_more}}">- 没有更多了 -</view>
  24 + <nodata class="t-c" wx:if="{{history.length==0 && is_get}}"></nodata>
22 25 </view>
23 26 \ No newline at end of file
... ...
packageD/pages/AI-test-skin/history_record/history_record.wxss
... ... @@ -4,10 +4,18 @@ page {
4 4 height: 100%;
5 5 }
6 6  
7   -.mgv5 {
  7 +.mgb5 {
8 8 margin-top: 5%;
9 9 margin-bottom: 5%;
10 10 }
  11 +.txt-center {
  12 + text-align: center;
  13 +}
  14 +.no-more {
  15 + font-size: 24rpx;
  16 + line-height: 3;
  17 + color: #bbb;
  18 +}
11 19  
12 20 .content {
13 21 padding: 5%;
... ...
packageD/pages/AI-test-skin/index/aiskin.wxml
1 1 <view class="container1">
2 2 <view class="history">
3   - <cover-view style="padding: 0 6rpx 0 25rpx;" bindtap="goto" data-url="/packageB/pages/AI-test-skin/history_record/history_record">历史档案</cover-view>
  3 + <cover-view style="padding: 0 6rpx 0 25rpx;" bindtap="goto" data-url="/packageD/pages/AI-test-skin/history_record/history_record">历史档案</cover-view>
4 4 <text class="iconfont icon-arrow_right"></text>
5 5 </view>
6 6 <image src="{{iurl}}/miniapp/images/skinimg/shouye.jpeg"></image>
7   - <view class="start_btn" bindtap="goto" data-url="/packageB/pages/AI-test-skin/shoot_notice/shoot_notice">
  7 + <view class="start_btn" bindtap="goto" data-url="/packageD/pages/AI-test-skin/shoot_notice/shoot_notice">
8 8 <text>开始测肤</text>
9 9 </view>
10 10 </view>
11 11 \ No newline at end of file
... ...