123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- <template>
- <view class="msg">
- <MyNav title="消息" bgColor="" :backIcon="false"></MyNav>
- <!-- 自定义导航栏 -->
- <!-- <u-navbar title='消息' fixed safeAreaInsetTop :placeholder='true' :bgColor="bgColor" >
- </u-navbar> -->
- <!-- 搜索框 -->
- <view class="search">
- <u-input placeholderStyle='color:#999' placeholder="搜索" border='none' v-model="search" @input="searchText">
- <template slot="suffix" style='margin-right:40rpx;'>
- <u-image :showLoading="true" :showError='true' src="/static/icon/search.png" width="40rpx"
- height="32rpx"></u-image>
- </template>
- </u-input>
- </view>
-
- <view style="width: 100%;height: 124rpx;"></view>
-
- <view class="msg-null" v-if="messageList.length == 0">
- <image src="https://t9.9026.com/imgs/dataNull.png" style="width: 394rpx;height: 396rpx;" mode=""></image>
- <view class="msg-null-text">
- <text>暂无数据</text>
- </view>
- </view>
-
- <!-- 消息列表 -->
- <view class="msgListBox" v-if="messageList.length > 0">
- <uni-swipe-action>
- <uni-swipe-action-item :right-options="options" v-for="(item,index) in messageList" :key="index" @change="change()">
- <template v-slot:right>
- <view style="display: flex;align-items: center;justify-content: center;" @click="deleteImg(item.id)">
- <image src="/static/icon/delete.png" style="width: 36rpx; height: 40rpx; margin-right: 20rpx; "></image>
- <text class="slot-button-text" style="color: red;">删除</text>
- </view>
- </template>
- <view class="childBox" @click="jumpPage(item.type,item.relation_id,item.product_type)">
- <view class="childBox-top">{{item.title}}</view>
- <view class="childBox-content">
- <text>{{item.content}}</text>
- <image v-if="!isOpenMsg" style="width: 12rpx;height: 20rpx;" src="/static/icon/right.png"></image>
- </view>
- <view class="childBox-bom">{{item.created_at}}</view>
- </view>
- </uni-swipe-action-item>
- </uni-swipe-action>
- </view>
- <!-- 触底 -->
- <view class="home-bottom" style="padding-bottom: 20rpx;" v-if="messageList.length > 0">
- <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText" />
- </view>
- <!-- 底部导航栏 -->
- <view style="height: 140rpx; width: 100%; background-color: #f9f9f9; "></view>
- <tab-bar checked="msg"></tab-bar>
- </view>
- </template>
- <script>
- import util from '@/utils/util.js'
- import TabBar from '../../components/TabBar/tabbar.vue'
- import MyNav from "@/components/my-nav/my-nav.vue"
- export default {
- components: {
- TabBar,
- MyNav
- },
- data() {
- return {
- //用户是否登录
- admin:'',
- //是否展示信息图标
- isOpenMsg:false,
- //自定义导航栏
- bgColor: '#fff',
- //搜索文字
- search:'',
- //删除按钮
- options: [{
- text: '删除',
- style: {
- backgroundColor: '#dd524d'
- }
- }],
-
- contentText: {
- contentdown: '查看更多',
- contentrefresh: '加载中',
- contentnomore: '—— 已经到底啦 ——'
- },
- //消息列表
- messageList: [],
- // 分页
- page: 1,
- pagesize: 15,
- totalElements: '',
- allListItem: '',
- // 组件uni-load-more
- status: 'noMore',
- };
- },
-
- async onLoad() {
- this.admin = this.$store.getters.userInfo
- await this.isLogin()
-
- },
-
- // 触底加载
- onReachBottom() {
- // 触底的时候请求数据,即为上拉加载更多
- var allTotal = this.page * this.pagesize
- console.log(allTotal, '----allTotal');
- //this.page为加载次数,this.pagesize为每一次加载的数据条数
- if (allTotal < this.totalElements) {
- //this.totalElements为请求数据的总条数。只要现有条数小于总条数就就执行一下代码
- this.allListItem = false;
- this.page++;
- //加载次数递加
- this.status = "loading"
- this.$api.my.messageList({ //请求更多数据列表
- page: this.page,
- }).then(res => {
- let ret = [...this.messageList, ...res.data.data]
- this.messageList = ret
- console.log(ret)
- })
- } else {
- this.allListItem = true;
- console.log('已加载全部数据')
- this.status = "noMore"
- }
- },
-
- methods: {
- isLogin(){
- //获取消息列表
- if(this.admin != undefined ){
- this.getMessageList()
- }else{
- this.messageList = ''
- }
- },
-
- //打开或关闭是触发
- change(){
- this.isOpenMsg = !this.isOpenMsg
- },
-
- //删除消息
- deleteImg(id){
- this.$api.my.delMessage({
- message_id:id
- }).then(res=>{
- if(res.code == 0 ){
- console.log(res.data);
- this.getMessageList()
- }else{
- uni.showToast({
- icon:'none',
- title:res.msg
- })
- }
-
- })
- },
-
-
- //跳转消息详情页面
- jumpPage(type,id,product_type){
- if(type>2){
- //实物奖品
- if(product_type == 1){
- uni.navigateTo({
- url:'/pages/my/prize/prize?product_type='+product_type
- })
- }else if(product_type == 2 ){
- //虚拟奖品
- uni.navigateTo({
- url:'/pages/my/prize/prize?product_type='+product_type
- })
- }else if(product_type == 3){
- //积分奖品
- uni.navigateTo({
- url:'/pages/my/integral/integralRecord'
- })
-
- }
-
- }else{
- uni.navigateTo({
- url:'/pages/index/active-detail/index?id='+id
- })
- }
- },
-
- // 搜索防抖
- searchText:util.debounce(function(){
- if(this.search !=''){
- this.goSearch()
- }else{
- this.getMessageList()
- }
- },500),
- //搜索
- goSearch(){
- uni.showLoading({
- title:'加载中'
- })
- this.$api.my.messageList({
- page: 0,
- keyword:this.search,
- }).then(res=>{
- if(res.code==0){
- uni.hideLoading()
- this.messageList = res.data.data
- this.totalElements = res.data.total
- this.pagesize = res.data.per_page
- }
- })
- },
- //获取消息列表
- getMessageList() {
- this.$api.my.messageList({
- page: 0
- }).then(res => {
- this.messageList = res.data.data
- this.totalElements = res.data.total
- this.pagesize = res.data.per_page
- console.log(this.messageList, '------>this.messageList');
- })
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- $pageColor:#F9F9F9;
- $bgColor:#FFFFFF;
- // flex布局居中对齐
- @mixin flexlayout {
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .msg {
- height: 100%;
- background-color: $pageColor;
- }
- .home-bottom {
- background-color: #f9f9f9;
- }
-
- .msg-null{
- margin-top: 162rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- .msg-null-text{
- margin-top: 40rpx;
- font-size: 28rpx;
- color: #333;
- }
- }
- // 搜索
- .search {
- position: fixed;
- z-index: 99;
- // top: 0;
- // width: 100%;
- padding: 0 30rpx;
- height: 124rpx;
- background-color: $bgColor;
- box-shadow: 0px 4rpx 8rpx 0px rgba(0, 0, 0, 0.04);
- @include flexlayout;
- ::v-deep .u-input {
- width: 690rpx !important;
- height: 68rpx !important;
- background: #F1F1F1;
- border-radius: 74rpx;
- }
- ::v-deep .u-input__content__field-wrapper {
- padding-left: 36rpx;
- }
- ::v-deep .u-input__content__field-wrapper__field {
- color: #999999 !important;
- font-size: 28rpx !important;
- }
- }
- // 消息列表
- .msgListBox {
- padding: 48rpx 30rpx;
- padding-top: 0;
- margin-top: 24rpx;
- background: #f9f9f9;
- box-shadow: 0rpx 4rpx 24rpx -10rpx rgba(101, 95, 90, 0.3);
- border-radius: 12rpx;
- .childBox {
- padding-top: 40rpx;
- padding-bottom: 40rpx;
- border-bottom: 2rpx solid rgba(240, 240, 240, .7);
-
- &:last-child {
- padding-bottom: 0;
- border-bottom: none;
- }
-
- &:first-child {
- padding-top: 48rpx;
- }
-
- .childBox-top {
- font-weight: bold;
- color: #333333;
- font-size: 32rpx;
- }
-
- .childBox-content {
- padding-right: 24rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- color: #333333;
- font-size: 28rpx;
- margin: 24rpx 0 12rpx;
- }
-
- .childBox-bom {
- color: #999999;
- font-size: 26rpx;
- }
- }
- }
- ::v-deep .uni-swipe_text--center {
- padding-bottom: 40rpx;
- border-bottom: 2rpx solid rgba(240, 240, 240, 0.7);
- &:last-child {
- padding-bottom: 0;
- border-bottom: none;
- }
- }
- </style>
|