msg.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. <view class="msg-null" v-if="messageList.length == 0">
  17. <image src="https://t9.9026.com/imgs/dataNull.png" style="width: 394rpx;height: 396rpx;" mode=""></image>
  18. <view class="msg-null-text">
  19. <text>暂无数据</text>
  20. </view>
  21. </view>
  22. <!-- 消息列表 -->
  23. <view class="msgListBox" v-if="messageList.length > 0">
  24. <uni-swipe-action>
  25. <uni-swipe-action-item :right-options="options" v-for="(item,index) in messageList" :key="index" >
  26. <template v-slot:right>
  27. <view style="display: flex;align-items: center;justify-content: center;" @click="deleteImg(item.id)">
  28. <image src="/static/icon/delete.png" style="width: 36rpx; height: 40rpx; margin-right: 20rpx; "></image>
  29. <text class="slot-button-text" style="color: red;">删除</text>
  30. </view>
  31. </template>
  32. <view class="childBox" @click="jumpPage(item.type,item.relation_id)">
  33. <view class="childBox-top">{{item.title}}</view>
  34. <view class="childBox-content">
  35. <text>{{item.content}}</text>
  36. <image style="width: 12rpx;height: 20rpx;" src="/static/icon/right.png"></image>
  37. </view>
  38. <view class="childBox-bom">{{item.created_at}}</view>
  39. </view>
  40. </uni-swipe-action-item>
  41. </uni-swipe-action>
  42. </view>
  43. <!-- 触底 -->
  44. <view class="home-bottom" v-if="messageList.length > 0">
  45. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText" />
  46. </view>
  47. <!-- 底部导航栏 -->
  48. <view style="height: 140rpx; width: 100%;"></view>
  49. <tab-bar checked="msg"></tab-bar>
  50. </view>
  51. </template>
  52. <script>
  53. import util from '@/utils/util.js'
  54. import TabBar from '../../components/TabBar/tabbar.vue'
  55. import MyNav from "@/components/my-nav/my-nav.vue"
  56. export default {
  57. components: {
  58. TabBar,
  59. MyNav
  60. },
  61. data() {
  62. return {
  63. //自定义导航栏
  64. bgColor: '#fff',
  65. //搜索文字
  66. search:'',
  67. //删除按钮
  68. options: [{
  69. text: '删除',
  70. style: {
  71. backgroundColor: '#dd524d'
  72. }
  73. }],
  74. //消息列表
  75. messageList: '',
  76. status: 'noMore',
  77. contentText: {
  78. contentdown: '查看更多',
  79. contentrefresh: '加载中',
  80. contentnomore: '—— 已经到底啦 ——'
  81. },
  82. };
  83. },
  84. onLoad() {
  85. //获取消息列表
  86. this.getMessageList()
  87. },
  88. methods: {
  89. //删除消息
  90. deleteImg(id){
  91. this.$api.my.delMessage({
  92. message_id:id
  93. }).then(res=>{
  94. if(res.code == 0 ){
  95. console.log(res.data);
  96. this.getMessageList()
  97. }else{
  98. uni.showToast({
  99. icon:'none',
  100. title:res.msg
  101. })
  102. }
  103. })
  104. },
  105. //跳转消息详情页面
  106. jumpPage(type,id){
  107. if(type>2){
  108. uni.navigateTo({
  109. url:'/pages/my/prize/prize'
  110. })
  111. }else{
  112. uni.navigateTo({
  113. url:'/pages/index/active-detail/index?id='+id
  114. })
  115. }
  116. },
  117. // 搜索防抖
  118. searchText:util.debounce(function(){
  119. if(this.search !=''){
  120. this.goSearch()
  121. }else{
  122. this.getMessageList()
  123. }
  124. },500),
  125. //搜索
  126. goSearch(){
  127. uni.showLoading({
  128. title:'加载中'
  129. })
  130. this.$api.my.messageList({
  131. page: 0,
  132. keyword:this.search,
  133. }).then(res=>{
  134. if(res.code==0){
  135. uni.hideLoading()
  136. this.messageList = res.data.data
  137. }
  138. })
  139. },
  140. //获取消息列表
  141. getMessageList() {
  142. this.$api.my.messageList({
  143. page: 0
  144. }).then(res => {
  145. this.messageList = res.data.data
  146. console.log(this.messageList, '------>this.messageList');
  147. })
  148. },
  149. },
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. $pageColor:#F9F9F9;
  154. $bgColor:#FFFFFF;
  155. // flex布局居中对齐
  156. @mixin flexlayout {
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. }
  161. .msg {
  162. height: 100%;
  163. background-color: $pageColor;
  164. }
  165. .home-bottom {
  166. background-color: #f9f9f9;
  167. padding-top: 120rpx;
  168. }
  169. .msg-null{
  170. margin-top: 162rpx;
  171. display: flex;
  172. flex-direction: column;
  173. align-items: center;
  174. justify-content: center;
  175. .msg-null-text{
  176. margin-top: 40rpx;
  177. font-size: 28rpx;
  178. color: #333;
  179. }
  180. }
  181. // 搜索
  182. .search {
  183. // position: fixed;
  184. // top: 0;
  185. // width: 100%;
  186. padding: 0 30rpx;
  187. height: 124rpx;
  188. background-color: $bgColor;
  189. box-shadow: 0px 4rpx 8rpx 0px rgba(0, 0, 0, 0.04);
  190. @include flexlayout;
  191. ::v-deep .u-input {
  192. width: 690rpx !important;
  193. height: 68rpx !important;
  194. background: #F1F1F1;
  195. border-radius: 74rpx;
  196. }
  197. ::v-deep .u-input__content__field-wrapper {
  198. padding-left: 36rpx;
  199. }
  200. ::v-deep .u-input__content__field-wrapper__field {
  201. color: #999999 !important;
  202. font-size: 28rpx !important;
  203. }
  204. }
  205. // 消息列表
  206. .msgListBox {
  207. padding: 48rpx 30rpx;
  208. padding-top: 0;
  209. margin-top: 24rpx;
  210. background: #f9f9f9;
  211. box-shadow: 0rpx 4rpx 24rpx -10rpx rgba(101, 95, 90, 0.3);
  212. border-radius: 12rpx;
  213. .childBox {
  214. padding-top: 40rpx;
  215. padding-bottom: 40rpx;
  216. border-bottom: 2rpx solid rgba(240, 240, 240, .7);
  217. &:last-child {
  218. padding-bottom: 0;
  219. border-bottom: none;
  220. }
  221. &:first-child {
  222. padding-top: 48rpx;
  223. }
  224. .childBox-top {
  225. font-weight: bold;
  226. color: #333333;
  227. font-size: 32rpx;
  228. }
  229. .childBox-content {
  230. padding-right: 24rpx;
  231. display: flex;
  232. align-items: center;
  233. justify-content: space-between;
  234. color: #333333;
  235. font-size: 28rpx;
  236. margin: 24rpx 0 12rpx;
  237. }
  238. .childBox-bom {
  239. color: #999999;
  240. font-size: 26rpx;
  241. }
  242. }
  243. }
  244. ::v-deep .uni-swipe_text--center {
  245. padding-bottom: 40rpx;
  246. border-bottom: 2rpx solid rgba(240, 240, 240, 0.7);
  247. &:last-child {
  248. padding-bottom: 0;
  249. border-bottom: none;
  250. }
  251. }
  252. </style>