xiaohaizhao hai 1 ano
pai
achega
f1d1699179

+ 2 - 2
components/My_listbox.vue

@@ -92,10 +92,10 @@ export default {
         },
         /* 分页 */
         paging(content, res) {
-            content.pageNumber = res.pageNumber;
+            content.pageNumber = res.pageNumber + 1;
             content.pageTotal = res.pageTotal;
             // this.pagingText = content.pageNumber + ' / ' + content.pageTotal;
-            this.bottomTips = res.total != 0 && content.pageNumber == content.pageTotal;
+            this.bottomTips = res.total != 0 && content.pageNumber >= content.pageTotal;
             this.empty = res.total == 0;
             return content;
         }

+ 230 - 0
packageA/affiche/detail.vue

@@ -0,0 +1,230 @@
+<template>
+    <My_listbox ref="List" @getlist="getDetail">
+        <view class="content">
+            <view class="title" v-if="detail.title">
+                {{ detail.title }}
+            </view>
+            <view v-if="detail.content" class="box">
+                <u-parse :content="detail.content" />
+            </view>
+            <view v-if="showAttinfos" class="box">
+                <view class="top">
+                    <view class="text">
+                        附件
+                    </view>
+                    <view class="but" hover-class="navigator-hover" @click="showUModal = true">
+                        发邮箱
+                    </view>
+                </view>
+
+                <view class="list" v-for="item in detail.attinfos" :key="item.attachmentid" @click="previewAttinof(item)"
+                    hover-class="navigator-hover">
+                    {{ item.document }}
+                </view>
+
+                <u-modal :show="showUModal" confirmColor='#C30D23' ref="uModal" showCancelButton :asyncClose="true"
+                    @confirm="onSend" @cancel="showUModal = false">
+                    <view class="slot-content">
+                        <view class="slot-title">
+                            发送邮件
+                        </view>
+                        <view class="slot-tips">
+                            文件将以邮件的形式发送到指定邮箱
+                        </view>
+                        <u--input :focus="showUModal" placeholder="请输入邮箱" v-model="eMail" border="bottom" clearable />
+                    </view>
+                </u-modal>
+            </view>
+        </view>
+        <view class="bottom" v-if="detail.readstatus != '已知'">
+            <view class="but" hover-class="navigator-hover" @click="know">
+                确认已知晓公告
+            </view>
+        </view>
+    </My_listbox>
+</template>
+
+<script>
+import { viewMedias, viewFlies, formattedFiles } from "../../utils/previewFile"
+export default {
+    data() {
+        return {
+            sat_noticeid: "",
+            detail: { readstatus: '已知' },
+            showAttinfos: false,
+            showUModal: false,
+            eMail: ""
+        }
+    },
+    onLoad(options) {
+        wx.setNavigationBarTitle({
+            title: this.getApps('资料库', '/packageA/affiche/detail').remark || '企业公告',
+        });
+        this.sat_noticeid = options.id;
+        this.getDetail();
+    },
+    methods: {
+        getDetail() {
+            this.$Http.basic({
+                "id": "20221101095003",
+                "content": {
+                    "sat_noticeid": this.sat_noticeid
+                }
+            }).then(res => {
+                this.$refs.List.RefreshToComplete()
+                console.log("获取通告详情", res)
+                if (this.cutoff(res.msg)) return;
+                res.data.attinfos = formattedFiles(res.data.attinfos)
+                this.detail = res.data;
+                this.showAttinfos = res.data.attinfos.length != 0
+            })
+        },
+        onSend() {
+            let { CheckEmail } = require("../../utils/basicInspection");
+            if (!CheckEmail(this.eMail || '')) return this.$refs.uModal.loading = false;
+            this.$Http.basic({
+                "id": "20240320153302",
+                "content": {
+                    "sat_noticeid": this.detail.sat_noticeid,
+                    "email": this.eMail
+                }
+            }).then(res => {
+                console.log("发送邮件", res)
+                if (this.cutoff(res.msg, '发送成功')) return this.$refs.uModal.loading = false;
+                this.showUModal = false;
+            })
+        },
+        know() {
+            let that = this;
+            uni.showModal({
+                title: '提示',
+                content: '是否确定已经知晓该公告',
+                success: ({ confirm }) => {
+                    if (confirm) that.$Http.basic({
+                        "id": "20240320152902",
+                        "content": {
+                            "sat_noticeid": that.sat_noticeid
+                        }
+                    }).then(res => {
+                        if (that.cutoff(res.msg, '确定成功')) return;
+                        that.getDetail();
+                    })
+                },
+            })
+        },
+        previewAttinof(item) {
+            if (['image', 'video'].includes(item.fileType)) {
+                const list = this.detail.attinfos.filter(v => v.fileType == item.fileType),
+                    index = list.findIndex(v => v.attachmentid == item.attachmentid);
+                viewMedias(list, index, item.fileType)
+            } else {
+                viewFlies(item)
+            }
+        }
+    },
+}
+</script>
+
+<style lang="scss">
+.content {
+    padding: 10px;
+    box-sizing: border-box;
+
+    .title {
+        width: 100%;
+        font-family: Source Han Sans SC, Source Han Sans SC;
+        font-weight: bold;
+        font-size: 18px;
+        color: #333333;
+        text-align: center;
+    }
+
+    .box {
+        width: 100%;
+        background: #FFFFFF;
+        border-radius: 8px;
+        padding: 10px;
+        box-sizing: border-box;
+        margin-top: 10px;
+
+        .top {
+            display: flex;
+            justify-content: space-between;
+
+            .text {
+                font-family: PingFang SC, PingFang SC;
+                font-weight: bold;
+                font-size: 16px;
+                color: #333333;
+            }
+
+            .but {
+                width: 66px;
+                height: 32px;
+                background: #C30D23;
+                border-radius: 5px;
+                margin-top: -3px;
+                font-family: Source Han Sans SC, Source Han Sans SC;
+                font-size: 14px;
+                color: #FFFFFF;
+                line-height: 32px;
+                text-align: center;
+            }
+        }
+    }
+}
+
+.slot-content {
+    width: 100%;
+    text-align: center;
+
+    .slot-title {
+        height: 26px;
+        font-family: Source Han Sans SC, Source Han Sans SC;
+        font-weight: bold;
+        font-size: 18px;
+        color: #000000;
+    }
+
+    .slot-tips {
+        line-height: 20px;
+        font-family: Source Han Sans SC, Source Han Sans SC;
+        font-size: 14px;
+        color: #666666;
+        margin-bottom: 30px;
+        margin-top: 10px;
+    }
+}
+
+.list {
+    font-family: Source Han Sans SC, Source Han Sans SC;
+    font-size: 14px;
+    color: #095DE0;
+    line-height: 20px;
+    margin-top: 10px;
+    border-radius: 4px;
+}
+
+.bottom {
+    position: fixed;
+    bottom: 0;
+    width: 100vw;
+    height: 65px;
+    background: #FFFFFF;
+    box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
+
+    .but {
+        width: 355px;
+        height: 45px;
+        line-height: 45px;
+        background: #C30D23;
+        border-radius: 5px;
+        font-family: PingFang SC, PingFang SC;
+        font-weight: bold;
+        font-size: 14px;
+        color: #FFFFFF;
+        text-align: center;
+        margin: 6px auto;
+    }
+}
+</style>

