kola-web 1 month ago
parent
commit
c4a5803530
  1. BIN
      src/images/empty1.png
  2. BIN
      src/images/empty2.png
  3. BIN
      src/images/file-label1.png
  4. BIN
      src/images/file-label2.png
  5. BIN
      src/images/file-label3.png
  6. BIN
      src/images/file-label4.png
  7. BIN
      src/images/file-label5.png
  8. BIN
      src/images/file-label6.png
  9. BIN
      src/images/file-label7.png
  10. 17
      src/pages/home/index.scss
  11. 31
      src/pages/home/index.ts
  12. 20
      src/pages/home/index.wxml
  13. 19
      src/pages/information/index.scss
  14. 50
      src/pages/information/index.ts
  15. 11
      src/pages/information/index.wxml
  16. 27
      src/pages/informationDetail/index.scss
  17. 54
      src/pages/informationDetail/index.ts
  18. 18
      src/pages/informationDetail/index.wxml

BIN
src/images/empty1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
src/images/empty2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
src/images/file-label1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/images/file-label2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
src/images/file-label3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
src/images/file-label4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
src/images/file-label5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
src/images/file-label6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/images/file-label7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

17
src/pages/home/index.scss

@ -584,11 +584,24 @@ page {
border-radius: 24rpx; border-radius: 24rpx;
display: flex; display: flex;
gap: 24rpx; gap: 24rpx;
.photo { .photo-wrap {
flex-shrink: 0; position: relative;
width: 176rpx; width: 176rpx;
height: 176rpx; height: 176rpx;
border-radius: 24rpx; 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 { .wrap {
padding-top: 12rpx; padding-top: 12rpx;

31
src/pages/home/index.ts

@ -26,6 +26,16 @@ Page({
sopList: [], sopList: [],
list: [] as any[], 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() { onShow() {
app.waitLogin({ type: 2 }).then(() => { app.waitLogin({ type: 2 }).then(() => {
@ -193,13 +203,14 @@ Page({
}).then((res) => { }).then((res) => {
res.list.forEach((item) => { res.list.forEach((item) => {
item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD'); item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD');
item.FileType = item.FileList[0]?.FileType || '';
}); });
this.setData({ this.setData({
list: res.list, list: res.list,
}); });
}); });
}, },
handleDetail(e: any) { handleBriefingDetail(e: any) {
const { id } = e.currentTarget.dataset; const { id } = e.currentTarget.dataset;
wx.navigateTo({ wx.navigateTo({
url: `/pages/informationDetail/index?id=${id}`, url: `/pages/informationDetail/index?id=${id}`,
@ -217,9 +228,23 @@ Page({
mask: true, mask: true,
}); });
app.mpBehavior({ PositionId: '1', OperateType: '2', OperateId: Id as string }); 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({ wx.downloadFile({
url: params.FileUrl, url: FileUrl,
filePath: `${wx.env.USER_DATA_PATH}/${params.FileName}`, filePath: `${wx.env.USER_DATA_PATH}/${FileName}`,
success: (res) => { success: (res) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
wx.openDocument({ wx.openDocument({

20
src/pages/home/index.wxml

@ -176,7 +176,7 @@
wx:key="index" wx:key="index"
class="card" class="card"
src="{{item.CoverImgUrl}}" src="{{item.CoverImgUrl}}"
bind:tap="handleDetail" bind:tap="handleBriefingDetail"
data-id="{{item.Id}}" data-id="{{item.Id}}"
></image> ></image>
<view class="none" wx:if="{{briefingList.length == 1}}"> <view class="none" wx:if="{{briefingList.length == 1}}">
@ -220,8 +220,22 @@
<van-icon name="arrow" /> <van-icon name="arrow" />
</view> </view>
</view> </view>
<view class="card" bind:tap="handleDetail" wx:for="{{list}}" wx:key="Id" data-id="{{item.Id}}"> <view
<image class="photo" src="{{item.CoverImgUrl}}"></image> class="card"
bind:tap="handleDetail"
wx:for="{{list}}"
wx:key="Id"
data-id="{{item.Id}}"
data-index="{{index}}"
>
<view class="photo-wrap">
<image class="photo" src="{{item.CoverImgUrl}}"></image>
<image
wx:if="{{fileLabelIcon[item.FileType] && item.ContentType==='5'}}"
class="label"
src="{{imageUrl}}{{fileLabelIcon[item.FileType]}}.png?t={{Timestamp}}"
></image>
</view>
<view class="wrap"> <view class="wrap">
<view class="title">{{item.Title}}</view> <view class="title">{{item.Title}}</view>
<view class="w-footer"> <view class="w-footer">

19
src/pages/information/index.scss

@ -32,11 +32,24 @@ page {
background-color: #fff; background-color: #fff;
border-radius: 24rpx; border-radius: 24rpx;
display: flex; display: flex;
.photo { .photo-wrap {
flex-shrink: 0; position: relative;
width: 176rpx; width: 176rpx;
height: 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 { .wrap {
padding: 12rpx 24rpx 0 24rpx; padding: 12rpx 24rpx 0 24rpx;

50
src/pages/information/index.ts

@ -27,6 +27,7 @@ Page({
}).then((res) => { }).then((res) => {
res.list.forEach((item) => { res.list.forEach((item) => {
item.PublishTime = dayjs(item.PublishTime).format('YYYY-MM-DD'); 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]; const list = res.page === 1 ? res.list : [...this.data.list, ...res.list];
this.setData({ this.setData({
@ -47,10 +48,51 @@ Page({
} }
}, },
handleDetail(e) { handleDetail(e) {
const { id } = e.currentTarget.dataset; const { id, index } = e.currentTarget.dataset;
const params = this.data.list[index];
wx.navigateTo({ if (params.ContentType === '5' && params.FileList[0]) {
url: `/pages/informationDetail/index?id=${id}`, 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) { onShareAppMessage(e) {

11
src/pages/information/index.wxml

@ -9,8 +9,15 @@
<!-- <view class="tag">安全性</view> --> <!-- <view class="tag">安全性</view> -->
<!-- <view class="tag">有效性</view> --> <!-- <view class="tag">有效性</view> -->
<!-- </view> --> <!-- </view> -->
<view class="card" bind:tap="handleDetail" wx:for="{{list}}" wx:key="Id" data-id="{{item.Id}}"> <view class="card" bind:tap="handleDetail" wx:for="{{list}}" wx:key="Id" data-id="{{item.Id}}" data-index="{{index}}">
<image class="photo" src="{{item.CoverImgUrl}}"></image> <view class="photo-wrap">
<image class="photo" src="{{item.CoverImgUrl}}"></image>
<image
wx:if="{{fileLabelIcon[item.FileType] && item.ContentType==='5'}}"
class="label"
src="{{imageUrl}}{{fileLabelIcon[item.FileType]}}.png?t={{Timestamp}}"
></image>
</view>
<view class="wrap"> <view class="wrap">
<view class="title">{{item.Title}}</view> <view class="title">{{item.Title}}</view>
<view class="w-footer"> <view class="w-footer">

27
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;
}
}

54
src/pages/informationDetail/index.ts

@ -10,6 +10,11 @@ Page({
position: 'bottom', position: 'bottom',
} as any, } as any,
pageShow: false,
empty1: false,
empty2: false,
errorMsg: '',
Timestamp: '', Timestamp: '',
doc: '1', doc: '1',
@ -45,22 +50,37 @@ Page({
data: { data: {
Id: this.data.id, Id: this.data.id,
}, },
}).then((res) => { showMsg: false,
if (res.ContentType == '4') { })
wx.hideShareMenu(); .then((res) => {
wx.offCopyUrl(); if (res.ContentType == '4') {
wx.setNavigationBarTitle({ wx.hideShareMenu();
title: '通知详情', 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) { handlePopup(e) {
const { index } = e.currentTarget.dataset; const { index } = e.currentTarget.dataset;
@ -132,6 +152,12 @@ Page({
}, },
}); });
}, },
handleBackHome() {
wx.reLaunch({
url: '/pages/home/index',
});
},
onShareAppMessage() { onShareAppMessage() {
const { Title, CoverImgUrl, Id } = this.data.detail; const { Title, CoverImgUrl, Id } = this.data.detail;
app.mpBehavior({ PositionId: '1', OperateType: '3', OperateId: Id as string }); app.mpBehavior({ PositionId: '1', OperateType: '3', OperateId: Id as string });

18
src/pages/informationDetail/index.wxml

@ -1,4 +1,4 @@
<view class="page"> <view class="page" wx:if="{{pageShow}}">
<view class="title">{{detail.Title}}</view> <view class="title">{{detail.Title}}</view>
<view class="info"> <view class="info">
<view class="date">{{detail.PublishTime}}</view> <view class="date">{{detail.PublishTime}}</view>
@ -29,6 +29,22 @@
</view> </view>
</view> </view>
<view class="empty1" wx:if="{{empty1}}">
<image class="empty" src="{{imageUrl}}empty1.png?t={{Timestamp}}"></image>
<view class="tip">无法查看该内容</view>
<view class="back-home" bind:tap="handleBackHome">回首页</view>
</view>
<view class="empty2" wx:elif="{{empty2}}">
<image class="empty" src="{{imageUrl}}empty2.png?t={{Timestamp}}"></image>
<view class="tip">内容不存在</view>
<view class="back-home" bind:tap="handleBackHome">回首页</view>
</view>
<view class="empty2" wx:elif="{{!pageShow}}">
<image class="empty" src="{{imageUrl}}empty2.png?t={{Timestamp}}"></image>
<view class="tip">{{errorMsg}}</view>
<view class="back-home" bind:tap="handleBackHome">回首页</view>
</view>
<popup <popup
show="{{popupShow}}" show="{{popupShow}}"
type="{{popupType}}" type="{{popupType}}"

Loading…
Cancel
Save