lhl 1 year ago
parent
commit
e332d73d50
5 changed files with 182 additions and 13 deletions
  1. 8 0
      api/index.js
  2. 6 0
      pages.json
  3. 133 0
      pages/public/artDetail.vue
  4. 23 1
      pages/user/model/phb.vue
  5. 12 12
      pages/user/teamph.vue

+ 8 - 0
api/index.js

@@ -61,3 +61,11 @@ export function getCardLookCountRank(data) {
 		data
 	});
 }
+
+export function getArtDetail(data) {
+	return request({
+			url: '/api/pub/getArtDetail',
+			method: 'post',
+			data
+		});
+}

+ 6 - 0
pages.json

@@ -305,6 +305,12 @@
 				"style": {
 					"navigationBarTitleText": "隐私协议"
 				}
+			},
+			{
+				"path": "artDetail",
+				"style": {
+					"navigationBarTitleText": ""
+				}
 			}
 		]
 	}],

+ 133 - 0
pages/public/artDetail.vue

@@ -0,0 +1,133 @@
+<template>
+	<view class="center">
+<!-- 		<view class="title clamp">{{ item.title }}</view>
+		<view class="time">{{ item.add_time }}</view> -->
+		<view class="main" v-for="(ls, index) in item.content" :key="index">
+			<view v-if="ls.type == 'rich-text'" v-html="ls.value" class="main"></view>
+			<video v-if="ls.type == 'video' && ls.value" :src="ls.value" style="width:100%;height: 300px" frameborder="0"></video>
+		</view>
+	</view>
+</template>
+
+<script>
+import { getArtDetail } from '@/api/index.js'
+export default {
+	data() {
+		return {
+			id: '',
+			item: ''
+		};
+	},
+	onLoad(option) {
+		this.id = option.id;
+		this.loadData();
+	},
+	onShareAppMessage(options) {
+		// 设置菜单中的转发按钮触发转发事件时的转发内容
+		let pages = getCurrentPages(); //获取加载的页面
+		let currentPage = pages[pages.length - 1]; //获取当前页面的对象
+		let url = currentPage.route; //当前页面url
+		let item = currentPage.options; //如果要获取url中所带的参数可以查看options
+		let shareObj = {
+			title: '水箱计算', // 默认是小程序的名称(可以写slogan等)
+			path: url + '?id=' + item.id, // 默认是当前页面,必须是以‘/’开头的完整路径
+			imageUrl: '',
+			success: function(res) {
+				// 转发成功之后的回调
+				if (res.errMsg == 'shareAppMessage:ok') {}
+			},
+			fail: function() {
+				// 转发失败之后的回调
+				if (res.errMsg == 'shareAppMessage:fail cancel') {
+					// 用户取消转发
+				} else if (res.errMsg == 'shareAppMessage:fail') {
+					// 转发失败,其中 detail message 为详细失败信息
+				}
+			}
+		};
+		return shareObj;
+	},
+	methods: {
+		loadData() {
+			getArtDetail({id:this.id}).then(({ data }) => {
+				let content = data.list[0]
+				content.content = content.content.replace(/<img/g, '<img class="rich-img"').replace(/<p>\s*<img/g, '<p class="pHeight"><img').replace(/<div/g, '<div style="max-width: 50% !important;"');
+				content.content = this.getVideo(content.content);
+				this.item = content;
+				uni.setNavigationBarTitle({
+					title: this.item.title
+				})
+			});
+		},
+		// 富文本视频解析
+		getVideo(data) {
+			let videoList = [];
+			let videoReg = /<video.*?(?:>|\/>)/gi; //匹配到字符串中的 video 标签
+			let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i; //匹配到字符串中的 video 标签 的路径
+			let arr = data.match(videoReg) || []; // arr 为包含所有video标签的数组
+			let articleList = data.split('</video>'); // 把字符串  从视频标签分成数组
+			arr.forEach((item, index) => {
+				var src = item.match(srcReg);
+				videoList.push(src[1]); //所要显示的字符串中 所有的video 标签 的路径
+			});
+			let needArticleList = [];
+			articleList.forEach((item, index) => {
+				if (item != '' && item != undefined) {
+					//  常见的标签渲染
+					needArticleList.push({
+						type: 'rich-text',
+						value: item + '</video>'
+					});
+				}
+				let articleListLength = articleList.length; // 插入到原有video 标签位置
+				if (index < articleListLength && videoList[index] != undefined) {
+					needArticleList.push({
+						type: 'video',
+						value: videoList[index]
+					});
+				}
+			});
+			return needArticleList;
+		}
+	}
+};
+</script>
+
+<style lang="scss">
+	page {
+		background-color: #fff;
+		min-height: 100%;
+		height: auto;
+	}
+.center {
+	min-height: 100%;
+	height: auto;
+	background: #ffffff;
+	padding: 30rpx 24rpx 0;
+}
+.title {
+	font-size: 32rpx;
+	font-family: PingFang SC;
+	font-weight: bold;
+	color: #333333;
+}
+.time {
+	font-size: 24rpx;
+	font-family: PingFangSC;
+	font-weight: 500;
+	color: #999999;
+	margin-top: 40rpx;
+}
+.main {
+	margin-top: 60rpx;
+}
+/deep/ .main {
+	.rich-img {
+		width: 100% !important;
+		height: auto;
+	}
+	* {
+		max-width: 100% !important;
+	}
+}
+</style>

+ 23 - 1
pages/user/model/phb.vue