+ 20 - 1
packageA/affiche/index.vue

@@ -63,9 +63,15 @@ export default {
         }
     },
     onLoad() {
+        wx.setNavigationBarTitle({
+            title: this.getApps('资料库', '/packageA/affiche/index').remark || '企业公告',
+        });
         this.getTypes()
         this.getList()
     },
+    onShow() {
+        this.updateList()
+    },
     methods: {
         getTypes() {
             this.$Http.basic({
@@ -100,10 +106,23 @@ export default {
                 this.$refs.List.RefreshToComplete()
                 console.log("获取通告列表", res)
                 if (this.cutoff(res.msg)) return;
-                this.list = res.data;
+                this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
                 this.content = this.$refs.List.paging(this.content, res)
             })
         },
+        updateList() {
+            if (this.content.pageNumber && this.content.pageNumber >= 2) {
+                let content = this.paging(this.content, true, true)
+                this.$Http.basic({
+                    "id": "20221111090904",
+                    content
+                }).then(res => {
+                    console.log("更新通告列表", res)
+                    if (this.cutoff(res.msg)) return;
+                    this.list = res.data;
+                })
+            }
+        },
         changeStatus() {
             this.activeStatus = this.activeStatus == '全部' ? '未读' : "全部";
             this.content.where.isread == this.activeStatus == '全部' ? "" : 2;

+ 2 - 0
pages.json

@@ -10,6 +10,8 @@
 		"root": "packageA",
 		"pages": [{
 			"path": "affiche/index"
+		}, {
+			"path": "affiche/detail"
 		}]
 	}],
 	"globalStyle": {

+ 5 - 4
pages/index/cloud/dataBank.vue

@@ -1,16 +1,17 @@
 <template>
-    <view>
-        资料库
-    </view>
+    <My_listbox>
+        <app-list model="资料库" />
+    </My_listbox>
 </template>
 
 <script>
 export default {
     data() {
         return {
-
         }
     },
+    created() {
+    }
 }
 </script>
 

+ 4 - 0
pages/index/index.vue

@@ -32,7 +32,11 @@ export default {
 		},
 		pageChange(detail) {
 			// this.$refs[detail.name]
+			uni.setNavigationBarTitle({
+				title: detail.name,
+			})
 			setTimeout(() => { detail.callBack() }, 300)
+			this.page = detail.name
 			console.log("切换页面", detail)
 		}
 	}

+ 83 - 0
utils/previewFile.js

@@ -0,0 +1,83 @@
+function formattedFiles(list) {
+    if (list.length == 0) return [];
+    let suffixList = {
+            image: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'svg', 'tiff'],
+            video: ['mp4', 'ogg', 'webm'],
+            word: ['doc', 'docx'],
+            excel: ['xls', 'xlsx'],
+            ppt: ['ppt', 'pptx'],
+            txt: ['txt', 'md', 'js', 'json'],
+            pdf: ['pdf'],
+            rar: ['7z', 'zip', 'rar', 'kz', 'ace', 'arj', 'bz2', 'cab', 'gz', 'iso', 'jar', 'lzh', 'tar', 'z'],
+            folder: ['folder']
+        },
+        typeList = [];
+    for (let key in suffixList) typeList.push(key);
+    for (let i = 0; i < list.length; i++) {
+        list[i].fileType = 'unknown';
+        const suffix = list[i].postfix.toLowerCase();
+        if (suffix != "folder") {
+            for (var key in suffixList) {
+                if (suffixList[key].some(value => value == suffix)) list[i].fileType = key;
+            }
+        } else {
+            list[i].fileType = "folder";
+        }
+    }
+    return list;
+}
+
+/* 预览媒体 */
+function viewMedias(files, index, type) {
+    // #ifndef MP
+    if (type == 'image') {
+        uni.previewImage({
+            current: index,
+            urls: files,
+            loop: true,
+        })
+    } else {
+        window.open(files[index].url)
+    }
+    // #endif
+    // #ifdef MP-WEIXIN
+    wx.previewMedia({
+        current: index,
+        sources: files,
+    })
+    // #endif       
+}
+/* 预览文档 */
+function viewFlies(item) {
+    uni.showLoading({
+        title: '加载中...',
+    })
+    uni.downloadFile({
+        url: item.url,
+        complete({
+            statusCode,
+            tempFilePath
+        }) {
+            if (statusCode != 200) return;
+            uni.openDocument({
+                filePath: tempFilePath,
+                fileType: item.postfix,
+                showMenu: true,
+                complete({
+                    errMsg
+                }) {
+                    uni.hideLoading();
+                    if (errMsg != "openDocument:ok") uni.showToast({
+                        title: '打开失败',
+                        icon: "none"
+                    })
+                }
+            })
+        }
+    })
+}
+module.exports = {
+    viewMedias,
+    viewFlies,
+    formattedFiles
+}

