feat: init project with miniprogram, cloud functions and admin console
这个提交包含在:
@@ -0,0 +1,42 @@
|
||||
var http = require('../../utils/request')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
plans: [
|
||||
{ name: '月度套餐', plan: 'monthly', days: 30, price: '¥29.9', desc: '30天畅享' },
|
||||
{ name: '季度套餐', plan: 'quarterly', days: 90, price: '¥79.9', desc: '90天畅享' },
|
||||
{ name: '年度套餐', plan: 'yearly', days: 365, price: '¥269', desc: '365天畅享' }
|
||||
],
|
||||
selected: null,
|
||||
purchasing: false
|
||||
},
|
||||
|
||||
onSelect: function (e) {
|
||||
this.setData({ selected: e.currentTarget.dataset.plan })
|
||||
},
|
||||
|
||||
onPurchase: function () {
|
||||
var self = this
|
||||
if (!self.data.selected) {
|
||||
wx.showToast({ title: '请选择套餐', icon: 'none' })
|
||||
return
|
||||
}
|
||||
self.setData({ purchasing: true })
|
||||
|
||||
http.post('/api/v1/subscription/purchase', {
|
||||
plan: self.data.selected,
|
||||
payment_method: 'wechat'
|
||||
}).then(function (data) {
|
||||
return http.post('/api/v1/subscription/verify', {
|
||||
order_id: data.order_id,
|
||||
plan: self.data.selected
|
||||
})
|
||||
}).then(function () {
|
||||
self.setData({ purchasing: false })
|
||||
wx.redirectTo({ url: '/pages/subscribe-success/subscribe-success' })
|
||||
}).catch(function () {
|
||||
self.setData({ purchasing: false })
|
||||
wx.showToast({ title: '购买失败', icon: 'none' })
|
||||
})
|
||||
}
|
||||
})
|
||||
在新工单中引用
屏蔽一个用户