|
@@ -8,6 +8,7 @@ import {
|
|
|
postWorksScore
|
|
|
} from '~/api/works'
|
|
|
import {
|
|
|
+ buyVip,
|
|
|
getVipInfo
|
|
|
} from '~/api/user'
|
|
|
import {
|
|
@@ -666,6 +667,48 @@ Page({
|
|
|
url: `/pages/otherWork/index?exampleId=${this.data.videoInfo.userRead.exampleId}`
|
|
|
})
|
|
|
},
|
|
|
+ async toBuy({
|
|
|
+ currentTarget
|
|
|
+ }) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: '提交中',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ let res = await buyVip({
|
|
|
+ productId: currentTarget.dataset.id
|
|
|
+ }).finally(() => {
|
|
|
+ wx.hideLoading()
|
|
|
+ })
|
|
|
+ let {
|
|
|
+ timeStamp,
|
|
|
+ nonceStr,
|
|
|
+ signType,
|
|
|
+ paySign
|
|
|
+ } = res
|
|
|
+ // package保留字
|
|
|
+ wx.requestPayment({
|
|
|
+ timeStamp,
|
|
|
+ nonceStr,
|
|
|
+ package: res.package,
|
|
|
+ signType,
|
|
|
+ paySign,
|
|
|
+ success: (res) => {
|
|
|
+ this.selectComponent('#vipModal').open({
|
|
|
+ type: 'svip'
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ this.setUserInfo()
|
|
|
+ }, 1500)
|
|
|
+ },
|
|
|
+ fail(res) {
|
|
|
+ wx.showToast({
|
|
|
+ title: "支付失败",
|
|
|
+ icon: "none",
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
creatShare() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
let video = this.data.videoInfo
|