| <template> | |
| 	<view class="index"> | |
| 		<view class="top"> | |
| 			<view class="content"> | |
| 				<image class="content-img" :src="shopInfo.image" mode="aspectFill"/> | |
| 				<view class="content-left"> | |
| 					<u-row style="margin: 10rpx;"> | |
| 						<u-col><text style="font-size: 32rpx;">{{ shopInfo.title }}</text></u-col> | |
| 					</u-row> | |
| 					<u-row justify="space-between" style="margin: 20rpx; font-size: 24rpx;"> | |
| 						<u-col span="6"> | |
| 							<view style="width: 200rpx;"> | |
| 								{{ shopInfo.classValue }} | |
| 							</view> | |
| 						</u-col> | |
| 						<u-col span="6"> | |
| 							<view style="width: 200rpx;"> | |
| 								{{ shopInfo.num }}人购买 | |
| 							</view> | |
| 						</u-col> | |
| 					</u-row> | |
| 					<!-- <u-row justify="space-between" style="margin: 10rpx; font-size: 30rpx;"> | |
| 						<u-col span="4" style="text-decoration:line-through"> | |
| 							<view style="color: #ddd;font-size: 28rpx;text-decoration:line-through;"> | |
| 								¥{{ shopInfo.oldPrice }} | |
| 							</view> | |
| 						</u-col> | |
| 						<u-col span="4"> | |
| 							<view style="color: #ff7800;font-size: 45rpx;"> | |
| 								¥{{ shopInfo.price }} | |
| 							</view> | |
| 						</u-col> | |
| 					</u-row> --> | |
| 					<!-- <u-row justify="space-between" style="margin: 10rpx; font-size: 30rpx;"> | |
| 						<u-col span="4" style="margin-top: 30rpx;"> | |
| 							<view class="icon"> | |
| 								<u-number-box style="margin: 0 auto;"  | |
| 								inputWidth="60px" | |
| 								v-model="registerForm.num" :min="1"> | |
| 									<view slot="minus" class="minus"> | |
| 										<u-icon name="minus" size="12" color="#fff"></u-icon> | |
| 									</view> | |
| 									<template v-slot:input> | |
| 										<input type="text" | |
| 										v-model="registerForm.num" | |
| 										style="color: #fff; | |
| 										text-align: center; | |
| 										" | |
| 										/> | |
| 									</template> | |
| 									<view slot="plus" class="plus"> | |
| 										<u-icon name="plus" color="#FFFFFF" size="12"></u-icon> | |
| 									</view> | |
| 								</u-number-box> | |
| 							</view> | |
| 						</u-col> | |
| 					</u-row> --> | |
| 				</view> | |
| 			</view> | |
| 		</view> | |
| 		 | |
| 		<view class="cell"> | |
| 			<view class="cell-box"> | |
| 				<view> | |
| 					{{ shopInfo.titleText }} | |
| 				</view> | |
| 			</view> | |
| 			<view class="ceil-input"> | |
| 				<view class=""> | |
| 					数量: | |
| 				</view> | |
| 				 | |
| 				<view class=""> | |
| 					<u-number-box v-model="registerForm.num"></u-number-box> | |
| 				</view> | |
| 			</view> | |
| 			<view class="price"> | |
| 				<view class=""> | |
| 					价格:¥{{ shopInfo.price }} | |
| 				</view> | |
| 				<view class="oldPrice"> | |
| 					原价:¥{{ shopInfo.oldPrice }} | |
| 				</view> | |
| 			</view> | |
| 		</view> | |
|  | |
| 		<view class="book"> | |
| 			<view class="book-text"> | |
| 				<view style="padding-top: 20rpx;font-size: 30rpx;">资源介绍</view> | |
| 			</view> | |
| 			<uv-parse :content="shopInfo.content"></uv-parse> | |
| 		</view> | |
|  | |
|  | |
| 		<view class="bottom-flex"> | |
| 			 | |
| 			<button open-type="contact" | |
| 			class="contact"> | |
| 				<view class="icon"> | |
| 					<u-icon name="server-man" size="50rpx"></u-icon> | |
| 				</view> | |
| 			</button> | |
|  | |
| 			<view class="button"> | |
| 				<view class="button-right"> | |
| 					<view @click="createPayOrder"> | |
| 						立即购买 (<text>¥{{ shopInfo.price * registerForm.num }}</text>) | |
| 					</view> | |
| 				</view> | |
| 			</view> | |
| 		</view> | |
| 		 | |
| 		<PrivacyAgreementPoup/> | |
| 	</view> | |
| </template> | |
|  | |
| <script> | |
| 	import PrivacyAgreementPoup from '@/components/PrivacyAgreementPoup/PrivacyAgreementPoup' | |
| 	export default { | |
| 		components : { | |
| 			PrivacyAgreementPoup | |
| 		}, | |
| 		data() { | |
| 			return { | |
| 				registerForm: { | |
| 					num: 1 | |
| 				}, | |
| 				shopInfo: {}, //商品信息 | |
| 			} | |
| 		}, | |
| 		onLoad() { | |
| 			this.getShopInfo() | |
| 		}, | |
| 		methods: { | |
|  | |
| 			//获取商品信息 | |
| 			getShopInfo() { | |
| 				this.$api('getPayShopOne', res => { | |
| 					this.shopInfo = res.result | |
| 				}) | |
| 			}, | |
|  | |
| 			//创建订单、支付 | |
| 			createPayOrder() { | |
|  | |
| 				this.registerForm.shopId = this.shopInfo.id | |
| 				this.$api('createPayOrder', this.registerForm, res => { | |
| 					this.registerForm.num = 1 | |
| 					if(res.code == 200){ | |
| 						uni.requestPayment({ | |
| 							provider: 'wxpay', // 服务提提供商 | |
| 							timeStamp: res.result.timeStamp, // 时间戳 | |
| 							nonceStr: res.result.nonceStr, // 随机字符串 | |
| 							package: res.result.packageValue, | |
| 							signType: res.result.signType, // 签名算法 | |
| 							paySign: res.result.paySign, // 签名 | |
| 							success: function (res) { | |
| 								console.log('支付成功',res); | |
| 								uni.switchTab({ | |
| 									url: '/pages/center/center' | |
| 								}) | |
| 							}, | |
| 							fail: function (err) { | |
| 								console.log('支付失败',err); | |
| 								uni.showToast({ | |
| 									icon:'none', | |
| 									title:"支付失败" | |
| 								}) | |
| 							} | |
| 						}); | |
| 					} | |
| 				}) | |
| 			} | |
|  | |
| 		} | |
| 	} | |
| </script> | |
|  | |
| <style scoped lang="scss"> | |
| 	.index { | |
| 		background-color: #ccc; | |
| 
 | |
| 		.bottom-flex { | |
| 			position: fixed; | |
| 			left: 0; | |
| 			bottom: 0; | |
| 			width: 100%; | |
| 			display: flex; | |
| 			height: 120rpx; | |
| 			padding: 10rpx 0; | |
| 			background-color: #fff; | |
| 			justify-content: space-between; | |
| 			box-sizing: border-box; | |
| 			padding: 0rpx 20rpx; | |
| 
 | |
| 			.icon { | |
| 				font-size: 26rpx; | |
| 				display: flex; | |
| 				flex-direction: column; | |
| 				justify-content: center; | |
| 				align-items: center; | |
| 			} | |
| 			.contact{ | |
| 				background: transparent; | |
| 				margin: 0; | |
| 				padding: 0 20rpx; | |
| 				display: flex; | |
| 				justify-content: center; | |
| 				align-items: center; | |
| 				&::after{ | |
| 					border: none; | |
| 				} | |
| 			} | |
| 		} | |
| 		.cell { | |
| 			display: flex; | |
| 			justify-content: center; | |
| 			flex-direction: column; | |
| 			align-items: center; | |
| 			background-color: #fff; | |
| 			width: 710rpx; | |
| 			padding: 20rpx; | |
| 			.cell-box{ | |
| 				display: flex; | |
| 				width: 90%; | |
| 				// background-color: rgb(253, 194, 4); | |
| 				border-radius: 10rpx; | |
| 				// font-size: 24rpx; | |
| 				justify-content: center; | |
| 				align-items: center; | |
| 				flex-direction: column; | |
| 				padding: 20rpx 0; | |
| 			} | |
| 			.ceil-input{ | |
| 				display: flex; | |
| 				justify-content: space-between; | |
| 				align-items: center; | |
| 				width: 100%; | |
| 			} | |
| 			.price{ | |
| 				width: 100%; | |
| 				line-height: 50rpx; | |
| 				color: #ff7800; | |
| 				.oldPrice{ | |
| 					text-decoration:line-through; | |
| 					font-size: 28rpx; | |
| 					color: #777; | |
| 				} | |
| 			} | |
| 		} | |
| 	} | |
| 
 | |
