msg.vue 6.3 KB

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