统一排行榜对齐星雀UI,页面资源后台配置实时刷新

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-06-27 01:26:11 +08:00
parent 1ab2e2080a
commit 21112173f2
292 changed files with 64010 additions and 81 deletions

View File

@@ -0,0 +1,313 @@
// pages/tijiao/tijiao.js
const app = getApp()
import request from '../../utils/request.js'
import PopupService from '../../services/popupService.js'
Page({
data: {
ossImageUrl: '',
apiBaseUrl: '',
shangpinData: null,
shangpinId: '',
nicheng: '',
beizhu: '',
zhiding: '',
jine: 0,
isSubmitting: false,
canSubmit: false,
isPaying: false,
orderId: '',
payParams: null,
checkCount: 0,
maxCheckCount: 3
},
onLoad(options) {
this.setData({
ossImageUrl: app.globalData.ossImageUrl || '',
apiBaseUrl: app.globalData.apiBaseUrl || ''
})
wx.setNavigationBarTitle({ title: '提交订单' })
try {
if (options.data) {
const shangpinData = JSON.parse(decodeURIComponent(options.data))
if (shangpinData.image && !shangpinData.image.startsWith('http')) {
shangpinData.image = this.data.ossImageUrl + shangpinData.image
}
if (shangpinData.price) {
const price = parseFloat(shangpinData.price) || 0
const priceInteger = Math.floor(price)
let priceDecimal = '00'
const decimalPart = (price - priceInteger).toFixed(2)
if (decimalPart > 0) {
priceDecimal = decimalPart.toString().split('.')[1]
}
shangpinData.priceInteger = priceInteger
shangpinData.priceDecimal = priceDecimal
}
this.setData({
shangpinData: shangpinData,
shangpinId: shangpinData.id || '',
jine: parseFloat(shangpinData.price) || 0,
})
} else {
this.handleDataError('商品数据不完整')
}
} catch (error) {
this.handleDataError('解析商品数据失败')
}
PopupService.checkAndShow(this, 'tijiao');
},
onHide() {
const popupComp = this.selectComponent('#popupNotice');
if (popupComp && popupComp.cleanup) {
popupComp.cleanup();
}
},
onShow() {
this.registerNotificationComponent();
},
registerNotificationComponent() {
const app = getApp();
const notificationComp = this.selectComponent('#global-notification');
if (notificationComp && notificationComp.showNotification) {
app.globalData.globalNotification = {
show: (data) => notificationComp.showNotification(data),
hide: () => notificationComp.hideNotification()
};
}
},
handleDataError(errorMsg) {
wx.showToast({ title: errorMsg || '数据错误', icon: 'none' })
setTimeout(() => { wx.navigateBack() }, 1500)
},
onNicknameInput(e) {
this.setData({ nicheng: e.detail.value.trim() }, () => { this.checkFormValid() })
},
onRemarkInput(e) {
this.setData({ beizhu: e.detail.value.trim() })
},
onZhidingInput(e) {
this.setData({ zhiding: e.detail.value.trim() })
},
checkFormValid() {
const { nicheng } = this.data
this.setData({ canSubmit: nicheng && nicheng.length > 0 && nicheng.length <= 15 })
},
// 提交订单(生产版:已去掉所有调试日志,保留关键错误日志)
onSubmitOrder() {
const { nicheng, beizhu, zhiding, jine, shangpinId, canSubmit, isSubmitting } = this.data
if (!canSubmit) {
wx.showToast({ title: '请填写游戏昵称', icon: 'none' })
return
}
// 防重复提交
if (isSubmitting) return
this.setData({ isSubmitting: true, isPaying: false })
wx.showLoading({ title: '创建订单中...', mask: true })
// 10秒超时
const timeoutTimer = setTimeout(() => {
wx.hideLoading()
wx.showToast({ title: '网络超时,请检查您是否已登录', icon: 'none' })
this.setData({ isSubmitting: false, isPaying: false })
}, 10000)
// 获取登录 code虚拟支付必须每单刷新 session_key
wx.login({
success: (loginRes) => {
const orderData = {
shangpin_id: shangpinId,
nicheng: nicheng,
beizhu: beizhu || '',
zhiding: zhiding || '',
jine: jine,
code: loginRes.code
}
request({
url: '/dingdan/virtual_xiadan',
method: 'POST',
data: orderData
})
.then(res => {
clearTimeout(timeoutTimer)
wx.hideLoading()
if (res.statusCode === 200 && res.data && res.data.code === 0 && res.data.data) {
const payParams = res.data.data.payParams || {}
this.setData({
orderId: res.data.data.dingdanid,
payParams: payParams,
isSubmitting: false,
isPaying: true,
checkCount: 0
})
// 调起虚拟支付
this.triggerVirtualPayment(payParams)
} else {
const msg = (res.data && res.data.msg) || '创建订单失败'
wx.showToast({ title: msg, icon: 'none' })
this.setData({ isSubmitting: false, isPaying: false })
}
})
.catch(error => {
clearTimeout(timeoutTimer)
wx.hideLoading()
console.error('下单请求异常', error)
wx.showToast({ title: '创建订单失败', icon: 'none' })
this.setData({ isSubmitting: false, isPaying: false })
})
},
fail: () => {
clearTimeout(timeoutTimer)
wx.hideLoading()
wx.showToast({ title: '获取登录状态失败', icon: 'none' })
this.setData({ isSubmitting: false, isPaying: false })
}
})
},
// 调起虚拟支付(防抖已通过 isPaying 状态控制)
triggerVirtualPayment(payParams) {
// 参数完整性检查
if (!payParams || !payParams.signData || !payParams.paySig || !payParams.signature) {
console.error('支付参数不完整', payParams)
wx.showToast({ title: '支付参数异常', icon: 'none' })
this.setData({ isSubmitting: false, isPaying: false })
return
}
wx.requestVirtualPayment({
signData: payParams.signData,
paySig: payParams.paySig,
signature: payParams.signature,
mode: payParams.mode || 'short_series_coin',
success: (res) => {
// 支付成功,进入复查流程
this.onPaymentSuccess()
},
fail: (err) => {
console.error('支付失败', err)
if (err.errCode === -2 || (err.errMsg && err.errMsg.indexOf('cancel') !== -1)) {
this.handleUserCancel()
} else {
this.handlePaymentFail(err)
}
}
})
},
// 用户取消支付
handleUserCancel() {
wx.showToast({ title: '已取消支付', icon: 'none', duration: 1500 })
if (this.data.orderId) {
request({
url: '/dingdan/shibai',
method: 'POST',
data: { dingdanid: this.data.orderId }
}).catch(() => {})
}
this.setData({ isSubmitting: false, isPaying: false })
},
// 其他支付失败
handlePaymentFail(err) {
wx.showToast({ title: '支付失败', icon: 'none', duration: 1500 })
if (this.data.orderId) {
request({
url: '/dingdan/shibai',
method: 'POST',
data: {
dingdanid: this.data.orderId,
yuanyin: 'payment_fail'
}
}).catch(() => {})
}
this.setData({ isSubmitting: false, isPaying: false })
},
// 支付成功,开始双重确认
onPaymentSuccess() {
if (!this.data.orderId) {
wx.showToast({ title: '订单ID丢失', icon: 'none' })
this.setData({ isSubmitting: false, isPaying: false })
return
}
wx.showToast({ title: '支付成功,确认中...', icon: 'none', duration: 1500 })
this.checkOrderStatus()
},
// 复查订单状态最多重试3次
checkOrderStatus() {
const { orderId, checkCount, maxCheckCount } = this.data
wx.showLoading({
title: `确认支付状态${checkCount > 0 ? `(${checkCount + 1})` : ''}`,
mask: true
})
const timeoutTimer = setTimeout(() => {
wx.hideLoading()
this.handleConfirmError('网络超时')
}, 5000)
request({
url: '/dingdan/virtual_fucha',
method: 'POST',
data: { dingdanid: orderId }
})
.then(res => {
clearTimeout(timeoutTimer)
wx.hideLoading()
if ( res.data && res.data.code === 0) {
this.handleConfirmSuccess()
} else {
const msg = (res.data && res.data.msg) || '订单状态异常'
this.handleConfirmError(msg)
}
})
.catch(error => {
clearTimeout(timeoutTimer)
wx.hideLoading()
this.handleConfirmError('检查失败')
})
},
handleConfirmSuccess() {
wx.showToast({ title: '购买成功!', icon: 'success', duration: 1500 })
setTimeout(() => {
wx.switchTab({ url: '/pages/index/index' })
}, 1500)
this.setData({ isSubmitting: false, isPaying: false })
},
handleConfirmError(errorMsg) {
const { checkCount, maxCheckCount } = this.data
const newCheckCount = checkCount + 1
if (newCheckCount < maxCheckCount) {
this.setData({ checkCount: newCheckCount })
setTimeout(() => { this.checkOrderStatus() }, 1000)
} else {
wx.showModal({
title: '支付确认中',
content: '支付已成功,但订单状态确认异常。请稍后在订单列表查看,如有问题请联系客服。',
showCancel: false,
confirmText: '我知道了',
success: (res) => {
if (res.confirm) wx.switchTab({ url: '/pages/index/index' })
}
})
this.setData({ isSubmitting: false, isPaying: false })
}
}
})

