index.vue 5.1 KB

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