|
@@ -20,21 +20,64 @@
|
|
|
<view class="pay-center-item">应付金额:<span class="pay-amount">{{payItem.payAmount}}</span></view>
|
|
|
</view>
|
|
|
<view class="pay-bottom">
|
|
|
- <u-cell-item title="去支付" @click="paythis(payItem.orderId)" style="color: #008CFF;"></u-cell-item>
|
|
|
+ <!-- <u-cell-item title="去支付" @click="paythis(payItem.orderId)" style="color: #008CFF;"></u-cell-item> -->
|
|
|
+ <u-cell-item title="去支付" @click="choosePayWay(payItem.orderId)" style="color: #008CFF;"></u-cell-item>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
</mescroll-body>
|
|
|
<view class="button-wrap" v-if="payList.length&&payList.length>=1">
|
|
|
- <button class="button" type="primary" @click="all()">全部缴费</button>
|
|
|
+ <!-- <button class="button" type="primary" @click="all()">全部缴费</button> -->
|
|
|
+ <button class="button" type="primary" @click="confirmPrice()">全部缴费</button>
|
|
|
</view>
|
|
|
+ <!-- 缴费提示-->
|
|
|
+ <u-modal
|
|
|
+ v-model="payTipsPop"
|
|
|
+ :title-style="{color: '#404040'}"
|
|
|
+ title="缴费提示"
|
|
|
+ :show-confirm-button="true"
|
|
|
+ confirm-text="立即缴费"
|
|
|
+ :confirm-style="{backgroundColor: '#3397FA', color: '#fff'}"
|
|
|
+ :show-cancel-button="true"
|
|
|
+ cancel-text="取消"
|
|
|
+ :cancel-style="{backgroundColor: '#EBF1FF', color: '#3397FA'}"
|
|
|
+ @confirm="payTipsPopConfirm">
|
|
|
+ <view class="slot-content">
|
|
|
+ <view class="pay-tips">
|
|
|
+ <text>{{payTipsItem.num}}</text>场停车欠费,共
|
|
|
+ <text>{{payTipsItem.price}}</text>元
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </u-modal>
|
|
|
+ <!-- 缴费方式-->
|
|
|
+ <u-modal
|
|
|
+ v-model="payWayPop"
|
|
|
+ :title-style="{color: '#404040'}"
|
|
|
+ title="缴费方式"
|
|
|
+ :show-confirm-button="false"
|
|
|
+ :show-cancel-button="false">
|
|
|
+ <view class="slot-content">
|
|
|
+ <view class="pay-way">
|
|
|
+ <view class="pay-way-item" @click="gyBankPay">
|
|
|
+ <image src="../../static/img/gy-bank-pay-icon.png" mode=""></image>
|
|
|
+ <view>贵州银行</view>
|
|
|
+ </view>
|
|
|
+ <view class="pay-way-item" @click="wechatPay">
|
|
|
+ <image src="../../static/img/wechat-pay-icon.png" mode=""></image>
|
|
|
+ <view>微信支付</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <button class="pay-way-close-btn" @click="payWayPop = false">关闭</button>
|
|
|
+ </view>
|
|
|
+ </u-modal>
|
|
|
<u-toast ref="uToast" />
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
|
|
|
+ import getUrlParams from "../../utils/getUrlParams.js";
|
|
|
export default {
|
|
|
mixins: [MescrollMixin], // 使用mixin
|
|
|
data() {
|
|
@@ -46,6 +89,16 @@
|
|
|
],
|
|
|
orderList: [],
|
|
|
PayUrl: "",
|
|
|
+ payTipsPop: false,
|
|
|
+ payWayPop: false,
|
|
|
+ // 选中去支付的单条条目
|
|
|
+ currentItem: [],
|
|
|
+ // 缴费提示类目
|
|
|
+ payTipsItem: {
|
|
|
+ num: '',
|
|
|
+ price: ''
|
|
|
+ },
|
|
|
+ code: null,
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -64,6 +117,19 @@
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
+ onLoad(){
|
|
|
+ // let locationLocaturl = window.location.hash;
|
|
|
+ // this.orderId = getUrlParams(locationLocaturl,"orderId"); // 截取orderId
|
|
|
+ // console.log('this.orderId',this.orderId);
|
|
|
+ // if (this.orderId) {
|
|
|
+ // this.handleGetOrderinfo(this.orderId);
|
|
|
+ // }
|
|
|
+ // this.code = getUrlParams(locationLocaturl,"code");
|
|
|
+ // if (this.code) {
|
|
|
+ // this.handleGetWXInfo(this.code)
|
|
|
+ // }
|
|
|
+
|
|
|
+ },
|
|
|
methods: {
|
|
|
customBack(){
|
|
|
this.$u.route({
|
|
@@ -157,7 +223,142 @@
|
|
|
type: 'error',
|
|
|
});
|
|
|
});
|
|
|
- }
|
|
|
+ },
|
|
|
+ // 去支付,选择支付方式
|
|
|
+ choosePayWay(item) {
|
|
|
+ console.log(item)
|
|
|
+ this.currentItem = []
|
|
|
+ this.currentItem.push(item)
|
|
|
+ this.payWayPop = true
|
|
|
+ },
|
|
|
+ // 贵阳银行支付
|
|
|
+ gyBankPay(list) {
|
|
|
+ this.$u.api.payGzbank({orderList: this.currentItem}).then(res=>{
|
|
|
+ let payUrl = res.data.url;
|
|
|
+ this.currentPayUrl=encodeURIComponent(res.data.url);
|
|
|
+ // console.log('this.currentPayUrl',this.currentPayUrl);
|
|
|
+ // return;
|
|
|
+ this.$u.route({
|
|
|
+ url: 'pages/payLists/pay',
|
|
|
+ params: {
|
|
|
+ currentPayUrl:this.currentPayUrl
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }).catch(err=>{
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: err.msg,
|
|
|
+ type: 'error',
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 微信支付
|
|
|
+ wechatPay() {
|
|
|
+ const openId = this.$store.state.vuex_wxinfo.openId
|
|
|
+ if (openId) {
|
|
|
+ this.getWXPay(this.currentItem)
|
|
|
+ } else {
|
|
|
+ this.getCode()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 全部缴费确认
|
|
|
+ confirmPrice() {
|
|
|
+ let orderNum = 0, price = 0
|
|
|
+ this.currentItem = []
|
|
|
+ this.payList.forEach(item => {
|
|
|
+ console.log(item)
|
|
|
+ if (item.orderStatus !== 2 && item.payStatus !== 1 ) {
|
|
|
+ price += item.payAmount
|
|
|
+ orderNum ++
|
|
|
+ this.currentItem.push(item.orderId)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.payTipsItem.num = orderNum
|
|
|
+ this.payTipsItem.price = price
|
|
|
+ if (orderNum !== 0 && price !== 0) {
|
|
|
+ this.payTipsPop = true
|
|
|
+ } else {
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: '没有需要支付的订单',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 缴费提示弹框确认
|
|
|
+ payTipsPopConfirm() {
|
|
|
+ this.payWayPop = true
|
|
|
+ },
|
|
|
+ getCode () {
|
|
|
+ var local = window.location.href // 获取页面url
|
|
|
+ let locationLocaturl = window.location.search;
|
|
|
+ this.code = getUrlParams(locationLocaturl,"code"); // 截取code
|
|
|
+ if (this.code == null || this.code === '') { // 如果没有code,则去请求
|
|
|
+ window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.config.wxAppid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_userinfo&#wechat_redirect`
|
|
|
+ } else {
|
|
|
+ this.handleGetWXInfo(this.code) //把code传给后台获取用户信息
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleGetWXInfo (code) { // 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
|
|
|
+ let _this = this
|
|
|
+ this.$u.api.getWXInfo(code).then((res) => {
|
|
|
+ if (res.code === 200 ) {
|
|
|
+ this.$u.vuex('vuex_wxinfo', res.data);
|
|
|
+ // 继续支付
|
|
|
+ this.getWXPay(this.currentItem)
|
|
|
+ }
|
|
|
+ }).catch((err) => {
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: err.msg,
|
|
|
+ type: 'error',
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async getWXPay(list){
|
|
|
+ let params = {
|
|
|
+ orderList: list,
|
|
|
+ openid:this.$store.state.vuex_wxinfo.openId
|
|
|
+ };
|
|
|
+ await this.$wxApi.config();
|
|
|
+ this.$pay.wechatPay(params).then(res =>{
|
|
|
+ if(res.code == 0){
|
|
|
+ // 成功
|
|
|
+ this.$u.route({
|
|
|
+ url:'pages/payLists/payLists',
|
|
|
+ // params: {
|
|
|
+ // keyword: this.keyword
|
|
|
+ // }
|
|
|
+ });
|
|
|
+ }else if(res.code == 1){
|
|
|
+ // 取消
|
|
|
+ // uni.redirectTo({
|
|
|
+ // url: '/pages/userCenter/myOrder/myOrder'
|
|
|
+ // })
|
|
|
+ }else if(res.code == 2){
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: '支付失败,请检查!',
|
|
|
+ type: 'error',
|
|
|
+ // url: '/pages/user/index'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleGetOrderinfo(orderId){
|
|
|
+ this.$u.api.getOrderinfo({id:orderId})
|
|
|
+ .then(res=>{
|
|
|
+ // this.$refs.uToast.show({
|
|
|
+ // title: res.msg,
|
|
|
+ // type: 'success',
|
|
|
+ // });
|
|
|
+ this.orderInfo = res.data;
|
|
|
+ console.log('handleGetOrderinfo',JSON.parse(JSON.stringify(res)));
|
|
|
+ }).catch(err=>{
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: err.msg,
|
|
|
+ type: 'error',
|
|
|
+ });
|
|
|
+ console.log('handleGetOrderinfo ',err)
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
}
|
|
|
};
|
|
|
</script>
|