Răsfoiți Sursa

获取指定支付产品支付项

mht 1 lună în urmă
părinte
comite
e1570340df
4 a modificat fișierele cu 29 adăugiri și 6 ștergeri
  1. 4 3
      src/api/product.js
  2. 19 1
      src/utils/config.js
  3. 3 1
      src/views/Recharge.vue
  4. 3 1
      src/views/Search.vue

+ 4 - 3
src/api/product.js

@@ -1,9 +1,10 @@
 import request from '@/utils/request'
 
 // 获取产品列表
-export function getProductList() {
+export function getProductList(payWayId) {
   return request({
-    url: '/web/getProductList',
-    method: 'get'
+    url: '/web/getProductList/v2',
+    method: 'get',
+    params: { payWayId }
   })
 } 

+ 19 - 1
src/utils/config.js

@@ -6,8 +6,26 @@ export const API_BASE_URL = isDev
   ? 'https://gbyy91.com/api'
   : 'https://gbyy91.com/api' // 生产环境 
 
+// 支付方式ID
+export const PAY_WAY_ID = {
+  ANDROID: 10,
+  IOS: 21
+}
+
+// 检测设备类型
+export function getDevicePayWayId() {
+  const ua = navigator.userAgent.toLowerCase()
+  if (/iphone|ipad|ipod|ios/.test(ua)) {
+    return PAY_WAY_ID.IOS
+  }
+  // 默认返回安卓支付方式
+  return PAY_WAY_ID.ANDROID
+}
+
 // 其他全局配置可以在这里添加
 export default {
   API_BASE_URL,
-  isDev
+  isDev,
+  PAY_WAY_ID,
+  getDevicePayWayId
 } 

+ 3 - 1
src/views/Recharge.vue

@@ -116,6 +116,7 @@ import { getProductList } from '@/api/product'
 import { getUserInfo } from '@/api/user'
 import { wechatPayCoin, wxPay } from '@/api/pay'
 import { ahtuCodeApi } from '@/api/pay'
+import { getDevicePayWayId } from '@/utils/config'
 
 export default {
   name: 'RechargePage',
@@ -211,7 +212,8 @@ export default {
     // 获取产品列表
     async fetchProductList() {
       try {
-        const res = await getProductList()
+        const payWayId = getDevicePayWayId()
+        const res = await getProductList(payWayId)
         this.rechargeOptions = res.data || []
       } catch (error) {
         console.error('获取产品列表失败:', error)

+ 3 - 1
src/views/Search.vue

@@ -106,6 +106,7 @@
 import { getProductList } from '@/api/product'
 import { getUserInfo } from '@/api/user'
 import { ahtuCodeApi } from '@/api/pay'
+import { getDevicePayWayId } from '@/utils/config'
 
 export default {
   name: 'SearchPage',
@@ -169,7 +170,8 @@ fetchUserInfo() {
     // 获取产品列表
     async fetchProductList() {
       try {
-        const res = await getProductList()
+        const payWayId = getDevicePayWayId()
+        const res = await getProductList(payWayId)
         this.coinOptions = res.data || []
       } catch (error) {
         console.error('获取产品列表失败:', error)