index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class='purchase-list'>
  3. <view class="content-title">
  4. <text class="text-bold" style="font-size: 40upx;">消息</text>
  5. <text>({{unreadCount}})</text>
  6. <text style="margin-left: 10upx;cursor: pointer;color: gray;" @click="handleUpdateAll">
  7. <uni-icons type="paperclip" size="15"></uni-icons>
  8. 全部已读
  9. </text>
  10. </view>
  11. <scroll-view class="purchase-body" scroll-y="true" @scrolltolower="scrolltolower" @scrolltoupper="scrolltoupper"
  12. @scroll="scroll" @touchstart="touchstart" @touchend="touchend">
  13. <uni-list :border="false" style="margin-top: 10px;">
  14. <uni-list-chat style="cursor: pointer;" v-for="item in listData" :avatar-circle="true" :key="item.id"
  15. :title="item.templateNickname" avatar="https://img.36krcdn.com/20200410/v2_fb948f4c18de4b22927f0361d53f6caf_img_png" :note="item.templateParams.content"
  16. :time="parseTime(item.createTime)" :clickable="true" badge-positon="left"
  17. :badge-text="item.readStatus?'':'dot'" @click="toggle(item)">
  18. </uni-list-chat>
  19. </uni-list>
  20. </scroll-view>
  21. <view>
  22. <!-- 底部弹窗 -->
  23. <uni-popup ref="popup" background-color="#fff" border-radius="10px 10px 0 0">
  24. <view class="popup-body">
  25. <view class="popup-close">
  26. <uni-icons type="closeempty" size="20" @click="popupClose"></uni-icons>
  27. </view>
  28. <view class="popup-content">
  29. <uni-forms :model="itemData" label-position="top">
  30. <uni-forms-item label="发送人">
  31. <uni-easyinput disabled v-model="itemData.name"/>
  32. </uni-forms-item>
  33. <uni-forms-item label="创建时间">
  34. <uni-easyinput disabled v-model="itemData.time"/>
  35. </uni-forms-item>
  36. <uni-forms-item label="内容" style="margin-bottom: 50px;">
  37. <uni-easyinput disabled type="textarea" v-model="itemData.content"/>
  38. </uni-forms-item>
  39. </uni-forms>
  40. </view>
  41. </view>
  42. </uni-popup>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import {
  48. getMyNotifyMessagePage,
  49. updateNotifyMessageRead,
  50. updateAllNotifyMessageRead,
  51. getUnreadNotifyMessageCount,
  52. } from "@/api/message/index"
  53. import myPull from '@/static/js/myPull.js'
  54. export default {
  55. data() {
  56. return {
  57. unreadCount: 0,
  58. pageNo: 1,
  59. pageSize: 10,
  60. listData: [],
  61. itemData: {
  62. name:'',
  63. time:'',
  64. content:'',
  65. },
  66. }
  67. },
  68. onLoad() {
  69. this.refresh();
  70. },
  71. created() {
  72. this.getUnreadCount();
  73. },
  74. methods: {
  75. popupClose(){
  76. this.$refs.popup.close();
  77. },
  78. toggle(item) {
  79. this.itemData.name = item.templateNickname;
  80. this.itemData.time = this.parseTime(item.createTime);
  81. this.itemData.content = item.templateParams.content;
  82. this.$refs.popup.open('bottom');
  83. if(item.readStatus==false){
  84. this.handleUpdate([item.id]);
  85. }
  86. },
  87. handleUpdateSingle(row) {
  88. this.handleUpdate([row.id])
  89. },
  90. handleUpdate(ids) {
  91. updateNotifyMessageRead(ids).then(response => {
  92. // this.$modal.msgSuccess("消息已读!")
  93. this.page = 1;
  94. this.getList(this.page, this.__pulldone)
  95. });
  96. },
  97. handleUpdateAll() {
  98. updateAllNotifyMessageRead().then(response => {
  99. this.$modal.msgSuccess("全部已读!")
  100. this.page = 1;
  101. this.getList(this.page, this.__pulldone)
  102. });
  103. },
  104. getUnreadCount() {
  105. getUnreadNotifyMessageCount().then(response => {
  106. this.unreadCount = response.data;
  107. })
  108. },
  109. /**
  110. * @name 获取列表
  111. */
  112. getList(page, done) {
  113. getMyNotifyMessagePage({
  114. pageNo: page,
  115. pageSize: this.pageSize
  116. }).then(response => {
  117. let list = response.data.list;
  118. done(list);
  119. });
  120. },
  121. /**
  122. * @name 触底加载
  123. */
  124. scrolltolower(event) {
  125. this.getList(this.page, this.__pulldone)
  126. },
  127. scroll(e) {
  128. // 重新设置pulldown
  129. this.setPullDown(e.detail.scrollTop < 10)
  130. },
  131. scrolltoupper() {
  132. },
  133. },
  134. mixins: [myPull({})],
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. .popup-body{
  139. z-index: 99;
  140. // margin-bottom: 60px;
  141. }
  142. .popup-close{
  143. cursor: pointer;
  144. height: 40px;
  145. line-height: 40px;
  146. padding-left: 10px;
  147. border-bottom: 1px solid #eaecef;
  148. }
  149. .popup-content{
  150. margin: 20px;
  151. }
  152. .purchase-list {
  153. background-color: #f5f5f5;
  154. height: 100%;
  155. overflow: hidden;
  156. .purchase-body {
  157. height: calc(100% - 88upx);
  158. overflow: auto
  159. }
  160. }
  161. .content-title {
  162. background-color: #ffffff;
  163. height: 88upx;
  164. font-size: 28upx;
  165. position: sticky;
  166. box-sizing: border-box;
  167. padding: 0 10px;
  168. border-bottom: 2upx solid #dddddd;
  169. box-shadow: rgba(0, 0, 0, 0.08) 0px 0px;
  170. min-width: 100%;
  171. overflow-x: auto;
  172. }
  173. .chat-custom-right {
  174. flex: 1;
  175. /* #ifndef APP-NVUE */
  176. display: flex;
  177. /* #endif */
  178. flex-direction: column;
  179. justify-content: space-between;
  180. align-items: flex-end;
  181. }
  182. .chat-custom-text {
  183. font-size: 12px;
  184. color: #999;
  185. }
  186. </style>