123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <template>
- <!-- pages/me.wxml -->
- <view class="container">
- <uni-search-bar :focus="true" v-model="searchValue" @input="search"
- style="width: 100%;"
- @cancel="cancel">
- </uni-search-bar>
- <!-- <view style="width: 100%;display: flex;">
- <uni-search-bar :focus="true" v-model="searchValue" @input="search"
- style="width: 70%;"
- @cancel="cancel">
- </uni-search-bar>
- <uni-data-select
- style="width: 30%;margin: auto;"
- v-model="value"
- placeholder="请选择排序"
- :localdata="range"
- @change="getList(value)"
- ></uni-data-select>
- </view> -->
- <view class="rnwdList">
- <view class="list" @tap="goDetails(item)" v-for="(item, index1) in qbwd" :key="index1">
- <span class="listTitle">{{ item.title }}</span>
- <view class="onePic">
- <image :src="loadImgSrcLocalhost(item.picture)">
- </image>
- </view>
- </view>
- </view>
- <!-- 新增资讯按钮 -->
- <!-- <button class="addInfomarionBtn" @click="addInfomation()"></button> -->
- </view>
- </template>
- <script>
- import { getMattersList } from '@/api/me/matters/matters.js'
- // pages/me.js
- export default {
- data() {
- return {
- qbwd:[],
- listParams:{
- pageNum: 1,
- pageSize: 7,
- title: '',
- isTop:0,
- type: 11,
- flag:''
- },
- topList:[],
- total:0,
- searchValue:'',
- favoriteList:[],
- value: 1,
- range: [
- { value: 'watch', text: "热度" },
- { value: 'like', text: "点赞" },
- { value: '', text: "最新" },
- ],
- };
- },
- created(){
- this.getList()
- },
- // 下拉刷新
- onPullDownRefresh() {
- setTimeout(() => {
- this.listParams.pageNum = 1;
- this.qbwd = [];
- let result = this.getList(this.listParams.flag,'刷新')
- },500)
- },
- onReachBottom(){
- let pageNum = this.listParams.pageNum
- let pageSize = this.listParams.pageSize
- let total = this.total
- if(pageNum * pageSize >= total){
- uni.showToast({
- title:'暂无更多数据'
- })
- return
- } else {
- this.listParams.pageNum += 1;
- this.getList(null,'dropDown')
- }
- },
- methods:{
- currentFavoriteCount(e){
- if(this.favoriteList.includes(e.id)){
- return e.likeNum + 1
- } else {
- return e.likeNum
- }
- },
- addFavorite(e){
- if(this.favoriteList.includes(e.id)) return
- likeServer({
- id:e.id,
- type:11
- }).then(e => {
- })
- this.favoriteList.push(e.id)
- return
- if(this.favoriteList.includes(e.id)){
- // 取消点赞
- likeServer({
- id:e.id,
- type:12
- })
- let deleteIdx = this.favoriteList.findIndex((v => v == e.id))
- this.favoriteList.splice(deleteIdx,1)
- } else {
- likeServer({
- id:e.id,
- type:12
- })
- this.favoriteList.push(e.id)
- }
- },
- cancel(){
- this.listParams.title = ''
- },
- fabClick(){
- uni.navigateTo({
- url: `/pages/handleAffairs/mattersAdd/mattersAdd`
- })
- },
- search(){
- this.listParams.title = this.searchValue
- this.getList()
- },
- getList(val = null,toastVal = '加载'){
- this.listParams.flag = val || ''
- this.qbwd = this.topList
- getMattersList(this.listParams).then(res => {
- this.qbwd = [...this.qbwd,...res.rows]
- this.total = res.total
- uni.showToast({
- title:`${toastVal}成功`
- })
- })
- },
- goDetails(e) {
- let id = e.id || ''
- let type = 11
- uni.navigateTo({
- url: `../mattersDetail/mattersDetail?id=${id}`
- });
- },
- // 新增资讯
- addInfomation(){
- uni.navigateTo({
- url: `../informationAdd/informationAdd`
- });
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {},
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {},
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {},
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {},
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {},
- };
- </script>
- <style lang="scss">
- @import './matters.css';
- .container{
- height: 100%;
- }
- .container{
- height: 100%;
- content: '\e633';
- }
- .favorite{
- .icon-shoucang:before{
- color: red;
- }
- }
- .not-favorite{
- }
- </style>
|