小程序提交
This commit is contained in:
83
miniprogram/pages/recharge/index.js
Normal file
83
miniprogram/pages/recharge/index.js
Normal file
@@ -0,0 +1,83 @@
|
||||
const app = getApp()
|
||||
const payment = require('../../utils/payment')
|
||||
const { request } = require('../../utils/request')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
enterpriseId: 0,
|
||||
enterpriseName: '',
|
||||
amountFen: 0,
|
||||
amountYuan: '0.00',
|
||||
paying: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
const rawScene = options && options.scene ? decodeURIComponent(options.scene) : ''
|
||||
const sceneParams = {}
|
||||
if (rawScene) {
|
||||
rawScene.split('&').forEach(pair => {
|
||||
const [k, v] = pair.split('=')
|
||||
if (k) sceneParams[k] = v || ''
|
||||
})
|
||||
}
|
||||
|
||||
const enterpriseId = parseInt(sceneParams.eid || options.eid || 0, 10) || 0
|
||||
const amountFen = parseInt(sceneParams.a || options.amountFen || 0, 10) || 0
|
||||
const amountYuan = (amountFen / 100).toFixed(2)
|
||||
|
||||
if (enterpriseId > 0) {
|
||||
app.globalData.enterpriseIdFromScene = enterpriseId
|
||||
}
|
||||
|
||||
this.setData({
|
||||
enterpriseId,
|
||||
enterpriseName: (app.globalData.userInfo && app.globalData.userInfo.enterpriseName) || '',
|
||||
amountFen,
|
||||
amountYuan
|
||||
})
|
||||
|
||||
app.ensureLogin()
|
||||
.then(() => {
|
||||
if (enterpriseId > 0) {
|
||||
request({
|
||||
url: '/api/enterprise/bind',
|
||||
method: 'POST',
|
||||
data: { enterpriseId },
|
||||
success: (res) => {
|
||||
const payload = res && res.data && res.data.data ? res.data.data : {}
|
||||
const enterpriseName = payload.enterpriseName || this.data.enterpriseName || ''
|
||||
this.setData({ enterpriseName })
|
||||
},
|
||||
fail: () => {}
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
wx.showToast({ title: '请先登录', icon: 'none' })
|
||||
})
|
||||
},
|
||||
|
||||
submitRecharge() {
|
||||
if (this.data.paying) return
|
||||
if (!this.data.enterpriseId || !this.data.amountFen) {
|
||||
wx.showToast({ title: '充值参数无效', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
this.setData({ paying: true })
|
||||
payment.recharge({
|
||||
amountYuan: Number(this.data.amountYuan),
|
||||
enterpriseId: this.data.enterpriseId,
|
||||
success: () => {
|
||||
this.setData({ paying: false })
|
||||
wx.showToast({ title: '充值成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
wx.navigateTo({ url: `/pages/enterprise/index?eid=${this.data.enterpriseId}` })
|
||||
}, 1200)
|
||||
},
|
||||
fail: () => {
|
||||
this.setData({ paying: false })
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
3
miniprogram/pages/recharge/index.json
Normal file
3
miniprogram/pages/recharge/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "企业余额充值"
|
||||
}
|
||||
20
miniprogram/pages/recharge/index.wxml
Normal file
20
miniprogram/pages/recharge/index.wxml
Normal file
@@ -0,0 +1,20 @@
|
||||
<view class="recharge-page">
|
||||
<view class="card">
|
||||
<view class="title">企业余额充值</view>
|
||||
<view class="subtitle">扫码后在小程序内完成支付,支付成功后自动进入企业余额</view>
|
||||
|
||||
<view class="amount-box">
|
||||
<text class="amount-label">充值金额</text>
|
||||
<text class="amount-value">¥{{amountYuan}}</text>
|
||||
</view>
|
||||
|
||||
<view class="meta-row">
|
||||
<text class="meta-label">企业名称</text>
|
||||
<text class="meta-value">{{enterpriseName || ('企业 #' + enterpriseId)}}</text>
|
||||
</view>
|
||||
|
||||
<button class="pay-btn" loading="{{paying}}" disabled="{{paying}}" bindtap="submitRecharge">
|
||||
<text class="pay-btn-text">{{paying ? '支付中...' : '立即充值'}}</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
106
miniprogram/pages/recharge/index.wxss
Normal file
106
miniprogram/pages/recharge/index.wxss
Normal file
@@ -0,0 +1,106 @@
|
||||
.recharge-page {
|
||||
min-height: 100vh;
|
||||
padding: 40rpx 28rpx;
|
||||
background: linear-gradient(180deg, #f5f3ff 0%, #ffffff 100%);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: #ffffff;
|
||||
border-radius: 32rpx;
|
||||
padding: 40rpx 32rpx;
|
||||
box-shadow: 0 20rpx 60rpx rgba(124, 58, 237, 0.08);
|
||||
border: 2rpx solid rgba(124, 58, 237, 0.06);
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 40rpx;
|
||||
font-weight: 700;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
margin-top: 16rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.7;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.amount-box {
|
||||
margin-top: 36rpx;
|
||||
padding: 32rpx;
|
||||
background: #f8fafc;
|
||||
border-radius: 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.amount-label {
|
||||
display: block;
|
||||
font-size: 24rpx;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.amount-value {
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
font-size: 64rpx;
|
||||
font-weight: 700;
|
||||
color: #7c3aed;
|
||||
}
|
||||
|
||||
.meta-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 28rpx;
|
||||
padding: 24rpx 8rpx 0;
|
||||
font-size: 26rpx;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
.meta-label {
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.meta-value {
|
||||
color: #111827;
|
||||
font-weight: 600;
|
||||
max-width: 420rpx;
|
||||
text-align: right;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.pay-btn {
|
||||
margin-top: 44rpx;
|
||||
height: 96rpx;
|
||||
line-height: 96rpx;
|
||||
border-radius: 999rpx;
|
||||
background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 55%, #a855f7 100%);
|
||||
color: #ffffff;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
box-shadow: 0 18rpx 36rpx rgba(124, 58, 237, 0.28);
|
||||
border: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.pay-btn::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.pay-btn-text {
|
||||
position: relative;
|
||||
padding-right: 28rpx;
|
||||
}
|
||||
|
||||
.pay-btn-text::after {
|
||||
content: '>';
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
font-size: 24rpx;
|
||||
opacity: 0.9;
|
||||
}
|
||||
Reference in New Issue
Block a user