Parcourir la source

资讯 && 法律下乡 - 点赞 排序

付宇航 il y a 1 an
Parent
commit
0e5b3a7bed

+ 9 - 0
api/information/information.js

@@ -62,6 +62,15 @@ export function updateServer(data) {
   })
 }
 
+// 点赞
+export function likeServer(data) {
+  return request({
+    url: '/jnb/information/like',
+    method: 'post',
+    data: data
+  })
+}
+
 // 删除资讯
 export function delServer(ids,type) {
   return request({

+ 83 - 24
pages/fuwu/fuwu.vue

@@ -1,49 +1,58 @@
 <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 v-if="index1 < 3" style="color: red;">[置顶]</span>
+	        <view class="list" @tap.stop="goDetails(item)" v-for="(item, index1) in qbwd" :key="index1">
+				<span v-if="item.isTop == 1" style="color: red;">[置顶]</span>
 	            <span class="listTitle">{{ item.titleName }}</span>
 	
-	            <view class="onePic" v-if="index1 >2  ? item.urls.length == 1 : false ">
+	            <view class="onePic" v-if="item.isTop != 1  ? item.urls.length == 1 : false ">
 	                <image :src="loadImgSrc(item.urls[index2])" v-for="(v, index2) in item.urls" :key="index2">
 					</image>
 	            </view>
-	            <view class="twoPic" v-if="index1 >2 ? item.urls.length == 2 : false">
+	            <view class="twoPic" v-if="item.isTop != 1 ? item.urls.length == 2 : false">
 	                <image :src="loadImgSrc(item.urls[index2])" v-for="(v, index2) in item.urls" :key="index2">
 					</image>
 	            </view>
 	
-	            <view class="threePic" v-if="index1 >2 ? item.urls.length == 3 : false">
+	            <view class="threePic" v-if="item.isTop != 1 ? item.urls.length == 3 : false">
 	                <image :src="loadImgSrc(item.urls[index2])" v-for="(v, index2) in item.urls" :key="index2">
 					</image>
 	            </view>
 	
-	           <!-- <view class="jlSj">
+	           <view class="jlSj">
 	                <span class="jf">
-	                    {{ item.jf }}
-	                    <em class="iconfont icon-jifen"></em>
+	                   <!-- {{ item.jf }}
+	                    <em class="iconfont icon-jifen"></em> -->
 	                </span>
 	                <view class="ck">
-	                    <span>
+	                    <!-- <span>
 	                        <em class="iconfont icon-pinglun"></em>
 	                        {{ item.pl }}
-	                    </span>
+	                    </span> -->
 	                    <span>
 	                        <em class="iconfont icon-chakan"></em>
-	                        {{ item.ck }}
+	                        {{ item.watchNum }}
 	                    </span>
-	                    <span>
-	                        <em class="iconfont icon-shoucang"></em>
-	                        {{ item.dz }}
+	                    <span :class=" favoriteList.includes(item.id) ? 'favorite' : 'not-favorite' ">
+	                        <em class="iconfont icon-shoucang" @click.stop="addFavorite(item)"></em>
+	                        {{ currentFavoriteCount(item) }}
 	                    </span>
 	                </view>
-	            </view> -->
+	            </view>
 	
 			</view>
 	    </view>
@@ -53,7 +62,7 @@
 </template>
 
 <script>
-import { listWxs ,listWx} from '@/api/information/information.js'
+import { listWxs ,listWx,likeServer} from '@/api/information/information.js'
 // pages/me.js
 export default {
     data() {
@@ -64,11 +73,19 @@ export default {
 			  pageSize: 7,
 			  titleName: '',
 			  type: 12,
-			  flag:''
+			  flag:'',
+			  isTop:0
 			},
 			topList:[],
 			total:0,
-			searchValue:''
+			searchValue:'',
+			favoriteList:[],
+			value: 1,
+			range: [
+				{ value: 'watch', text: "热度" },
+				{ value: 'like', text: "点赞" },
+				{ value: '', text: "最新" },
+			],
 		};
     },
 	created(){
@@ -97,6 +114,38 @@ export default {
 		}
 	},
 	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:12
+			}).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.titleName = ''
 		},
@@ -104,7 +153,8 @@ export default {
 			this.listParams.titleName = this.searchValue
 			this.getList()
 		},