+ 17 - 7
utils/tool.js

@@ -82,15 +82,25 @@ function mount() {
         if (exitTime && msg == '成功') setTimeout(uni.navigateBack, exitTime)
         return msg != '成功';
     };
-    Vue.prototype.paging = (content, init) => {
-        if (content.pageTotal == undefined || !content.pageTotal) content.pageTotal = 1;
-        if (content.pageNumber == undefined || !content.pageNumber) content.pageNumber = 1;
-        if (content.pageSize == undefined || !content.pageSize) content.pageSize = 20;
-        if (init) content.pageNumber = 1;
-        return content.pageNumber > content.pageTotal;
+    Vue.prototype.paging = (content, init, update) => {
+        if (update) {
+            let content1 = JSON.parse(JSON.stringify(content));
+            content1.pageSize = (content1.pageNumber - 1) * content1.pageSize;
+            content1.pageNumber = 1;
+            return content1
+        } else {
+            if (content.pageTotal == undefined || !content.pageTotal) content.pageTotal = 1;
+            if (content.pageNumber == undefined || !content.pageNumber) content.pageNumber = 1;
+            if (content.pageSize == undefined || !content.pageSize) content.pageSize = 20;
+            if (init) content.pageNumber = 1;
+            return content.pageNumber > content.pageTotal;
+        }
     }
     Vue.prototype.tovw = (num) => (num * 100 / 375).toFixed(3) + "vw";
-    Vue.prototype.getApps = appRemark => Object.values(uni.getStorageSync('authList')[appRemark]);
+    Vue.prototype.getApps = (appRemark, route) => {
+        const list = Object.values(uni.getStorageSync('authList')[appRemark])
+        return route ? list.find(v => v.path == route || v.pathDetail == route) : list
+    };
     Vue.prototype.getHeight = (even, that, calculate = true) => {
         return new Promise((resolve, reject) => {
             if (calculate) {