From 56016a9a88e441371a1245bde4af155774144d21 Mon Sep 17 00:00:00 2001 From: ivo Date: Wed, 15 Feb 2023 16:46:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=A0=87=E5=87=86=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/additive/list/additive-list.wxml | 6 +- pages/home/home.wxml | 4 +- pages/home/home.wxss | 3 + pages/home/session/session.js | 97 ++++++++++++++++++++++++-- pages/home/session/session.json | 5 +- pages/home/session/session.wxml | 62 +++++++++++++--- pages/home/session/session.wxss | 43 +++++++++++- services/api/session.js | 8 +++ 8 files changed, 208 insertions(+), 20 deletions(-) diff --git a/pages/additive/list/additive-list.wxml b/pages/additive/list/additive-list.wxml index b635889..8921284 100644 --- a/pages/additive/list/additive-list.wxml +++ b/pages/additive/list/additive-list.wxml @@ -8,7 +8,11 @@ - {{item.name}} + + {{item.name}} + cns: {{item.cns}} + ins: {{item.ins}} + {{item.enName}} {{item.function}} diff --git a/pages/home/home.wxml b/pages/home/home.wxml index 67464a3..059b173 100644 --- a/pages/home/home.wxml +++ b/pages/home/home.wxml @@ -13,7 +13,9 @@ - + diff --git a/pages/home/home.wxss b/pages/home/home.wxss index 7c8299d..0619562 100644 --- a/pages/home/home.wxss +++ b/pages/home/home.wxss @@ -51,6 +51,9 @@ page { margin-right: 70px; background-color: #ffcd38; font-weight: 600; + display: flex; + justify-content: center; + align-items: center; } .home-page-container, diff --git a/pages/home/session/session.js b/pages/home/session/session.js index d91662c..11e8804 100644 --- a/pages/home/session/session.js +++ b/pages/home/session/session.js @@ -1,7 +1,8 @@ // pages/home/session/session.js import { sessionQuery, - sessionAdditiveQuery + sessionAdditiveQuery, + sessionChangeStandard } from '../../../services/api/session'; import { sessionUpload @@ -38,6 +39,10 @@ Page({ }, visibleImages: false, additives: [], + inter: '', + standardPopupVisible: false, + standardDialogVisible: false, + changeStandard: '' }, /** @@ -49,6 +54,54 @@ Page({ this.init(); }, + onChangeStandard() { + this.setData({ + standardDialogVisible: true + }) + }, + + onChangeStandardInput(e) { + this.setData({ + changeStandard: e.detail.value + }); + }, + + confirmStandardDialog() { + sessionChangeStandard({ + id: this.sessionId, + standard: this.data.changeStandard + }).then(respose => { + if (respose.code == 10000) { + this.setData({ + standardDialogVisible: false, + changeStandard: '' + }); + this.init(); + } + }) + }, + + closeStandardDialog() { + this.setData({ + standardDialogVisible: false + }) + }, + + onOpenStandard() { + if (this.data.pageData.standardInfo.isFound != 1) { + return + } + this.setData({ + standardPopupVisible: true + }) + }, + + onVisibleChange(e) { + this.setData({ + standardPopupVisible: e.detail.visible, + }); + }, + init() { sessionQuery({ id: this.sessionId @@ -59,13 +112,16 @@ Page({ pageData: respose.content }) console.log(this.data.pageData); + if (respose.content.standardInfo.isFound == 2) { + this.startInter(); + } } }) sessionAdditiveQuery({ id: this.sessionId }).then(respose => { this.setData({ - additives: respose.content.additives + additives: respose.content?.additives }) }) }, @@ -91,11 +147,44 @@ Page({ }, + /** + * 启动定时器 + */ + startInter: function () { + var that = this; + that.data.inter = setInterval( + function () { + // TODO 你需要无限循环执行的任务 + console.log('setInterval 每过500毫秒执行一次任务') + sessionQuery({ + id: that.sessionId + }).then(respose => { + if (respose.code == 10000) { + console.log(respose.content); + if (respose.content.standardInfo.isFound != 2) { + that.setData({ + pageData: respose.content + }) + console.log(this.data.pageData); + this.endInter(); + } + } + }) + }, 3000); + }, + /** + * 结束定时器 + */ + endInter: function () { + var that = this; + clearInterval(that.data.inter); + }, + /** * 生命周期函数--监听页面卸载 */ onUnload() { - + this.endInter() }, /** @@ -120,7 +209,7 @@ Page({ }, onTabsClick(event) { - console.log(`Click tab, tab-panel value is ${event.detail.value}.`); + // console.log(`Click tab, tab-panel value is ${event.detail.value}.`); }, onShowImages() { diff --git a/pages/home/session/session.json b/pages/home/session/session.json index 7b5da53..6b751b3 100644 --- a/pages/home/session/session.json +++ b/pages/home/session/session.json @@ -14,6 +14,9 @@ "t-image-viewer": "tdesign-miniprogram/image-viewer/image-viewer", "t-grid": "tdesign-miniprogram/grid/grid", "t-grid-item": "tdesign-miniprogram/grid/grid-item", - "t-rate": "tdesign-miniprogram/rate/rate" + "t-rate": "tdesign-miniprogram/rate/rate", + "t-popup": "tdesign-miniprogram/popup/popup", + "t-dialog": "tdesign-miniprogram/dialog/dialog", + "t-input": "tdesign-miniprogram/input/input" } } \ No newline at end of file diff --git a/pages/home/session/session.wxml b/pages/home/session/session.wxml index 3fd7e12..c7cd01a 100644 --- a/pages/home/session/session.wxml +++ b/pages/home/session/session.wxml @@ -3,8 +3,7 @@ - {{ pageData.typeName ? pageData.typeName : '无分类 | ' }} - {{ pageData.typeCode ? pageData.typeCode : 'xxx' }} + {{ pageData.standardInfo.name ? pageData.standardInfo.name : '暂无分类' }} {{ tag }} @@ -37,15 +36,18 @@ 类别: - {{pageData.typeCode}} {{pageData.typeName}} - 暂无分类 + {{pageData.standardInfo.name ? pageData.standardInfo.name : "暂无分类"}} 食品标准号: - {{pageData.standard}} + {{pageData.standard}} 暂无数据 + {{pageData.standardInfo.type}} + 标准查询中… + 修正 + 未查询到该标准,请前往国家标准网站查询或修正识别错误,再次查询。 @@ -61,7 +63,7 @@ 添加剂: {{pageData.additives.count}} - 无添加 + 无添加 @@ -79,14 +81,18 @@ 生产企业 - - {{item}} + + + {{item}} + - - {{item}} + + + {{item}} + @@ -134,4 +140,38 @@ - \ No newline at end of file + + + + + {{pageData.standardInfo.code}} + + 标准名称: + {{pageData.standardInfo.name}} + + + 标准类型: + {{pageData.standardInfo.type}} + + + 发布机构: + {{pageData.standardInfo.publicBy}} + + + 发布时间: + {{pageData.standardInfo.publicDate}} + + + 终止时间: + {{pageData.standardInfo.abolitionDate}} + + + 说明: + {{pageData.standardInfo.comment}} + + + + + + + \ No newline at end of file diff --git a/pages/home/session/session.wxss b/pages/home/session/session.wxss index 5df13fb..24e651e 100644 --- a/pages/home/session/session.wxss +++ b/pages/home/session/session.wxss @@ -86,7 +86,7 @@ .body-row { display: flex; flex-wrap: nowrap; - margin-bottom: 5px; + margin-bottom: 10px; } @@ -95,12 +95,17 @@ line-height: 1.5rem; font-weight: 500; color: rgb(20, 20, 20); + min-width: 100px; } .body-title { font-weight: 600; } +.comment { + color: rgb(150, 150, 150); +} + .body-value { font-size: 1rem; line-height: 1.5rem; @@ -110,7 +115,7 @@ .body-company { display: flex; flex-wrap: nowrap; - margin-top: 10px; + margin-top: 20px; } .body-company-icon { @@ -199,4 +204,38 @@ display: flex; justify-content: center; margin-top: 40px; +} + +.standard-tag { + margin-left: 10px; +} + +.standard-info { + background: #fff; + color: #333; + /* display: flex; + align-items: center; + justify-content: center; */ + width: 100%; + height: 500px; + padding-top: 10px; + padding-bottom: 30px; + overflow: auto; +} + +.standard-info-title { + font-size: 1.25rem; + line-height: 1.75rem; + font-weight: 600; + margin: 15px; +} + +.standard-info-item { + margin: 20px; + display: flex; +} + +.standard-info-item-title { + font-weight: 600; + min-width: 80px; } \ No newline at end of file diff --git a/services/api/session.js b/services/api/session.js index adae139..8e88014 100644 --- a/services/api/session.js +++ b/services/api/session.js @@ -74,4 +74,12 @@ export function sessionList(params) { params: params, method: 'GET' }); +} + +export function sessionChangeStandard(params) { + return request({ + path: '/session/standard/update', + params: params, + method: 'GET' + }); } \ No newline at end of file