-		getList(){
+		getList(val = null){
+			this.listParams.flag = val || ''
 			this.qbwd = this.topList
 			listWxs(this.listParams).then(res => {
 				this.qbwd = [...this.qbwd,...res.rows]
@@ -155,9 +205,18 @@ export default {
     onShareAppMessage() {},
 };
 </script>
-<style>
+<style lang="scss">
 @import './fuwu.css';
 .container{
 	height: 100%;
+	content: '\e633';
+}
+.favorite{
+	.icon-shoucang:before{
+		color: red;
+	}
+}
+.not-favorite{
+	
 }
 </style>

+ 2 - 2
pages/informationDetail/informationDetail.vue

@@ -6,7 +6,7 @@
             <view class="wenzhangLy">
                 <!-- 头像昵称 -->
                 <view class="txTime">
-                    <image :src="loadImgSrc(detailInfo.headImg!=null?detailInfo.headImg:'/profile/upload/2024/03/05/abf969632ee94bd5a429c8c2dbb2f6b4 (1)_20240305092823A002.png')"></image>
+                    <image :src="loadImgSrc(detailInfo.headImg!=null?detailInfo.headImg:'/profile/upload/2024/03/05/abf969632ee94bd5a429c8c2dbb2f6b4 (1)_20240305092823A002.png')" style="border-radius: 50px;"></image>
                     <view class="time">
                         <p>{{detailInfo.nickName?detailInfo.nickName:'网友'}}</p>
                         <span>{{ detailInfo.createTime }}</span>
@@ -23,7 +23,7 @@
                     <!-- 图片轮播 -->
                     <swiper :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration" :circular="circular">
                         <block v-for="(one, index) in detailInfo.urls" :key="index">
-                            <swiper-item><image :src="loadImgSrc(one)" mode="aspectFill"></image></swiper-item>
+                            <swiper-item><image :src="loadImgSrc(one)"  style="background-size: 100% 100%;"></image></swiper-item>
                         </block>
                     </swiper>
                 </view>

+ 88 - 27
pages/toLegal/toLegal.vue

@@ -1,49 +1,57 @@
 <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 v-if="index1 < 3" style="color: red;">[置顶]</span>
+				<span v-if="item.isTop == 1" style="color: red;">[置顶]</span>
 	            <span class="listTitle">{{ item.titleName }}</span>
-	
-	            <view class="onePic" v-if="index1 >2  ? item.urls.length == 1 : false ">
+	            <view class="onePic" v-if="item.isTop != 1 ? item.urls.length == 1 : false ">
 	                <image :src="loadImgSrc(item.urls[index2])" v-for="(v, index2) in item.urls" :key="index2">
 					</image>
 	            </view>
-	            <view class="twoPic" v-if="index1 >2 ? item.urls.length == 2 : false">
+	            <view class="twoPic" v-if="item.isTop != 1 ? item.urls.length == 2 : false">
 	                <image :src="loadImgSrc(item.urls[index2])" v-for="(v, index2) in item.urls" :key="index2">
 					</image>
 	            </view>
 	
-	            <view class="threePic" v-if="index1 >2 ? item.urls.length == 3 : false">
+	            <view class="threePic" v-if="item.isTop != 1 ? item.urls.length == 3 : false">
 	                <image :src="loadImgSrc(item.urls[index2])" v-for="(v, index2) in item.urls" :key="index2">
 					</image>
 	            </view>
 	
-	           <!-- <view class="jlSj">
+	           <view class="jlSj">
 	                <span class="jf">
-	                    {{ item.jf }}
-	                    <em class="iconfont icon-jifen"></em>
+	                   <!-- {{ item.jf }}
+	                    <em class="iconfont icon-jifen"></em> -->
 	                </span>
-	                <view class="ck">
-	                    <span>
+	                <view class="ck favoriteIcon">
+	                    <!-- <span>
 	                        <em class="iconfont icon-pinglun"></em>
 	                        {{ item.pl }}
-	                    </span>
+	                    </span> -->
 	                    <span>
 	                        <em class="iconfont icon-chakan"></em>
-	                        {{ item.ck }}
+	                        {{ item.watchNum }}
 	                    </span>
-	                    <span>
-	                        <em class="iconfont icon-shoucang"></em>
-	                        {{ item.dz }}
+	                    <span :class=" favoriteList.includes(item.id) ? 'favorite' : 'not-favorite' ">
+	                        <em class="iconfont icon-shoucang" @click.stop="addFavorite(item)"></em>
+	                        {{ currentFavoriteCount(item) }}
 	                    </span>
 	                </view>
-	            </view> -->
+	            </view>
 	
 			</view>
 	    </view>
@@ -53,7 +61,7 @@
 </template>
 
 <script>
-import { listWxs ,listWx} from '@/api/information/information.js'
+import { listWxs ,listWx,likeServer} from '@/api/information/information.js'
 // pages/me.js
 export default {
     data() {
@@ -63,18 +71,26 @@ export default {
 			  pageNum: 1,
 			  pageSize: 7,
 			  titleName: '',
-			  type: 12,
+			  isTop:0,
+			  type: 11,
 			  flag:''
 			},
 			topList:[],
 			total:0,
-			searchValue:''
+			searchValue:'',
+			favoriteList:[],
+			value: 1,
+			range: [
+				{ value: 'watch', text: "热度" },
+				{ value: 'like', text: "点赞" },
+				{ value: '', text: "最新" },
+			],
 		};
     },
 	created(){
 		// 查置顶
 		listWx({
-			type:12,
+			type:11,
 			isTop:1
 		}).then(e => {
 			this.topList = e.data
@@ -97,6 +113,38 @@ export default {
 		}
 	},
 	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.titleName = ''
 		},
@@ -104,7 +152,8 @@ export default {
 			this.listParams.titleName = this.searchValue
 			this.getList()
 		},
-		getList(){
+		getList(val = null){
+			this.listParams.flag = val || ''
 			this.qbwd = this.topList
 			listWxs(this.listParams).then(res => {
 				this.qbwd = [...this.qbwd,...res.rows]
@@ -113,7 +162,7 @@ export default {
 		},
 		goDetails(e) {
 			let id = e.id || ''
-			let type = 12
+			let type = 11
 		    uni.navigateTo({
 		        url: `../informationDetail/informationDetail?id=${id}&type=${type}`
 		    });
@@ -155,9 +204,21 @@ export default {
     onShareAppMessage() {},
 };
 </script>
-<style>
+<style lang="scss">
 @import './toLegal.css';
 .container{
 	height: 100%;
 }
+.container{
+	height: 100%;
+	content: '\e633';
+}
+.favorite{
+	.icon-shoucang:before{
+		color: red;
+	}
+}
+.not-favorite{
+	
+}
 </style>