chat.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="container">
  3. <view class="search-box">
  4. <u-search
  5. v-model="searchForm.keyword"
  6. :clearabled="true"
  7. bg-color="#E5E5E5"
  8. :input-style="searchInputStyle"
  9. placeholder="请输入搜索内容"
  10. ></u-search>
  11. </view>
  12. <view class="list-box">
  13. <view class="list-item-box" v-for="item in list" :key="item.id" @click="onChatClick(item)">
  14. <view class="main-box">
  15. <view class="icon-box">
  16. <cover-image class="icon" :src="`/static/chat-icon/${item.type}.png`"></cover-image>
  17. </view>
  18. <view class="content-box">
  19. <view class="title">
  20. {{item.title}}
  21. </view>
  22. <view class="text">
  23. {{item.content}}
  24. </view>
  25. </view>
  26. <view class="other-box">
  27. <view class="date">
  28. {{item.time}}
  29. </view>
  30. <view class="tag">
  31. {{item.count}}
  32. </view>
  33. </view>
  34. </view>
  35. <view class="line-box"></view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script setup>
  41. import { ref } from 'vue'
  42. import { onLoad } from '@dcloudio/uni-app'
  43. const searchInputStyle = {
  44. backgroundColor: '#E5E5E5'
  45. }
  46. const searchForm = ref({
  47. keyword: ''
  48. })
  49. const list = ref([
  50. {
  51. id: '1',
  52. title: '会费缴交成功通知',
  53. content: '尊敬的用户,您在2023年8月16日15:00成交缴交会费……',
  54. type: 'zhifu',
  55. time: '8/16',
  56. count: 1
  57. },
  58. {
  59. id: '2',
  60. title: '继续教育通知',
  61. content: '尊敬的用户,您预约2023年8月16日《广州市存量房网……',
  62. type: 'jiaoyu',
  63. time: '8/16',
  64. count: 1
  65. },
  66. {
  67. id: '3',
  68. title: '课程购买成功通知',
  69. content: '尊敬的用户,您在成功购买2023年8月16日《广州市存……',
  70. type: 'goumai',
  71. time: '8/16',
  72. count: 1
  73. },
  74. {
  75. id: '4',
  76. title: '个人会员生日祝福',
  77. content: '尊敬的用户,今日是您的生日,协会祝你在……',
  78. type: 'shengri',
  79. time: '8/16',
  80. count: 1
  81. },
  82. ])
  83. function onChatClick(chat) {
  84. uni.navigateTo({
  85. url: `/pages/chatDetail/chatDetail?id=${chat.id}&title=${chat.title}`
  86. })
  87. }
  88. onLoad(() => {
  89. uni.setTabBarBadge({ //显示数字
  90. index: 1, //tabbar下标
  91. text: '999' //数字
  92. })
  93. })
  94. </script>
  95. <style lang="scss" scoped>
  96. .container {
  97. height: 100vh;
  98. width: 100vw;
  99. background-color: $uni-bg-color;
  100. padding: 0 20rpx;
  101. .search-box {
  102. margin-bottom: 20rpx;
  103. ::v-deep(.u-search) {
  104. background-color: #e5e5e5;
  105. border-radius: 50rpx;
  106. .u-action {
  107. width: 18%;
  108. background-color: $uni-color-primary;
  109. border-radius: 50rpx;
  110. color: $uni-text-color-inverse;
  111. margin-right: 8rpx;
  112. font-size: 28rpx;
  113. line-height: 50rpx;
  114. letter-spacing: 3rpx;
  115. text-align: center;
  116. }
  117. }
  118. }
  119. .list-box {
  120. padding: 0 20rpx;
  121. .list-item-box {
  122. .main-box {
  123. display: flex;
  124. justify-content: space-between;
  125. align-items: center;
  126. padding: 30rpx 0;
  127. .icon-box {
  128. width: 15%;
  129. display: flex;
  130. justify-content: center;
  131. align-items: center;
  132. .icon {
  133. width: 70rpx;
  134. height: 70rpx;
  135. }
  136. }
  137. .content-box {
  138. width: 67%;
  139. display: flex;
  140. flex-direction: column;
  141. justify-content: space-around;
  142. gap: 10rpx;
  143. .title {
  144. height: calc(70% - 5rpx);
  145. font-size: $uni-title-font-size-2;
  146. font-weight: bold;
  147. }
  148. .text {
  149. height: calc(30% - 5rpx);
  150. font-size: $uni-font-size-3;
  151. color: $uni-text-color-grey;
  152. @include text-overflow();
  153. }
  154. }
  155. .other-box {
  156. width: 18%;
  157. display: flex;
  158. flex-direction: column;
  159. justify-content: space-around;
  160. align-items: center;
  161. gap: 10rpx;
  162. .date {
  163. font-size: $uni-font-size-3;
  164. color: $uni-text-color-grey;
  165. }
  166. .tag {
  167. font-size: $uni-font-size-3;
  168. width: 42rpx;
  169. background-color: $uni-color-error;
  170. color: $uni-text-color-inverse;
  171. border-radius: 20rpx;
  172. text-align: center;
  173. }
  174. }
  175. }
  176. .line-box {
  177. height: 1rpx;
  178. width: 80%;
  179. background-color: #E5E5E5;
  180. margin: 0 auto;
  181. }
  182. }
  183. }
  184. }
  185. </style>