index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <oa-scroll
  3. customClass="appMessage-container scroll-height"
  4. :pageSize="state.size"
  5. :total="state.total"
  6. :refresherLoad="true"
  7. :refresherEnabled="true"
  8. :refresherDefaultStyle="'none'"
  9. :refresherThreshold="44"
  10. :refresherBackground="'#f5f6f7'"
  11. @load="load"
  12. @refresh="refresh"
  13. :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
  14. >
  15. <template #default>
  16. <u-loading-page :loading="state.loading" fontSize="16" style="z-index: 99"></u-loading-page>
  17. <view class="content-area" v-for="(group, date) in proxy.$common.groupedItems(state.noticeList, 'createTime')" :key="date">
  18. <view class="content-area-time font14">{{ proxy.$time.jktTimes(date, "否") }}</view>
  19. <view
  20. class="content-area-center flex bg-white list-cell list-cell-arrow"
  21. :id="ind == noticeList.length - 1 ? 'bottomInfo' : ''"
  22. v-for="(el, ind) in group"
  23. :key="ind"
  24. v-show="noticeList.length > 0"
  25. @click="goContentDetails(el)"
  26. >
  27. <view style="width: 100%; max-width: 100%">
  28. <view class="content-area-center-title font16">{{ el.infoTitle }}</view>
  29. <view class="content-area-center-cont font14">{{ el.infoContent }}</view>
  30. </view>
  31. <view class="content-area-center-badge"><u-badge :isDot="el.readFlag == 0 ? true : false" type="error"></u-badge></view>
  32. <view class="content-area-center-time font14">{{ proxy.$time.jktTimes(el.createTime.replace("T", " ")) }}</view>
  33. </view>
  34. </view>
  35. </template>
  36. </oa-scroll>
  37. </template>
  38. <script setup>
  39. /*----------------------------------依赖引入-----------------------------------*/
  40. import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  41. import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
  42. /*----------------------------------接口引入-----------------------------------*/
  43. import { getMceList, updateMceReceiveStatus } from "@/api/mine/info.js";
  44. /*----------------------------------组件引入-----------------------------------*/
  45. /*----------------------------------store引入-----------------------------------*/
  46. /*----------------------------------公共方法引入-----------------------------------*/
  47. /*----------------------------------公共变量-----------------------------------*/
  48. const { proxy } = getCurrentInstance();
  49. /*----------------------------------变量声明-----------------------------------*/
  50. const state = reactive({
  51. scrollIntoView: "",
  52. loading: false,
  53. noticeList: [],
  54. size: 10,
  55. current: 1,
  56. total: 0,
  57. options: {
  58. typeName: "",
  59. },
  60. });
  61. const { scrollIntoView, noticeList } = toRefs(state);
  62. /**
  63. * @跳转相应类型系统
  64. */
  65. function goContentDetails(e) {
  66. if (e.infoType == 4) {
  67. proxy.$tab.navigateTo(`/pages/business/fireIot/alarmManage/alarmDetails/index?contentId=${e.contentId}`).then(() => {});
  68. } else if (e.infoType == 5) {
  69. proxy.$tab.navigateTo(`/pages/business/common/projectMange/record/details?reportId=${e.moduleId}`).then(() => {});
  70. } else {
  71. proxy.$tab.navigateTo(`/pages/common/appMessage/details?contentId=${e.contentId}`).then(() => {});
  72. }
  73. //是否已读
  74. if (!e.readFlag) {
  75. updateMceReceiveStatus({ id: e.id });
  76. }
  77. }
  78. /**
  79. * @通知公告列表
  80. * @api接口调用
  81. */
  82. function init(obj) {
  83. uni.setNavigationBarTitle({
  84. title: obj.typeName ? obj.typeName : "消息列表",
  85. });
  86. state.loading = true;
  87. getMceList({
  88. size: state.size,
  89. current: state.current,
  90. infoType: obj?.type,
  91. })
  92. .then((requset) => {
  93. if (requset.status === "SUCCESS") {
  94. state.noticeList = requset.data.records;
  95. state.total = requset.data.total;
  96. state.loading = false;
  97. }
  98. setTimeout(() => {
  99. scrollIntoView.value = "bottomInfo";
  100. }, 0);
  101. if ("id" in obj) {
  102. state.noticeList.forEach((e) => {
  103. if (e.id == obj.id) {
  104. goContentDetails(e);
  105. }
  106. });
  107. }
  108. })
  109. .catch((err) => {
  110. state.loading = false;
  111. });
  112. }
  113. /**
  114. * @scrollView加载数据
  115. */
  116. function load() {
  117. state.size += 10;
  118. init(state.options);
  119. }
  120. /**
  121. * @scrollView刷新数据
  122. */
  123. function refresh() {
  124. state.size = 10;
  125. init(state.options);
  126. }
  127. onLoad((options) => {
  128. state.options = options;
  129. init(state.options);
  130. uni.$on("projectMange_record", function (value) {
  131. delete state.options.id;
  132. init(state.options);
  133. });
  134. });
  135. onReady(() => {});
  136. onShow(() => {
  137. //调用系统主题颜色
  138. proxy.$settingStore.systemThemeColor([1]);
  139. });
  140. onUnload(() => {
  141. uni.$off("projectMange_record"); //将值删除监听器
  142. });
  143. // 自定义导航事件
  144. onNavigationBarButtonTap((e) => {
  145. if (e.float == "right") {
  146. proxy.$tab.navigateTo("/pages/mine/setting/index");
  147. }
  148. });
  149. </script>
  150. <style lang="scss" scoped>
  151. :deep(.uni-page-head__title) {
  152. opacity: 1 !important;
  153. }
  154. .content-area {
  155. padding: 0 10px;
  156. &-time {
  157. padding: 10px;
  158. text-align: left;
  159. color: #000000;
  160. font-weight: 600;
  161. }
  162. &-center {
  163. margin: 0;
  164. padding: 15px;
  165. overflow: hidden;
  166. border-bottom: 1px solid #eaeef1;
  167. &:nth-child(2) {
  168. border-radius: 10px 10px 0 0;
  169. }
  170. &:last-child {
  171. border-radius: 0 0 10px 10px;
  172. border-bottom: 0px solid #eaeef1;
  173. }
  174. &-avatar {
  175. margin: auto 0;
  176. }
  177. &-title {
  178. margin: 0 0 10px 0;
  179. font-weight: 600;
  180. color: #000000;
  181. }
  182. &-cont {
  183. color: #666666;
  184. }
  185. &-badge {
  186. margin: auto 10px auto 0;
  187. }
  188. &-time {
  189. margin: auto 0.9375rem auto 0;
  190. }
  191. }
  192. }
  193. </style>