Browse Source

2022-1-20

cmy 3 years ago
parent
commit
924d06a0f1
3 changed files with 319 additions and 299 deletions
  1. 10 1
      api/user.js
  2. 302 292
      pages/index/classify.vue
  3. 7 6
      pages/product/product.vue

+ 10 - 1
api/user.js

@@ -152,4 +152,13 @@ export function edit(data) {
 		method: 'post',
 		data
 	});
-}
+}
+// 获取积分信息
+export function integralList(data) {
+	return request({
+		url: '/api/integral',
+		method: 'get',
+		data
+	});
+}
+

+ 302 - 292
pages/index/classify.vue

@@ -1,40 +1,33 @@
 <template>
 	<view class="container">
 		<!-- 头部轮播 -->
-		<!-- <view class="carousel-section">
-			<swiper class="carousel" autoplay="true" duration="400" interval="5000">
-				<swiper-item v-for="(item, index) in bannerImg" :key="index" class="carousel-item" @click="bannerNavToUrl(item)">
-					<image :src="item.img" mode=" scaleToFill" />
-				</swiper-item>
-			</swiper>
-		</view> -->
 		<view class="top">
 			<view class="bg"></view>
 			<view class="title-box">
 				<view class="title-one">
-					<text>555</text>
+					<text>{{integral.two}}</text>
 					<text>推销得分</text>
 				</view>
 				<view class="title-one">
-					<text>555</text>
+					<text>{{integral.one}}</text>
 					<text>推荐得分</text>
 				</view>
 				<view class="title-one">
-					<text>555</text>
+					<text>{{integral.gain}}</text>
 					<text>购买得分</text>
 				</view>
 			</view>
-			<view class="title-box1"  @click="navTo('/pages/user/shareQrCode')">
-					<view class="title-bg">
-						<image src="../../static/img/libao.jpg" mode=""></image>
-					</view>
-					<view class="title-between">
-						<text>邀请有礼</text>
-						<text>转发海报邀请好友获得更多奖励</text>
-					</view>
-					<view class="title-right">
-						<image src="../../static/user/right01.png" mode=""></image>
-					</view>
+			<view class="title-box1" @click="navTo('/pages/user/shareQrCode')">
+				<view class="title-bg">
+					<image src="../../static/img/libao.jpg" mode=""></image>
+				</view>
+				<view class="title-between">
+					<text>邀请有礼</text>
+					<text>转发海报邀请好友获得更多奖励</text>
+				</view>
+				<view class="title-right">
+					<image src="../../static/user/right01.png" mode=""></image>
+				</view>
 			</view>
 		</view>
 		<view class="goodsList-box">
@@ -46,12 +39,12 @@
 					</view>
 					<view class="goods-money flex">
 						<view class="money-box">
-							<text class="otMoney">¥{{ ls.ot_price }}</text>
-							<image src="../../static/icon/in2.png"></image>
+							<text class="money">现金:¥{{ (ls.price) - ls.max_integral }}</text>
+							<!-- <image src="../../static/icon/in2.png"></image> -->
 							<!-- <image src="../../static/error/errorImage.jpg"></image> -->
 							<!-- <text class="decline">直降{{ ls.ot_price - ls.price}}元</text> -->
 							<!-- <view class="otMoney-box"> -->
-							<view class="money">¥{{ ls.price }}</view>
+							<view class="money">积分:{{ ls.max_integral }}</view>
 							<!-- <text class="sales">已售{{ ls.sales }}件</text> -->
 							<!-- </view> -->
 						</view>
@@ -64,304 +57,321 @@
 </template>
 
 <script>
