diff --git a/src/images/empty1.png b/src/images/empty1.png new file mode 100644 index 0000000..c4f26c5 Binary files /dev/null and b/src/images/empty1.png differ diff --git a/src/images/empty2.png b/src/images/empty2.png new file mode 100644 index 0000000..09022f8 Binary files /dev/null and b/src/images/empty2.png differ diff --git a/src/images/file-label1.png b/src/images/file-label1.png new file mode 100644 index 0000000..2597a00 Binary files /dev/null and b/src/images/file-label1.png differ diff --git a/src/images/file-label2.png b/src/images/file-label2.png new file mode 100644 index 0000000..77d4457 Binary files /dev/null and b/src/images/file-label2.png differ diff --git a/src/images/file-label3.png b/src/images/file-label3.png new file mode 100644 index 0000000..e7920da Binary files /dev/null and b/src/images/file-label3.png differ diff --git a/src/images/file-label4.png b/src/images/file-label4.png new file mode 100644 index 0000000..9c429c4 Binary files /dev/null and b/src/images/file-label4.png differ diff --git a/src/images/file-label5.png b/src/images/file-label5.png new file mode 100644 index 0000000..bf0b788 Binary files /dev/null and b/src/images/file-label5.png differ diff --git a/src/images/file-label6.png b/src/images/file-label6.png new file mode 100644 index 0000000..c4525f4 Binary files /dev/null and b/src/images/file-label6.png differ diff --git a/src/images/file-label7.png b/src/images/file-label7.png new file mode 100644 index 0000000..d16e7c4 Binary files /dev/null and b/src/images/file-label7.png differ diff --git a/src/pages/home/index.scss b/src/pages/home/index.scss index 4e8d075..9e66c4d 100644 --- a/src/pages/home/index.scss +++ b/src/pages/home/index.scss @@ -584,11 +584,24 @@ page { border-radius: 24rpx; display: flex; gap: 24rpx; - .photo { - flex-shrink: 0; + .photo-wrap { + position: relative; width: 176rpx; height: 176rpx; border-radius: 24rpx; + .photo { + flex-shrink: 0; + width: 100%; + height: 100%; + border-radius: 24rpx; + } + .label { + position: absolute; + left: -12rpx; + bottom: 12rpx; + width: 74rpx; + height: 36rpx; + } } .wrap { padding-top: 12rpx; diff --git a/src/pages/home/index.ts b/src/pages/home/index.ts index 6437079..3bf9056 100644 --- a/src/pages/home/index.ts +++ b/src/pages/home/index.ts @@ -26,6 +26,16 @@ Page({ sopList: [], list: [] as any[], + + fileLabelIcon: { + pdf: 'file-label1', + doc: 'file-label2', + docx: 'file-label3', + pptx: 'file-label4', + xls: 'file-label5', + xlsx: 'file-label6', + ppt: 'file-label7', + }, }, onShow() { app.waitLogin({ type: 2 }).then(() => { @@ -193,13 +203,14 @@ Page({ }).then((res) => { res.list.forEach((item) => { item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD'); + item.FileType = item.FileList[0]?.FileType || ''; }); this.setData({ list: res.list, }); }); }, - handleDetail(e: any) { + handleBriefingDetail(e: any) { const { id } = e.currentTarget.dataset; wx.navigateTo({ url: `/pages/informationDetail/index?id=${id}`, @@ -217,9 +228,23 @@ Page({ mask: true, }); app.mpBehavior({ PositionId: '1', OperateType: '2', OperateId: Id as string }); + this.handleFile(params); + }, + handleDetail(e: any) { + const { id, index } = e.currentTarget.dataset; + const params = this.data.list[index]; + if (params.ContentType === '5' && params.FileList[0]) { + this.handleFile(params.FileList[0]); + } else { + wx.navigateTo({ + url: `/pages/informationDetail/index?id=${id}`, + }); + } + }, + handleFile({ FileUrl, FileName }) { wx.downloadFile({ - url: params.FileUrl, - filePath: `${wx.env.USER_DATA_PATH}/${params.FileName}`, + url: FileUrl, + filePath: `${wx.env.USER_DATA_PATH}/${FileName}`, success: (res) => { if (res.statusCode === 200) { wx.openDocument({ diff --git a/src/pages/home/index.wxml b/src/pages/home/index.wxml index 4d561a8..9ec7896 100644 --- a/src/pages/home/index.wxml +++ b/src/pages/home/index.wxml @@ -176,7 +176,7 @@ wx:key="index" class="card" src="{{item.CoverImgUrl}}" - bind:tap="handleDetail" + bind:tap="handleBriefingDetail" data-id="{{item.Id}}" > @@ -220,8 +220,22 @@ - - + + + + + {{item.Title}} diff --git a/src/pages/information/index.scss b/src/pages/information/index.scss index 0e747e5..8b8423d 100644 --- a/src/pages/information/index.scss +++ b/src/pages/information/index.scss @@ -32,11 +32,24 @@ page { background-color: #fff; border-radius: 24rpx; display: flex; - .photo { - flex-shrink: 0; + .photo-wrap { + position: relative; width: 176rpx; height: 176rpx; - border-radius: 12rpx; + border-radius: 24rpx; + .photo { + flex-shrink: 0; + width: 100%; + height: 100%; + border-radius: 24rpx; + } + .label { + position: absolute; + left: -12rpx; + bottom: 12rpx; + width: 74rpx; + height: 36rpx; + } } .wrap { padding: 12rpx 24rpx 0 24rpx; diff --git a/src/pages/information/index.ts b/src/pages/information/index.ts index 313bc26..aed003f 100644 --- a/src/pages/information/index.ts +++ b/src/pages/information/index.ts @@ -27,6 +27,7 @@ Page({ }).then((res) => { res.list.forEach((item) => { item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD'); + item.FileType = item.FileList[0]?.FileType || ''; }); const list = res.page === 1 ? res.list : [...this.data.list, ...res.list]; this.setData({ @@ -47,10 +48,51 @@ Page({ } }, handleDetail(e) { - const { id } = e.currentTarget.dataset; - - wx.navigateTo({ - url: `/pages/informationDetail/index?id=${id}`, + const { id, index } = e.currentTarget.dataset; + const params = this.data.list[index]; + if (params.ContentType === '5' && params.FileList[0]) { + this.handleFile(params.FileList[0]); + } else { + wx.navigateTo({ + url: `/pages/informationDetail/index?id=${id}`, + }); + } + }, + handleFile({ FileUrl, FileName }) { + wx.downloadFile({ + url: FileUrl, + filePath: `${wx.env.USER_DATA_PATH}/${FileName}`, + success: (res) => { + if (res.statusCode === 200) { + wx.openDocument({ + showMenu: false, + filePath: res.filePath, + success: () => { + wx.hideLoading(); + }, + fail: () => { + wx.showToast({ + title: '下载文件失败', + icon: 'none', + }); + wx.hideLoading(); + }, + }); + } else { + wx.hideLoading(); + wx.showToast({ + title: '下载文件失败', + icon: 'none', + }); + } + }, + fail() { + wx.hideLoading(); + wx.showToast({ + title: '下载文件失败', + icon: 'none', + }); + }, }); }, onShareAppMessage(e) { diff --git a/src/pages/information/index.wxml b/src/pages/information/index.wxml index 0142998..4655c70 100644 --- a/src/pages/information/index.wxml +++ b/src/pages/information/index.wxml @@ -9,8 +9,15 @@ - - + + + + + {{item.Title}} diff --git a/src/pages/informationDetail/index.scss b/src/pages/informationDetail/index.scss index a5f61ad..a72cb0b 100644 --- a/src/pages/informationDetail/index.scss +++ b/src/pages/informationDetail/index.scss @@ -112,3 +112,30 @@ } } } + +.empty1, +.empty2 { + padding: 300rpx 0 0; + text-align: center; + .empty { + width: 458rpx; + height: 304rpx; + } + .tip { + font-size: 32rpx; + color: rgba(33, 29, 46, 1); + line-height: 36rpx; + } + .back-home { + margin: 60rpx auto 0; + width: 404rpx; + height: 88rpx; + display: flex; + align-items: center; + justify-content: center; + font-size: 36rpx; + color: rgba(255, 255, 255, 1); + background: linear-gradient(197deg, #ffbcf9 0%, #b982ff 100%); + border-radius: 100rpx 100rpx 100rpx 100rpx; + } +} diff --git a/src/pages/informationDetail/index.ts b/src/pages/informationDetail/index.ts index b391fb7..ddbb20c 100644 --- a/src/pages/informationDetail/index.ts +++ b/src/pages/informationDetail/index.ts @@ -10,6 +10,11 @@ Page({ position: 'bottom', } as any, + pageShow: false, + empty1: false, + empty2: false, + errorMsg: '', + Timestamp: '', doc: '1', @@ -45,22 +50,37 @@ Page({ data: { Id: this.data.id, }, - }).then((res) => { - if (res.ContentType == '4') { - wx.hideShareMenu(); - wx.offCopyUrl(); - wx.setNavigationBarTitle({ - title: '通知详情', + showMsg: false, + }) + .then((res) => { + if (res.ContentType == '4') { + wx.hideShareMenu(); + wx.offCopyUrl(); + wx.setNavigationBarTitle({ + title: '通知详情', + }); + } + this.setData({ + pageShow: true, + detail: { + ...res, + PublishTime: dayjs(res.PublishTime).format('YYYY-MM-DD'), + }, + showShare: res.ContentType !== '4', + }); + }) + .catch((err) => { + console.log(err); + const { errorCode, errorMsg } = err.data.data; + const empty1 = errorCode === '1'; + const empty2 = errorCode === '2'; + this.setData({ + pageShow: false, + errorMsg, + empty1, + empty2, }); - } - this.setData({ - detail: { - ...res, - PublishTime: dayjs(res.PublishTime).format('YYYY-MM-DD'), - }, - showShare: res.ContentType !== '4', }); - }); }, handlePopup(e) { const { index } = e.currentTarget.dataset; @@ -132,6 +152,12 @@ Page({ }, }); }, + handleBackHome() { + wx.reLaunch({ + url: '/pages/home/index', + }); + }, + onShareAppMessage() { const { Title, CoverImgUrl, Id } = this.data.detail; app.mpBehavior({ PositionId: '1', OperateType: '3', OperateId: Id as string }); diff --git a/src/pages/informationDetail/index.wxml b/src/pages/informationDetail/index.wxml index 10a7bf3..11d700b 100644 --- a/src/pages/informationDetail/index.wxml +++ b/src/pages/informationDetail/index.wxml @@ -1,4 +1,4 @@ - + {{detail.Title}} {{detail.PublishTime}} @@ -29,6 +29,22 @@ + + + 无法查看该内容 + 回首页 + + + + 内容不存在 + 回首页 + + + + {{errorMsg}} + 回首页 + +