|
@@ -32,11 +32,31 @@
|
|
|
<view>包月说明</view>
|
|
|
<view>1、停车不足30分钟,免费;</view>
|
|
|
<view>2、停车 超过20分钟,按2元/小时收费;</view>
|
|
|
- <view>3、月卡会员在有效期内停车免费</view>
|
|
|
+ <!-- <view>3、月卡会员在有效期内停车免费</view> -->
|
|
|
</view>
|
|
|
<view class="handle-monthly-confirm-button">
|
|
|
<button type="default"@click="submit(roadNo)">确认包月</button>
|
|
|
</view>
|
|
|
+ <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>
|
|
@@ -64,7 +84,9 @@
|
|
|
month: 1,
|
|
|
dateRange:""
|
|
|
},
|
|
|
- label:""
|
|
|
+ label:"",
|
|
|
+ payWayPop: false,
|
|
|
+ jumpUrl: undefined
|
|
|
}
|
|
|
},
|
|
|
onLoad (page) {
|
|
@@ -72,7 +94,12 @@
|
|
|
this.roadNo = page.roadNo;
|
|
|
this.getMonthInfo(this.roadNo);
|
|
|
}
|
|
|
-
|
|
|
+ if (page.vehicleNo) {
|
|
|
+ this.vehicleNo = page.vehicleNo
|
|
|
+ }
|
|
|
+ const baseUrl = window.location.href.split('#')[0]
|
|
|
+ let jumpUrl = baseUrl + '#' + '/pages/center/monthly/monthly'
|
|
|
+ this.jumpUrl = jumpUrl
|
|
|
},
|
|
|
mounted(){
|
|
|
// console.log(this.lastActiveDate)
|
|
@@ -155,23 +182,29 @@
|
|
|
this.lastActiveDate = res.data.lastActiveDate;
|
|
|
this.form.monthAmount=res.data.monthAmount;
|
|
|
this.carLicenseList = [];
|
|
|
+ let vehicleNoItem = null
|
|
|
res.data.vehicleList.forEach(item => {
|
|
|
const obj = {
|
|
|
value: item.energyType,
|
|
|
label: item.vehicleNo,
|
|
|
energyType:item.energyType
|
|
|
}
|
|
|
+ if (this.vehicleNo == item.vehicleNo) {
|
|
|
+ vehicleNoItem = obj
|
|
|
+ }
|
|
|
this.carLicenseList.push(obj)
|
|
|
});
|
|
|
- console.log('this.carLicenseList',this.carLicenseList)
|
|
|
- this.form.carLicense = this.carLicenseList[0]
|
|
|
+ // 判断是否url存在车牌号,存在则选中项默认选中
|
|
|
+ if (vehicleNoItem) {
|
|
|
+ this.form.carLicense = vehicleNoItem
|
|
|
+ } else {
|
|
|
+ this.form.carLicense = this.carLicenseList[0]
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
})
|
|
|
},
|
|
|
submit(roadNo){
|
|
|
- // console.log(this.monthStartTime)
|
|
|
- // console.log('this.form.carLicense',this.form.carLicense);
|
|
|
this.$u.api.createMonth({
|
|
|
roadNo:this.roadNo,
|
|
|
vehicleNo:this.form.carLicense.label,
|
|
@@ -184,26 +217,7 @@
|
|
|
if(res.code === 200){
|
|
|
this.monthId = res.data.monthId
|
|
|
console.log(this.monthId)
|
|
|
- this.$u.api.monthPay({
|
|
|
- monthId:this.monthId
|
|
|
- }).then(res => {
|
|
|
- console.log("monthPay",res)
|
|
|
- if(res.code === 200){
|
|
|
- // this.payUrl=encodeURIComponent(res.data.url);
|
|
|
- // this.$u.route({
|
|
|
- // url: 'pages/handleMonthly/monthPay',
|
|
|
- // params: {
|
|
|
- // payUrl:this.payUrl
|
|
|
- // }
|
|
|
- // });
|
|
|
- window.location.href = res.data.url
|
|
|
- } else {
|
|
|
- this.$refs.uToast.show({
|
|
|
- title: res.msg,
|
|
|
- type: 'error',
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
+ this.payWayPop = true
|
|
|
}else{
|
|
|
this.$refs.uToast.show({
|
|
|
title: res.msg,
|
|
@@ -213,7 +227,109 @@
|
|
|
}).catch(err=>{
|
|
|
|
|
|
});
|
|
|
- // this.getMonthInfo(roadNo)
|
|
|
+ },
|
|
|
+ gyBankPay() {
|
|
|
+ this.$u.api.monthPay({
|
|
|
+ monthId: this.monthId,
|
|
|
+ jumpUrl: this.jumpUrl
|
|
|
+ }).then(res => {
|
|
|
+ if(res.code === 200){
|
|
|
+ window.location.href = res.data.url
|
|
|
+ } else {
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: res.msg,
|
|
|
+ type: 'error',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 微信支付
|
|
|
+ * 判断vuex中是否存在openId
|
|
|
+ * 存在直接调起微信支付
|
|
|
+ * 不存在则通过微信登录去获取用户的code
|
|
|
+ * 完成后通过code去获取用户的openId等信息
|
|
|
+ * 最后再调起微信支付
|
|
|
+ * */
|
|
|
+ wechatPay() {
|
|
|
+ const openId = this.$store.state.vuex_wxinfo.openId
|
|
|
+ if (openId) {
|
|
|
+ this.getWXPay()
|
|
|
+ } else {
|
|
|
+ this.getCode()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 调起微信支付接口
|
|
|
+ * @param {Array} list 需要支付的订单组合数组
|
|
|
+ * @param {Number} deviceNo 设备编号(在停车锁部分需要)
|
|
|
+ * */
|
|
|
+ async getWXPay(){
|
|
|
+ // 支付成功跳转到包月页面
|
|
|
+ let params = {
|
|
|
+ monthId: this.monthId,
|
|
|
+ openid: this.$store.state.vuex_wxinfo.openId
|
|
|
+ };
|
|
|
+ await this.$wxApi.config();
|
|
|
+ this.$pay.wechatPay(params, '/monthpay/wechat', this.jumpUrl).then(res =>{
|
|
|
+ switch (Number(res.code)) {
|
|
|
+ case 0: // 成功
|
|
|
+ //#ifdef H5
|
|
|
+ window.location.reload();
|
|
|
+ //#endif
|
|
|
+ break;
|
|
|
+ case 1: // 取消
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: '已取消支付',
|
|
|
+ type: 'info',
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 2: // 支付失败
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: '支付失败,请检查!',
|
|
|
+ type: 'error',
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 获取code
|
|
|
+ * 1 微信登录获取code
|
|
|
+ * 2 url中截取
|
|
|
+ * */
|
|
|
+ getCode () {
|
|
|
+ // 获取页面完整url
|
|
|
+ const local = window.location.href
|
|
|
+ // 获取url后面的参数
|
|
|
+ const locationLocaturl = window.location.search;
|
|
|
+ // 截取url中的code
|
|
|
+ this.code = getUrlParams(locationLocaturl, "code");
|
|
|
+ // 如果没有code,则去请求
|
|
|
+ if (this.code == null || this.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 {
|
|
|
+ // 把code传给后台获取用户信息
|
|
|
+ this.handleGetWXInfo(this.code)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 通过code获取openId等用户信息
|
|
|
+ * 拿到用户信息后再调起微信支付
|
|
|
+ * */
|
|
|
+ handleGetWXInfo (code) {
|
|
|
+ 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',
|
|
|
+ });
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
computed:{
|
|
@@ -239,4 +355,5 @@
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
@import './handleMonthly.scss';
|
|
|
+@import '../paymentMethod/paymentMethod.scss'
|
|
|
</style>
|