-import { loadIndexs,groom } from '@/api/index.js';
-export default {
-	data() {
-		return {
-			list: [],
-			bannerImg: [],
-			title: '',
-			goods: [],
-			page: 1,
-			limit: 10
-		};
-	},
-	onLoad(option) {
-		// 获取查询对象
-		this.type = option.type;
-		// 加载基础数据
-		// this.loadData();
-	},
-	methods: {
-		//动态改变标头
-		getTitle() {
-			let title = ''
-			if(this.type == 1) {
-				title = "精选好货"
-				// this.list = this.goods.bastList
-			}else if(this.type == 2) {
-				title = "热销专区"
-				// this.list = this.goods.likeInfo
-			}else if(this.type == 3) {
-				title = "收藏夹"
-			}else {
-				title = "促销单品"
-			}
-			uni.setNavigationBarTitle({
-				title: title
-			});
-		},
-		navTo: function(url) {
-			uni.navigateTo({
-				url
-			});
+	import {
+		getProducts
+	} from '@/api/product.js';
+	import {
+		integralList
+	} from '@/api/user.js';
+
+
+	export default {
+		data() {
+			return {
+				list: [],
+				page: 1,
+				limit: 1000,
+				loadingType: 'more',
+				integral: {
+					gain: 0,
+					one: 0,
+					two: 0,
+				}
+			};
 		},
-		// 请求载入数据
-		async loadData() {
-			// loadIndexs({})
-			// 	.then(({ data }) => {
-			// 		let goods = data.info;
-			// 		console.log(data)
-			// 		this.goods = goods
-			// 		this.goods.likeInfo = data.likeInfo
-			// 		// this.goodsList = goods.firstList; //最新商品
-			// 		// this.bastList = goods.bastList; //精品推荐
-			// 		this.getTitle()
-			// 		uni.stopPullDownRefresh();
-			// 	})
-			// 	.catch(e => {
-			// 		uni.stopPullDownRefresh();
-			// 	});
-			let data = {
-				page: this.page,
-				limit: this.limit
-			}
-			let type = this.type
-			groom(data,type).then(res => {
-				this.list = res.data.list
-				this.getTitle()
-				console.log(res.data)
-			})
+		onLoad(option) {
+			// 获取查询对象
+			this.type = option.type;
+			// 加载基础数据
+			this.loadData();
+			this.getArticleList();
 		},
-		// 轮播图跳转
-		// bannerNavToUrl(item) {
-		// 	// #ifdef H5
-		// 	if (item.wap_link.indexOf('http') > 0) {
-		// 		window.location.href = item.wap_link;
-		// 	}
-		// 	// #endif
-		// 	if (item.wap_link) {
-		// 		uni.navigateTo({
-		// 			url: item.wap_link
-		// 		});
-		// 	}
-		// }
-	}
-};
+		methods: {
+			getArticleList() {
+				let obj = this
+				if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
+					return
+				}
+				obj.loadingType = 'loading'
+				getProducts({
+					page: obj.page,
+					limit: obj.limit,
+					is_integral: 1
+				}, obj.cid).then(({
+					data
+				}) => {
+					obj.list = obj.list.concat(data)
+					obj.page++
+					if (data.length == obj.limit) {
+						obj.loadingType = 'more'
+					} else {
+						obj.loadingType = 'noMore'
+					}
+				})
+			},
+			navTo: function(url) {
+				uni.navigateTo({
+					url
+				});
+			},
+			// 请求载入数据
+			async loadData() {
+				integralList().then(res => {
+					this.integral={
+						gain: res.data.gain,//购买
+						one:  res.data.gain,//直推
+						two:  res.data.gain//间推
+					}
+				})
+			},
+		}
+	};
 </script>
 
 <style lang="scss">
-page {
-	background: $page-color-base;
-}
-.top{
-	.bg{
-		width: 1000rpx;
-		height: 200rpx;
-		background: #52C696;
-		overflow: hidden;
-		text-align: center;
-		border-bottom-left-radius: 50%;
-		border-bottom-right-radius: 50%;
-		margin-left: -125rpx;
-		
+	page {
+		background: $page-color-base;
 	}
-	.title-box{
-		position: relative;
-		z-index: 999;
-		margin: -100rpx auto;
-		display: flex;
-		justify-content: space-around;
-		align-items: center;
-		width: 702rpx;
-		height: 137rpx;
-		background: #FFFFFF;
-		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
-		border-radius: 10rpx;
-		.title-one{
+
+	.top {
+		.bg {
+			width: 1000rpx;
+			height: 200rpx;
+			background: #52C696;
+			overflow: hidden;
+			text-align: center;
+			border-bottom-left-radius: 50%;
+			border-bottom-right-radius: 50%;
+			margin-left: -125rpx;
+
+		}
+
+		.title-box {
+			position: relative;
+			z-index: 999;
+			margin: -100rpx auto;
 			display: flex;
-			flex-direction: column;
+			justify-content: space-around;
 			align-items: center;
-			text:nth-child(2){
-				font-size: 26rpx;
-				font-family: PingFang SC;
-				font-weight: 500;
-				color: #666666;
-				
-			}
-		}
-	}
-	.title-box1{
-		margin: 120rpx auto;
-		display: flex;
-		justify-content: space-around;
-		align-items: center;
-		width: 702rpx;
-		height: 137rpx;
-		background: #FFFFFF;
-		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
-		border-radius: 10rpx;
-		.title-bg{
-			width: 123rpx;
-			height: 123rpx;
-			image{
-				width: 100%;
-				height: 100%;
+			width: 702rpx;
+			height: 137rpx;
+			background: #FFFFFF;
+			box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
+			border-radius: 10rpx;
+
+			.title-one {
+				display: flex;
+				flex-direction: column;
+				align-items: center;
+
+				text:nth-child(2) {
+					font-size: 26rpx;
+					font-family: PingFang SC;
+					font-weight: 500;
+					color: #666666;
+
+				}
 			}
 		}
-		.title-between{
+
+		.title-box1 {
+			margin: 120rpx auto 0;
 			display: flex;
-			
-			flex-direction: column;
-			text:nth-child(1){
-				width: 131rpx;
-				font-size: 33rpx;
-				font-family: PingFang SC;
-				font-weight: bold;
-				color: #333333;
-				line-height: 34rpx;
-			
+			justify-content: space-around;
+			align-items: center;
+			width: 702rpx;
+			height: 137rpx;
+			background: #FFFFFF;
+			box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
+			border-radius: 10rpx;
+
+			.title-bg {
+				width: 123rpx;
+				height: 123rpx;
+
+				image {
+					width: 100%;
+					height: 100%;
+				}
 			}
-			text:nth-child(2){
-				width: 350rpx;
-				font-size: 24rpx;
-				font-family: PingFang SC;
-				font-weight: 500;
-				color: #999999;
-				line-height: 44rpx;
+
+			.title-between {
+				display: flex;
+
+				flex-direction: column;
+
+				text:nth-child(1) {
+					width: 131rpx;
+					font-size: 33rpx;
+					font-family: PingFang SC;
+					font-weight: bold;
+					color: #333333;
+					line-height: 34rpx;
+
+				}
+
+				text:nth-child(2) {
+					width: 350rpx;
+					font-size: 24rpx;
+					font-family: PingFang SC;
+					font-weight: 500;
+					color: #999999;
+					line-height: 44rpx;
+				}
+			}
+
+			.title-right {
+				width: 16rpx;
+				height: 30rpx;
+
+				image {
+					width: 100%;
+					height: 100%;
+				}
 			}
+
 		}
-		.title-right{
-			width: 16rpx;
-			height: 30rpx;
-			image{
+	}
+
+	.carousel-section {
+		padding: 0;
+
+		.titleNview-placing {
+			padding-top: 0;
+			height: 0;
+		}
+
+		.swiper-dots {
+			left: 45rpx;
+			bottom: 40rpx;
+		}
+
+		.carousel {
+			width: 100%;
+			height: 360rpx;
+
+			.carousel-item {
+				width: 100%;
+				height: 100%;
+				overflow: hidden;
+			}
+
+			image {
 				width: 100%;
 				height: 100%;
 			}
 		}
-		
 	}
-}
-.carousel-section {
-	padding: 0;
-	.titleNview-placing {
-		padding-top: 0;
-		height: 0;
-	}
-	.swiper-dots {
-		left: 45rpx;
-		bottom: 40rpx;
-	}
-	.carousel {
-		width: 100%;
-		height: 360rpx;
-		.carousel-item {
-			width: 100%;
+
+	// 中间标题样式
+	.type-title-box {
+		padding: 40rpx;
+
+		.title-content {
 			height: 100%;
-			overflow: hidden;
+			width: 200rpx;
+			text-align: center;
+			font-size: $font-lg;
+			font-weight: 500;
+			color: $font-color-dark;
 		}
-		image {
-			width: 100%;
-			height: 100%;
+
+		.title-border {
+			width: 250rpx;
+			height: 2rpx;
+			background-color: #e9e9e9;
 		}
 	}
-}
-// 中间标题样式
-.type-title-box {
-	padding: 40rpx;
-	.title-content {
-		height: 100%;
-		width: 200rpx;
-		text-align: center;
-		font-size: $font-lg;
-		font-weight: 500;
-		color: $font-color-dark;
-	}
-	.title-border {
-		width: 250rpx;
-		height: 2rpx;
-		background-color: #e9e9e9;
-	}
-}
-// 商品列表
-.goodsList-box {
-	padding: 30rpx;
-	.goodsList-item {
-		box-shadow:0 0 20rpx 6rpx #f1f1f1;
-		border-radius: 10rpx;
-		margin-bottom: 30rpx;
-		background-color: #ffffff;
+
+	// 商品列表
+	.goodsList-box {
 		padding: 30rpx;
-		image {
-			flex-shrink: 0;
-			border-radius: $border-radius-sm;
-			height: 180rpx;
-			width: 180rpx;
-		}
-		.goodsList-content {
-			margin-left: 20rpx;
-			flex-grow: 1;
-			height: 180rpx;
-			position: relative;
-			.title {
-				font-size: $font-base;
-				color: $font-color-dark;
-				font-weight: bold;
+
+		.goodsList-item {
+			box-shadow: 0 0 20rpx 6rpx #f1f1f1;
+			border-radius: 10rpx;
+			margin-bottom: 30rpx;
+			background-color: #ffffff;
+			padding: 30rpx;
+
+			image {
+				flex-shrink: 0;
+				border-radius: $border-radius-sm;
+				height: 180rpx;
+				width: 180rpx;
 			}
-			.goods-money {
-				position: absolute;
-				left: 0;
-				bottom: 0;
-				width:100%;
-				.money-box {
-					.otMoney {
-						color: #999999;
-						text-decoration: line-through;
-						margin-right: 15rpx;
-						font-size: 20rpx;
-					}
-					.money {
-						color: #FF6F0F;
-						font-weight: bold;
-						font-size: 35rpx;
-					}
-					image {
-						width: 20rpx;
-						height: 20rpx;
-						margin-right: 5rpx;
+
+			.goodsList-content {
+				margin-left: 20rpx;
+				flex-grow: 1;
+				height: 180rpx;
+				position: relative;
+
+				.title {
+					font-size: $font-base;
+					color: $font-color-dark;
+					font-weight: bold;
+				}
+
+				.goods-money {
+					position: absolute;
+					left: 0;
+					bottom: 0;
+					width: 100%;
+
+					.money-box {
+						.otMoney {
+							color: #999999;
+							// text-decoration: line-through;
+							margin-right: 15rpx;
+							font-size: 20rpx;
+						}
+
+						.money {
+							color: #FF6F0F;
+							font-weight: bold;
+							font-size: 30rpx;
+						}
+
+						image {
+							width: 20rpx;
+							height: 20rpx;
+							margin-right: 5rpx;
+						}
+
+						.decline {
+							color: #B59467;
+							font-size: 20rpx;
+						}
+
+						.sales {
+							color: $font-color-light;
+						}
 					}
-					.decline {
-						color: #B59467;
-						font-size: 20rpx;
+
+					.button {
+						background: #52C696;
+						height: 50rpx;
+						border-radius: 20rpx;
+						padding: 10rpx 15rpx;
+						color: #fff;
+						font-size: 25rpx;
 					}
-					.sales {
-						color: $font-color-light;
+
+					.cart {
+						border: 1px solid $color-red;
+						color: $color-red;
+						font-size: $font-base;
+						font-weight: bold;
+						border-radius: 99px;
+						width: 55rpx;
+						height: 55rpx;
+						display: flex;
+						justify-content: center;
+						align-items: center;
 					}
 				}
-				.button {
-					background: #52C696;
-					height: 50rpx;
-					border-radius: 20rpx;
-					padding: 10rpx 15rpx;
-					color: #fff;
-					font-size: 25rpx;
-					position: relative;
-					top: 20rpx;
-				}
-				.cart {
-					border: 1px solid $color-red;
-					color: $color-red;
-					font-size: $font-base;
-					font-weight: bold;
-					border-radius: 99px;
-					width: 55rpx;
-					height: 55rpx;
-					display: flex;
-					justify-content: center;
-					align-items: center;
-				}
 			}
 		}
 	}
-}
 </style>

+ 7 - 6
pages/product/product.vue

@@ -121,7 +121,7 @@
 			</view>
 		</view>
 		<!-- 底部操作菜单 -->
-		<view class="page-bottom" v-if="goodsType == 0">
+		<view class="page-bottom" v-if="goodsType == 0&&goodsObjact.id">
 			<!-- <navigator url="/pages/index/index" open-type="switchTab" class="p-b-btn">
 				<text class="iconfont iconhome"></text>
 				<text>首页</text>
@@ -130,14 +130,14 @@
 				<text class="iconfont iconcart"></text>
 				<text>购物车</text>
 			</navigator> -->
-			<view class="p-b-btn" :class="{ active: goodsObjact.userCollect }" @click="toFavorite(goodsObjact)">
+			<view class="p-b-btn" :class="{ active: goodsObjact.userCollect }" v-if="goodsObjact.can_up_level!=1" @click="toFavorite(goodsObjact)">
 				<text class="iconfont "
 					:class="{ iconlike: !goodsObjact.userCollect, iconlikefill: goodsObjact.userCollect }"></text>
 				<text>收藏</text>
 			</view>
 
 			<view class="action-btn-group">
-				<button type="primary" class=" action-btn no-border buy-now-btn" @click="toggleSpec(2)">加入购物车</button>
+				<button type="primary" class=" action-btn no-border buy-now-btn"  v-if="goodsObjact.can_up_level!=1" @click="toggleSpec(2)">加入购物车</button>
 				<button type="primary" class=" action-btn no-border  add-cart-btn" @click="toggleSpec(1)">立即购买</button>
 			</view>
 		</view>
@@ -504,7 +504,8 @@
 					cartNum: obj.goodsNumber, //商品数量
 					uniqueId: obj.uniqueId, //商品标签
 					new: '1', //商品是否新增加到购物车1为不加入0为加入
-					mer_id: obj.shopId
+					mer_id: obj.shopId,
+					can_up_level:obj.goodsObjact.can_up_level,
 					// type: 0,//0为余额支付  1为消费券支付 2为积分支付
 				};
 				if (obj.type == 2) {
@@ -1252,6 +1253,7 @@
 			overflow: hidden;
 			// margin-left: 20rpx;
 			position: relative;
+			flex-grow: 1;
 
 			// &:after {
 			// 	content: '';
@@ -1267,7 +1269,7 @@
 				display: flex;
 				align-items: center;
 				justify-content: center;
-				width: 375rpx;
+				width: 100%;
 				height: 100%;
 				font-size: $font-base;
 				padding: 0;
@@ -1280,7 +1282,6 @@
 				}
 
 				&.add-cart-btn {
-
 					background: #52C696;
 				}
 			}