Files
JMApp/pages/refund/refund.js
XiaoMo d098203c87 refactor: 统一API路径前缀并更新静态资源域名
- 将所有API路径从'/v2/miniprogram'统一为'/miniprogram'
- 更新静态资源域名从'http://jm.v0750.com'到'https://jm-static.v0750.com'
- 在utils/login.js中设置统一的baseUrl为'https://t-jm.v0750.com/v3'
- 移除不再使用的initial_url和baseUrl配置项
2025-12-15 23:27:34 +08:00

149 lines
3.7 KiB
JavaScript

var t = require("../../utils/login.js");
Page({
data: {
userInfo: {
mobile: '',
uid: '',
givenamount: "0.00",
money: "0.00",
principal: "0.00",
}, // 用户查询结果
list: [], // 退款记录列表
showResult: false // 控制查询结果显示
},
onSubmitToGroup(e) {
const mobile = e.detail.value.code
if (!mobile) {
wx.showToast({
title: '请输入手机号码',
icon: 'none'
})
return
}
// 手机号格式验证
if (!/^1[3-9]\d{9}$/.test(mobile)) {
wx.showToast({
title: '请输入正确的手机号码',
icon: 'none'
})
return
}
wx.showLoading({
title: '查询中...'
})
t.request('/miniprogram/refund/query', { mobile }, !0).then((res) => {
wx.hideLoading()
if (res.code == 200) {
this.setData({
userInfo: res.data.user,
list: res.data.list,
showResult: true
})
} else {
wx.showToast({
title: res.message || '查询失败',
icon: 'none'
})
}
})
},
// 线上退款
onSubmitToGroup1() {
wx.showModal({
title: '确认退款',
content: '确定退款,将清零用户赠送金额,退还本金',
success: (res) => {
if (res.confirm) {
wx.showLoading({
title: '退款中...'
})
if (!this.data.userInfo.recharge || !this.data.userInfo.token) {
wx.showToast({
title: '退款信息不完整',
icon: 'none'
})
return
}
t.request('/miniprogram/pay/refund', {token: this.data.userInfo.token}, !0).then((res) => {
wx.hideLoading()
if (res.code == 200) {
wx.showToast({
title: '退款成功',
icon: 'success'
})
// 刷新页面数据
this.setData({
showResult: false,
userInfo: {
mobile: '',
uid: '',
givenamount: "0.00",
money: "0.00",
principal: "0.00"
}
})
} else {
wx.showToast({
title: res.message || '退款失败',
icon: 'none'
})
}
})
}
}
})
},
// 线下退款
onSubmitToGroup2() {
wx.showModal({
title: '确认退款',
content: `确定退款金额:${this.data.userInfo.money}`,
success: (res) => {
if (res.confirm) {
wx.showLoading({
title: '退款中...'
})
if (!this.data.userInfo.token) {
wx.showToast({
title: '退款信息不完整',
icon: 'none'
})
return
}
t.request('/miniprogram/pay/refundOffline', {token: this.data.userInfo.token}, !0).then((res) => {
wx.hideLoading()
if (res.code == 200) {
wx.showToast({
title: '退款成功',
icon: 'success'
})
// 刷新页面数据
this.setData({
showResult: false,
userInfo: {
mobile: '',
uid: '',
givenamount: "0.00",
money: "0.00",
principal: "0.00"
}
})
} else {
wx.showToast({
title: res.message || '退款失败',
icon: 'none'
})
}
})
}
}
})
}
})