dl_uniapp/pages/components/notice-index.vue
2025-05-08 18:07:19 +08:00

1011 lines
24 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="dl-notice-box-index">
<!-- 标题 -->
<view :class="['dl-title','01'==nowUserType?'dl-tgz':'']">
<view class="right-text">
<text :class="['dl-text','01'==nowUserType?'dl-tgz-text':'']">通告</text>
</view>
<view class="left-search">
<view class="left-search-box" style="width: 90%;" @click="goSeach">
<uni-search-bar radius="20" style="width: 100%;" placeholder="VIP极速搜索" clearButton="auto"
cancelButton="none" :readonly="!canSearch" :focus="focus" @confirm="search" @clear="clear">
</uni-search-bar>
<image class="dl-vip" src="@/static/index/vip.png" mode="aspectFit"></image>
</view>
</view>
<view class="right-text">
</view>
</view>
<!-- 菜单 -->
<view class="dl-menu-box" style="padding-top: 10rpx;">
<view v-for="(item,index) in menus" @click="itemClick(index,item)" class="dl-menu-dom">
<view :class="index==menuIndex?'dl-menu click':'dl-menu'">{{item}}</view>
</view>
</view>
<!-- 筛选条件 -->
<view class="dl-menu-box" style="padding-bottom: 20rpx;padding-left: 15rpx;padding-right: 15rpx;">
<view :class="[0==chooseCondition?'dl-focus dl-search-box':'dl-search-box']" @click="choosePlat(0)"
:key="chooseCondition">
<text>{{queryParams.platformName}}</text>
<view class="image-box">
<image v-if="0==chooseCondition" class="dl-icon" src="@/static/index/shang.png" mode="aspectFit">
</image>
<image v-else class="dl-icon" src="@/static/index/sanjiao.png" mode="aspectFit"></image>
</view>
</view>
<view :class="[1==chooseCondition?'dl-focus dl-search-box':'dl-search-box']" @click="choosePlat(1)"
:key="chooseCondition">
<text>{{queryParams.bloggerTypeName}}</text>
<view class="image-box">
<image v-if="1==chooseCondition" class="dl-icon" src="@/static/index/shang.png" mode="aspectFit">
</image>
<image v-else class="dl-icon" src="@/static/index/sanjiao.png" mode="aspectFit"></image>
</view>
</view>
<view :class="[2==chooseCondition?'dl-focus dl-search-box':'dl-search-box']" @click="choosePlat(2)"
:key="chooseCondition">
<text>筛选</text>
<view class="image-box">
<image v-if="2==chooseCondition" class="dl-icon" src="@/static/index/shang.png" mode="aspectFit">
</image>
<image v-else class="dl-icon" src="@/static/index/sanjiao.png" mode="aspectFit"></image>
<image class="dl-vip" src="@/static/index/vip.png" mode="aspectFit"></image>
</view>
</view>
</view>
<!-- 主体内容区域 -->
<view class="dl-body">
<!-- 随手转发 -->
<view class="dl-public-box" v-if="isOpenZf=='1'&&point&&point>0">
<view class="dl-left">
<image class="dl-icon" src="@/static/index/gift.png" mode="aspectFit"></image>
</view>
<view class="dl-center">
<view>随手转发上传通告赚零花</view>
<view>每条轻松赚<text>{{point/10}}</text>元</view>
</view>
<view class="dl-right">
<view class="dl-opt-dom" @click="toPublish()">去转发</view>
</view>
</view>
<!-- 通告列表 -->
<view :class="[isOpenZf?'dl-item-box open-zf':'dl-item-box']">
<scroll-view style="height: 100%;" scroll-y="true" @scrolltolower="onReachBottomCus" refresher-enabled
@refresherrefresh="onRefresherrefresh" :refresher-triggered="isTriggered">
<notice-item v-if="dataList.length>0" :dataList="dataList" @goDetail="goDetail()"></notice-item>
<view style="text-align: center" v-if="dataList.length==0">
<image class="" src="@/static/images/nothing.png"></image>
</view>
</scroll-view>
</view>
</view>
<!-- 右侧抽屉 -->
<uni-drawer ref="showRight" mode="right" :mask-click="true" @change="change($event)" width="160">
<view class="scroll-view">
<view style="position: absolute;height: 100%;width: 30%;z-index: 99;" @click="closeDrawer"></view>
<scroll-view class="scroll-view-box" scroll-y="true">
<view style="padding-left:30%;background: transparent;height: 100%;">
<view class="uni-common-mt">
<view class="info-content" @click="confirmItem(null)">
<image v-show="0==chooseCondition" class="image" src="@/static/platform/quanbu.png"
mode="aspectFit"></image>
<view class="title">不限</view>
</view>
<view v-show="0==chooseCondition" class="info-content" v-for="(item,index) in platformList"
@click="confirmItem(item)" :key="index">
<image class="image" :src="'/static/platform/'+item.code+'.png'" mode="aspectFit">
</image>
<view class="title">{{item.title}}</view>
</view>
<view v-show="1==chooseCondition" class="info-content"
v-for="(item,index) in bloggerTypeList" @click="confirmItem(item)" :key="index">
<view class="title">{{item.title}}</view>
</view>
</view>
</view>
</scroll-view>
</view>
</uni-drawer>
<!-- 右侧抽屉 -->
<uni-drawer ref="showRight2" mode="right" :mask-click="true" @change="change($event)" width="260">
<view class="scroll-view">
<view style="position: absolute;height: 100%;width: 30%;z-index: 99;" @click="closeDrawer"></view>
<scroll-view class="scroll-view-box" scroll-y="true">
<view style="padding-left:30%;background: transparent;height: 100%;">
<view class="uni-common-mt">
<view class="uni-form-item uni-column">
<view class="title">粉丝量要求</view>
<view class="dl-drawer-item">
<input class="uni-input" v-model="queryParams.fansDown" type="digit"
placeholder="最低" />
<view>—</view>
<input class="uni-input" v-model="queryParams.fansUp" type="digit"
placeholder="最高" />
</view>
</view>
<view class="uni-form-item uni-column">
<view class="title">奖励类型</view>
<view class="dl-drawer-item">
<view
:class="[''==queryParams.rewardType?'dl-focus dl-reward-type':'dl-reward-type']"
@click="chooseRewardType('')">不限</view>
<view
:class="['money'==queryParams.rewardType?'dl-focus dl-reward-type':'dl-reward-type']"
@click="chooseRewardType('money')">稿费
</view>
<view
:class="['gift'==queryParams.rewardType?'dl-focus dl-reward-type':'dl-reward-type']"
@click="chooseRewardType('gift')">赠品
</view>
</view>
</view>
<view class="uni-form-item uni-column">
<view class="title">稿费要求</view>
<view class="dl-drawer-item">
<input class="uni-input" v-model="queryParams.feeDown" type="digit"
placeholder="最低" />
<view>—</view>
<input class="uni-input" v-model="queryParams.feeUp" type="digit"
placeholder="最高" />
</view>
</view>
<view class="uni-form-item uni-column">
<view class="title">地区</view>
<view class="dl-drawer-item">
<uni-data-picker style="width: 100%;padding: 10rpx 10rpx 10rpx 0;" placeholder="请选择"
popup-title="请选择地址" :localdata="dataTree" v-model="queryParams.cityId"
@change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened"
@popupclosed="onpopupclosed">
</uni-data-picker>
</view>
</view>
<view style="display: flex;margin-top: 10rpx;">
<button class="mini-btn" type="default" size="mini" @click="reset()">重置</button>
<button class="mini-btn" type="warn" size="mini"
@click="onRefresherrefresh()">应用</button>
</view>
</view>
</view>
</scroll-view>
</view>
</uni-drawer>
</view>
</template>
<script>
import noticeItem from '@/pages/components/notice-item.vue'
import rightsCode from '@/utils/rightsCode'
import {
getCatgByCode,
getByCodeInfo,
getConfigByCode
} from '@/api/system/config.js'
import {
toast,
hasRights
} from '@/utils/common.js'
import {
getNoticeList
} from '@/api/business/notice.js'
import {
dealMemberRights,
getMemberDetail
} from '@/api/business/member.js'
import {
getJSONData
} from '@/utils/auth.js';
import {
getUserType
} from '@/utils/common.js'
import constant from '@/utils/constant';
import store from '@/store'
import {
changeUserType
} from '@/utils/common.js'
import {
treeCity
} from '@/api/business/base.js'
export default {
props: {
nowUserType: {
type: String,
default: null
}
},
components: {
noticeItem
},
data() {
return {
//城市树结构
dataTree: [],
menus: ['全部', '最新', '平台结算', '急招', '品牌置换'],
menuIndex: 0,
dataList: [],
//每条赚多少积分
point: 10,
focus: false,
queryParams: {
pageNum: 1,
pageSize: 30,
//排序方式:new-最新money-高奖励;
sortBy: "",
//品牌置换--只要有值代表查品牌置换
gift: "",
platformCode: "",
platformName: "平台",
bloggerType: "",
bloggerTypeName: "领域",
//搜索的文字
searchValue: "",
//奖励类型选中值:""-不限 | money-稿费 | gift-赠品
rewardType: "",
//粉丝量要求
fansUp: null,
fansDown: null,
//稿费要求
feeUp: null,
feeDown: null,
},
//是否显示搜索框
canSearch: false,
//当前焦点
chooseCondition: 9,
total: 0,
//下来刷新状态
isTriggered: false,
//平台列表
platformList: [],
//博主分类
bloggerTypeList: [],
isOpenZf: '0'
}
},
mounted() {
this.initData("dl_platform", "platformList")
this.initData("dl_blogger_type", "bloggerTypeList")
this.getByCodeInfo()
this.selectDataList()
this.initAddress()
//鉴权
// this.checkRights()
this.getConfigKey()
},
onLoad: function() {
},
methods: {
getConfigKey() {
getConfigByCode('isOpenZf').then(res => {
if (res.msg) {
this.isOpenZf = res.msg
}
})
},
/**初始化树结构*/
initAddress() {
treeCity().then(res => {
res.data.forEach(it => {
if (it.children) {
it.children.forEach(item => {
item.children = null
})
}
})
this.dataTree = res.data
}).catch((e) => {
uni.showToast({
icon: 'error',
duration: 2000,
title: e
});
})
},
/**
* 去发布
*/
toPublish() {
getMemberDetail().then(res => {
if (!res.data.identityType) {
uni.showToast({
title: '暂未通告主认证,请先认证',
icon: 'none',
duration: 1000
})
} else {
changeUserType("01")
this.$tab.navigateTo(`/pages/notice/public-notice`)
}
})
},
/**
* 查询发布通告送多少积分
*/
getByCodeInfo() {
getByCodeInfo({
code: constant.fbgg
}).then(res => {
if (res.code == 200 && null != res.data) {
this.point = res.data.content
}
}).catch((e) => {
uni.showToast({
icon: 'error',
duration: 2000,
title: e
});
})
},
/**
* 初始化数据
* @param {Object} code
* @param {Object} dataObj
*/
initData(code, dataObj) {
let that = this
getCatgByCode({
code: code
}).then(res => {
if (res.code == 200) {
this[dataObj] = res.data
}
}).catch((e) => {
uni.showToast({
icon: 'error',
duration: 2000,
title: e
});
})
},
/**
* 确认选择的条目
* @param {Object} item
*/
confirmItem(item) {
if (0 == this.chooseCondition) {
//选择平台
if (null == item) {
this.queryParams.platformCode = ""
this.queryParams.platformName = "平台"
} else {
this.queryParams.platformCode = item.code
this.queryParams.platformName = item.title
}
} else if (1 == this.chooseCondition) {
//选择领域
if (null == item) {
this.queryParams.bloggerType = ""
this.queryParams.bloggerTypeName = "领域"
} else {
this.queryParams.bloggerType = item.code
this.queryParams.bloggerTypeName = item.title
}
}
this.onRefresherrefresh()
this.closeDrawer()
},
/**
* 选择平台
*/
async choosePlat(index) {
if (index == 2) {
//鉴权
if (!await this.checkIfHasRights(rightsCode.subscribeSelect)) {
return
}
this.$refs.showRight2.open()
} else {
this.$refs.showRight.open()
}
this.chooseCondition = index
},
/**
* 选择奖励类型
* @param {Object} value
*/
chooseRewardType(value) {
this.queryParams.rewardType = value
},
/**
* 重置筛选条件
*/
reset() {
this.queryParams.rewardType = ""
this.queryParams.feeUp = null
this.queryParams.feeDown = null
this.queryParams.fansDown = null
this.queryParams.fansUp = null
this.queryParams.cityId = null
},
// 关闭窗口
closeDrawer(e) {
this.chooseCondition = 9
this.$refs.showRight.close()
this.$refs.showRight2.close()
},
// 抽屉状态发生变化触发
change(e) {
if (!e) {
//抽屉关闭
this.chooseCondition = 9
}
},
/**
* 菜单点击
* @param {Object} index
* @param {Object} item
*/
async itemClick(index, item) {
this.queryParams.gift = null
this.queryParams.sortBy = null
this.queryParams.isUrgent = null
this.queryParams.isPlatformFree = null
if ('全部' == item) {
} else if ('最新' == item) {
//最新
this.queryParams.sortBy = "new"
} else if ('急招' == item) {
this.queryParams.isUrgent = "1"
} else if ('平台结算' == item) {
//高奖励
this.queryParams.isPlatformFree = "1"
} else if ('品牌置换' == item) {
//品牌置换
this.queryParams.gift = "gift"
}
this.menuIndex = index
this.onRefresherrefresh()
},
/**
* 鉴权
*/
async checkRights() {
let res = await hasRights(rightsCode.searchNotice)
if (!res) {
this.canSearch = false
} else {
this.canSearch = true
}
},
/**
* 搜索
*/
async goSeach() {
//鉴权
if (!await this.checkIfHasRights(rightsCode.searchNotice)) {
this.canSearch = false
return
} else {
this.canSearch = true
if (!this.focus) {
this.focus = true
}
}
},
/**
* 鉴权通用方法
* @param {Object} rigthsCode
*/
async checkIfHasRights(rigthsCode) {
let res = await hasRights(rigthsCode)
if (!res) {
this.$emit("openVip")
return false
}
return true
},
/**
* 上滑加载数据
*/
onReachBottomCus() {
//判断 如果页码*页容量大于等于总条数,提示该页数据加载完毕
if (this.queryParams.pageNum * this.queryParams.pageSize >= this.total) {
toast("没有更多数据了")
return
}
//页码+1,调用获取数据的方法获取第二页数据
this.queryParams.pageNum++
this.selectDataList()
},
/**
* 下拉刷新数据
*/
onRefresherrefresh() {
this.isTriggered = true
this.queryParams.pageNum = 1
this.total = 0
this.closeDrawer()
this.selectDataList()
},
/**
* 文本搜索
* @param {Object} res
*/
search(res) {
this.queryParams.searchValue = res.value
this.onRefresherrefresh()
},
/**
* 清空搜索
*/
clear() {
this.queryParams.searchValue = ""
this.onRefresherrefresh()
},
/**
* 查询数据
*/
selectDataList() {
getNoticeList(this.queryParams).then(res => {
this.isTriggered = false
if (res.code == 200) {
if (this.queryParams.pageNum == 1) {
this.dataList = res.data.records
} else {
this.dataList = this.dataList.concat(res.data.records)
}
this.total = res.data.total
}
}).catch((e) => {
this.isTriggered = false
uni.showToast({
icon: 'error',
duration: 2000,
title: e
});
})
},
/**
* 查看通告详情
* @param {Object} item
*/
goDetail(item) {
let userInfo = getJSONData(constant.userInfo)
if (!userInfo) {
store.dispatch('LogOut').then(res => {
uni.reLaunch({
url: '/pages/login'
})
})
} else {
let userType = getUserType()
let param = {
userId: userInfo.userId,
userType: userType,
noticeId: item.id,
rightsCode: 'unlock_notice',
deplete: 1
}
dealMemberRights(param).then(res => {
if (res.code == 200) {
this.$tab.navigateTo(`/pages/notice/detail?id=${item.id}`)
}
}).catch((e) => {
uni.showToast({
icon: 'error',
duration: 2000,
title: e
});
})
}
},
/**扣除解锁通告权益*/
dealMemberRights() {
dealMemberRights()
}
}
}
</script>
<style lang="scss">
@mixin flex {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.uni-popup__wrapper {
background-color: transparent !important;
}
.dl-notice-box-index {
// padding-top: var(--status-bar-height);
width: 100%;
color: #363636;
background-color: white;
font-size: 38rpx;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: start;
position: relative;
.dl-tgz {
background-color: #4260ff !important;
}
.dl-tgz-text {
color: white !important;
}
.dl-title {
width: 100%;
display: flex;
position: relative;
z-index: 10;
padding-top: calc(var(--status-bar-height) + 25rpx);
padding-left: 15rpx;
padding-right: 10rpx;
padding-bottom: 10rpx;
// padding: 25rpx 10rpx 10rpx 15rpx;
border-bottom: 1px solid #F4F4F4;
.left-search {
flex: 1;
display: flex;
align-items: center;
justify-content: left;
position: relative;
.left-search-box {
display: flex;
align-items: self-start;
justify-content: center;
position: relative;
.dl-image {
width: 40rpx;
height: 40rpx;
}
.dl-vip {
position: absolute;
height: 20rpx;
width: 50rpx;
top: 0rpx;
right: -10px;
}
}
.dl-zhezhao {
background: transparent;
z-index: 99;
position: absolute;
width: 100%;
height: 100%;
}
}
.right-text {
width: 140rpx;
display: flex;
align-items: center;
justify-content: center;
.dl-text {
color: #FC1F3E;
font-size: 40rpx;
line-height: 78rpx;
font-weight: bold;
}
}
}
.dl-menu-box {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
padding-top: 20rpx;
.dl-menu-dom {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
.dl-menu {
font-size: 30rpx;
padding-bottom: 10rpx;
text-align: center;
}
}
.click {
font-size: 32rpx !important;
color: #FF434E;
font-weight: bold;
border-bottom: 3px solid #FF434E;
}
.dl-search-box {
border: 1rpx solid rgba(0, 0, 0, 0);
position: relative;
flex-grow: 1;
font-size: 30rpx;
margin: 0 15rpx;
padding: 10rpx 25rpx;
background-color: #F7F7F7;
border-radius: 40rpx;
align-items: center;
justify-content: left;
display: flex;
.image-box {
flex: 1;
}
.dl-icon {
width: 20rpx;
height: 20rpx;
float: right;
}
.dl-vip {
position: absolute;
width: 50rpx;
height: 20rpx;
top: -12rpx;
right: -5px;
}
}
}
.dl-body {
flex: 1;
width: 100%;
height: 100%;
background-color: #EEEEEE;
padding: 20rpx 20rpx 0 20rpx;
.dl-member-box {
display: flex;
align-items: center;
border-radius: 35rpx;
justify-content: center;
height: 85rpx;
width: 100%;
background: url('/static/index/member-bg.png');
background-size: 100% 100%;
background-position: center;
/* 图片居中显示 */
background-repeat: no-repeat;
/* 不重复背景图片 */
.dl-left {
display: flex;
flex: 1;
padding-left: 30rpx;
align-items: center;
font-size: 30rpx;
color: #623109;
justify-content: left;
.dl-icon {
width: 60rpx;
height: 56rpx;
}
}
.dl-right {
.dl-go-view {
width: 190rpx;
float: right;
height: 76rpx;
}
}
}
.dl-public-box {
display: flex;
align-items: center;
border-radius: 35rpx;
justify-content: center;
height: 130rpx;
width: 100%;
background: url('/static/index/bg.png');
background-size: 100% 100%;
background-position: center;
/* 图片居中显示 */
background-repeat: no-repeat;
/* 不重复背景图片 */
.dl-left {
width: 135rpx;
display: flex;
padding-left: 30rpx;
align-items: center;
font-size: 30rpx;
color: #623109;
justify-content: left;
.dl-icon {
width: 80rpx;
height: 80rpx;
}
}
.dl-center {
flex: 1;
flex-direction: column;
display: flex;
align-items: self-start;
justify-content: center;
font-size: 27rpx;
color: #363636;
font-weight: bold;
text {
color: #FC1F3E;
}
}
.dl-right {
width: 200rpx;
display: flex;
align-items: center;
justify-content: center;
.dl-opt-dom {
font-size: 27rpx;
background-color: #FC1F3E;
border-radius: 30rpx;
color: white;
padding: 10rpx 30rpx;
}
}
}
.dl-item-box {
height: calc(100vh - var(--status-bar-height) - var(--window-bottom) - 585rpx);
isplay: flex;
flex-direction: column;
}
.open-zf {
height: calc(100vh - var(--status-bar-height) - var(--window-bottom) - 450rpx) !important;
}
}
}
.scroll-view {
/* #ifndef APP-NVUE */
width: 100%;
height: 100%;
/* #endif */
flex: 1;
}
// 处理抽屉内容滚动
.scroll-view-box {
flex: 1;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
// padding-top: calc(var(--status-bar-height) + 100rpx);
// padding-bottom: 100rpx;
font-size: 30rpx;
.uni-common-mt {
padding-top: calc(var(--status-bar-height) + 100rpx);
padding-left: 20rpx;
padding-bottom: 100rpx;
height: 100%;
background: white;
}
}
.info-content {
padding: 20rpx 30rpx;
display: flex;
align-items: center;
border-bottom: 1px solid #F4F4F4;
justify-content: center;
.image {
flex: none;
width: 40rpx;
height: 40rpx;
}
.title {
flex: 1;
padding-left: 15rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.dl-focus {
border: 1rpx solid RGBA(255, 175, 179, 1) !important;
background-color: RGBA(255, 175, 179, 0.3) !important;
color: #FF434E !important;
}
.popup-content {
@include flex;
align-items: center;
justify-content: center;
padding: 15px;
height: 50px;
}
.uni-popup {
top: 370rpx !important;
}
.vue-ref {
top: 370rpx !important;
}
.dl-drawer-item {
display: flex;
color: #929292;
align-items: center;
justify-content: center;
border-bottom: 1px solid #F4F4F4;
margin-bottom: 20rpx;
input {
border: 1rpx solid #F4F4F4;
border-radius: 15rpx;
color: #929292;
padding: 5rpx 10rpx;
margin: 10rpx 0;
text-align: center;
height: 60rpx;
line-height: 60rpx;
}
.dl-reward-type {
flex: 1;
text-align: center;
border: 1rpx solid #F4F4F4;
color: #929292;
border-radius: 15rpx;
padding: 10rpx 25rpx;
margin: 10rpx;
}
}
.uni-drawer--right {
width: 100% !important;
background: transparent !important;
}
.input-value-border {
border: 1px solid #F4F4F4 !important;
font-size: 30rpx !important;
color: #929292 !important;
}
.placeholder {
font-size: 30rpx !important;
}
.text-color {
color: #929292 !important;
}
</style>