11 changed files with 328 additions and 96 deletions
@ -0,0 +1,105 @@ |
|||
<template> |
|||
<view > |
|||
<view class="mask" v-show="isPay" @click="isShow=false"></view> |
|||
|
|||
<view class="order_popup" v-show="isPay"> |
|||
<view class="order_popup_title"> |
|||
<text> |
|||
Payment Method |
|||
</text> |
|||
<image src="../static/img/close1.png" mode="" @click="isPay=false"></image> |
|||
</view> |
|||
<view class="order_popup_pay" > |
|||
<view class="pay_item" @click="selectPay(0)"> |
|||
<image src="../static/img/select1.png" mode="" class="pay_item_select" v-if="pay_index==0"></image> |
|||
<image src="../static/img/select2.png" mode="" class="pay_item_select" v-else></image> |
|||
<view class="pay_item_right"> |
|||
<image src="../static/img/pay_pal.png" mode=""></image> |
|||
<text>Pay Pal</text> |
|||
</view> |
|||
</view> |
|||
<view class="pay_item" @click="selectPay(1)"> |
|||
<image src="../static/img/select1.png" mode="" class="pay_item_select" v-if="pay_index==1"></image> |
|||
<image src="../static/img/select2.png" mode="" class="pay_item_select" v-else></image> |
|||
<view class="pay_item_right"> |
|||
<image src="../static/img/card.png" mode=""></image> |
|||
<text>Credit/Debit Card</text> |
|||
</view> |
|||
</view> |
|||
<view class="pay_item" @click="selectPay(2)"> |
|||
<image src="../static/img/select1.png" mode="" class="pay_item_select" v-if="pay_index==2"></image> |
|||
<image src="../static/img/select2.png" mode="" class="pay_item_select" v-else></image> |
|||
<view class="pay_item_right"> |
|||
<image src="../static/img/GPay.png" mode=""></image> |
|||
<text>Google Pay</text> |
|||
</view> |
|||
</view> |
|||
<view class="pay_item" @click="selectPay(3)"> |
|||
<image src="../static/img/select1.png" mode="" class="pay_item_select" v-if="pay_index==3"></image> |
|||
<image src="../static/img/select2.png" mode="" class="pay_item_select" v-else></image> |
|||
<view class="pay_item_right"> |
|||
<image src="../static/img/APay.png" mode=""></image> |
|||
<text>Apple pay</text> |
|||
</view> |
|||
</view> |
|||
<!-- <navigator url="/pages/order/paySuccess"> --> |
|||
<button @click="getPayDate">PAY NOW</button> |
|||
<!-- </navigator> --> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
import {defaultRequest2} from '../api/index.js' |
|||
export default { |
|||
props:{ |
|||
payShow:false, |
|||
orderId:'' |
|||
}, |
|||
data() { |
|||
return { |
|||
pay_index:0 |
|||
} |
|||
}, |
|||
methods:{ |
|||
// 选择支付方式 |
|||
selectPay(index){ |
|||
this.pay_index=index |
|||
}, |
|||
// 获取调用支付信息数据 |
|||
getPayDate(id){ |
|||
let data={_action:'payorder',order_id:id,order_type:'GOODSBUY',payment_method:'alipay.native'} |
|||
defaultRequest2(data).then(res=>{ |
|||
console.info(res) |
|||
if(res.error==0){ |
|||
//订单对象,从服务器获取 |
|||
if(res.data.need_pay_amount==0) return |
|||
uni.requestPayment({ |
|||
provider: 'alipay', |
|||
orderInfo: res.data.prepay_data.order_info, //支付宝订单数据 |
|||
success: function (res) { |
|||
console.log('success:' + JSON.stringify(res)); |
|||
uni.redirectTo({ |
|||
url: 'paySuccess?order_id='+id |
|||
}); |
|||
}, |
|||
fail: function (err) { |
|||
console.log('fail:' + JSON.stringify(err)); |
|||
uni.showToast({ |
|||
title:'Payment failed', |
|||
icon:'none' |
|||
}) |
|||
uni.navigateBack() |
|||
} |
|||
}); |
|||
} |
|||
}) |
|||
|
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style> |
|||
</style> |
|||
Loading…
Reference in new issue