| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <template>
- <view class="flex-common-css page-box box-bg">
- <Nav :title="'消息'" :genre="1" is_fixed></Nav>
- <view class="page-box-bg-fff m-lr20 r-20">
- <z-tabs ref="tabs" :list="tabsList" :active-style="{color:'#10B261',fontWeight:'bold',fontSize:'30rpx'}"
- :bar-style="{background:'#10B261'}" :inactive-style="{fontWeight:'bold',fontSize:'28rpx'}"
- :current="current" :bar-animate-mode="'worm'" @change="tabsChange" />
- </view>
- <view class="scroll-view-css flex-direction">
- <!-- <EnScroll ref="scroll" class="main" @onRefresh="onRefresh" @onScrollBottom="onScrollBottom"> -->
- <view class="m-t20" v-if="list.length <=0">
- <Enblank :message="'暂无消息'">
- </Enblank>
- </view>
- <view class="m-lr20 page-env-160">
- <view class="row-c page-box-bg-fff m-t20 r-30 p-30 box-shadow-197" @click.stop="goToInfo(index)"
- v-for="(item,index) in list" :key="index">
- <view class="icon-box">
- <view class="read-dot" v-if="item.is_read === 0"></view>
- <image class="wh-80 r-circle" :src="item.type" mode=""></image>
- </view>
- <view class="flex m-l20">
- <view class="row-justify-sb center flex">
- <text class="text-color-333 sys-weight-400 size-30"> {{item.title}}</text>
- <uni-icons type="right" size="18" color="#999999"></uni-icons>
- </view>
- <view class="row-justify-sb center m-t10">
- <text class="size-26 text-color-666"> {{item.content}}</text>
- <text class="size-24 text-color-999">{{item.created_date}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- </EnScroll> -->
- </view>
- </template>
- <script>
- // 任务列表
- import TaskItem from "@/common/task/task-item.vue";
- import {
- getNotices,
- setRead
- } from "@/api/news";
- import tools from "@/service/tools";
- export default {
- components: {
- TaskItem
- },
- data() {
- return {
- current: 0,
- tabsList: [{
- name: '全部',
- is_dot: false,
- dot_color: 'red',
- disabled: false
- }, {
- name: '未读(0)',
- is_dot: false,
- dot_color: 'red',
- disabled: false
- }, {
- name: '已读',
- is_dot: false,
- dot_color: '',
- disabled: false
- }],
- leftImg: ['task-house', 'task-house', 'task-business', 'task-repayment', 'task-repayment'],
- iconList: ['task-audit', 'task-do', 'task-stay', 'task-stay', 'task-stay'],
- list: [{
- is_read: 0,
- type: 'https://copyright.bdstatic.com/vcg/creative/d6c6a351be227d5d3b3e8c1f96f56e50.jpg@h_1280',
- title: '您有最新的留言',
- content: '万汇房产',
- created_date: '2024-10-10 16:24'
- },
- {
- is_read: 0,
- type: 'https://pic.rmb.bdstatic.com/bjh/3ea195479f8a/250303/f53064611fee7c092312f3b6ea8e439d.jpeg',
- title: '您有最新的看房留言',
- content: '万汇房产',
- created_date: '2024-10-10 16:24'
- }],
- page: 1,
- isEnd: false,
- isAJAX: false
- }
- },
- watch: {},
- mounted() {
- // this.startNotices();
- },
- methods: {
- goToInfo(index) {
- let item = this.list[index];
- console.log(item)
- if (item.type === 1) {
- this.list[index].is_read = 1;
- //跳转详情
- uni.navigateTo({
- url: 'pages/notice/module/notice-info?id=' + item.id
- });
- } else {
- this.setRead(index);
- //调用已读
- if (item.type === 2) {
- if (item.relevance_id <= 0) {
- tools.error('任务信息异常')
- return false;
- }
- //任务详情
- uni.navigateTo({
- url: '/page_task/task_details/task_details?taskId=' + item.relevance_id
- });
- } else if (item.type === 3) {
- uni.setStorageSync('taskType', 1)
- uni.switchTab({
- url: '/pages/task/task'
- });
- } else {
- //领取列表
- uni.navigateTo({
- url: '/page_task/gain_task/gain_task'
- });
- }
- }
- },
- setRead(index) {
- setRead({
- 'id': this.list[index].id
- }).then((res) => {
- if (res.code === 1) {
- this.list[index].is_read = 1;
- }
- })
- },
- startNotices() {
- this.list = [];
- this.page = 1;
- this.isEnd = false;
- this.isAJAX = false;
- this.getNotices();
- },
- getNotices() {
- if (this.isEnd || this.isAJAX) {
- return;
- }
- this.isAJAX = true
- getNotices({
- 'page': this.page,
- 'type': this.current
- }).then((res) => {
- this.isAJAX = false
- if (res.code === 1) {
- if (res.data.items.length <= 0) {
- this.isEnd = true;
- } else {
- this.tabsList[1].name = '未读(' + res.data.unreadNum + ')'
- this.tabsList[1].is_dot = res.data.unreadNum > 0
- res.data.items.forEach((item) => {
- item.is_del = false;
- this.list.push(item)
- })
- // this.list.push(...res.data)
- tools.hideLoading()
- }
- ++this.page;
- }
- })
- },
- tabsChange(index) {
- this.current = index;
- // this.startNotices()
- },
- getLeftImg(index) {
- return `https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/task/${this.leftImg[index]}.png`
- },
- // 下拉刷新
- onRefresh() {
- tools.showLoading()
- this.startNotices()
- setTimeout(() => {
- this.$refs.scroll.onEndPulling()
- }, 200)
- console.log("下拉刷新");
- },
- // 滚动到底部
- onScrollBottom() {
- // uni.showLoading({
- // title: '数据加载中'
- // })
- tools.showLoading()
- this.getNotices()
- // setTimeout(() => {
- // uni.showToast({
- // title: '加载完成',
- // icon: 'none'
- // })
- // }, 1000)
- console.log("到底部了");
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .box-bg {
- background-image: url('https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/task/task-nav-bg.png');
- background-repeat: no-repeat;
- background-size: 100% auto;
- }
- .icon-box {
- position: relative;
- .read-dot {
- width: 14rpx;
- height: 14rpx;
- border-radius: 50%;
- background-color: #E91919;
- position: absolute;
- top: 0rpx;
- right: 10rpx;
- z-index: 9;
- }
- }
- </style>
|