index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <view class="index_container">
  3. <view class="user_info">
  4. </view>
  5. <!-- <view class="grid_container">
  6. <uni-grid :column="2" :showBorder="false" :square="false">
  7. <uni-grid-item>
  8. <view class="grid-item-box">
  9. <text class="iconfont icon-clock-in grid_icon"></text>
  10. <text class="text">打卡</text>
  11. </view>
  12. </uni-grid-item>
  13. <uni-grid-item>
  14. <view class="grid-item-box">
  15. <text class="iconfont icon-init-process grid_icon"></text>
  16. <text class="text">发起流程</text>
  17. </view>
  18. </uni-grid-item>
  19. </uni-grid>
  20. </view> -->
  21. <uni-collapse>
  22. <uni-collapse-item title-border="show" :border="true" :show-animation="false" :open="false">
  23. <template v-slot:title>
  24. <uni-section title="待办消息" type="line" titleFontSize="20px"></uni-section>
  25. </template>
  26. <view class="process_container">
  27. <view class="no_process">
  28. <uni-section title="无待办消息"></uni-section>
  29. </view>
  30. <view class="process_list">
  31. </view>
  32. </view>
  33. </uni-collapse-item>
  34. </uni-collapse>
  35. <uni-collapse>
  36. <uni-collapse-item title-border="show" :border="true" :show-animation="false" :open="true">
  37. <template v-slot:title>
  38. <uni-section title="消息" type="line" titleFontSize="20px"></uni-section>
  39. </template>
  40. <view class="segmented_control_container">
  41. <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
  42. activeColor="#409eff"></uni-segmented-control>
  43. </view>
  44. <view class="content">
  45. <view @click="onClickmessage(message)" v-for="(message, index) in messages" :key="index"
  46. :class="message.is_read?' ':'message_container_unread'" class="message_container">
  47. <uni-card :title="message.user" :sub-title="message.title" :extra="message.time" :is-full="true">
  48. <template v-slot:title>
  49. <uni-row>
  50. <view class="message_top_container">
  51. <uni-col :span="24">
  52. <text class="message_user">
  53. {{ message.user }}
  54. </text>
  55. </uni-col>
  56. </view>
  57. </uni-row>
  58. <uni-row>
  59. <view class="message_mid_container">
  60. <uni-col :span="19">
  61. <text class="message_title hidden_over">
  62. <text :class="message.icon" class="iconfont"></text>
  63. {{ message.title }}
  64. </text>
  65. </uni-col>
  66. <uni-col :span="4">
  67. <text class="message_time">
  68. {{ message.time }}
  69. </text>
  70. </uni-col>
  71. </view>
  72. </uni-row>
  73. </template>
  74. <view class="message_bottom_container">
  75. <text class="message_content hidden_over">
  76. {{ message.content }}
  77. </text>
  78. </view>
  79. </uni-card>
  80. </view>
  81. </view>
  82. </uni-collapse-item>
  83. </uni-collapse>
  84. </view>
  85. </template>
  86. <script setup lang="ts">
  87. import { onMounted, reactive, ref } from 'vue';
  88. const items = reactive(['全部', '已读', '未读'])
  89. const current = ref(1)
  90. let messages = reactive([])
  91. onMounted(() => {
  92. onClickItem({ currentIndex: 0 })
  93. console.log(messages);
  94. })
  95. // 点击消息分段器
  96. function onClickItem({ currentIndex }) {
  97. switch (currentIndex) {
  98. case 0:
  99. current.value = 0;
  100. messages = [
  101. {
  102. user: "账户1",
  103. title: "已读公告1",
  104. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  105. time: "2024/10/10",
  106. icon: 'icon-announce',
  107. is_read: 1
  108. },
  109. {
  110. user: "账户2",
  111. title: "已读通知2",
  112. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  113. time: "2024/10/10",
  114. icon: 'icon-notify',
  115. is_read: 1
  116. },
  117. {
  118. user: "账户3",
  119. title: "未读公告3未读公告3未读公告3未读公告3未读公告3未读公告3",
  120. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  121. time: "2024/10/10",
  122. icon: 'icon-announce',
  123. is_read: 0
  124. },
  125. {
  126. user: "账户4",
  127. title: "未读通知4",
  128. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  129. time: "2024/10/10",
  130. icon: 'icon-notify',
  131. is_read: 0
  132. }
  133. ]
  134. break;
  135. case 1:
  136. current.value = 1;
  137. messages = [
  138. {
  139. user: "账户1",
  140. title: "已读公告1",
  141. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  142. time: "2024/10/10",
  143. icon: 'icon-announce',
  144. is_read: 1
  145. },
  146. {
  147. user: "账户2",
  148. title: "已读通知2",
  149. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  150. time: "2024/10/10",
  151. icon: 'icon-notify',
  152. is_read: 1
  153. }
  154. ]
  155. break;
  156. case 2:
  157. current.value = 2;
  158. messages = [
  159. {
  160. user: "账户3",
  161. title: "未读公告3",
  162. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  163. time: "2024/10/10",
  164. icon: 'icon-announce',
  165. is_read: 0
  166. },
  167. {
  168. user: "账户4",
  169. title: "未读通知4",
  170. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  171. time: "2024/10/10",
  172. icon: 'icon-notify',
  173. is_read: 0
  174. }
  175. ]
  176. break;
  177. }
  178. }
  179. // 点击消息
  180. function onClickmessage(e) {
  181. console.log('onClickmessage', e);
  182. }
  183. </script>
  184. <style lang="scss">
  185. // iconfont
  186. @import "@/static/font/ygoa/iconfont.css";
  187. .grid_container {
  188. .grid-item-box {
  189. flex: 1;
  190. /* #ifndef APP-NVUE */
  191. display: flex;
  192. /* #endif */
  193. flex-direction: column;
  194. align-items: center;
  195. justify-content: center;
  196. padding: 15px 0;
  197. .grid_icon {
  198. color: #ff8500;
  199. font-size: 30px;
  200. }
  201. .text {
  202. text-align: center;
  203. font-size: 26rpx;
  204. margin-top: 10rpx;
  205. }
  206. }
  207. }
  208. .segmented_control_container {
  209. // margin-top: 10px;
  210. }
  211. .message_container {
  212. border-left: #f5f5f5 .4rem solid;
  213. .message_top_container {
  214. padding: 5px 5px 0;
  215. .message_user {
  216. color: #000000;
  217. }
  218. }
  219. .message_mid_container {
  220. padding: 5px;
  221. height: 1.1rem;
  222. .message_title {
  223. font-size: 1.1rem;
  224. }
  225. .message_time {
  226. font-size: 0.8rem;
  227. }
  228. }
  229. .message_bottom_container {
  230. .message_content {}
  231. }
  232. }
  233. .message_container_unread {
  234. // 未读样式
  235. border-left-color: #0f6cbd;
  236. .message_user {
  237. color: #000000;
  238. font-weight: bold;
  239. }
  240. .message_title {
  241. color: #0f6cbd;
  242. font-weight: bold;
  243. }
  244. }
  245. .hidden_over {
  246. white-space: nowrap; // 不换行
  247. overflow: hidden; // 超出内容隐藏
  248. text-overflow: ellipsis; // 超出部分显示省略号
  249. display: inline-block;
  250. max-width: 100%;
  251. }
  252. </style>