| 	.top { | |
| 		padding-top: var(--status-bar-height); | |
| 		position: relative; | |
| 		height: 230rpx; | |
| 		background-color: #000; | |
| 	} | |
| 
 | |
| 	.content { | |
| 		position: absolute; | |
| 		top: 20rpx; | |
| 		width: 100%; | |
| 		height: 250rpx; | |
| 		display: flex; | |
| 	} | |
| 
 | |
| 	.content-img { | |
| 		width: 270rpx; | |
| 		height: 180rpx; | |
| 		border-radius: 10rpx; | |
| 		margin-right: 20rpx; | |
| 		margin-left: 20rpx; | |
| 	} | |
| 
 | |
| 	.content-left { | |
| 		color: #fff; | |
| 		font-size: 28rpx; | |
| 		line-height: 50rpx; | |
| 	} | |
| 
 | |
| 	 | |
| 	/deep/ .book { | |
| 		margin-top: 20rpx; | |
| 		background-color: #fff; | |
| 		padding: 0 20rpx; | |
| 		padding-bottom: 150rpx; | |
| 		line-height: 50rpx; | |
| 		font-size: 30rpx; | |
| 		img { | |
| 			width: 100% !important; | |
| 			border-radius: 10rpx; | |
| 		} | |
| 	} | |
| 
 | |
