From 960c49a8b3ac11dff27cad71137f986f90f00923 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期五, 26 四月 2024 19:16:32 +0800 Subject: [PATCH] 样书申请、详情页资源显示bug修改 --- packageDomain/pages/sampleBookList/applicationForm/index.js | 39 ++++++++++++++++++++++++++++++++++----- 1 files changed, 34 insertions(+), 5 deletions(-) diff --git a/packageDomain/pages/sampleBookList/applicationForm/index.js b/packageDomain/pages/sampleBookList/applicationForm/index.js index bcb4620..8a7d525 100644 --- a/packageDomain/pages/sampleBookList/applicationForm/index.js +++ b/packageDomain/pages/sampleBookList/applicationForm/index.js @@ -68,19 +68,48 @@ }) } if (wx.getStorageSync("paperBookList")) { + const paperBookList = JSON.parse(wx.getStorageSync("paperBookList")) + for (let index = 0; index < paperBookList.length; index++) { + const item = paperBookList[index]; + if (item.publicationDate) + item.publicationDate = this.formatDate(item.publicationDate) + } that.setData({ - paperBookList: JSON.parse(wx.getStorageSync("paperBookList")), - bookList: JSON.parse(wx.getStorageSync("paperBookList")) + paperBookList: paperBookList, + bookList: paperBookList }) } if (wx.getStorageSync("electronicBookList")) { + const electronicBookList = JSON.parse(wx.getStorageSync("electronicBookList")) + for (let index = 0; index < electronicBookList.length; index++) { + const item = electronicBookList[index]; + if (item.publicationDate) + item.publicationDate = this.formatDate(item.publicationDate) + } that.setData({ - electronicBookList: JSON.parse(wx.getStorageSync("electronicBookList")) + electronicBookList: electronicBookList }) } that.getSelectBookCount(); that.getSelectPaperBookCount(); that.getPaperType(); + } + }, + + formatDate(inputDate) { + // 浣跨敤姝e垯琛ㄨ揪寮忓尮閰嶆棩鏈熼儴鍒� + const dateMatch = inputDate.match(/^(\d{4})\/(\d{1,2})\/(\d{1,2})/); + if (dateMatch) { + // 鎻愬彇骞淬�佹湀銆佹棩 + const year = dateMatch[1]; + const month = dateMatch[2].padStart(2, '0'); // 纭繚鏈堜唤涓轰袱浣嶆暟 + const day = dateMatch[3].padStart(2, '0'); // 纭繚鏃ユ湡涓轰袱浣嶆暟 + + // 鎷兼帴骞惰繑鍥炴牸寮忓寲鍚庣殑鏃ユ湡 + return `${year}-${month}-${day}`; + } else { + // 濡傛灉娌℃湁鍖归厤鍒版棩鏈熼儴鍒嗭紝鍒欒繑鍥炲師濮嬭緭鍏ユ垨鎶涘嚭閿欒 + return inputDate; // 鎴栬�� throw new Error('Invalid date format'); } }, @@ -310,7 +339,7 @@ that.setData({ bookList: eList }) - wx.setStorageSync("electronicBookList", eList); + wx.setStorageSync("electronicBookList", JSON.stringify(eList)); } else { let pList = that.data.paperBookList; pList.forEach((obj, index) => { @@ -321,7 +350,7 @@ that.setData({ bookList: pList }) - wx.setStorageSync("paperBookList", pList); + wx.setStorageSync("paperBookList", JSON.stringify(pList)); } } else if (res.cancel) {} } -- Gitblit v1.9.1