| | |
| | | </view> |
| | | </view> |
| | | </block> |
| | | <button class="pay-it" @click="pay">付款</button> |
| | | <button class="pay-it" @click="checkLocation">付款</button> |
| | | <view v-if="bordShow" style="height: 470rpx"></view> |
| | | <!-- 数字键盘 --> |
| | | <u-popup zIndex="500" :show="bordShow" :overlay="false" @close="bordShow = false"> |
| | | <key-bord @changeMoney="changeMoney" :num.sync="money" @close="bordShow = false" @pay="pay"></key-bord> |
| | | <key-bord @changeMoney="changeMoney" :num.sync="money" @close="bordShow = false" @pay="checkLocation"></key-bord> |
| | | </u-popup> |
| | | <!-- 优惠券弹窗 --> |
| | | <u-popup v-if="payWay==2" mode="bottom" :closeable="true" :show="couponShow" @close="couponShow = false" :round="10"> |
| | |
| | | <script> |
| | | import { |
| | | config, |
| | | ACCESSTOKEN |
| | | ACCESSTOKEN, |
| | | CHECK_LOCATION |
| | | } from 'common/config.js'; |
| | | import { |
| | | queryShopByCid, |
| | |
| | | saveOrder, |
| | | } from 'common/api/index' |
| | | |
| | | import wx from 'weixin-js-sdk'; |
| | | import {accMul, fenToYuan} from 'common/util' // 使用js-sdk |
| | | import wx from 'weixin-js-sdk'; // 使用js-sdk |
| | | |
| | | export default { |
| | | data() { |
| | |
| | | useScoreFlag: -1, //商铺是否可用积分 0否 1是 |
| | | userCouponFlag: -1, //商铺是否可用优惠券 0否 1是 |
| | | }, |
| | | lat: '', //纬度 |
| | | lng: '', //经度 |
| | | money: '', // 金额 |
| | | token: null, |
| | | isNew: false, // 是否新用户,新用户查询不到积分和银行卡 |
| | |
| | | return 0 |
| | | } |
| | | if (this.checkCoupon.discountType == 1) { |
| | | const num = this.$utils.fenToYuan(this.couponInfo.discount) |
| | | const num = this.$utils.fenToYuan(this.checkCoupon.discount) |
| | | return parseFloat(num); |
| | | } |
| | | const dis = 1 - parseFloat(this.checkCoupon.discount) |
| | |
| | | timestamp: res.timestamp, // 必填,生成签名的时间戳 |
| | | nonceStr: res.noncestr, // 必填,生成签名的随机串 |
| | | signature: res.signature, // 必填,签名 |
| | | jsApiList: ['hideAllNonBaseMenuItem'], // 必填,需要使用的JS接口列表 |
| | | jsApiList: ['hideAllNonBaseMenuItem','getLocation'], // 必填,需要使用的JS接口列表 |
| | | openTagList: ['wx-open-launch-weapp'] //可选,需要使用的开放标签列表 |
| | | }); |
| | | wx.ready(function () { |
| | | wx.ready( ()=> { |
| | | wx.hideAllNonBaseMenuItem(); |
| | | if(CHECK_LOCATION){ |
| | | this.wxGetLocation() |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }, |
| | | wxGetLocation(callback){ |
| | | wx.getLocation({ |
| | | type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02' |
| | | complete: (res)=> { |
| | | if(res.errMsg==="getLocation:ok"){ |
| | | this.lat = parseFloat(res.latitude).toFixed(6); // 纬度,浮点数,范围为90 ~ -90 |
| | | this.lng = parseFloat(res.longitude).toFixed(6); // 经度,浮点数,范围为180 ~ -180。 |
| | | if(callback) callback() |
| | | }else{ |
| | | uni.showModal({ |
| | | title: '提示', |
| | | content: "获取地理位置失败,无法进行支付!", |
| | | confirmText: '重新授权', |
| | | cancelText: '退出', |
| | | success: ret=>{ |
| | | if(ret.confirm){ |
| | | this.wxGetLocation() |
| | | }else{ |
| | | this.clickDone() |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | } |
| | | }); |
| | | }, |
| | | // 获取会员相关信息 |
| | | showCoupon() { |
| | | if (this.UNIONID) { |
| | | if (this.UNIONID||this.payWay==5) { |
| | | if (uni.$u.test.isEmpty(this.money)) { |
| | | uni.$u.toast('请输入金额!') |
| | | return |
| | |
| | | }, |
| | | //获取用户优惠券 |
| | | queryUseSweepPayCoupon() { |
| | | const applyPayWayStr = { |
| | | 2: 1, |
| | | 5: 2, |
| | | 15: 3 |
| | | } |
| | | queryUseSweepPayCoupon({ |
| | | params: { |
| | | score: 0, |
| | | applyPayWayStr: this.payWay, |
| | | applyPayWayStr: applyPayWayStr[this.payWay], |
| | | cusid: this.shopInfo.id, |
| | | money: this.$utils.accMul(this.money,100), |
| | | } |
| | |
| | | this.couponInfo = this.checkCoupon; |
| | | this.couponShow = false; |
| | | }, |
| | | checkLocation(){ |
| | | if(!CHECK_LOCATION){ |
| | | this.pay() |
| | | return |
| | | } |
| | | if (uni.$u.test.isEmpty(this.money)) { |
| | | uni.$u.toast('请输入金额!') |
| | | return |
| | | } |
| | | if(!this.lat){ |
| | | this.wxGetLocation(this.pay) |
| | | }else{ |
| | | this.pay() |
| | | } |
| | | }, |
| | | //确认支付 |
| | | pay() { |
| | | if (uni.$u.test.isEmpty(this.money)) { |
| | |
| | | payWay: this.payWay, |
| | | buyerNote: this.buyerNote, |
| | | score: 0, |
| | | couponDetailId: this.couponInfo.id |
| | | couponDetailId: this.couponInfo.id, |
| | | lat: this.lat, |
| | | lng: this.lng |
| | | } |
| | | if (this.activityQrcodeId) { |
| | | params.activityQrcodeId = this.activityQrcodeId |