mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-18 01:06:39 +08:00
fixed alipay mobile payment
This commit is contained in:
parent
471017657f
commit
495f86e7fc
@ -120,6 +120,15 @@ func (h *PaymentHandler) Pay(c *gin.Context) {
|
|||||||
returnURL = fmt.Sprintf("%s/payReturn", data.Host)
|
returnURL = fmt.Sprintf("%s/payReturn", data.Host)
|
||||||
}
|
}
|
||||||
money := fmt.Sprintf("%.2f", amount)
|
money := fmt.Sprintf("%.2f", amount)
|
||||||
|
if data.Device == "wechat" {
|
||||||
|
payURL, err = h.alipayService.PayMobile(payment.AlipayParams{
|
||||||
|
OutTradeNo: orderNo,
|
||||||
|
Subject: product.Name,
|
||||||
|
TotalFee: money,
|
||||||
|
ReturnURL: returnURL,
|
||||||
|
NotifyURL: notifyURL,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
payURL, err = h.alipayService.PayPC(payment.AlipayParams{
|
payURL, err = h.alipayService.PayPC(payment.AlipayParams{
|
||||||
OutTradeNo: orderNo,
|
OutTradeNo: orderNo,
|
||||||
Subject: product.Name,
|
Subject: product.Name,
|
||||||
@ -127,6 +136,8 @@ func (h *PaymentHandler) Pay(c *gin.Context) {
|
|||||||
ReturnURL: returnURL,
|
ReturnURL: returnURL,
|
||||||
NotifyURL: notifyURL,
|
NotifyURL: notifyURL,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resp.ERROR(c, "error with generate pay url: "+err.Error())
|
resp.ERROR(c, "error with generate pay url: "+err.Error())
|
||||||
return
|
return
|
||||||
|
@ -67,10 +67,8 @@ func (s *AlipayService) PayMobile(params AlipayParams) (string, error) {
|
|||||||
bm.Set("out_trade_no", params.OutTradeNo)
|
bm.Set("out_trade_no", params.OutTradeNo)
|
||||||
bm.Set("quit_url", params.ReturnURL)
|
bm.Set("quit_url", params.ReturnURL)
|
||||||
bm.Set("total_amount", params.TotalFee)
|
bm.Set("total_amount", params.TotalFee)
|
||||||
bm.Set("return_url", params.ReturnURL)
|
|
||||||
bm.Set("notify_url", params.NotifyURL)
|
|
||||||
bm.Set("product_code", "QUICK_WAP_WAY")
|
bm.Set("product_code", "QUICK_WAP_WAY")
|
||||||
return s.client.TradeWapPay(context.Background(), bm)
|
return s.client.SetNotifyUrl(params.NotifyURL).SetReturnUrl(params.ReturnURL).TradeWapPay(context.Background(), bm)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AlipayService) PayPC(params AlipayParams) (string, error) {
|
func (s *AlipayService) PayPC(params AlipayParams) (string, error) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
VUE_APP_API_HOST=http://localhost:5678
|
VUE_APP_API_HOST=http://www.geekai.me:6004
|
||||||
VUE_APP_WS_HOST=ws://localhost:5678
|
VUE_APP_WS_HOST=ws://www.geekai.me:6004
|
||||||
VUE_APP_USER=18888888888
|
VUE_APP_USER=18888888888
|
||||||
VUE_APP_PASS=12345678
|
VUE_APP_PASS=12345678
|
||||||
VUE_APP_ADMIN_USER=admin
|
VUE_APP_ADMIN_USER=admin
|
||||||
|
@ -13,6 +13,7 @@ import {showMessageInfo} from "@/utils/dialog";
|
|||||||
import {useSharedStore} from "@/store/sharedata";
|
import {useSharedStore} from "@/store/sharedata";
|
||||||
import {getUserToken} from "@/store/session";
|
import {getUserToken} from "@/store/session";
|
||||||
import {router} from "@/router";
|
import {router} from "@/router";
|
||||||
|
import {onBeforeRouteLeave, onBeforeRouteUpdate} from "vue-router";
|
||||||
|
|
||||||
const debounce = (fn, delay) => {
|
const debounce = (fn, delay) => {
|
||||||
let timer
|
let timer
|
||||||
@ -49,17 +50,11 @@ onMounted(() => {
|
|||||||
|
|
||||||
checkSession().then(() => {
|
checkSession().then(() => {
|
||||||
store.setIsLogin(true)
|
store.setIsLogin(true)
|
||||||
connect()
|
|
||||||
}).catch(()=>{})
|
}).catch(()=>{})
|
||||||
|
|
||||||
// 自动跳转到手机端
|
|
||||||
if (isMobile() && !router.currentRoute.value.path.startsWith("/mobile")) {
|
|
||||||
router.push("/mobile/index")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(() => store.isLogin, (val) => {
|
watch(() => store.isLogin, (val) => {
|
||||||
if (val) {
|
if (val && store.socket.readyState !== WebSocket.OPEN) {
|
||||||
connect()
|
connect()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -80,16 +75,25 @@ const connect = () => {
|
|||||||
_socket.addEventListener('open', () => {
|
_socket.addEventListener('open', () => {
|
||||||
console.log('WebSocket 已连接')
|
console.log('WebSocket 已连接')
|
||||||
handler.value = setInterval(() => {
|
handler.value = setInterval(() => {
|
||||||
|
if (_socket.readyState === WebSocket.OPEN) {
|
||||||
_socket.send(JSON.stringify({"type":"ping"}))
|
_socket.send(JSON.stringify({"type":"ping"}))
|
||||||
|
}
|
||||||
},5000)
|
},5000)
|
||||||
|
|
||||||
|
// 绑定事件监听
|
||||||
for (const key in store.messageHandlers) {
|
for (const key in store.messageHandlers) {
|
||||||
console.log(key, store.messageHandlers[key])
|
console.log(store.messageHandlers[key])
|
||||||
store.setMessageHandler(store.messageHandlers[key])
|
store.setMessageHandler(store.messageHandlers[key])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
_socket.addEventListener('close', () => {
|
_socket.addEventListener('close', () => {
|
||||||
|
// 移除事件监听
|
||||||
|
for (const key in store.messageHandlers) {
|
||||||
|
if (store.socket) {
|
||||||
|
store.socket.removeEventListener('message', this.messageHandlers[key])
|
||||||
|
}
|
||||||
|
}
|
||||||
store.setSocket(null)
|
store.setSocket(null)
|
||||||
clearInterval(handler.value)
|
clearInterval(handler.value)
|
||||||
connect()
|
connect()
|
||||||
|
@ -56,6 +56,9 @@ export const useSharedStore = defineStore('shared', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeMessageHandler(key) {
|
removeMessageHandler(key) {
|
||||||
|
if (this.socket) {
|
||||||
|
this.socket.removeEventListener('message', this.messageHandlers[key])
|
||||||
|
}
|
||||||
delete this.messageHandlers[key]
|
delete this.messageHandlers[key]
|
||||||
},
|
},
|
||||||
setMobileTheme(theme) {
|
setMobileTheme(theme) {
|
||||||
|
@ -219,6 +219,7 @@ import ChatReply from "@/components/ChatReply.vue";
|
|||||||
import {Delete, Edit, InfoFilled, More, Plus, Promotion, Search, Share, VideoPause} from '@element-plus/icons-vue'
|
import {Delete, Edit, InfoFilled, More, Plus, Promotion, Search, Share, VideoPause} from '@element-plus/icons-vue'
|
||||||
import 'highlight.js/styles/a11y-dark.css'
|
import 'highlight.js/styles/a11y-dark.css'
|
||||||
import {
|
import {
|
||||||
|
isMobile,
|
||||||
randString,
|
randString,
|
||||||
removeArrayItem,
|
removeArrayItem,
|
||||||
UUID
|
UUID
|
||||||
@ -274,6 +275,9 @@ watch(() => store.chatStream, (newValue) => {
|
|||||||
stream.value = newValue
|
stream.value = newValue
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (isMobile()) {
|
||||||
|
router.push('/mobile/chat')
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化角色ID参数
|
// 初始化角色ID参数
|
||||||
if (router.currentRoute.value.query.role_id) {
|
if (router.currentRoute.value.query.role_id) {
|
||||||
|
@ -62,9 +62,14 @@ import FooterBar from "@/components/FooterBar.vue";
|
|||||||
import {httpGet} from "@/utils/http";
|
import {httpGet} from "@/utils/http";
|
||||||
import {ElMessage} from "element-plus";
|
import {ElMessage} from "element-plus";
|
||||||
import {checkSession, getLicenseInfo, getSystemInfo} from "@/store/cache";
|
import {checkSession, getLicenseInfo, getSystemInfo} from "@/store/cache";
|
||||||
|
import {isMobile} from "@/utils/libs";
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
if (isMobile()) {
|
||||||
|
router.push("/mobile/index")
|
||||||
|
}
|
||||||
|
|
||||||
const title = ref("")
|
const title = ref("")
|
||||||
const logo = ref("")
|
const logo = ref("")
|
||||||
const slogan = ref("")
|
const slogan = ref("")
|
||||||
|
Loading…
Reference in New Issue
Block a user