View File

@@ -0,0 +1,5 @@
{
"usingComponents": {
"global-notification": "/components/global-notification/global-notification"
}
}

View File

@@ -0,0 +1,124 @@
<!--pages/tijiao/tijiao.wxml-->
<view class="submit-page">
<!-- 商品信息区域 -->
<view class="product-section">
<view class="product-card">
<!-- 商品图片 -->
<view class="product-image-box">
<image
src="{{shangpinData && shangpinData.image ? shangpinData.image : ''}}"
mode="aspectFill"
class="product-image"
/>
</view>
<!-- 商品信息 -->
<view class="product-info">
<view class="product-title">
<text class="title-text">{{shangpinData && shangpinData.title ? shangpinData.title : '商品标题'}}</text>
</view>
<!-- 价格信息 -->
<view class="price-info">
<text class="price-label">价格:</text>
<view class="price-value">
<text class="price-icon">¥</text>
<text class="price-integer">{{shangpinData && shangpinData.priceInteger ? shangpinData.priceInteger : '0'}}</text>
<text class="price-decimal">.{{shangpinData && shangpinData.priceDecimal ? shangpinData.priceDecimal : '00'}}</text>
</view>
</view>
</view>
</view>
</view>
<!-- 表单区域(左右布局) -->
<view class="form-section">
<view class="form-card">
<!-- 游戏昵称 - 左右布局 -->
<view class="form-item-row">
<view class="item-label-row">
<text class="label-text-bold">昵称</text>
<text class="label-required">*</text>
</view>
<input
class="item-input-row"
type="text"
placeholder="请输入您的昵称"
placeholder-class="input-placeholder-gray"
maxlength="15"
value="{{nicheng}}"
bindinput="onNicknameInput"
/>
</view>
<!-- 备注信息 - 左右布局 -->
<view class="form-item-row">
<view class="item-label-row">
<text class="label-text-bold">备注</text>
</view>
<input
class="item-input-row"
type="text"
placeholder="请补充您要补充的其他联系信息"
placeholder-class="input-placeholder-gray"
maxlength="30"
value="{{beizhu}}"
bindinput="onRemarkInput"
/>
</view>
<!-- 指定打手ID - 左右布局 -->
<view class="form-item-row">
<view class="item-label-row">
<text class="label-text-bold">指定服务者ID(选填)</text>
</view>
<input
class="item-input-row"
type="text"
placeholder="填写您需要指定的服务者"
placeholder-class="input-placeholder-gray"
maxlength="20"
value="{{zhiding}}"
bindinput="onZhidingInput"
/>
</view>
<!-- 支付方式 -->
<view class="payment-item">
<view class="payment-method">
<image src="/images/weixinzhifu.png" class="payment-icon" />
<text class="payment-text">微信支付</text>
<view class="payment-checkbox">
<text class="checkbox-text">✓</text>
</view>
</view>
</view>
</view>
</view>
<!-- 底部操作栏 -->
<view class="footer-section">
<view class="total-price">
<text class="total-label">总价:</text>
<view class="total-value">
<text class="price-icon">¥</text>
<text class="price-integer">{{shangpinData && shangpinData.priceInteger ? shangpinData.priceInteger : '0'}}</text>
<text class="price-decimal">.{{shangpinData && shangpinData.priceDecimal ? shangpinData.priceDecimal : '00'}}</text>
</view>
</view>
<view
class="submit-btn {{canSubmit && !isSubmitting ? 'submit-btn-active' : 'submit-btn-disabled'}}"
bindtap="onSubmitOrder"
>
<text class="btn-text">{{isSubmitting ? '提交中...' : '提交订单'}}</text>
<view class="btn-glow"></view>
</view>
</view>
<!-- 全局通知组件 -->
<global-notification id="global-notification" />
<!-- 弹窗公告组件(供 PopupService 调用) -->
<popup-notice id="popupNotice" />
</view>

