feat: init project with miniprogram, cloud functions and admin console

这个提交包含在:
Guoguo
2026-04-22 21:24:20 +08:00
当前提交 a84e37a6e2
修改 106 个文件,包含 5902 行新增0 行删除
@@ -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' })
})
}
})
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "订阅套餐"
}
@@ -0,0 +1,15 @@
<view class="container">
<view wx:for="{{plans}}" wx:key="plan"
class="card plan-card {{selected === item.plan ? 'plan-active' : ''}}"
bindtap="onSelect" data-plan="{{item.plan}}">
<view class="plan-name">{{item.name}}</view>
<view class="plan-price">{{item.price}}</view>
<view class="plan-desc text-muted">{{item.desc}}</view>
</view>
<view class="btn-area-fixed">
<view class="btn-primary" bindtap="onPurchase" disabled="{{purchasing || !selected}}">
{{purchasing ? '处理中...' : '立即订阅'}}
</view>
</view>
</view>
@@ -0,0 +1,27 @@
.plan-card {
text-align: center;
border: 2rpx solid #eeeeee;
transition: border-color 0.2s;
}
.plan-active {
border-color: #333333;
background-color: #fafafa;
}
.plan-name {
font-size: 32rpx;
font-weight: 600;
margin-bottom: 12rpx;
}
.plan-price {
font-size: 48rpx;
font-weight: 700;
color: #333333;
margin-bottom: 8rpx;
}
.plan-desc {
font-size: 24rpx;
}