|
@@ -45,7 +45,7 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="time_coupon">
|
|
<view class="time_coupon">
|
|
|
- <view class="select_coupon" @click="isSelectDate = true">
|
|
|
|
|
|
|
+ <view class="select_coupon" @click="onSelectTime">
|
|
|
<text>预约时间 <text class="red">*</text> </text>
|
|
<text>预约时间 <text class="red">*</text> </text>
|
|
|
<view class="right" v-if="preferential>0">-{{preferential}}元
|
|
<view class="right" v-if="preferential>0">-{{preferential}}元
|
|
|
<image src="/static/identify/more.png" mode="" />
|
|
<image src="/static/identify/more.png" mode="" />
|
|
@@ -130,352 +130,334 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <selectTime @dateSend="onSelect" v-if="isSelectDate" />
|
|
|
|
|
|
|
+ <ServiceTimePicker
|
|
|
|
|
+ ref="stp"
|
|
|
|
|
+ startHour="09:00"
|
|
|
|
|
+ endHour="21:00"
|
|
|
|
|
+ :duration="120"
|
|
|
|
|
+ :bookedTimes="bookedTimes"
|
|
|
|
|
+ @confirm="onTimeConfirm"
|
|
|
|
|
+ ></ServiceTimePicker>
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
- import wx from 'weixin-js-sdk'
|
|
|
|
|
- import selectTime from '@/components/date/select_time.vue'
|
|
|
|
|
- import {
|
|
|
|
|
- orderDeatails,
|
|
|
|
|
- getInfo,
|
|
|
|
|
- payoff,
|
|
|
|
|
- pay,
|
|
|
|
|
- getSignature,
|
|
|
|
|
- getCoupon,
|
|
|
|
|
- getFareSetting,
|
|
|
|
|
- verification
|
|
|
|
|
- } from '@/api/index.js'
|
|
|
|
|
- export default {
|
|
|
|
|
- components: {
|
|
|
|
|
- selectTime
|
|
|
|
|
- },
|
|
|
|
|
- data() {
|
|
|
|
|
- return {
|
|
|
|
|
- form: {
|
|
|
|
|
- dMoney: 0,
|
|
|
|
|
- cOpenId: uni.getStorageSync('wx_copenid'),
|
|
|
|
|
- },
|
|
|
|
|
- query: {},
|
|
|
|
|
- details: {},
|
|
|
|
|
- // 变量
|
|
|
|
|
- orderType: '',
|
|
|
|
|
- dBalance: 0, //账户余额
|
|
|
|
|
- dTotalMoney: 0,
|
|
|
|
|
- totalPrice: '', //总金额
|
|
|
|
|
- preferential: '', //优惠金额
|
|
|
|
|
- priceDifference: '', //升级差价
|
|
|
|
|
- // 交通费
|
|
|
|
|
- baseFare: '', //起步价
|
|
|
|
|
- baseDistance: '', //起步距离
|
|
|
|
|
- additionalFarePer: '', //超出费用
|
|
|
|
|
- // 优惠劵
|
|
|
|
|
- couponId: '',
|
|
|
|
|
- couponNum: 0,
|
|
|
|
|
- couponReceiveId: '', //优惠券id
|
|
|
|
|
- // 服务时间
|
|
|
|
|
- isSelectDate: false,
|
|
|
|
|
- // 支付计时
|
|
|
|
|
- remainingTime: '',
|
|
|
|
|
- // 支付方式
|
|
|
|
|
- selectedPayment: null,
|
|
|
|
|
|
|
+import wx from 'weixin-js-sdk';
|
|
|
|
|
+import ServiceTimePicker from '@/components/picker/service-time.vue';
|
|
|
|
|
+import {
|
|
|
|
|
+ orderDeatails,
|
|
|
|
|
+ getInfo,
|
|
|
|
|
+ payoff,
|
|
|
|
|
+ pay,
|
|
|
|
|
+ getSignature,
|
|
|
|
|
+ getCoupon,
|
|
|
|
|
+ getFareSetting,
|
|
|
|
|
+ verification
|
|
|
|
|
+} from '@/api/index.js';
|
|
|
|
|
+export default {
|
|
|
|
|
+ components: {
|
|
|
|
|
+ ServiceTimePicker
|
|
|
|
|
+ },
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ form: {
|
|
|
|
|
+ dMoney: 0,
|
|
|
|
|
+ cOpenId: uni.getStorageSync('wx_copenid'),
|
|
|
|
|
+ },
|
|
|
|
|
+ query: {},
|
|
|
|
|
+ details: {},
|
|
|
|
|
+ // 变量
|
|
|
|
|
+ orderType: '',
|
|
|
|
|
+ dBalance: 0, //账户余额
|
|
|
|
|
+ dTotalMoney: 0,
|
|
|
|
|
+ totalPrice: '', //总金额
|
|
|
|
|
+ preferential: '', //优惠金额
|
|
|
|
|
+ priceDifference: '', //升级差价
|
|
|
|
|
+ // 交通费
|
|
|
|
|
+ baseFare: '', //起步价
|
|
|
|
|
+ baseDistance: '', //起步距离
|
|
|
|
|
+ additionalFarePer: '', //超出费用
|
|
|
|
|
+ // 优惠劵
|
|
|
|
|
+ couponId: '',
|
|
|
|
|
+ couponNum: 0,
|
|
|
|
|
+ couponReceiveId: '', //优惠券id
|
|
|
|
|
+ // 服务时间
|
|
|
|
|
+ bookedTimes: [
|
|
|
|
|
+ // { start: '2026-01-03 19:00', end: '2026-01-03 20:00' }
|
|
|
|
|
+ ],
|
|
|
|
|
+ // 支付计时
|
|
|
|
|
+ remainingTime: '',
|
|
|
|
|
+ // 支付方式
|
|
|
|
|
+ selectedPayment: null,
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ onLoad(query) {
|
|
|
|
|
+ this.query = query;
|
|
|
|
|
+
|
|
|
|
|
+ wx.checkJsApi({
|
|
|
|
|
+ jsApiList: ['chooseImage'],
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ // 以键值对的形式返回,可用的api值true,不可用为false
|
|
|
|
|
+ // 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
|
|
|
}
|
|
}
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ onShow() {
|
|
|
|
|
+ this.getInfo()
|
|
|
|
|
+ this.getOrder()
|
|
|
|
|
+ this.getCoupon()
|
|
|
|
|
+
|
|
|
|
|
+ let couponData = uni.getStorageSync('couponData');
|
|
|
|
|
+ if (couponData) {
|
|
|
|
|
+ this.couponId = couponData.id
|
|
|
|
|
+ this.verification()
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ getInfo() {
|
|
|
|
|
+ getInfo().then(res => {
|
|
|
|
|
+ this.dBalance = res.data.data.dBalance.toFixed(2)
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
- onLoad(query) {
|
|
|
|
|
- this.query = query;
|
|
|
|
|
-
|
|
|
|
|
- wx.checkJsApi({
|
|
|
|
|
- jsApiList: ['chooseImage'],
|
|
|
|
|
- success: (res) => {
|
|
|
|
|
- // 以键值对的形式返回,可用的api值true,不可用为false
|
|
|
|
|
- // 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
|
|
|
|
|
|
|
+ getCoupon() {
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ openid: uni.getStorageSync('wx_copenid')
|
|
|
|
|
+ }
|
|
|
|
|
+ getCoupon(params).then(res => {
|
|
|
|
|
+ if (res.data.data.length > 0) {
|
|
|
|
|
+ this.couponNum = res.data.data.length
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.couponNum = 0
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
- onShow() {
|
|
|
|
|
- this.getInfo()
|
|
|
|
|
- this.getOrder()
|
|
|
|
|
- this.getCoupon()
|
|
|
|
|
-
|
|
|
|
|
- let couponData = uni.getStorageSync('couponData');
|
|
|
|
|
- if (couponData) {
|
|
|
|
|
- this.couponId = couponData.id
|
|
|
|
|
- this.verification()
|
|
|
|
|
|
|
+ getOrder() {
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ orderNo: this.query.orderNo,
|
|
|
|
|
+ couponReceiveId: this.couponId
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- methods: {
|
|
|
|
|
- getInfo() {
|
|
|
|
|
- getInfo().then(res => {
|
|
|
|
|
- this.dBalance = res.data.data.dBalance.toFixed(2)
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- getCoupon() {
|
|
|
|
|
- let params = {
|
|
|
|
|
- openid: uni.getStorageSync('wx_copenid')
|
|
|
|
|
- }
|
|
|
|
|
- getCoupon(params).then(res => {
|
|
|
|
|
- if (res.data.data.length > 0) {
|
|
|
|
|
- this.couponNum = res.data.data.length
|
|
|
|
|
- } else {
|
|
|
|
|
- this.couponNum = 0
|
|
|
|
|
|
|
+ orderDeatails(params).then(res => {
|
|
|
|
|
+ console.log(res)
|
|
|
|
|
+ if (res.data.code === 200) {
|
|
|
|
|
+ this.details = {
|
|
|
|
|
+ ...res.data.data.records[0],
|
|
|
|
|
+ distance: res.data.data.records[0].distance.toFixed(2)
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- getOrder() {
|
|
|
|
|
- let params = {
|
|
|
|
|
- orderNo: this.query.orderNo,
|
|
|
|
|
- couponReceiveId: this.couponId
|
|
|
|
|
|
|
+ // 这四个值相关 orderType 2: 现金
|
|
|
|
|
+ this.orderType = this.details.orderType;
|
|
|
|
|
+ this.totalPrice = this.details.totalPrice;
|
|
|
|
|
+ this.dTotalMoney = this.details.dTotalMoney;
|
|
|
|
|
+ this.priceDifference = this.details.priceDifference;
|
|
|
|
|
+ // 支付倒计时
|
|
|
|
|
+ this.remainingTime = res.data.data.records[0].remainingTime;
|
|
|
|
|
+ // 获取部门车费
|
|
|
|
|
+ this.fareSetting(res.data.data.records[0].deptId);
|
|
|
}
|
|
}
|
|
|
- orderDeatails(params).then(res => {
|
|
|
|
|
- console.log(res)
|
|
|
|
|
- if (res.data.code === 200) {
|
|
|
|
|
- this.details = {
|
|
|
|
|
- ...res.data.data.records[0],
|
|
|
|
|
- distance: res.data.data.records[0].distance.toFixed(2)
|
|
|
|
|
- }
|
|
|
|
|
- // 这四个值相关 orderType 2: 现金
|
|
|
|
|
- this.orderType = this.details.orderType;
|
|
|
|
|
- this.totalPrice = this.details.totalPrice;
|
|
|
|
|
- this.dTotalMoney = this.details.dTotalMoney;
|
|
|
|
|
- this.priceDifference = this.details.priceDifference;
|
|
|
|
|
- // 支付倒计时
|
|
|
|
|
- this.remainingTime = res.data.data.records[0].remainingTime;
|
|
|
|
|
- // 获取部门车费
|
|
|
|
|
- this.fareSetting(res.data.data.records[0].deptId);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ // 获取部门车费
|
|
|
|
|
+ fareSetting(id) {
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ deptId: id,
|
|
|
|
|
+ enable: 1
|
|
|
|
|
+ }
|
|
|
|
|
+ getFareSetting(params).then(res => {
|
|
|
|
|
+ this.baseFare = res.data.data.records[0].baseFare
|
|
|
|
|
+ this.baseDistance = res.data.data.records[0].baseDistance
|
|
|
|
|
+ this.additionalFarePer = res.data.data.records[0].additionalFarePer
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ // 服务时间
|
|
|
|
|
+ onSelectTime() {
|
|
|
|
|
+ this.$refs.stp.show = true;
|
|
|
|
|
+ },
|
|
|
|
|
+ onTimeConfirm(e) {
|
|
|
|
|
+ console.log(e)
|
|
|
|
|
+ },
|
|
|
|
|
+ onRefresh() {
|
|
|
|
|
+ this.remainingTime = 0
|
|
|
|
|
+ },
|
|
|
|
|
+ selectCoupon() {
|
|
|
|
|
+ if (this.remainingTime > 0) {
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: '/pages/my/coupon?title=select'
|
|
|
})
|
|
})
|
|
|
- },
|
|
|
|
|
- // 获取部门车费
|
|
|
|
|
- fareSetting(id) {
|
|
|
|
|
- let params = {
|
|
|
|
|
- deptId: id,
|
|
|
|
|
- enable: 1
|
|
|
|
|
- }
|
|
|
|
|
- getFareSetting(params).then(res => {
|
|
|
|
|
- this.baseFare = res.data.data.records[0].baseFare
|
|
|
|
|
- this.baseDistance = res.data.data.records[0].baseDistance
|
|
|
|
|
- this.additionalFarePer = res.data.data.records[0].additionalFarePer
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '已过期,请重新下单',
|
|
|
|
|
+ icon: 'none'
|
|
|
})
|
|
})
|
|
|
- },
|
|
|
|
|
- onSelect(e) {
|
|
|
|
|
- console.log(e)
|
|
|
|
|
- this.isSelectDate = false
|
|
|
|
|
- },
|
|
|
|
|
- onRefresh() {
|
|
|
|
|
- this.remainingTime = 0
|
|
|
|
|
- },
|
|
|
|
|
- selectCoupon() {
|
|
|
|
|
- if (this.remainingTime > 0) {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '/pages/my/coupon?title=select'
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '已过期,请重新下单',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- changeAddress(id) {
|
|
|
|
|
- let str = uni.$u.queryParams({
|
|
|
|
|
- name: '支付订单',
|
|
|
|
|
- orderNo: id
|
|
|
|
|
- });
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: `/pages/address/index${str}`
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ changeAddress(id) {
|
|
|
|
|
+ let str = uni.$u.queryParams({
|
|
|
|
|
+ name: '支付订单',
|
|
|
|
|
+ orderNo: id
|
|
|
|
|
+ });
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: `/pages/address/index${str}`
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ //选择支付方式
|
|
|
|
|
+ onRadioChange(e) {
|
|
|
|
|
+ this.selectedPayment = e.target.value
|
|
|
|
|
+ },
|
|
|
|
|
+ // 支付
|
|
|
|
|
+ goPay() {
|
|
|
|
|
+ this.form.dMoney = this.totalPrice
|
|
|
|
|
+ if (this.remainingTime == 0) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '订单已过期',
|
|
|
|
|
+ icon: 'none'
|
|
|
})
|
|
})
|
|
|
- },
|
|
|
|
|
- //选择支付方式
|
|
|
|
|
- onRadioChange(e) {
|
|
|
|
|
- this.selectedPayment = e.target.value
|
|
|
|
|
- },
|
|
|
|
|
- // 支付
|
|
|
|
|
- goPay() {
|
|
|
|
|
- this.form.dMoney = this.totalPrice
|
|
|
|
|
- if (this.remainingTime == 0) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '订单已过期',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- })
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (this.selectedPayment == null) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '请选择支付方式',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- })
|
|
|
|
|
- } else if (this.selectedPayment == 1) {
|
|
|
|
|
- //微信支付
|
|
|
|
|
- this.weixinPay()
|
|
|
|
|
- } else if (this.selectedPayment == 2) {
|
|
|
|
|
- //余额支付
|
|
|
|
|
- this.nowYuyue()
|
|
|
|
|
- } else if (this.selectedPayment == 3){
|
|
|
|
|
- this.rmbPay()
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- //微信支付
|
|
|
|
|
- weixinPay() {
|
|
|
|
|
- let params = {
|
|
|
|
|
- cId: this.details.cId,
|
|
|
|
|
- payType: this.selectedPayment,
|
|
|
|
|
- couponReceiveId: this.couponReceiveId,
|
|
|
|
|
- preferential: this.preferential, //优惠金额
|
|
|
|
|
- totalPrice: this.totalPrice, //总金额
|
|
|
|
|
- }
|
|
|
|
|
- let url = 'https://test.baoxianzhanggui.com/fragrance/'
|
|
|
|
|
- payoff(params).then(res => {
|
|
|
|
|
- let payConfig = JSON.parse(res.data.data)
|
|
|
|
|
- getSignature(url).then(res => {
|
|
|
|
|
- this.wxconfig = res.data
|
|
|
|
|
- wx.config({
|
|
|
|
|
- beta: true,
|
|
|
|
|
- debug: false,
|
|
|
|
|
- appId: this.wxconfig.appId, // 公众号ID
|
|
|
|
|
- // appId: uni.getAppBaseInfo().host.appId, // 公众号ID
|
|
|
|
|
- timestamp: this.wxconfig.timestamp, // 时间戳,自1970年以来的秒数
|
|
|
|
|
- nonceStr: this.wxconfig.nonceStr, // 随机串
|
|
|
|
|
- signature: this.wxconfig.sign, // 微信签名方式
|
|
|
|
|
- jsApiList: ['getBrandWCPayRequest']
|
|
|
|
|
- });
|
|
|
|
|
- var vm = this
|
|
|
|
|
- wx.invoke(
|
|
|
|
|
- 'getBrandWCPayRequest',
|
|
|
|
|
- // 下面参数内容都是后台返回的
|
|
|
|
|
- {
|
|
|
|
|
- 'appId': payConfig.appid, // 公众号名称,由商户传入
|
|
|
|
|
- 'timeStamp': payConfig.timeStamp, // 时间戳
|
|
|
|
|
- 'nonceStr': payConfig.nonceStr, // 随机串
|
|
|
|
|
- 'package': payConfig.package, // 预支付id
|
|
|
|
|
- 'signType': payConfig.signType, // 微信签名方式
|
|
|
|
|
- 'paySign': payConfig.paySign, // 微信签名
|
|
|
|
|
- },
|
|
|
|
|
- function(res) {
|
|
|
|
|
- // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
|
|
|
|
-
|
|
|
|
|
- // JSON.stringify(res);
|
|
|
|
|
- if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
|
|
|
-
|
|
|
|
|
- vm.$message.success(
|
|
|
|
|
- "支付成功") // 使用alert来弹窗 支付成功 是没有反应的。所以这里改为框架页面的弹窗就好了。注意必须要上这个微信浏览器内置事件外 转this指向才能弹窗
|
|
|
|
|
- // vm.isDisabledSubmitBtn = false;
|
|
|
|
|
- uni.switchTab({
|
|
|
|
|
- url: '../order/order',
|
|
|
|
|
- })
|
|
|
|
|
- } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '已取消支付',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- })
|
|
|
|
|
- // alert('支付取消');
|
|
|
|
|
- // vm.isDisabledSubmitBtn = false;
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- alert('付款失败');
|
|
|
|
|
- // vm.isDisabledSubmitBtn = false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.selectedPayment == null) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '请选择支付方式',
|
|
|
|
|
+ icon: 'none'
|
|
|
})
|
|
})
|
|
|
- },
|
|
|
|
|
- //拉取微信支付的方法
|
|
|
|
|
- pullWchatPay(data) {
|
|
|
|
|
- var that = this;
|
|
|
|
|
- let onBridgeReady = () => {
|
|
|
|
|
- if (WeixinJSBridge && appId) {
|
|
|
|
|
- WeixinJSBridge.invoke(
|
|
|
|
|
- 'getBrandWCPayRequest', {
|
|
|
|
|
- appId: data.appId,
|
|
|
|
|
- nonceStr: data.nonceStr,
|
|
|
|
|
- package: data.package,
|
|
|
|
|
- paySign: data.paySign,
|
|
|
|
|
- signType: data.signType,
|
|
|
|
|
- timeStamp: data.timeStamp
|
|
|
|
|
- },
|
|
|
|
|
- function(res) {
|
|
|
|
|
- console.log('调起支付时的警告');
|
|
|
|
|
- if (res.err_msg === 'get_brand_wcpay_request:ok') {
|
|
|
|
|
- _this.payType = 0;
|
|
|
|
|
- console.log('支付成功回调')
|
|
|
|
|
- } else {
|
|
|
|
|
- console.log('支付失败')
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // 检测支付环境中的 WeixinJSBridge
|
|
|
|
|
- if (typeof WeixinJSBridge == "undefined") {
|
|
|
|
|
- if (document.addEventListener) {
|
|
|
|
|
- //android机型,调取支付支付环境偶尔有延迟,这里增加延时器处理
|
|
|
|
|
- var timev = setTimeout(() => {
|
|
|
|
|
- clearTimeout(timev)
|
|
|
|
|
- document.addEventListener('WeixinJSBridgeReady', onBridgeReady(),
|
|
|
|
|
- false);
|
|
|
|
|
- }, 1000)
|
|
|
|
|
- } else if (document.attachEvent) {
|
|
|
|
|
- document.attachEvent('WeixinJSBridgeReady', onBridgeReady());
|
|
|
|
|
- document.attachEvent('onWeixinJSBridgeReady', onBridgeReady());
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- onBridgeReady();
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- //账号余额支付
|
|
|
|
|
- nowYuyue() {
|
|
|
|
|
- if (parseInt(this.dBalance) < parseInt(this.totalPrice)) {
|
|
|
|
|
- uni.showModal({
|
|
|
|
|
- title: '账户余额不足',
|
|
|
|
|
- content: '请充值',
|
|
|
|
|
- success: function(res) {
|
|
|
|
|
- if (res.confirm) {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '../my/pay?name=充值'
|
|
|
|
|
- })
|
|
|
|
|
- } else if (res.cancel) {}
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ } else if (this.selectedPayment == 1) {
|
|
|
|
|
+ //微信支付
|
|
|
|
|
+ this.weixinPay()
|
|
|
|
|
+ } else if (this.selectedPayment == 2) {
|
|
|
|
|
+ //余额支付
|
|
|
|
|
+ this.nowYuyue()
|
|
|
|
|
+ } else if (this.selectedPayment == 3){
|
|
|
|
|
+ this.rmbPay()
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ //微信支付
|
|
|
|
|
+ weixinPay() {
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ cId: this.details.cId,
|
|
|
|
|
+ payType: this.selectedPayment,
|
|
|
|
|
+ couponReceiveId: this.couponReceiveId,
|
|
|
|
|
+ preferential: this.preferential, //优惠金额
|
|
|
|
|
+ totalPrice: this.totalPrice, //总金额
|
|
|
|
|
+ }
|
|
|
|
|
+ let url = 'https://test.baoxianzhanggui.com/fragrance/'
|
|
|
|
|
+ payoff(params).then(res => {
|
|
|
|
|
+ let payConfig = JSON.parse(res.data.data)
|
|
|
|
|
+ getSignature(url).then(res => {
|
|
|
|
|
+ this.wxconfig = res.data
|
|
|
|
|
+ wx.config({
|
|
|
|
|
+ beta: true,
|
|
|
|
|
+ debug: false,
|
|
|
|
|
+ appId: this.wxconfig.appId, // 公众号ID
|
|
|
|
|
+ // appId: uni.getAppBaseInfo().host.appId, // 公众号ID
|
|
|
|
|
+ timestamp: this.wxconfig.timestamp, // 时间戳,自1970年以来的秒数
|
|
|
|
|
+ nonceStr: this.wxconfig.nonceStr, // 随机串
|
|
|
|
|
+ signature: this.wxconfig.sign, // 微信签名方式
|
|
|
|
|
+ jsApiList: ['getBrandWCPayRequest']
|
|
|
});
|
|
});
|
|
|
- } else {
|
|
|
|
|
- var data = {
|
|
|
|
|
- cId: this.details.cId,
|
|
|
|
|
- payType: this.selectedPayment,
|
|
|
|
|
- couponReceiveId: this.couponReceiveId,
|
|
|
|
|
- preferential: this.preferential, //优惠金额
|
|
|
|
|
- totalPrice: this.totalPrice, //总金额
|
|
|
|
|
- }
|
|
|
|
|
- payoff(data).then(res => {
|
|
|
|
|
- if (res.data.code == 200) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '支付成功!',
|
|
|
|
|
- })
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
|
|
+ var vm = this
|
|
|
|
|
+ wx.invoke(
|
|
|
|
|
+ 'getBrandWCPayRequest',
|
|
|
|
|
+ // 下面参数内容都是后台返回的
|
|
|
|
|
+ {
|
|
|
|
|
+ 'appId': payConfig.appid, // 公众号名称,由商户传入
|
|
|
|
|
+ 'timeStamp': payConfig.timeStamp, // 时间戳
|
|
|
|
|
+ 'nonceStr': payConfig.nonceStr, // 随机串
|
|
|
|
|
+ 'package': payConfig.package, // 预支付id
|
|
|
|
|
+ 'signType': payConfig.signType, // 微信签名方式
|
|
|
|
|
+ 'paySign': payConfig.paySign, // 微信签名
|
|
|
|
|
+ },
|
|
|
|
|
+ function(res) {
|
|
|
|
|
+ // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
|
|
|
|
+
|
|
|
|
|
+ // JSON.stringify(res);
|
|
|
|
|
+ if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
|
|
|
+
|
|
|
|
|
+ vm.$message.success(
|
|
|
|
|
+ "支付成功") // 使用alert来弹窗 支付成功 是没有反应的。所以这里改为框架页面的弹窗就好了。注意必须要上这个微信浏览器内置事件外 转this指向才能弹窗
|
|
|
|
|
+ // vm.isDisabledSubmitBtn = false;
|
|
|
uni.switchTab({
|
|
uni.switchTab({
|
|
|
url: '../order/order',
|
|
url: '../order/order',
|
|
|
})
|
|
})
|
|
|
- }, 2000)
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- icon: 'error',
|
|
|
|
|
- title: res.data.msg,
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '已取消支付',
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ // alert('支付取消');
|
|
|
|
|
+ // vm.isDisabledSubmitBtn = false;
|
|
|
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ alert('付款失败');
|
|
|
|
|
+ // vm.isDisabledSubmitBtn = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ //拉取微信支付的方法
|
|
|
|
|
+ pullWchatPay(data) {
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ let onBridgeReady = () => {
|
|
|
|
|
+ if (WeixinJSBridge && appId) {
|
|
|
|
|
+ WeixinJSBridge.invoke(
|
|
|
|
|
+ 'getBrandWCPayRequest', {
|
|
|
|
|
+ appId: data.appId,
|
|
|
|
|
+ nonceStr: data.nonceStr,
|
|
|
|
|
+ package: data.package,
|
|
|
|
|
+ paySign: data.paySign,
|
|
|
|
|
+ signType: data.signType,
|
|
|
|
|
+ timeStamp: data.timeStamp
|
|
|
|
|
+ },
|
|
|
|
|
+ function(res) {
|
|
|
|
|
+ console.log('调起支付时的警告');
|
|
|
|
|
+ if (res.err_msg === 'get_brand_wcpay_request:ok') {
|
|
|
|
|
+ _this.payType = 0;
|
|
|
|
|
+ console.log('支付成功回调')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('支付失败')
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- //现金支付
|
|
|
|
|
- rmbPay(){
|
|
|
|
|
- let params = {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ // 检测支付环境中的 WeixinJSBridge
|
|
|
|
|
+ if (typeof WeixinJSBridge == "undefined") {
|
|
|
|
|
+ if (document.addEventListener) {
|
|
|
|
|
+ //android机型,调取支付支付环境偶尔有延迟,这里增加延时器处理
|
|
|
|
|
+ var timev = setTimeout(() => {
|
|
|
|
|
+ clearTimeout(timev)
|
|
|
|
|
+ document.addEventListener('WeixinJSBridgeReady', onBridgeReady(),
|
|
|
|
|
+ false);
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+ } else if (document.attachEvent) {
|
|
|
|
|
+ document.attachEvent('WeixinJSBridgeReady', onBridgeReady());
|
|
|
|
|
+ document.attachEvent('onWeixinJSBridgeReady', onBridgeReady());
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ onBridgeReady();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ //账号余额支付
|
|
|
|
|
+ nowYuyue() {
|
|
|
|
|
+ if (parseInt(this.dBalance) < parseInt(this.totalPrice)) {
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ title: '账户余额不足',
|
|
|
|
|
+ content: '请充值',
|
|
|
|
|
+ success: function(res) {
|
|
|
|
|
+ if (res.confirm) {
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: '../my/pay?name=充值'
|
|
|
|
|
+ })
|
|
|
|
|
+ } else if (res.cancel) {}
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ var data = {
|
|
|
cId: this.details.cId,
|
|
cId: this.details.cId,
|
|
|
payType: this.selectedPayment,
|
|
payType: this.selectedPayment,
|
|
|
couponReceiveId: this.couponReceiveId,
|
|
couponReceiveId: this.couponReceiveId,
|
|
|
preferential: this.preferential, //优惠金额
|
|
preferential: this.preferential, //优惠金额
|
|
|
totalPrice: this.totalPrice, //总金额
|
|
totalPrice: this.totalPrice, //总金额
|
|
|
}
|
|
}
|
|
|
- payoff(params).then(res => {
|
|
|
|
|
|
|
+ payoff(data).then(res => {
|
|
|
if (res.data.code == 200) {
|
|
if (res.data.code == 200) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '支付成功!',
|
|
title: '支付成功!',
|
|
@@ -491,28 +473,57 @@
|
|
|
title: res.data.msg,
|
|
title: res.data.msg,
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
- },
|
|
|
|
|
- verification() {
|
|
|
|
|
- let params = {
|
|
|
|
|
- cId: this.details.cId,
|
|
|
|
|
- couponReceiveId: this.couponId
|
|
|
|
|
- }
|
|
|
|
|
- verification(params).then(res => {
|
|
|
|
|
- if (res.data.msg == '不满足优惠券门槛金额') {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: res.data.msg,
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ //现金支付
|
|
|
|
|
+ rmbPay(){
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ cId: this.details.cId,
|
|
|
|
|
+ payType: this.selectedPayment,
|
|
|
|
|
+ couponReceiveId: this.couponReceiveId,
|
|
|
|
|
+ preferential: this.preferential, //优惠金额
|
|
|
|
|
+ totalPrice: this.totalPrice, //总金额
|
|
|
|
|
+ }
|
|
|
|
|
+ payoff(params).then(res => {
|
|
|
|
|
+ if (res.data.code == 200) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '支付成功!',
|
|
|
|
|
+ })
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ uni.switchTab({
|
|
|
|
|
+ url: '../order/order',
|
|
|
})
|
|
})
|
|
|
- }
|
|
|
|
|
- this.couponReceiveId = res.data.data.couponReceiveId
|
|
|
|
|
- this.preferential = res.data.data.preferential
|
|
|
|
|
- this.totalPrice = res.data.data.totalPrice
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }, 2000)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ icon: 'error',
|
|
|
|
|
+ title: res.data.msg,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ verification() {
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ cId: this.details.cId,
|
|
|
|
|
+ couponReceiveId: this.couponId
|
|
|
|
|
+ }
|
|
|
|
|
+ verification(params).then(res => {
|
|
|
|
|
+ if (res.data.msg == '不满足优惠券门槛金额') {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: res.data.msg,
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ this.couponReceiveId = res.data.data.couponReceiveId
|
|
|
|
|
+ this.preferential = res.data.data.preferential
|
|
|
|
|
+ this.totalPrice = res.data.data.totalPrice
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|