3daf0a09 by lttnew

优化支付

1 parent 3c74f831
......@@ -17,8 +17,18 @@
let userName = uni.getStorageSync('userName')
if (userName) {
await getInfo(this)
this.globalData.isLogin = true
try {
await getInfo(this)
this.globalData.isLogin = true
} catch (e) {
this.globalData.isLogin = false
uni.removeStorageSync('token')
uni.removeStorageSync('userName')
uni.reLaunch({
url: '/login/login'
})
return
}
// 道馆用户跳转到道馆首页
const deptType = this.globalData.deptType
const userType = this.globalData.userType
......
......@@ -1684,12 +1684,14 @@ export function getMyStatus() {
// 个人会员缴费支付
export function goPay(params) {
let url = `/person/paymentRangeNew/pay/${params.id}/${params.payType}`
const type = params.type || params.payType
let url = `/person/paymentRangeNew/pay/${params.id}/${type}`
const queryParams = []
if (params.id) queryParams.push(`id=${params.id}`)
if (params.contactPerson) queryParams.push(`contactPerson=${params.contactPerson}`)
if (params.contactTel) queryParams.push(`contactTel=${params.contactTel}`)
if (params.payType) queryParams.push(`payType=${params.payType}`)
if (type) queryParams.push(`type=${type}`)
if (queryParams.length > 0) {
url += '?' + queryParams.join('&')
}
......@@ -1701,25 +1703,25 @@ export function goPay(params) {
}
// 再次支付
export function payForOrder(params) {
let url = `/common/order/payForOrder/${params.id}`
const queryParams = []
if (params.id) queryParams.push(`id=${encodeURIComponent(params.id)}`)
if (params.payType) queryParams.push(`payType=${encodeURIComponent(params.payType)}`)
if (params.type) queryParams.push(`type=${encodeURIComponent(params.type)}`)
if (params.addresId) queryParams.push(`addresId=${encodeURIComponent(params.addresId)}`)
if (params.contactPerson) queryParams.push(`contactPerson=${encodeURIComponent(params.contactPerson)}`)
if (params.contactTel) queryParams.push(`contactTel=${encodeURIComponent(params.contactTel)}`)
if (queryParams.length > 0) {
url += '?' + queryParams.join('&')
}
return request({
url,
method: 'post',
showLoading: false
})
}
// 再次支付
export function payForOrder(params) {
let url = `/common/order/payForOrder/${params.id}`
const queryParams = []
if (params.id) queryParams.push(`id=${encodeURIComponent(params.id)}`)
if (params.payType) queryParams.push(`payType=${encodeURIComponent(params.payType)}`)
if (params.type) queryParams.push(`type=${encodeURIComponent(params.type)}`)
if (params.addresId) queryParams.push(`addresId=${encodeURIComponent(params.addresId)}`)
if (params.contactPerson) queryParams.push(`contactPerson=${encodeURIComponent(params.contactPerson)}`)
if (params.contactTel) queryParams.push(`contactTel=${encodeURIComponent(params.contactTel)}`)
if (queryParams.length > 0) {
url += '?' + queryParams.join('&')
}
return request({
url,
method: 'post',
showLoading: false
})
}
/**
* 取消订单
......@@ -1962,20 +1964,20 @@ export function confirmExam(examId) {
})
}
// 提交级位考试订单
export function commitJiExam(params) {
const type = params.type || params.payType
const url = `/exam/info/commitJi/${params.id}/${params.addresId}/${type}`
return request({
url,
method: 'post',
params: {
...params,
type
},
showLoading: false
})
}
// 提交级位考试订单
export function commitJiExam(params) {
const type = params.type || params.payType
const url = `/exam/info/commitJi/${params.id}/${params.addresId}/${type}`
return request({
url,
method: 'post',
params: {
...params,
type
},
showLoading: false
})
}
// 级位考试支付
export function payJiExam(orderId) {
......@@ -2252,3 +2254,14 @@ export function inMyMember(params) {
params
})
}
/**
* 退款
* @param params
* @returns {id}
*/
export function refundOrder(id) {
return request({
url: `/common/order/refundOrder/${id}`,
method: 'post'
})
}
\ No newline at end of file
......
......@@ -138,10 +138,11 @@ function getInfo(appInstance) {
console.log('getInfo跳转判断 - deptType:', deptType, 'userType:', app.globalData.userType)
// 道馆用户跳转道馆首页
return res
}).catch(err => {
console.error('getInfo 失败:', err)
})
}
}).catch(err => {
console.error('getInfo 失败:', err)
throw err
})
}
function getWebInfo() {
return request({
......
import config from '@/config.js'
import _ from 'underscore'
const excludeUrls = ['getMemberCountInfo', 'getInfo']
const excludeUrls = ['getMemberCountInfo']
const SUCCESS_CODES = [0, 200]
const TOKEN_EXPIRE_CODES = [60001, 60002, 401]
......@@ -111,22 +111,22 @@ const request = function (req) {
throw new Error(`HTTP ${statusCode}`)
}
// 业务状态码处理
const isSuccess = SUCCESS_CODES.includes(data.code) ||
data.pageData?.code == 200 ||
excludeUrls.some(url => req.url.includes(url))
if (isSuccess) {
resolve(data)
return
}
// Token过期处理
if (TOKEN_EXPIRE_CODES.includes(data.code)) {
handleTokenExpire()
reject(new Error('登录已过期,请重新登录'))
return
}
// Token过期处理
if (TOKEN_EXPIRE_CODES.includes(data.code)) {
handleTokenExpire()
reject(new Error('登录已过期,请重新登录'))
return
}
// 业务状态码处理
const isSuccess = SUCCESS_CODES.includes(data.code) ||
data.pageData?.code == 200 ||
excludeUrls.some(url => req.url.includes(url))
if (isSuccess) {
resolve(data)
return
}
// 业务错误(code != 200 且非 Token 过期)- 统一显示错误提示
const errorMsg = data.msg || '操作失败'
......
......@@ -118,10 +118,62 @@ const preferentialPolicy = ref(false)
const preferentialData = ref({
name: '优惠'
})
const payType = ref('2')
const isPaying = ref(false)
const payName = ref('')
const assoName = ref('')
const payType = ref('2')
const isPaying = ref(false)
const payName = ref('')
const assoName = ref('')
const app = getApp()
const pickFirst = (...values) => {
const value = values.find(item => item !== undefined && item !== null && String(item).trim() !== '')
return value ? String(value) : ''
}
const getOrderContent = (content) => {
if (!content) return {}
if (typeof content === 'object') return content
try {
return JSON.parse(content)
} catch (e) {
return {}
}
}
const fillPayDisplayInfo = (data = {}, content = {}, option = {}) => {
const memberInfo = app.globalData?.memberInfo || {}
const deptInfo = app.globalData?.dept || app.globalData?.userInfo?.dept || {}
payName.value = pickFirst(
memberInfo.name,
content.memberName,
data.memberName,
data.payDeptName,
content.payDeptName,
data.payMemName,
content.payMemName,
option.payName ? decodeURIComponent(option.payName) : '',
data.orderName,
content.orderName,
deptInfo.deptName
)
assoName.value = pickFirst(
memberInfo.aname,
memberInfo.associateName,
memberInfo.assoName,
deptInfo.aname,
deptInfo.associateName,
data.assoName,
data.associateName,
data.associationName,
data.aname,
data.parentName,
content.assoName,
content.associateName,
content.associationName,
content.aname,
content.parentName,
option.assoName ? decodeURIComponent(option.assoName) : ''
)
}
const memberTotalFee = computed(() => {
const total = memberFee.value * form.value.renewYear
......@@ -272,32 +324,29 @@ const handelPay = async () => {
isPaying.value = false
}
onLoad((option) => {
console.log(66, option)
// 接收订单ID(再次支付时)
if (option.orderId) {
payForm.value.id = option.orderId
payForm.value.payStatus = '0'
// 获取订单详情
to(api.orderDetail(option.orderId)).then(([err, res]) => {
if (!err && res.data) {
const content = res.data.content ? JSON.parse(res.data.content) : {}
form.value.renewYear = content.yearCount || 1
payName.value = res.data.orderName || ''
}
})
}
onLoad((option) => {
console.log(66, option)
fillPayDisplayInfo({}, {}, option)
// 接收订单ID(再次支付时)
if (option.orderId) {
payForm.value.id = option.orderId
payForm.value.payStatus = '0'
// 获取订单详情
to(api.orderDetail(option.orderId)).then(([err, res]) => {
if (!err && res.data) {
const content = getOrderContent(res.data.content)
form.value.renewYear = content.yearCount || 1
fillPayDisplayInfo(res.data, content, option)
}
})
}
// 接收年限
if (option.renewYear) {
form.value.renewYear = Number(option.renewYear)
}
// 接收缴费单位和所属协会
payName.value = payName.value || decodeURIComponent(option.payName || '')
console.log(77, payName.value)
assoName.value = decodeURIComponent(option.assoName || '')
// 初始化获取费用和优惠
init()
})
// 初始化获取费用和优惠
init()
})
// 初始化接口
async function init() {
......
......@@ -358,11 +358,13 @@ function closePasswordTipDialog() {
passwordTipPopup.value?.close()
}
function goAuthPayV2() {
async function goAuthPayV2() {
if (!canAuthPayByAccountStatus()) {
showAuthPayDialog('当前账号状态暂无法办理缴费业务')
return
}
const canGoPay = await handelGetMyRecent()
if (!canGoPay) return
// if (authPayDisabled.value) {
// showAuthPayDialog('您有一笔缴费正在审核中,请勿重复缴费。您可前往【认证详情】查看审核进度。')
// return
......
......@@ -148,7 +148,7 @@ const retryLoad = () => {
const url = currentPage.$page.options.url;
if (url) {
let fullUrl = BASE_URL + decodeURIComponent(url);
let fullUrl = config.baseUrl_api + decodeURIComponent(url);
openPdfWithDocument(fullUrl);
}
};
......@@ -234,4 +234,4 @@ web-view {
width: 100%;
height: 100%;
}
</style>
\ No newline at end of file
</style>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!