xiaokuaisong-xiaochengxu/uniapp04/pages/test/test.vue
2024-10-18 15:53:00 +08:00

93 lines
2.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<button @click="onButton">支付按钮</button>
</template>
<script setup>
import { ref } from 'vue';
import {apiImageUrl} from '../../API/api'
/* const onButton = () => {
my.request({
url: 'http://localhost:9999/api/Alipay/trade',
method: 'GET',
success: (result) => {
console.log(result);
if (result.data.code === 0) { // 假设 0 表示成功
my.tradePay({
tradeNo: result.data.data,
success: (res) => {
my.navigateTo({
url: '/pages/index/index'
});
console.log('成功');
},
fail: (res) => {
my.alert({
content: JSON.stringify(res),
});
console.log('失败');
console.log(res);
}
});
} else {
console.error('请求失败:', result.data.message);
}
},
fail: (error) => {
console.error('请求失败:', error);
}
});
}; */
const onButton = () => {
my.request({
url: apiImageUrl+'/api/Alipay/trade',
method: 'GET',
success: function(result) {
console.log(result);
console.log(result.data.data);
my.tradePay({
tradeNO: result.data.data,
success: (res) => {
console.log('成功调用')
// my.navigateTo({
// url: '/pages/index/index',
// })
console.log(res);
},
fail: (res) => {
my.alert({
content: JSON.stringify(res),
})
console.log('失败');
console.log(res);
}
})
}
})
}
/* const onButton=()=>{
uni.request({
url:'http://localhost:9999/api/Alipay/trade',
method:'GET',
success:function(result){
console.log(result);
my.tradePay ({
// 调用统一收单交易创建接口alipay.trade.create获得返回字段支付宝交易号 trade_no
url:'http://localhost:9999/api/Alipay/trade',
method:'GET',
tradeNO: '201711152100110410533667792',
success: res => {
my.alert ({
content: JSON.stringify (res),
});
},
fail: error => {
console.error('调用 my.tradePay 失败: ', JSON.stringify(error));
},
});
}
})
} */
</script>