message.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view>
  3. <!---消息系统暂未实现-->
  4. <cu-custom bgColor="bg-blue" :isBack="true">
  5. <block slot="backText">返回</block>
  6. <block slot="content">消息中心</block>
  7. </cu-custom>
  8. <scroll-view class="VerticalMain" scroll-y scroll-with-animation>
  9. <view class="cu-bar bg-white solid-bottom margin-top">
  10. <view class="action">
  11. <text class="cuIcon-notification text-orange "></text> 消息
  12. </view>
  13. </view>
  14. <view class="cu-list menu-avatar">
  15. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in messageList" :key="index"
  16. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  17. <view class="cu-avatar round lg" :style="[{backgroundImage:'url('+(item.createBy.photo?item.createBy.photo:'/static/user/flat-avatar.png')+')'}]"></view>
  18. <view class="content">
  19. <view class="text-bold text-grey">
  20. <view class="ellipsis-description" v-html="item.title"></view>
  21. </view>
  22. <view class=" text-gray text-sm">
  23. <div class="margin-left-xs ellipsis-description" v-html="item.content"></div>
  24. </view>
  25. </view>
  26. <view class="action" style="120px">
  27. <view class="text-grey text" >{{item.createDate}}</view>
  28. <!-- <view class="cu-tag round bg-grey sm">5</view> -->
  29. </view>
  30. <view class="move">
  31. <view class="bg-grey">置顶</view>
  32. <view class="bg-red">删除</view>
  33. </view>
  34. </view>
  35. <view v-if="messageList.length === 0">
  36. <view class="padding-lr bg-white">
  37. <view class="padding">暂无消息!</view>
  38. </view>
  39. </view>
  40. </view>
  41. </scroll-view>
  42. <view class="cu-tabbar-height"></view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. messageList: []
  50. };
  51. },
  52. async mounted () {
  53. },
  54. methods: {
  55. VerticalMain(e) {
  56. // #ifdef MP-ALIPAY
  57. return false //支付宝小程序暂时不支持双向联动
  58. // #endif
  59. let that = this;
  60. let tabHeight = 0;
  61. if (this.load) {
  62. for (let i = 0; i < this.list.length; i++) {
  63. let view = uni.createSelectorQuery().select("#main-" + this.list[i].id);
  64. view.fields({
  65. size: true
  66. }, data => {
  67. this.list[i].top = tabHeight;
  68. tabHeight = tabHeight + data.height;
  69. this.list[i].bottom = tabHeight;
  70. }).exec();
  71. }
  72. this.load = false
  73. }
  74. let scrollTop = e.detail.scrollTop + 10;
  75. for (let i = 0; i < this.list.length; i++) {
  76. if (scrollTop > this.list[i].top && scrollTop < this.list[i].bottom) {
  77. this.verticalNavTop = (this.list[i].id - 1) * 50
  78. this.tabCur = this.list[i].id
  79. console.log(scrollTop)
  80. return false
  81. }
  82. }
  83. },
  84. InputFocus(e) {
  85. this.InputBottom = e.detail.height
  86. },
  87. InputBlur(e) {
  88. this.InputBottom = 0
  89. },
  90. showModal(e) {
  91. this.modalName = e.currentTarget.dataset.target
  92. },
  93. hideModal(e) {
  94. this.modalName = null
  95. },
  96. Gridchange(e) {
  97. this.gridCol = e.detail.value
  98. },
  99. Gridswitch(e) {
  100. this.gridBorder = e.detail.value
  101. },
  102. MenuBorder(e) {
  103. this.menuBorder = e.detail.value
  104. },
  105. MenuArrow(e) {
  106. this.menuArrow = e.detail.value
  107. },
  108. MenuCard(e) {
  109. this.menuCard = e.detail.value
  110. },
  111. SwitchSex(e) {
  112. this.skin = e.detail.value
  113. },
  114. // ListTouch触摸开始
  115. ListTouchStart(e) {
  116. this.listTouchStart = e.touches[0].pageX
  117. },
  118. // ListTouch计算方向
  119. ListTouchMove(e) {
  120. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > 0 ? 'right' : 'left'
  121. },
  122. // ListTouch计算滚动
  123. ListTouchEnd(e) {
  124. if (this.listTouchDirection == 'left') {
  125. this.modalName = e.currentTarget.dataset.target
  126. } else {
  127. this.modalName = null
  128. }
  129. this.listTouchDirection = null
  130. }
  131. }
  132. }
  133. </script>
  134. <style>
  135. .ellipsis-description {
  136. font-size: 12px;
  137. line-height: $line-height-base;
  138. display: -webkit-box;/*作为弹性伸缩盒子模型显示*/
  139. -webkit-line-clamp: 1; /*显示的行数;如果要设置2行加...则设置为2*/
  140. overflow: hidden; /*超出的文本隐藏*/
  141. text-overflow: ellipsis; /* 溢出用省略号*/
  142. -webkit-box-orient: vertical;/*伸缩盒子的子元素排列:从上到下*/
  143. }
  144. .cu-list.menu-avatar>.cu-item .action {
  145. width: 120px;
  146. text-align: center;
  147. }
  148. .page {
  149. height: 100Vh;
  150. width: 100vw;
  151. }
  152. .page.show {
  153. overflow: hidden;
  154. }
  155. .switch-sex::after {
  156. content: "\e716";
  157. }
  158. .switch-sex::before {
  159. content: "\e7a9";
  160. }
  161. .switch-music::after {
  162. content: "\e66a";
  163. }
  164. .switch-music::before {
  165. content: "\e6db";
  166. }
  167. /* .fixed {
  168. position: fixed;
  169. z-index: 99;
  170. }
  171. */
  172. .VerticalNav.nav {
  173. width: 200upx;
  174. white-space: initial;
  175. }
  176. .VerticalNav.nav .cu-item {
  177. width: 100%;
  178. text-align: center;
  179. background-color: #fff;
  180. margin: 0;
  181. border: none;
  182. height: 50px;
  183. position: relative;
  184. }
  185. .VerticalNav.nav .cu-item.cur {
  186. background-color: #f1f1f1;
  187. }
  188. .top-warp{
  189. z-index: 9990;
  190. position: fixed;
  191. /* top: --window-top; /* css变量 */
  192. left: 0;
  193. width: 100%;
  194. /* height: 120upx; */
  195. /* background-color: white; */
  196. }
  197. .top-warp .tip{
  198. font-size: 28upx;
  199. height: 60upx;
  200. line-height: 60upx;
  201. text-align: center;
  202. }
  203. </style>