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 try {
20 await getInfo(this) 21 await getInfo(this)
21 this.globalData.isLogin = true 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 }
...@@ -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
......
...@@ -140,6 +140,7 @@ function getInfo(appInstance) { ...@@ -140,6 +140,7 @@ function getInfo(appInstance) {
140 return res 140 return res
141 }).catch(err => { 141 }).catch(err => {
142 console.error('getInfo 失败:', err) 142 console.error('getInfo 失败:', err)
143 throw err
143 }) 144 })
144 } 145 }
145 146
......
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,6 +111,13 @@ const request = function (req) { ...@@ -111,6 +111,13 @@ const request = function (req) {
111 throw new Error(`HTTP ${statusCode}`) 111 throw new Error(`HTTP ${statusCode}`)
112 } 112 }
113 113
114 // Token过期处理
115 if (TOKEN_EXPIRE_CODES.includes(data.code)) {
116 handleTokenExpire()
117 reject(new Error('登录已过期,请重新登录'))
118 return
119 }
120
114 // 业务状态码处理 121 // 业务状态码处理
115 const isSuccess = SUCCESS_CODES.includes(data.code) || 122 const isSuccess = SUCCESS_CODES.includes(data.code) ||
116 data.pageData?.code == 200 || 123 data.pageData?.code == 200 ||
...@@ -121,13 +128,6 @@ const request = function (req) { ...@@ -121,13 +128,6 @@ const request = function (req) {
121 return 128 return
122 } 129 }
123 130
124 // Token过期处理
125 if (TOKEN_EXPIRE_CODES.includes(data.code)) {
126 handleTokenExpire()
127 reject(new Error('登录已过期,请重新登录'))
128 return
129 }
130
131 // 业务错误(code != 200 且非 Token 过期)- 统一显示错误提示 131 // 业务错误(code != 200 且非 Token 过期)- 统一显示错误提示
132 const errorMsg = data.msg || '操作失败' 132 const errorMsg = data.msg || '操作失败'
133 showError(errorMsg) 133 showError(errorMsg)
......
...@@ -122,6 +122,58 @@ const payType = ref('2') ...@@ -122,6 +122,58 @@ 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
...@@ -274,6 +326,7 @@ const handelPay = async () => { ...@@ -274,6 +326,7 @@ const handelPay = async () => {
274 326
275 onLoad((option) => { 327 onLoad((option) => {
276 console.log(66, option) 328 console.log(66, option)
329 fillPayDisplayInfo({}, {}, option)
277 // 接收订单ID(再次支付时) 330 // 接收订单ID(再次支付时)
278 if (option.orderId) { 331 if (option.orderId) {
279 payForm.value.id = option.orderId 332 payForm.value.id = option.orderId
...@@ -281,9 +334,9 @@ onLoad((option) => { ...@@ -281,9 +334,9 @@ onLoad((option) => {
281 // 获取订单详情 334 // 获取订单详情
282 to(api.orderDetail(option.orderId)).then(([err, res]) => { 335 to(api.orderDetail(option.orderId)).then(([err, res]) => {
283 if (!err && res.data) { 336 if (!err && res.data) {
284 const content = res.data.content ? JSON.parse(res.data.content) : {} 337 const content = getOrderContent(res.data.content)
285 form.value.renewYear = content.yearCount || 1 338 form.value.renewYear = content.yearCount || 1
286 payName.value = res.data.orderName || '' 339 fillPayDisplayInfo(res.data, content, option)
287 } 340 }
288 }) 341 })
289 } 342 }
...@@ -291,10 +344,6 @@ onLoad((option) => { ...@@ -291,10 +344,6 @@ onLoad((option) => {
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 // 接收缴费单位和所属协会
295 payName.value = payName.value || decodeURIComponent(option.payName || '')
296 console.log(77, payName.value)
297 assoName.value = decodeURIComponent(option.assoName || '')
298 // 初始化获取费用和优惠 347 // 初始化获取费用和优惠
299 init() 348 init()
300 }) 349 })
......
...@@ -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 };
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!