知识付费微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

314 lines
6.0 KiB

<template>
<view class="index">
<view class="top">
<view class="content">
<image class="content-img" :src="shopInfo.image" />
<view class="content-left">
<u-row style="margin: 10rpx;">
<u-col>{{ shopInfo.title }}</u-col>
</u-row>
<u-row justify="space-between" style="margin: 20rpx; font-size: 12px;">
<u-col span="6">
级别:初级
</u-col>
<u-col span="6">
{{ shopInfo.num }}人学习
</u-col>
</u-row>
<u-row justify="space-between" style="margin: 10rpx; font-size: 16px;">
<u-col span="4">
<view style="color: #ff7800;font-size: 45rpx;">
{{ shopInfo.price }}
</view>
</u-col>
<u-col span="4" style="text-decoration:line-through">
<view class="icon">
<u-number-box style="margin: 0 auto;" 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>
<text style="width: 50px;text-align: center;" class="input">
{{ registerForm.num }}
</text>
</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>
无法查看资源内容请购买!
</view>
</view>
</view>
<view class="book">
<view class="book-text">
<view style="padding-top: 20rpx;font-size: 14px;">资源介绍</view>
<uv-parse :content="shopInfo.content"></uv-parse>
</view>
</view>
<view class="bottom-flex">
<view class="icon">
<u-icon name="server-man" size="40rpx"></u-icon>
客服
</view>
<view class="button">
<view class="button-right">
<view @click="createPayOrder">
立即购买 ({{ shopInfo.price * registerForm.num }})
</view>
</view>
</view>
</view>
</view>
</template>
<script>
// wxf173d7bec0f1bbe0
export default {
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 => {
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: 100rpx;
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;
}
}
}
.top {
padding-top: var(--status-bar-height);
position: relative;
height: 230rpx;
background-color: #000;
}
.content {
position: absolute;
top: 20rpx;
width: 100%;
height: 250rpx;
}
.content-img {
position: absolute;
top: 20rpx;
left: 20rpx;
width: 220rpx;
height: 160rpx;
border-radius: 10rpx;
}
.content-left {
position: absolute;
color: #fff;
font-size: 14px;
left: 35%;
top: 20rpx;
line-height: 50rpx;
}
.cell {
display: flex;
justify-content: center;
align-items: center;
height: 140rpx;
background-color: #fff;
width: 100%;
}
.cell-box {
display: flex;
width: 90%;
background-color: rgb(253, 194, 4);
height: 70rpx;
border-radius: 10rpx;
font-size: 12px;
justify-content: center;
align-items: center;
}
/deep/ .book {
margin-top: 20rpx;
min-height: 600rpx;
background-color: #fff;
img {
width: 100% !important;
}
}
/deep/ .book-text {
width: 94%;
margin-left: 3%;
min-height: 700rpx;
font-size: 13px;
line-height: 40rpx;
padding-bottom: 100rpx;
img {
width: 100% !important;
}
}
.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(51, 51, 51);
// border-top-right-radius: 50rpx;
// border-bottom-right-radius: 50rpx;
border-radius: 50rpx;
color: #fff;
}
// 步进器
.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>