3daf0a09 by lttnew

优化支付

1 parent 3c74f831
...@@ -17,8 +17,18 @@ ...@@ -17,8 +17,18 @@
17 17
18 let userName = uni.getStorageSync('userName') 18 let userName = uni.getStorageSync('userName')
19 if (userName) { 19 if (userName) {
20 await getInfo(this) 20 try {
21 this.globalData.isLogin = true 21 await getInfo(this)
22 this.globalData.isLogin = true
23 } catch (e) {
24 this.globalData.isLogin = false
25 uni.removeStorageSync('token')
26 uni.removeStorageSync('userName')
27 uni.reLaunch({
28 url: '/login/login'
29 })
30 return
31 }
22 // 道馆用户跳转到道馆首页 32 // 道馆用户跳转到道馆首页
23 const deptType = this.globalData.deptType 33 const deptType = this.globalData.deptType
24 const userType = this.globalData.userType 34 const userType = this.globalData.userType
......
...@@ -1684,12 +1684,14 @@ export function getMyStatus() { ...@@ -1684,12 +1684,14 @@ export function getMyStatus() {
1684 1684
1685 // 个人会员缴费支付 1685 // 个人会员缴费支付
1686 export function goPay(params) { 1686 export function goPay(params) {
1687 let url = `/person/paymentRangeNew/pay/${params.id}/${params.payType}` 1687 const type = params.type || params.payType
1688 let url = `/person/paymentRangeNew/pay/${params.id}/${type}`
1688 const queryParams = [] 1689 const queryParams = []
1689 if (params.id) queryParams.push(`id=${params.id}`) 1690 if (params.id) queryParams.push(`id=${params.id}`)
1690 if (params.contactPerson) queryParams.push(`contactPerson=${params.contactPerson}`) 1691 if (params.contactPerson) queryParams.push(`contactPerson=${params.contactPerson}`)
1691 if (params.contactTel) queryParams.push(`contactTel=${params.contactTel}`) 1692 if (params.contactTel) queryParams.push(`contactTel=${params.contactTel}`)
1692 if (params.payType) queryParams.push(`payType=${params.payType}`) 1693 if (params.payType) queryParams.push(`payType=${params.payType}`)
1694 if (type) queryParams.push(`type=${type}`)
1693 if (queryParams.length > 0) { 1695 if (queryParams.length > 0) {
1694 url += '?' + queryParams.join('&') 1696 url += '?' + queryParams.join('&')
1695 } 1697 }
...@@ -1701,25 +1703,25 @@ export function goPay(params) { ...@@ -1701,25 +1703,25 @@ export function goPay(params) {
1701 } 1703 }
1702 1704
1703 1705
1704 // 再次支付 1706 // 再次支付
1705 export function payForOrder(params) { 1707 export function payForOrder(params) {
1706 let url = `/common/order/payForOrder/${params.id}` 1708 let url = `/common/order/payForOrder/${params.id}`
1707 const queryParams = [] 1709 const queryParams = []
1708 if (params.id) queryParams.push(`id=${encodeURIComponent(params.id)}`) 1710 if (params.id) queryParams.push(`id=${encodeURIComponent(params.id)}`)
1709 if (params.payType) queryParams.push(`payType=${encodeURIComponent(params.payType)}`) 1711 if (params.payType) queryParams.push(`payType=${encodeURIComponent(params.payType)}`)
1710 if (params.type) queryParams.push(`type=${encodeURIComponent(params.type)}`) 1712 if (params.type) queryParams.push(`type=${encodeURIComponent(params.type)}`)
1711 if (params.addresId) queryParams.push(`addresId=${encodeURIComponent(params.addresId)}`) 1713 if (params.addresId) queryParams.push(`addresId=${encodeURIComponent(params.addresId)}`)
1712 if (params.contactPerson) queryParams.push(`contactPerson=${encodeURIComponent(params.contactPerson)}`) 1714 if (params.contactPerson) queryParams.push(`contactPerson=${encodeURIComponent(params.contactPerson)}`)
1713 if (params.contactTel) queryParams.push(`contactTel=${encodeURIComponent(params.contactTel)}`) 1715 if (params.contactTel) queryParams.push(`contactTel=${encodeURIComponent(params.contactTel)}`)
1714 if (queryParams.length > 0) { 1716 if (queryParams.length > 0) {
1715 url += '?' + queryParams.join('&') 1717 url += '?' + queryParams.join('&')
1716 } 1718 }
1717 return request({ 1719 return request({
1718 url, 1720 url,
1719 method: 'post', 1721 method: 'post',
1720 showLoading: false 1722 showLoading: false
1721 }) 1723 })
1722 } 1724 }
1723 1725
1724 /** 1726 /**
1725 * 取消订单 1727 * 取消订单
...@@ -1962,20 +1964,20 @@ export function confirmExam(examId) { ...@@ -1962,20 +1964,20 @@ export function confirmExam(examId) {
1962 }) 1964 })
1963 } 1965 }
1964 1966
1965 // 提交级位考试订单 1967 // 提交级位考试订单
1966 export function commitJiExam(params) { 1968 export function commitJiExam(params) {
1967 const type = params.type || params.payType 1969 const type = params.type || params.payType
1968 const url = `/exam/info/commitJi/${params.id}/${params.addresId}/${type}` 1970 const url = `/exam/info/commitJi/${params.id}/${params.addresId}/${type}`
1969 return request({ 1971 return request({
1970 url, 1972 url,
1971 method: 'post', 1973 method: 'post',
1972 params: { 1974 params: {
1973 ...params, 1975 ...params,
1974 type 1976 type
1975 }, 1977 },
1976 showLoading: false 1978 showLoading: false
1977 }) 1979 })
1978 } 1980 }
1979 1981
1980 // 级位考试支付 1982 // 级位考试支付
1981 export function payJiExam(orderId) { 1983 export function payJiExam(orderId) {
...@@ -2252,3 +2254,14 @@ export function inMyMember(params) { ...@@ -2252,3 +2254,14 @@ export function inMyMember(params) {
2252 params 2254 params
2253 }) 2255 })
2254 } 2256 }
2257 /**
2258 * 退款
2259 * @param params
2260 * @returns {id}
2261 */
2262 export function refundOrder(id) {
2263 return request({
2264 url: `/common/order/refundOrder/${id}`,
2265 method: 'post'
2266 })
2267 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -138,10 +138,11 @@ function getInfo(appInstance) { ...@@ -138,10 +138,11 @@ function getInfo(appInstance) {
138 console.log('getInfo跳转判断 - deptType:', deptType, 'userType:', app.globalData.userType) 138 console.log('getInfo跳转判断 - deptType:', deptType, 'userType:', app.globalData.userType)
139 // 道馆用户跳转道馆首页 139 // 道馆用户跳转道馆首页
140 return res 140 return res
141 }).catch(err => { 141 }).catch(err => {
142 console.error('getInfo 失败:', err) 142 console.error('getInfo 失败:', err)
143 }) 143 throw err
144 } 144 })
145 }
145 146
146 function getWebInfo() { 147 function getWebInfo() {
147 return request({ 148 return request({
......
1 import config from '@/config.js' 1 import config from '@/config.js'
2 import _ from 'underscore' 2 import _ from 'underscore'
3 3
4 const excludeUrls = ['getMemberCountInfo', 'getInfo'] 4 const excludeUrls = ['getMemberCountInfo']
5 const SUCCESS_CODES = [0, 200] 5 const SUCCESS_CODES = [0, 200]
6 const TOKEN_EXPIRE_CODES = [60001, 60002, 401] 6 const TOKEN_EXPIRE_CODES = [60001, 60002, 401]
7 7
...@@ -111,22 +111,22 @@ const request = function (req) { ...@@ -111,22 +111,22 @@ const request = function (req) {
111 throw new Error(`HTTP ${statusCode}`) 111 throw new Error(`HTTP ${statusCode}`)
112 } 112 }
113 113
114 // 业务状态码处理 114 // Token过期处理
115 const isSuccess = SUCCESS_CODES.includes(data.code) || 115 if (TOKEN_EXPIRE_CODES.includes(data.code)) {
116 data.pageData?.code == 200 || 116 handleTokenExpire()
117 excludeUrls.some(url => req.url.includes(url)) 117 reject(new Error('登录已过期,请重新登录'))
118 118 return
119 if (isSuccess) { 119 }
120 resolve(data) 120
121 return 121 // 业务状态码处理
122 } 122 const isSuccess = SUCCESS_CODES.includes(data.code) ||
123 123 data.pageData?.code == 200 ||
124 // Token过期处理 124 excludeUrls.some(url => req.url.includes(url))
125 if (TOKEN_EXPIRE_CODES.includes(data.code)) { 125
126 handleTokenExpire() 126 if (isSuccess) {
127 reject(new Error('登录已过期,请重新登录')) 127 resolve(data)
128 return 128 return
129 } 129 }
130 130
131 // 业务错误(code != 200 且非 Token 过期)- 统一显示错误提示 131 // 业务错误(code != 200 且非 Token 过期)- 统一显示错误提示
132 const errorMsg = data.msg || '操作失败' 132 const errorMsg = data.msg || '操作失败'
......
...@@ -118,10 +118,62 @@ const preferentialPolicy = ref(false) ...@@ -118,10 +118,62 @@ const preferentialPolicy = ref(false)
118 const preferentialData = ref({ 118 const preferentialData = ref({
119 name: '优惠' 119 name: '优惠'
120 }) 120 })
121 const payType = ref('2') 121 const payType = ref('2')
122 const isPaying = ref(false) 122 const isPaying = ref(false)
123 const payName = ref('') 123 const payName = ref('')
124 const assoName = ref('') 124 const assoName = ref('')
125 const app = getApp()
126
127 const pickFirst = (...values) => {
128 const value = values.find(item => item !== undefined && item !== null && String(item).trim() !== '')
129 return value ? String(value) : ''
130 }
131
132 const getOrderContent = (content) => {
133 if (!content) return {}
134 if (typeof content === 'object') return content
135 try {
136 return JSON.parse(content)
137 } catch (e) {
138 return {}
139 }
140 }
141
142 const fillPayDisplayInfo = (data = {}, content = {}, option = {}) => {
143 const memberInfo = app.globalData?.memberInfo || {}
144 const deptInfo = app.globalData?.dept || app.globalData?.userInfo?.dept || {}
145 payName.value = pickFirst(
146 memberInfo.name,
147 content.memberName,
148 data.memberName,
149 data.payDeptName,
150 content.payDeptName,
151 data.payMemName,
152 content.payMemName,
153 option.payName ? decodeURIComponent(option.payName) : '',
154 data.orderName,
155 content.orderName,
156 deptInfo.deptName
157 )
158 assoName.value = pickFirst(
159 memberInfo.aname,
160 memberInfo.associateName,
161 memberInfo.assoName,
162 deptInfo.aname,
163 deptInfo.associateName,
164 data.assoName,
165 data.associateName,
166 data.associationName,
167 data.aname,
168 data.parentName,
169 content.assoName,
170 content.associateName,
171 content.associationName,
172 content.aname,
173 content.parentName,
174 option.assoName ? decodeURIComponent(option.assoName) : ''
175 )
176 }
125 177
126 const memberTotalFee = computed(() => { 178 const memberTotalFee = computed(() => {
127 const total = memberFee.value * form.value.renewYear 179 const total = memberFee.value * form.value.renewYear
...@@ -272,32 +324,29 @@ const handelPay = async () => { ...@@ -272,32 +324,29 @@ const handelPay = async () => {
272 isPaying.value = false 324 isPaying.value = false
273 } 325 }
274 326
275 onLoad((option) => { 327 onLoad((option) => {
276 console.log(66, option) 328 console.log(66, option)
277 // 接收订单ID(再次支付时) 329 fillPayDisplayInfo({}, {}, option)
278 if (option.orderId) { 330 // 接收订单ID(再次支付时)
279 payForm.value.id = option.orderId 331 if (option.orderId) {
280 payForm.value.payStatus = '0' 332 payForm.value.id = option.orderId
281 // 获取订单详情 333 payForm.value.payStatus = '0'
282 to(api.orderDetail(option.orderId)).then(([err, res]) => { 334 // 获取订单详情
283 if (!err && res.data) { 335 to(api.orderDetail(option.orderId)).then(([err, res]) => {
284 const content = res.data.content ? JSON.parse(res.data.content) : {} 336 if (!err && res.data) {
285 form.value.renewYear = content.yearCount || 1 337 const content = getOrderContent(res.data.content)
286 payName.value = res.data.orderName || '' 338 form.value.renewYear = content.yearCount || 1
287 } 339 fillPayDisplayInfo(res.data, content, option)
288 }) 340 }
289 } 341 })
342 }
290 // 接收年限 343 // 接收年限
291 if (option.renewYear) { 344 if (option.renewYear) {
292 form.value.renewYear = Number(option.renewYear) 345 form.value.renewYear = Number(option.renewYear)
293 } 346 }
294 // 接收缴费单位和所属协会 347 // 初始化获取费用和优惠
295 payName.value = payName.value || decodeURIComponent(option.payName || '') 348 init()
296 console.log(77, payName.value) 349 })
297 assoName.value = decodeURIComponent(option.assoName || '')
298 // 初始化获取费用和优惠
299 init()
300 })
301 350
302 // 初始化接口 351 // 初始化接口
303 async function init() { 352 async function init() {
......
...@@ -358,11 +358,13 @@ function closePasswordTipDialog() { ...@@ -358,11 +358,13 @@ function closePasswordTipDialog() {
358 passwordTipPopup.value?.close() 358 passwordTipPopup.value?.close()
359 } 359 }
360 360
361 function goAuthPayV2() { 361 async function goAuthPayV2() {
362 if (!canAuthPayByAccountStatus()) { 362 if (!canAuthPayByAccountStatus()) {
363 showAuthPayDialog('当前账号状态暂无法办理缴费业务') 363 showAuthPayDialog('当前账号状态暂无法办理缴费业务')
364 return 364 return
365 } 365 }
366 const canGoPay = await handelGetMyRecent()
367 if (!canGoPay) return
366 // if (authPayDisabled.value) { 368 // if (authPayDisabled.value) {
367 // showAuthPayDialog('您有一笔缴费正在审核中,请勿重复缴费。您可前往【认证详情】查看审核进度。') 369 // showAuthPayDialog('您有一笔缴费正在审核中,请勿重复缴费。您可前往【认证详情】查看审核进度。')
368 // return 370 // return
......
...@@ -148,7 +148,7 @@ const retryLoad = () => { ...@@ -148,7 +148,7 @@ const retryLoad = () => {
148 const url = currentPage.$page.options.url; 148 const url = currentPage.$page.options.url;
149 149
150 if (url) { 150 if (url) {
151 let fullUrl = BASE_URL + decodeURIComponent(url); 151 let fullUrl = config.baseUrl_api + decodeURIComponent(url);
152 openPdfWithDocument(fullUrl); 152 openPdfWithDocument(fullUrl);
153 } 153 }
154 }; 154 };
...@@ -234,4 +234,4 @@ web-view { ...@@ -234,4 +234,4 @@ web-view {
234 width: 100%; 234 width: 100%;
235 height: 100%; 235 height: 100%;
236 } 236 }
237 </style>
...\ No newline at end of file ...\ No newline at end of file
237 </style>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!