msg.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="msg">
  3. <MyNav title="消息" bgColor="" :backIcon="false"></MyNav>
  4. <!-- <!自定义导航栏
  5. <u-navbar title='消息' fixed safeAreaInsetTop :placeholder='true' :bgColor="bgColor" >
  6. </u-navbar> -->
  7. <!-- 搜索框 -->
  8. <view class="search">
  9. <u-input placeholder="搜索" border='none' v-model="search" @input="searchText">
  10. <template slot="suffix" style='margin-right:40rpx;'>
  11. <u-image :showLoading="true" :showError='true' src="/static/icon/search.png" width="40rpx"
  12. height="32rpx"></u-image>
  13. </template>
  14. </u-input>
  15. </view>
  16. <!-- 消息列表 -->
  17. <view class="msgListBox">
  18. <view class="childBox" v-for="(item,index) in messageList" :key="index" >
  19. <view class="childBox-top" >{{item.title}}</view>
  20. <view class="childBox-content" >
  21. <text>{{item.content}}</text>
  22. <image style="width: 12rpx;height: 20rpx;" src="/static/icon/right.png" ></image>
  23. </view>
  24. <view class="childBox-bom">{{item.created_at}}</view>
  25. </view>
  26. <uni-swipe-action v-if="false">
  27. <uni-swipe-action-item :right-options="options" v-for="(item,index) in messageList" :key="index">
  28. <template v-slot:right>
  29. <view style="display: flex;align-items: center;justify-content: center;">
  30. <image src="/static/icon//data.png" style="width: 60rpx; height: 54rpx;"></image>
  31. <text class="slot-button-text">删除</text>
  32. </view>
  33. </template>
  34. <view class="childBox">
  35. <view class="childBox-top">{{item.title}}</view>
  36. <view class="childBox-content">
  37. <text>{{item.content}}</text>
  38. <image style="width: 12rpx;height: 20rpx;" src="/static/icon/right.png"></image>
  39. </view>
  40. <view class="childBox-bom">{{item.created_at}}</view>
  41. </view>
  42. </uni-swipe-action-item>
  43. </uni-swipe-action>
  44. </view>
  45. <!-- 触底 -->
  46. <view class="home-bottom">
  47. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText" />
  48. </view>
  49. <!-- 底部导航栏 -->
  50. <view style="height: 140rpx; width: 100%;"></view>
  51. <tab-bar checked="msg"></tab-bar>
  52. </view>
  53. </template>
  54. <script>
  55. import util from '@/utils/util.js'
  56. import TabBar from '../../components/TabBar/tabbar.vue'
  57. import MyNav from "@/components/my-nav/my-nav.vue"
  58. export default {
  59. components: {
  60. TabBar,
  61. MyNav
  62. },
  63. data() {
  64. return {
  65. //自定义导航栏
  66. bgColor: '#fff',
  67. //搜索文字
  68. search:'',
  69. //删除按钮
  70. options: [{
  71. text: '删除',
  72. style: {
  73. backgroundColor: '#dd524d'
  74. }
  75. }],
  76. //消息列表
  77. messageList: '',
  78. status: 'noMore',
  79. contentText: {
  80. contentdown: '查看更多',
  81. contentrefresh: '加载中',
  82. contentnomore: '—— 已经到底啦 ——'
  83. },
  84. };
  85. },
  86. onLoad() {
  87. //获取消息列表
  88. this.getMessageList()
  89. },
  90. methods: {
  91. // 搜索防抖
  92. searchText:util.debounce(function(){
  93. if(this.search !=''){
  94. this.goSearch()
  95. }else{
  96. this.getMessageList()
  97. }
  98. },500),
  99. //搜索
  100. goSearch(){
  101. uni.showLoading({
  102. title:'加载中'
  103. })
  104. this.$api.my.messageList({
  105. page: 0,
  106. keyword:this.search,
  107. }).then(res=>{
  108. if(res.code==0){
  109. uni.hideLoading()
  110. this.messageList = res.data.data
  111. }
  112. })
  113. },
  114. //获取消息列表
  115. getMessageList() {
  116. this.$api.my.messageList({
  117. page: 0
  118. }).then(res => {
  119. this.messageList = res.data.data
  120. console.log(this.messageList, '------>this.messageList');
  121. })
  122. },
  123. },
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. $pageColor:#F9F9F9;
  128. $bgColor:#FFFFFF;
  129. // flex布局居中对齐
  130. @mixin flexlayout {
  131. display: flex;
  132. align-items: center;
  133. justify-content: center;
  134. }
  135. .msg {
  136. height: 100%;
  137. background-color: $pageColor;
  138. }
  139. .home-bottom {
  140. background-color: #f9f9f9;
  141. padding-top: 120rpx;
  142. }
  143. // 搜索
  144. .search {
  145. // position: fixed;
  146. // top: 0;
  147. // width: 100%;
  148. padding: 0 30rpx;
  149. height: 124rpx;
  150. background-color: $bgColor;
  151. box-shadow: 0px 4rpx 8rpx 0px rgba(0, 0, 0, 0.04);
  152. @include flexlayout;
  153. ::v-deep .u-input {
  154. width: 690rpx !important;
  155. height: 68rpx !important;
  156. background: #F1F1F1;
  157. border-radius: 74rpx;
  158. }
  159. ::v-deep .u-input__content__field-wrapper {
  160. padding-left: 36rpx;
  161. }
  162. ::v-deep .u-input__content__field-wrapper__field {
  163. color: #999999 !important;
  164. font-size: 28rpx !important;
  165. }
  166. }
  167. // 消息列表
  168. .msgListBox {
  169. padding: 48rpx 30rpx;
  170. padding-top: 0;
  171. margin-top: 24rpx;
  172. background: $bgColor;
  173. box-shadow: 0rpx 4rpx 24rpx -10rpx rgba(101, 95, 90, 0.3);
  174. border-radius: 12rpx;
  175. .childBox {
  176. padding-top: 40rpx;
  177. padding-bottom: 40rpx;
  178. border-bottom: 2rpx solid rgba(240, 240, 240, .7);
  179. &:last-child {
  180. padding-bottom: 0;
  181. border-bottom: none;
  182. }
  183. &:first-child {
  184. padding-top: 48rpx;
  185. }
  186. .childBox-top {
  187. font-weight: bold;
  188. color: #333333;
  189. font-size: 32rpx;
  190. }
  191. .childBox-content {
  192. padding-right: 24rpx;
  193. display: flex;
  194. align-items: center;
  195. justify-content: space-between;
  196. color: #333333;
  197. font-size: 28rpx;
  198. margin: 24rpx 0 12rpx;
  199. }
  200. .childBox-bom {
  201. color: #999999;
  202. font-size: 26rpx;
  203. }
  204. }
  205. }
  206. ::v-deep .uni-swipe_text--center {
  207. padding-bottom: 40rpx;
  208. border-bottom: 2rpx solid rgba(240, 240, 240, 0.7);
  209. &:last-child {
  210. padding-bottom: 0;
  211. border-bottom: none;
  212. }
  213. }
  214. </style>