Initial commit
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<myNav title="支付demo" bgColor="nonoe" titleColor="#614D49" :backIcon="false" :backHome="false" :flex="false">
|
||||
</myNav>
|
||||
|
||||
|
||||
<view class="button-container">
|
||||
<button class="start-btn" @click="toPay">立即支付</button>
|
||||
</view>
|
||||
|
||||
<view class="button-container">
|
||||
<button class="start-btn" @click="refund">立即退款</button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onMounted,
|
||||
ref
|
||||
} from 'vue'
|
||||
import myNav from '@/components/my-nav.vue'
|
||||
import {
|
||||
urls
|
||||
} from '@/util/apiUrl.js'
|
||||
import dohttp from '@/util/requestConfig.js'
|
||||
const provider = ref("")
|
||||
|
||||
|
||||
const toPay = async() => {
|
||||
const result = await createOrder()
|
||||
console.log("toPay------------",result)
|
||||
uni.requestPayment({
|
||||
provider:'wxpay',
|
||||
timeStamp:result.timeStamp,
|
||||
nonceStr:result.nonceStr,
|
||||
package:result.packageStr,
|
||||
signType:result.signType,
|
||||
paySign:result.paySign,
|
||||
success: function (res) {
|
||||
console.log('success:' + JSON.stringify(res));
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('fail:' + JSON.stringify(err));
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
const createOrder=()=>{
|
||||
return dohttp.post(urls.createOrder)
|
||||
}
|
||||
const refund=()=>{
|
||||
|
||||
dohttp.post(urls.refund).then((result)=>{
|
||||
console.log("urls.refundurls.refund",result)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
uni.getProvider({
|
||||
"service": "payment",
|
||||
success(data) {
|
||||
if (data.provider && data.provider.length > 0) {
|
||||
provider.value = data.provider[0]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.content {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: #f9f8f8;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-family: SourceHanSansBold;
|
||||
}
|
||||
|
||||
/* 按钮 */
|
||||
.button-container {
|
||||
text-align: center;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.start-btn {
|
||||
width: 50%;
|
||||
background: linear-gradient(to right, #7c5afe, #6253e5);
|
||||
color: white;
|
||||
font-size: 24rpx;
|
||||
border-radius: 50rpx;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user