Browse Source

2022-1-20

cmy 3 years ago
parent
commit
68ac0ae37c
7 changed files with 234 additions and 63 deletions
  1. 10 0
      api/index.js
  2. 1 7
      pages.json
  3. 95 24
      pages/index/artDetail.vue
  4. 1 5
      pages/index/artList.vue
  5. 1 1
      pages/index/index.vue
  6. 122 0
      pages/index/shopList.vue
  7. 4 26
      pages/user/user.vue

+ 10 - 0
api/index.js

@@ -43,4 +43,14 @@ export function hotList(data) {
 	});
 }
 
+// 获取文章热门列表
+export function getArtDetai(data,id) {
+	return request({
+		url: '/api/article/details/'+id,
+		method: 'get',
+		data
+	});
+}
+
+
 

+ 1 - 7
pages.json

@@ -27,14 +27,8 @@
 		{
 			"path": "pages/index/artList",
 			"style": {
-				"navigationBarTitleText": "公司简介",
-				"app-plus": {
-					"titleNView": {
-						"type": "transparent"
-					}
-				}
+				"navigationBarTitleText": "公司文化"
 			}
-			
 		},
 		{
 			"path": "pages/index/artDetail",

+ 95 - 24
pages/index/artDetail.vue

@@ -1,42 +1,113 @@
 <template>
-	<view class="contet">
-		<view class="" v-html="content">
-			
+	<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 {
-		loadIndexs,
-		getArticleList,
-		getArtDetai
-	} from '@/api/index.js';
+		details
+	} from '@/api/user.js';
 	export default {
 		data() {
 			return {
-				content: '',
-				id: 0,
-			}
+				id: '',
+				item: ''
+			};
 		},
-		onLoad(opt) {
-			this.id = opt.id
-			this.getDetai()
+		onLoad(option) {
+			this.id = option.id;
+			this.loadData();
 		},
 		methods: {
-			getDetai() {
-				let obj = this
-				getArtDetai({},obj.id).then(res => {
-					console.log(res)
-					obj.content = res.data.content
-					if(obj.content != null){
-						obj.content = obj.content.replace(/<img/g,"<img style='max-width:100%;height:auto;min-width:100%;'");
-					}//小程序商品详情图超出屏幕问题
-				})
+			loadData() {
+				details({}, this.id).then(({
+					data
+				}) => {
+					console.log(data);
+					data.content = data.content.replace(/<img/g, '<img class="rich-img"').replace(/<p>\s*<img/g,
+						'<p class="pHeight"><img');
+					data.content = this.getVideo(data.content);
+					this.item = data;
+				});
+			},
+			// 富文本视频解析
+			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>
+<style lang="scss">
+	page {
+		min-height: 100%;
+		height: 0;
+	}
+
+	.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;
+		text-align: center;
+	}
+
+	.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;
+		}
+	}
 </style>

+ 1 - 5
pages/index/artList.vue

@@ -16,11 +16,7 @@
 </template>
 
 <script>