@@ -11,6 +11,9 @@
 			
 			<view class="bd" v-if="showList.length > 0">
 				<image :src="tit_bg" mode="widthFix" class="bd-tit"></image>
+				<view class="gzsm" @click="navTo('/pages/public/artDetail?id=4')">
+					规<br>则<br>说<br>明
+				</view>
 				<view class="bd-top flex">
 					<view class="top-item" @click="navTo('/pages/user/model/model?uid=' + showList[1].auth_info.uid + '&type=2&mtype=1')">
 						<view class="top-logo yp">
@@ -79,7 +82,7 @@
 
 <script>
 	import { getInviteCountRank } from '@/api/user.js'
-	import { getCardLookCountRank } from '@/api/index.js'
+	import { getCardLookCountRank,getArtDetail } from '@/api/index.js'
 	export default {
 		data() {
 			return {
@@ -110,6 +113,11 @@
 			console.log(this.$store.state.baseURL)
 			this.times = ((new Date().setHours(0, 0, 0) - (new Date().getDay() - 1) *24 * 60 * 60 *1000)/1000).toFixed(0)
 			this.getCardLookCountRank()
+			getArtDetail({
+				id: 4
+			}).then(res => {
+				console.log(res);
+			})
 		},
 		onReachBottom() {
 
@@ -381,4 +389,18 @@
 		text-align: center;
 		line-height: 500rpx;
 	}
+	.gzsm {
+		width: 44rpx;
+		// height: 127rpx;
+		display: inline-block;
+		background-color: #dd2525;
+		position: absolute;
+		right: 0;
+		top: 53rpx;
+		border-radius: 10rpx 0 0 10rpx;
+		color: #ffc573;
+		font-size: 24rpx;
+		text-align: center;
+		padding: 10rpx;
+	}
 </style>

+ 12 - 12
pages/user/teamph.vue

@@ -12,10 +12,10 @@
 
 				<view class="ph-item flex">
 					<view class="item-logo yj-logo">
-						<image :src="navList[currentIndex].list[1].avatar || ''" mode="" class="avt"></image>
+						<image :src="navList[currentIndex].list[1].auth_info.avatar || navList[currentIndex].list[1].avatar || ''" mode="" class="avt"></image>
 					</view>
 					<view class="item-name clamp">
-						{{navList[currentIndex].list[1].nickname || '暂无'}}
+						{{navList[currentIndex].list[1].auth_info.name || navList[currentIndex].list[1].nickname || '暂无'}}
 					</view>
 					<view class="item-id">
 						ID: {{navList[currentIndex].list[1].uid || '0'}}
@@ -24,15 +24,15 @@
 						团队数
 					</view>
 					<view class="item-val">
-						{{navList[currentIndex].list[1].count || '0'}}
+						{{navList[currentIndex].list[1].invite_count || '0'}}
 					</view>
 				</view>
 				<view class="ph-item flex">
 					<view class="item-logo gj-logo">
-						<image :src="navList[currentIndex].list[0].avatar || ''" mode="" class="avt"></image>
+						<image :src="navList[currentIndex].list[0].auth_info.avatar || navList[currentIndex].list[0].avatar || ''" mode="" class="avt"></image>
 					</view>
 					<view class="item-name clamp">
-						{{navList[currentIndex].list[0].nickname || '暂无'}}
+						{{navList[currentIndex].list[0].auth_info.name ||navList[currentIndex].list[0].nickname || '暂无'}}
 					</view>
 					<view class="item-id">
 						ID: {{navList[currentIndex].list[0].uid || '0'}}
@@ -41,15 +41,15 @@
 						团队数
 					</view>
 					<view class="item-val">
-						{{navList[currentIndex].list[0].count || '0'}}
+						{{navList[currentIndex].list[0].invite_count || '0'}}
 					</view>
 				</view>
 				<view class="ph-item flex">
 					<view class="item-logo jj-logo">
-						<image :src="navList[currentIndex].list[2].avatar || ''" mode="" class="avt"></image>
+						<image :src="navList[currentIndex].list[2].auth_info.avatar || navList[currentIndex].list[2].avatar || ''" mode="" class="avt"></image>
 					</view>
 					<view class="item-name clamp">
-						{{navList[currentIndex].list[2].nickname || '暂无'}}
+						{{navList[currentIndex].list[2].auth_info.name || navList[currentIndex].list[2].nickname || '暂无'}}
 					</view>
 					<view class="item-id">
 						ID: {{navList[currentIndex].list[2].uid || '0'}}
@@ -58,7 +58,7 @@
 						团队数
 					</view>
 					<view class="item-val">
-						{{navList[currentIndex].list[2].count || '0'}}
+						{{navList[currentIndex].list[2].invite_count || '0'}}
 					</view>
 				</view>
 			</view>
@@ -70,10 +70,10 @@
 				<view class="item-xh">
 					{{index + 1}}
 				</view>
-				<image :src="item.avatar" mode="" class="item-logo"></image>
+				<image :src="item.auth_info.avatar || item.avatar" mode="" class="item-logo"></image>
 				<view class="item-info">
 					<view class="info-name">
-						{{item.nickname}}
+						{{item.auth_info.name || item.nickname || '微信用户'}}
 					</view>
 					<view class="info-id">
 						ID: {{item.uid}}
@@ -81,7 +81,7 @@
 				</view>
 				<view class="item-tg">
 					<view class="tg-val">
-						{{item.count}}
+						{{item.invite_count || 0}}
 					</view>
 					<view class="tg-tit">
 						团队数