msg.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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,item.product_type)">
  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. admin:'',
  65. //是否展示信息图标
  66. isOpenMsg:false,
  67. //自定义导航栏
  68. bgColor: '#fff',
  69. //搜索文字
  70. search:'',
  71. //删除按钮
  72. options: [{
  73. text: '删除',
  74. style: {
  75. backgroundColor: '#dd524d'
  76. }
  77. }],
  78. //消息列表
  79. messageList: '',
  80. status: 'noMore',
  81. contentText: {
  82. contentdown: '查看更多',
  83. contentrefresh: '加载中',
  84. contentnomore: '—— 已经到底啦 ——'
  85. },
  86. };
  87. },
  88. async onLoad() {
  89. this.admin = this.$store.getters.userInfo
  90. await this.isLogin()
  91. },
  92. methods: {
  93. isLogin(){
  94. //获取消息列表
  95. if(this.admin != undefined ){
  96. this.getMessageList()
  97. }else{
  98. this.messageList = ''
  99. }
  100. },
  101. //打开或关闭是触发
  102. change(){
  103. this.isOpenMsg = !this.isOpenMsg
  104. },
  105. //删除消息
  106. deleteImg(id){
  107. this.$api.my.delMessage({
  108. message_id:id
  109. }).then(res=>{
  110. if(res.code == 0 ){
  111. console.log(res.data);
  112. this.getMessageList()
  113. }else{
  114. uni.showToast({
  115. icon:'none',
  116. title:res.msg
  117. })
  118. }
  119. })
  120. },
  121. //跳转消息详情页面
  122. jumpPage(type,id,product_type){
  123. if(type>2){
  124. //实物奖品
  125. if(product_type == 1){
  126. uni.navigateTo({
  127. url:'/pages/my/prize/prize?product_type='+product_type
  128. })
  129. }else if(product_type == 2 ){
  130. //虚拟奖品
  131. uni.navigateTo({
  132. url:'/pages/my/prize/prize?product_type='+product_type
  133. })
  134. }else if(product_type == 3){
  135. //积分奖品
  136. uni.navigateTo({
  137. url:'/pages/my/integral/integralRecord'
  138. })
  139. }
  140. }else{
  141. uni.navigateTo({
  142. url:'/pages/index/active-detail/index?id='+id
  143. })
  144. }
  145. },
  146. // 搜索防抖
  147. searchText:util.debounce(function(){
  148. if(this.search !=''){
  149. this.goSearch()
  150. }else{
  151. this.getMessageList()
  152. }
  153. },500),
  154. //搜索
  155. goSearch(){
  156. uni.showLoading({
  157. title:'加载中'
  158. })
  159. this.$api.my.messageList({
  160. page: 0,
  161. keyword:this.search,
  162. }).then(res=>{
  163. if(res.code==0){
  164. uni.hideLoading()
  165. this.messageList = res.data.data
  166. }
  167. })
  168. },
  169. //获取消息列表
  170. getMessageList() {
  171. this.$api.my.messageList({
  172. page: 0
  173. }).then(res => {
  174. this.messageList = res.data.data
  175. console.log(this.messageList, '------>this.messageList');
  176. })
  177. },
  178. },
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. $pageColor:#F9F9F9;
  183. $bgColor:#FFFFFF;
  184. // flex布局居中对齐
  185. @mixin flexlayout {
  186. display: flex;
  187. align-items: center;
  188. justify-content: center;
  189. }
  190. .msg {
  191. height: 100%;
  192. background-color: $pageColor;
  193. }
  194. .home-bottom {
  195. background-color: #f9f9f9;
  196. padding-top: 120rpx;
  197. }
  198. .msg-null{
  199. margin-top: 162rpx;
  200. display: flex;
  201. flex-direction: column;
  202. align-items: center;
  203. justify-content: center;
  204. .msg-null-text{
  205. margin-top: 40rpx;
  206. font-size: 28rpx;
  207. color: #333;
  208. }
  209. }
  210. // 搜索
  211. .search {
  212. // position: fixed;
  213. // top: 0;
  214. // width: 100%;
  215. padding: 0 30rpx;
  216. height: 124rpx;
  217. background-color: $bgColor;
  218. box-shadow: 0px 4rpx 8rpx 0px rgba(0, 0, 0, 0.04);
  219. @include flexlayout;
  220. ::v-deep .u-input {
  221. width: 690rpx !important;
  222. height: 68rpx !important;
  223. background: #F1F1F1;
  224. border-radius: 74rpx;
  225. }
  226. ::v-deep .u-input__content__field-wrapper {
  227. padding-left: 36rpx;
  228. }
  229. ::v-deep .u-input__content__field-wrapper__field {
  230. color: #999999 !important;
  231. font-size: 28rpx !important;
  232. }
  233. }
  234. // 消息列表
  235. .msgListBox {
  236. padding: 48rpx 30rpx;
  237. padding-top: 0;
  238. margin-top: 24rpx;
  239. background: #f9f9f9;
  240. box-shadow: 0rpx 4rpx 24rpx -10rpx rgba(101, 95, 90, 0.3);
  241. border-radius: 12rpx;
  242. .childBox {
  243. padding-top: 40rpx;
  244. padding-bottom: 40rpx;
  245. border-bottom: 2rpx solid rgba(240, 240, 240, .7);
  246. &:last-child {
  247. padding-bottom: 0;
  248. border-bottom: none;
  249. }
  250. &:first-child {
  251. padding-top: 48rpx;
  252. }
  253. .childBox-top {
  254. font-weight: bold;
  255. color: #333333;
  256. font-size: 32rpx;
  257. }
  258. .childBox-content {
  259. padding-right: 24rpx;
  260. display: flex;
  261. align-items: center;
  262. justify-content: space-between;
  263. color: #333333;
  264. font-size: 28rpx;
  265. margin: 24rpx 0 12rpx;
  266. }
  267. .childBox-bom {
  268. color: #999999;
  269. font-size: 26rpx;
  270. }
  271. }
  272. }
  273. ::v-deep .uni-swipe_text--center {
  274. padding-bottom: 40rpx;
  275. border-bottom: 2rpx solid rgba(240, 240, 240, 0.7);
  276. &:last-child {
  277. padding-bottom: 0;
  278. border-bottom: none;
  279. }
  280. }
  281. </style>