index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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="内容">
  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.getList(this.page, this.__pulldone)
  94. });
  95. },
  96. handleUpdateAll() {
  97. updateAllNotifyMessageRead().then(response => {
  98. this.$modal.msgSuccess("全部已读!")
  99. this.getList(this.page, this.__pulldone)
  100. });
  101. },
  102. getUnreadCount() {
  103. getUnreadNotifyMessageCount().then(response => {
  104. this.unreadCount = response.data;
  105. })
  106. },
  107. /**
  108. * @name 获取列表
  109. */
  110. getList(page, done) {
  111. getMyNotifyMessagePage({
  112. pageNo: page,
  113. pageSize: this.pageSize
  114. }).then(response => {
  115. let list = response.data.list;
  116. done(list);
  117. });
  118. },
  119. /**
  120. * @name 触底加载
  121. */
  122. scrolltolower(event) {
  123. this.getList(this.page, this.__pulldone)
  124. },
  125. scroll(e) {
  126. // 重新设置pulldown
  127. this.setPullDown(e.detail.scrollTop < 10)
  128. },
  129. scrolltoupper() {
  130. },
  131. },
  132. mixins: [myPull({})],
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .popup-body{
  137. z-index: 99;
  138. // margin-bottom: 60px;
  139. }
  140. .popup-close{
  141. cursor: pointer;
  142. height: 40px;
  143. line-height: 40px;
  144. padding-left: 10px;
  145. border-bottom: 1px solid #eaecef;
  146. }
  147. .popup-content{
  148. margin: 20px;
  149. }
  150. .purchase-list {
  151. background-color: #f5f5f5;
  152. height: 100%;
  153. overflow: hidden;
  154. .purchase-body {
  155. height: calc(100% - 88upx);
  156. overflow: auto
  157. }
  158. }
  159. .content-title {
  160. background-color: #ffffff;
  161. height: 88upx;
  162. font-size: 28upx;
  163. position: sticky;
  164. box-sizing: border-box;
  165. padding: 0 10px;
  166. border-bottom: 2upx solid #dddddd;
  167. box-shadow: rgba(0, 0, 0, 0.08) 0px 0px;
  168. min-width: 100%;
  169. overflow-x: auto;
  170. }
  171. .chat-custom-right {
  172. flex: 1;
  173. /* #ifndef APP-NVUE */
  174. display: flex;
  175. /* #endif */
  176. flex-direction: column;
  177. justify-content: space-between;
  178. align-items: flex-end;
  179. }
  180. .chat-custom-text {
  181. font-size: 12px;
  182. color: #999;
  183. }
  184. </style>