View File

@@ -0,0 +1,280 @@
/* pages/tijiao/tijiao.wxss */
.submit-page {
display: flex;
flex-direction: column;
min-height: 100vh;
background: linear-gradient(135deg, #f8f9ff 0%, #f0f3ff 100%);
box-sizing: border-box;
}
/* 商品信息区域 */
.product-section {
padding: 30rpx 30rpx 20rpx 30rpx;
flex-shrink: 0;
}
.product-card {
background: white;
border-radius: 20rpx;
padding: 30rpx;
display: flex;
align-items: center;
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.06);
}
.product-image-box {
width: 160rpx;
height: 160rpx;
border-radius: 16rpx;
overflow: hidden;
background: #f5f5f5;
flex-shrink: 0;
margin-right: 24rpx;
}
.product-image {
width: 100%;
height: 100%;
}
.product-info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 160rpx;
}
.product-title {
margin-bottom: 20rpx;
}
.title-text {
font-size: 30rpx;
font-weight: 600;
color: #222;
line-height: 1.4;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.price-info {
display: flex;
align-items: baseline;
}
.price-label {
font-size: 26rpx;
color: #666;
font-weight: 500;
}
.price-value {
display: flex;
align-items: baseline;
}
.price-icon {
font-size: 28rpx;
color: #ff4d4f;
font-weight: 600;
}
.price-integer {
font-size: 38rpx;
color: #ff4d4f;
font-weight: 700;
margin-left: 4rpx;
}
.price-decimal {
font-size: 28rpx;
color: #ff4d4f;
font-weight: 600;
}
/* 表单区域 */
.form-section {
padding: 0 30rpx 20rpx 30rpx;
flex-shrink: 0;
}
.form-card {
background: white;
border-radius: 20rpx;
padding: 30rpx;
box-shadow: 0 6rpx 24rpx rgba(0, 0, 0, 0.05);
}
.form-item-row {
display: flex;
align-items: center;
padding: 25rpx 0;
border-bottom: 1rpx solid #f5f5f5;
}
.form-item-row:last-child {
border-bottom: none;
}
.item-label-row {
width: 220rpx;
flex-shrink: 0;
display: flex;
align-items: center;
}
.label-text-bold {
font-size: 30rpx;
font-weight: 600;
color: #333;
}
.label-required {
font-size: 30rpx;
color: #ff4d4f;
margin-left: 8rpx;
}
.item-input-row {
flex: 1;
font-size: 28rpx;
color: #222;
height: 60rpx;
line-height: 60rpx;
padding: 0 20rpx;
text-align: right;
background: #fafafa;
border-radius: 10rpx;
}
.input-placeholder-gray {
color: #999;
font-size: 28rpx;
}
/* 支付方式 */
.payment-item {
margin-top: 30rpx;
padding-top: 30rpx;
border-top: 1rpx solid #f0f0f0;
}
.payment-method {
display: flex;
align-items: center;
padding: 20rpx 0;
}
.payment-icon {
width: 48rpx;
height: 48rpx;
margin-right: 20rpx;
}
.payment-text {
font-size: 28rpx;
color: #333;
font-weight: 500;
flex: 1;
}
.payment-checkbox {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
background: #52c41a;
display: flex;
align-items: center;
justify-content: center;
}
.checkbox-text {
color: white;
font-size: 28rpx;
font-weight: 600;
}
/* 底部操作栏 */
.footer-section {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 30rpx;
background: white;
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.08);
margin-top: auto;
flex-shrink: 0;
}
.total-price {
display: flex;
align-items: baseline;
flex: 1;
}
.total-label {
font-size: 30rpx;
color: #333;
font-weight: 600;
}
.total-value {
display: flex;
align-items: baseline;
}
.submit-btn {
width: 240rpx;
height: 88rpx;
border-radius: 44rpx;
display: flex;
align-items: center;
justify-content: center;
position: relative;
overflow: hidden;
transition: all 0.3s;
}
.submit-btn-active {
background: linear-gradient(135deg, #52c41a, #389e0d);
box-shadow: 0 8rpx 32rpx rgba(255, 77, 79, 0.4);
}
.submit-btn-disabled {
background: #ccc;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
}
.submit-btn-active:active {
transform: scale(0.98);
box-shadow: 0 4rpx 20rpx rgba(255, 77, 79, 0.5);
}
.btn-text {
font-size: 32rpx;
color: white;
font-weight: 600;
position: relative;
z-index: 2;
}
.btn-glow {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
transform: translateX(-100%);
animation: btnGlow 3s infinite;
}
@keyframes btnGlow {
0% { transform: translateX(-100%); }
50% { transform: translateX(100%); }
100% { transform: translateX(100%); }
}