diff --git a/jiuyi2/api/mine.js b/jiuyi2/api/mine.js index 3282bb13..62888e9c 100644 --- a/jiuyi2/api/mine.js +++ b/jiuyi2/api/mine.js @@ -209,10 +209,11 @@ const mine = { }, /** - * 支付 + * 支付宝支付 * @param {Object} param */ - recharge(param) { + alipayPay(param) { + console.log('alipayPay',param) return util.request({ url: '/user/alipay/recharge', query: param.query, @@ -221,6 +222,19 @@ const mine = { }) }, + /** + * 微信支付 + * @param {Object} param + */ + wechatPay(param) { + return util.request({ + url: '/user/wxPay/unifiedOrder', + query: param.query, + method: 'POST', + load: true, + }) + }, + /** * 获取收益列表 * @param {Object} param diff --git a/jiuyi2/common/js/config.js b/jiuyi2/common/js/config.js index 36cfa819..9fba98a9 100644 --- a/jiuyi2/common/js/config.js +++ b/jiuyi2/common/js/config.js @@ -6,7 +6,8 @@ const config = { // host: 'h5api', // #endif // #ifndef H5 - host: 'http://91f.xyz:8080', + // host: 'http://91f.xyz:8080', + host: 'http://fc25a42.r24.cpolar.top', // #endif // 是否vivo显示 showVivo: true, diff --git a/jiuyi2/common/js/util.js b/jiuyi2/common/js/util.js index f9a91a5d..50a3ddbf 100644 --- a/jiuyi2/common/js/util.js +++ b/jiuyi2/common/js/util.js @@ -213,7 +213,7 @@ const util = { responseType: params.responseType || 'text', // 请求成功返回 success: res => { - // console.log('request success', url, res, params.data ? params.data : '') + console.log('request success', url, res, params.data ? params.data : '') // 关闭加载效果 if (params.load) { uni.hideLoading() diff --git a/jiuyi2/manifest.json b/jiuyi2/manifest.json index ecec5357..a0a1e684 100644 --- a/jiuyi2/manifest.json +++ b/jiuyi2/manifest.json @@ -82,6 +82,12 @@ "payment" : { "alipay" : { "__platform__" : [ "ios", "android" ] + }, + "appleiap" : {}, + "weixin" : { + "__platform__" : [ "ios", "android" ], + "appid" : "wxe58baf0d5b31d33b", + "UniversalLinks" : "https://91f.xyz" } }, "share" : {}, diff --git a/jiuyi2/pages/index/seedLog.vue b/jiuyi2/pages/index/seedLog.vue index d9bda9e6..5bc70882 100644 --- a/jiuyi2/pages/index/seedLog.vue +++ b/jiuyi2/pages/index/seedLog.vue @@ -96,7 +96,7 @@ - + {{item.reason}} {{item.createTime}} diff --git a/jiuyi2/pages/index/wallet/topUp.vue b/jiuyi2/pages/index/wallet/topUp.vue index b992576a..167eca3b 100644 --- a/jiuyi2/pages/index/wallet/topUp.vue +++ b/jiuyi2/pages/index/wallet/topUp.vue @@ -4,7 +4,9 @@ */ import { - reactive + ref, + reactive, + computed, } from 'vue'; import util from '@/common/js/util'; import api from '@/api/index.js'; @@ -19,24 +21,55 @@ const form = reactive({ totalAmount: '', }) + // 支付列表 + const paymentList = reactive([{ + img: '/static/shop-alipay-payment.png', + name: '支付宝', + provider: 'alipay', + apiRequest: (event) => { + return api.mine.alipayPay(event) + } + }, + { + img: '/static/shop-weixin-pay.png', + name: '微信支付', + provider: 'wxpay', + apiRequest: (event) => { + return api.mine.wechatPay(event) + } + }, + ]) + // 支付列表下标 + const paymentIndex = ref(0) + // 当前支付方式 + const payment = computed(() => paymentList[paymentIndex.value]) onLoad((option) => { - if(option.amount) form.totalAmount = option.amount + if (option.amount) form.totalAmount = option.amount }) + /** + * 选择支付方式 + * @param {Object} event + */ + function handlePaymentIndex(event) { + const index = event.detail.value + if (paymentIndex.value === index) return + paymentIndex.value = index + } + // 充值 function handleSubmit() { - console.log('handleSubmit') // 验证 util.isAuth({ success: rs => { - payment() + handlePayment() }, }) } // 调用支付 - function payment() { + function handlePayment() { const data = { ...form } @@ -45,17 +78,17 @@ util.alert('金额不正确') return } - console.log('payment') - api.mine.recharge({ + // 调用支付方式 + payment.value.apiRequest({ query: { ...data, }, }).then(rs => { - console.log('recharge rs', rs) + console.log('payment rs', rs) if (rs.code == 200) { uni.requestPayment({ - provider: 'alipay', + provider: payment.value.provider, orderInfo: rs.msg, success: rs => { console.log('requestPayment', rs) @@ -94,11 +127,13 @@ 充值方式 - - - 支付宝 - - + + + + {{payment.name}} + + + diff --git a/jiuyi2/vite.config.js b/jiuyi2/vite.config.js index fc5535df..59b7eb25 100644 --- a/jiuyi2/vite.config.js +++ b/jiuyi2/vite.config.js @@ -3,7 +3,8 @@ import { } from 'vite'; import uni from '@dcloudio/vite-plugin-uni'; -let target = 'http://91f.xyz:8080' +// let target = 'http://91f.xyz:8080' +let target = 'http://fc25a42.r24.cpolar.top' export default defineConfig({ plugins: [uni()],