msg.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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" @click="jumpPage(item.type,item.relation_id)" >
  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. jumpPage(type,id){
  93. if(type>2){
  94. uni.navigateTo({
  95. url:'/pages/my/prize/prize'
  96. })
  97. }else{
  98. uni.navigateTo({
  99. url:'/pages/index/active-detail/index?id='+id
  100. })
  101. }
  102. },
  103. // 搜索防抖
  104. searchText:util.debounce(function(){
  105. if(this.search !=''){
  106. this.goSearch()
  107. }else{
  108. this.getMessageList()
  109. }
  110. },500),
  111. //搜索
  112. goSearch(){
  113. uni.showLoading({
  114. title:'加载中'
  115. })
  116. this.$api.my.messageList({
  117. page: 0,
  118. keyword:this.search,
  119. }).then(res=>{
  120. if(res.code==0){
  121. uni.hideLoading()
  122. this.messageList = res.data.data
  123. }
  124. })
  125. },
  126. //获取消息列表
  127. getMessageList() {
  128. this.$api.my.messageList({
  129. page: 0
  130. }).then(res => {
  131. this.messageList = res.data.data
  132. console.log(this.messageList, '------>this.messageList');
  133. })
  134. },
  135. },
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. $pageColor:#F9F9F9;
  140. $bgColor:#FFFFFF;
  141. // flex布局居中对齐
  142. @mixin flexlayout {
  143. display: flex;
  144. align-items: center;
  145. justify-content: center;
  146. }
  147. .msg {
  148. height: 100%;
  149. background-color: $pageColor;
  150. }
  151. .home-bottom {
  152. background-color: #f9f9f9;
  153. padding-top: 120rpx;
  154. }
  155. // 搜索
  156. .search {
  157. // position: fixed;
  158. // top: 0;
  159. // width: 100%;
  160. padding: 0 30rpx;
  161. height: 124rpx;
  162. background-color: $bgColor;
  163. box-shadow: 0px 4rpx 8rpx 0px rgba(0, 0, 0, 0.04);
  164. @include flexlayout;
  165. ::v-deep .u-input {
  166. width: 690rpx !important;
  167. height: 68rpx !important;
  168. background: #F1F1F1;
  169. border-radius: 74rpx;
  170. }
  171. ::v-deep .u-input__content__field-wrapper {
  172. padding-left: 36rpx;
  173. }
  174. ::v-deep .u-input__content__field-wrapper__field {
  175. color: #999999 !important;
  176. font-size: 28rpx !important;
  177. }
  178. }
  179. // 消息列表
  180. .msgListBox {
  181. padding: 48rpx 30rpx;
  182. padding-top: 0;
  183. margin-top: 24rpx;
  184. background: $bgColor;
  185. box-shadow: 0rpx 4rpx 24rpx -10rpx rgba(101, 95, 90, 0.3);
  186. border-radius: 12rpx;
  187. .childBox {
  188. padding-top: 40rpx;
  189. padding-bottom: 40rpx;
  190. border-bottom: 2rpx solid rgba(240, 240, 240, .7);
  191. &:last-child {
  192. padding-bottom: 0;
  193. border-bottom: none;
  194. }
  195. &:first-child {
  196. padding-top: 48rpx;
  197. }
  198. .childBox-top {
  199. font-weight: bold;
  200. color: #333333;
  201. font-size: 32rpx;
  202. }
  203. .childBox-content {
  204. padding-right: 24rpx;
  205. display: flex;
  206. align-items: center;
  207. justify-content: space-between;
  208. color: #333333;
  209. font-size: 28rpx;
  210. margin: 24rpx 0 12rpx;
  211. }
  212. .childBox-bom {
  213. color: #999999;
  214. font-size: 26rpx;
  215. }
  216. }
  217. }
  218. ::v-deep .uni-swipe_text--center {
  219. padding-bottom: 40rpx;
  220. border-bottom: 2rpx solid rgba(240, 240, 240, 0.7);
  221. &:last-child {
  222. padding-bottom: 0;
  223. border-bottom: none;
  224. }
  225. }
  226. </style>