فهرست منبع

未读通告弹窗

xiaohaizhao 1 سال پیش
والد
کامیت
35e70bf672
4فایلهای تغییر یافته به همراه231 افزوده شده و 0 حذف شده
  1. 130 0
      pages/index/annunciate/index.js
  2. 4 0
      pages/index/annunciate/index.json
  3. 64 0
      pages/index/annunciate/index.scss
  4. 33 0
      pages/index/annunciate/index.wxml

+ 130 - 0
pages/index/annunciate/index.js

@@ -0,0 +1,130 @@
+const _Http = getApp().globalData.http;
+let editor = null;
+Component({
+  options: {
+    addGlobalClass: true
+  },
+  data: {
+    lookItem: null,
+    show: false,
+    height: 0,
+  },
+  methods: {
+    getList() {
+      _Http.basic({
+        id: 20221111090904,
+        content: {
+          nocache: true,
+          "pageNumber": 1,
+          "pageSize": 9999,
+          "pageTotal": 1,
+          "where": {
+            "condition": "",
+            isread: 0
+          }
+        }
+      }).then(res => {
+        console.log("未读通告", res)
+        if (res.msg != '成功') return;
+        if (res.data.length) {
+          res.data = res.data.map(v => {
+            v.inquire = false;
+            return v
+          });
+          this.setData({
+            lookItem: res.data[0],
+            list: res.data,
+            show: true
+          });
+          this.getDetail();
+        }
+      })
+    },
+    getDetail() {
+      let lookItem = this.data.lookItem;
+      _Http.basic({
+        "classname": "saletool.notice.notice",
+        "method": "queryNoticeMain",
+        "content": {
+          "sat_noticeid": lookItem.sat_noticeid
+        }
+      }).then(res => {
+        console.log("通告详情", res)
+        if (res.msg != '成功') return;
+        lookItem.content = res.data.content;
+        lookItem.inquire = true;
+        this.data.list[lookItem.rowindex - 1].content = res.data.content;
+        this.setData({
+          lookItem
+        });
+        this.rander(lookItem.content)
+      });
+    },
+    rander(html) {
+      this.setHeight();
+      if (editor == null) {
+        wx.createSelectorQuery().in(this).select('#editor').context(function (res) {
+          editor = res.context;
+          this.rander(html)
+        }).exec()
+      } else {
+        editor.setContents({
+          html,
+          complete: res => {
+            console.log("渲染富文本", res)
+          }
+        })
+      };
+    },
+    async setHeight() {
+      let boxHeight = await this.queryElement(".box", "height"),
+        headHeight = await this.queryElement(".head", "height"),
+        bottomHeight = await this.queryElement(".bottom", "height"),
+        height = boxHeight - headHeight - bottomHeight - 5;
+      this.setData({
+        height
+      })
+    },
+    queryElement(element, field) {
+      return new Promise((resolve, reject) => {
+        wx.createSelectorQuery().in(this).select(element).boundingClientRect().exec(res => {
+          resolve(field ? res[0][field] : res[0])
+        })
+      })
+    },
+    changeLook(e) {
+      let lookItem = this.data.lookItem;
+      this.rander("")
+      switch (e.target.id) {
+        case "previous":
+          lookItem = this.data.list[lookItem.rowindex - 2];
+          this.setData({
+            lookItem
+          });
+          lookItem.inquire ? this.rander(lookItem.content) : this.getDetail();
+          break;
+        case "next":
+          lookItem = this.data.list[lookItem.rowindex];
+          this.setData({
+            lookItem
+          });
+          lookItem.inquire ? this.rander(lookItem.content) : this.getDetail();
+          break;
+        default:
+          console.log("关闭")
+          this.setData({
+            show: false
+          })
+          break;
+      }
+    }
+  },
+  lifetimes: {
+    attached() {
+      wx.createSelectorQuery().in(this).select('#editor').context(function (res) {
+        editor = res.context;
+      }).exec()
+      this.getList()
+    }
+  }
+})

+ 4 - 0
pages/index/annunciate/index.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 64 - 0
pages/index/annunciate/index.scss

@@ -0,0 +1,64 @@
+.box {
+	position: relative;
+	padding: 10rpx 20rpx;
+	height: 100%;
+	box-sizing: border-box;
+	overflow: hidden;
+
+	.head {
+		.title {
+			font-size: 30rpx;
+			font-weight: bold;
+			line-height: 46rpx;
+			text-align: center;
+		}
+
+		.rep {
+			display: flex;
+			justify-content: space-between;
+			margin-top: 8rpx;
+			padding-bottom: 8rpx;
+			border-bottom: 1rpx solid #ddd;
+
+			.rep-left,
+			.rep-right {
+				display: flex;
+				align-items: center;
+				height: 16px;
+				font-size: 24rpx;
+				color: #666;
+			}
+		}
+
+		padding-bottom: 8rpx;
+		box-sizing: border-box;
+	}
+
+	.bottom {
+		position: fixed;
+		left: 0;
+		bottom: 0;
+		width: 100%;
+		display: flex;
+		justify-content: space-between;
+		align-items: center;
+		border-top: 1px solid #ddd;
+		padding: 20rpx;
+		box-sizing: border-box;
+		background-color: #fff;
+
+		.count {
+			font-size: 28rpx;
+			color: #666;
+		}
+
+		.button-box {
+			display: flex;
+
+			.button {
+				height: 50rpx;
+			}
+		}
+
+	}
+}

+ 33 - 0
pages/index/annunciate/index.wxml

@@ -0,0 +1,33 @@
+<van-popup id='popup' show="{{ show }}" round custom-style="width: 90vw;height: 70vh;" z-index='999999999999999999'>
+	<!--  bind:click-overlay='onClose' bind:close="onClose" -->
+	<view class="box">
+		<view class="head">
+			<view class="title" bindtap="totop">
+				{{lookItem.title}}
+			</view>
+			<view class="rep">
+				<view class="rep-left">
+					<van-tag wx:if="{{lookItem.classname}}" plain type="primary">{{lookItem.classname}}</van-tag>
+					<view style="margin-left: 10rpx;">
+						{{lookItem.createdate}}
+					</view>
+				</view>
+				<view class="rep-right">
+					<text class="iconfont icon-a-tonggaoliulanliang" style="margin-right: 8rpx;" />{{lookItem.readcount}}
+				</view>
+			</view>
+		</view>
+		<editor class="editor" style="height:{{height}}px;" id='editor' read-only />
+		<view class="bottom">
+			<view class="count">
+				{{lookItem.rowindex}}/{{list.length}}
+			</view>
+			<view class="button-box">
+				<van-button custom-class='button' wx:if="{{lookItem.rowindex!=1}}" plain type="info" id='previous' catchtap="changeLook">上一条</van-button>
+				<view style="width: 20rpx;" />
+				<van-button wx:if="{{lookItem.rowindex==list.length}}" custom-class='button' plain type="info" catchtap="changeLook">关闭</van-button>
+				<van-button wx:else custom-class='button' plain type="info" id='next' catchtap="changeLook">下一条</van-button>
+			</view>
+		</view>
+	</view>
+</van-popup>