-	import { article,articleList } from '@/api/user.js';
-	import {
-		loadIndexs,
-		getArticleList
-	} from '@/api/index.js';
+	import { article } from '@/api/user.js';
 	export default {
 		data() {
 			return {

+ 1 - 1
pages/index/index.vue

@@ -67,7 +67,7 @@
 					公司文化
 				</view>
 			</view>
-			<view class="right" @click="nav('/pages/index/artList?cid=1')">
+			<view class="right" @click="nav('/pages/index/artList?cid=1&tit=' + encodeURI('公司文化'))">
 				<view class="jj-more-tit">
 					更多
 				</view>

+ 122 - 0
pages/index/shopList.vue

@@ -0,0 +1,122 @@
+<template>
+	<view class="main">
+		<view class="list-box-h">
+			<view v-for="(item, index) in dataList" :key="index" class="guess-item" @click="navToDetailPage(item)">
+				<image :src="item.image"></image>
+				<view class="guess-box">
+					<view class="title clamp2">{{ item.store_name }}</view>
+					<view class="price-box flex">
+						<view class="yuanprice">{{ item.ot_price }}</view>
+						<image src="../../static/img/jiantou.png" mode=""></image>
+						<view class="jiang">直降{{ (item.ot_price - item.price).toFixed(2) }}元</view>
+					</view>
+					<view class="price">¥{{ item.price }}</view>
+					<view class="btn">立即购买</view>
+				</view>
+			</view>
+		</view>
+		<uni-load-more :status="loadingType"></uni-load-more>
+	</view>
+</template>
+
+<script>
+	import { article } from '@/api/user.js';
+	export default {
+		data() {
+			return {
+				list: [],
+				page: 1,
+				limit: 10,
+				loadingType: 'more',
+				cid: 0,
+			}
+		},
+		onLoad(opt) {
+			this.cid = opt.cid
+			this.tit = decodeURI(opt.tit)
+			uni.setNavigationBarTitle({
+				title: this.tit 
+			})
+			this.getArticleList()
+		},
+		methods: {
+			navto(url) {
+				uni.navigateTo({
+					url: url
+				})
+			},
+			getArticleList() {
+				let obj = this
+				if(obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
+					return
+				}
+				obj.loadingType = 'loading'
+				article({
+					page: obj.page,
+					limit: obj.limit
+				},obj.cid).then(({data}) => {
+					obj.list = obj.list.concat(data)
+					obj.page++
+					if(data.length == obj.limit) {
+						obj.loadingType = 'more'
+					}else {
+						obj.loadingType = 'noMore'
+					}
+				})
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	page {
+		background-color: #fff;
+		min-height: 100%;
+	}
+	.main {
+		margin-top: 40rpx;
+		padding: 0 40rpx;
+		.main-t-t {
+			// width: 100;
+			display: flex;
+			justify-content: center;
+			.main-t-t-i {
+				width: 376rpx;
+				height: 34rpx;
+				margin: auto;
+			}
+		}
+		.main-top {
+			align-items: center;
+	
+			.main-left {
+				display: flex;
+				justify-content: flex-start;
+				align-items: center;
+	
+				.shu {
+					width: 8rpx;
+					height: 38rpx;
+					background: #05ab81;
+					border-radius: 4rpx;
+				}
+	
+				.main-title {
+					margin-left: 10rpx;
+					font-size: 36rpx;
+					font-family: PingFang SC;
+					font-weight: bold;
+					color: #202739;
+				}
+	
+				.main-tip {
+					font-size: 22rpx;
+					font-family: PingFang SC;
+					font-weight: bold;
+					color: #95a0b1;
+					margin-left: 14rpx;
+				}
+			}
+		}
+	}
+</style>

+ 4 - 26
pages/user/user.vue

@@ -68,11 +68,11 @@
 			<view>
 				<view class="item-box item-box-a">
 					<view class="order-section">
-						<view class="order-item" @click="navTo('/pages/money/award')" hover-class="common-hover" :hover-stay-time="50">
+						<view class="order-item" @click="navTo('/pages/user/award')" hover-class="common-hover" :hover-stay-time="50">
 							<view class="icon icon-b"><image class="icon-img" src="/static/user/yue.png" mode="aspectFit"></image></view>
 							<view class="order-font">我的余额</view>
 						</view>
-						<view class="order-item" @click="navTo('/pages/user/wallet')" hover-class="common-hover" :hover-stay-time="50">
+						<view class="order-item" @click="navTo('/pages/money/wallet')" hover-class="common-hover" :hover-stay-time="50">
 							<view class="icon icon-b"><image class="icon-img" src="/static/user/yongjin.png" mode="aspectFit"></image></view>
 							<view class="order-font">我的佣金</view>
 						</view>
@@ -90,34 +90,18 @@
 					<uni-list>
 						<uni-list-item title="我的收藏" @click="navTo('/pages/user/favorites')" thumb="/static/user/shoucang.png"></uni-list-item>
 						<uni-list-item title="收货地址" @click="navTo('/pages/set/address')" thumb="/static/user/dizhi.png"></uni-list-item>
-						<uni-list-item title="联系客服" @click="showPopup" thumb="/static/user/kefu.png"></uni-list-item>
+						<!-- <uni-list-item title="联系客服" @click="showPopup" thumb="/static/user/kefu.png"></uni-list-item> -->
 					</uni-list>
 				</view>
 			</view>
 		</scroll-view>
-		<uni-popup ref="popup" type="center">
-			<view class="popup">
-				<view class="popup-dox">
-					<image class="popup-logo" src="../../static/img/img009.png"></image>
-					<view class="pop-title">已为您定制专属客服</view>
-					<view>{{ weixin }}</view>
-					<image class="popup-text" @longtap="bc_code" :src="erweima"></image>
-					<view class="btn" @click="copy(weixin)">复制微信号</view>
-					<view class="pop-tip flex">
-						<view class="weixin"><image src="../../static/img/weixin.png" mode=""></image></view>
-						<view>长按保存二维码</view>
-					</view>
-				</view>
-			</view>
-			<view class="close_icon" @click="close"><image src="../../static/img/Close.png"></image></view>
-		</uni-popup>
 	</view>
 </template>
 <script>
 import { mapState, mapMutations } from 'vuex';
 import uniList from '@/components/uni-list/uni-list.vue';
 import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
-import { orderData, getUserInfo, getMyStore,service } from '@/api/user.js';
+import { orderData, getUserInfo, getMyStore } from '@/api/user.js';
 import { saveUrl, interceptor } from '@/utils/loginUtils.js';
 import { logout } from '@/api/set.js';
 // import uniCopy from '@/js_sdk/xb-copy/uni-copy.js';
@@ -136,8 +120,6 @@ export default {
 			moving: false,
 			userDowm: 0, //卡片升级专属高度
 			userMaxDowm: 0, //卡片最高高度
-			erweima: '',
-			weixin: '',
 		};
 	},
 	onShow() {
@@ -292,10 +274,6 @@ export default {
 				.catch(e => {
 					console.log(e);
 				});
-			service({}).then(({ data }) => {
-				this.erweima = data.service_qr;
-				this.weixin = data.service_wechat;
-			});
 		},
 		/**
 		 * 统一跳转接口,拦截未登录路由