123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <template>
- <view class="pages">
- <view class="" :style="{height: navHeight+'px' }"></view>
- <u-navbar
- title="订单详情"
- :safeAreaInsetTop="true"
- @leftClick="leftClick"
- :titleStyle="{color:'#fff'}"
- leftIconColor="#fff"
- bgColor="#ED0000">
- </u-navbar>
- <view class="page-wrap">
- <view class="pay-list">
- <radio-group @change="payRadioChange">
- <view class="pay-list-item u-flex u-row-between" @click="payRadioClick('weixin')">
- <view class="left u-flex">
- <image class="icon" :src="staticUrl+'/img/share-ico.png'" ></image>
- <view class="name">微信支付</view>
- </view>
- <radio color="#2DCF8C" value="weixin" :checked="'weixin' === radioCurrent" />
- </view>
- <view class="pay-list-item u-flex u-row-between" @click="payRadioClick('yue')">
- <view class="left u-flex">
- <image class="icon" :src="staticUrl+'/img/share-ico.png'" ></image>
- <view class="name">账户余额</view>
- <view class="num">剩余¥:2000</view>
- </view>
- <radio color="#2DCF8C" value="yue" :checked="'yue' === radioCurrent" />
- </view>
- <view class="pay-list-item u-flex u-row-between" @click="payRadioClick('shouxin')">
- <view class="left u-flex">
- <image class="icon" :src="staticUrl+'/img/share-ico.png'" ></image>
- <view class="name">授信余额</view>
- <view class="num">剩余¥:2000</view>
- </view>
- <radio color="#2DCF8C" value="shouxin" :checked="'shouxin' === radioCurrent" />
- </view>
- </radio-group>
- </view>
- <view class="full-btn" @click="submit">支付</view>
- </view>
- </view>
- </template>
- <script>
- import { systemInfo } from "@/mixin.js";
-
- import wxH5 from "weixin-jsapi";
-
- export default{
- mixins:[systemInfo],
- name:'',
- components:{
-
- },
- props:{
-
- },
- data(){
- return{
- staticUrl:this.$commonConfig.staticUrl,
-
- radioCurrent: 'weixin',
-
- }
- },
- onLoad(){
- this.getSystemInfo();
-
- },
- methods:{
- leftClick(e){
- let pages = getCurrentPages();
- if(pages.length==1){
- uni.$u.route('/pages/index/index')
- }else{
- uni.navigateBack()
- };
- },
- payRadioChange({ detail }) {
- this.radioCurrent = detail.value;
- },
- payRadioClick(value) {
- this.radioCurrent = value;
- },
- submit(){
- console.log('this.radioCurrent', this.radioCurrent);
- },
- getTemplateIdList(){
- this.$u.api.templateIdList({templateLabel:'order_pay'}).then(res=>{
- console.log('getTemplateIdList',res.data);
- this.templateIdList = res.data.list.map(item=>{
- return item.templateId
- });
-
-
-
- }).catch(err=>{
- console.log('getTemplateIdList',err);
- })
- },
- pay(item){
-
- this.gotoPay(this.orderDetails.id);
-
-
- this.setTemplate(this.orderDetails.id);
-
- },
- gotoPay(orderId){
- this.$u.api.gotoPay({orderId:orderId,openid:''}).then(res=>{
- this.payResult = res.data.payInfo;
- this.payResult.package = res.data.payInfo.packageValue;
-
- this.initConfig(this.payResult)
-
-
- this.wxPay()
-
-
-
-
-
-
- console.log('gotoPayres',res.data);
- }).catch(err=>{
- this.paypass = '';
- this.checkPassShow = false;
- console.log('gotoPay',err);
- })
- },
- wxPay(){
- let that = this;
- uni.requestPayment({
- ... this.payResult,
- "provider": "wxpay",
- "orderInfo": {
-
-
-
-
-
-
-
- },
- success(res) {
- that.payQuery();
- },
- fail(e) {
- console.log('wxPayfail',e);
- }
- })
- },
- payQuery(){
- let that = this;
- let retryCount = 0;
- let maxRetryCount = 5;
- let interval = 2000;
- let timeout = 10000;
- let timer;
- uni.showLoading({
- title:'支付结果查询中'
- })
- timer = setInterval(() => {
- retryCount++;
- if (retryCount > maxRetryCount || retryCount * interval > timeout) {
- clearInterval(timer);
- uni.hideLoading();
- console.log("支付查询超时或达到最大重试次数");
-
- this.reloadList()
- } else {
- console.log("第" + retryCount + "次查询");
-
-
-
- this.$u.api.payQuery({orderId:this.orderId}).then(res=>{
-
- let payStatus = res.data.payStatus;
- if(payStatus===1){
- uni.$u.route('/center/paysuccess');
- }else if(payStatus===0||payStatus===2){
- this.payQuery()
- }else if(payStatus===3){
- uni.toast('支付失败')
- }
- clearInterval(timer);
- }).catch(err=>{
- console.log('payQuery',err);
- }).finally(()=>{
- uni.hideLoading()
- })
- }
- }, interval);
- },
-
- initConfig() {
-
- let that = this
- wxH5.config({
- debug: false,
- appId: that.payResult.appId,
- timestamp: that.payResult.timeStamp,
- nonceStr: that.payResult.nonceStr,
- signature: that.payResult.paySign,
- jsApiList: ['chooseWXPay', 'checkJsApi']
- })
- wxH5.ready(() => {
- wxH5.chooseWXPay({
- timestamp: that.payResult.timeStamp,
- nonceStr: that.payResult.nonceStr,
- package: that.payResult.packageValue,
- signType: 'SHA1',
- paySign: that.payResult.paySign,
- success: () => {
- that.payQuery();
- },
- fail: (e) => {
- uni.$u.route('/center/order', {
- status: 0
- });
- console.log('wxPayfail', e);
- },
- cancel: () => {
- uni.$u.route('/center/order', {
- status: 0
- });
- that.cansubmit = true;
- }
- })
- })
-
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .pay-list{
- .pay-list-item{
- margin-bottom: 24rpx;
- .icon{
- width: 40rpx;
- height: 40rpx;
- margin-right: 24rpx;
- }
- .name{
- margin-right: 24rpx;
- }
- .num{
-
- }
- }
- }
- </style>
|