| 	/deep/ .book-text { | |
| 		padding-bottom: 20rpx; | |
| 	} | |
| 
 | |
| 	.book-img { | |
| 		padding-top: 20rpx; | |
| 		width: 100%; | |
| 		height: 300rpx; | |
| 	} | |
| 
 | |
| 	.button { | |
| 		position: relative; | |
| 		display: flex; | |
| 		top: 10rpx; | |
| 		width: 350rpx; | |
| 		height: 80%; | |
| 		font-size: 12px; | |
| 	} | |
| 
 | |
| 	.button-left { | |
| 		display: flex; | |
| 		justify-content: center; | |
| 		align-items: center; | |
| 		flex: 1; | |
| 		height: 100%; | |
| 		background-color: rgb(253, 194, 5); | |
| 		// border-top-left-radius: 50rpx; | |
| 		// border-bottom-left-radius: 50rpx; | |
| 	} | |
| 
 | |
| 	.button-right { | |
| 		display: flex; | |
| 		justify-content: center; | |
| 		align-items: center; | |
| 		flex: 1; | |
| 		height: 100%; | |
| 		// background-color: rgb(253, 194, 5); | |
| 		background-color: rgb(51, 51, 51); | |
| 		// border-top-right-radius: 50rpx; | |
| 		// border-bottom-right-radius: 50rpx; | |
| 		border-radius: 50rpx; | |
| 		color: #fff; | |
| 		text{ | |
| 			font-size: 32rpx; | |
| 		} | |
| 	} | |
| 
 | |
| 
 | |
| 
 | |
| 	// 步进器 | |
| 
 | |
| 	.minus { | |
| 		width: 22px; | |
| 		height: 22px; | |
| 		border-width: 1px; | |
| 		border-color: white; | |
| 		border-style: solid; | |
| 		border-top-left-radius: 100px; | |
| 		border-top-right-radius: 100px; | |
| 		border-bottom-left-radius: 100px; | |
| 		border-bottom-right-radius: 100px; | |
| 		@include flex; | |
| 		justify-content: center; | |
| 		align-items: center; | |
| 	} | |
| 
 | |
| 	.input { | |
| 		padding: 0 10px; | |
| 		margin: 0 10rpx; | |
| 	} | |
| 
 | |
| 	.plus { | |
| 		width: 22px; | |
| 		height: 22px; | |
| 		background-color: rgb(253, 194, 5); | |
| 		border-radius: 50%; | |
| 		/* #ifndef APP-NVUE */ | |
| 		display: flex; | |
| 		/* #endif */ | |
| 		justify-content: center; | |
| 		align-items: center; | |
| 	} | |
| </style> |