shish 1 год назад
Родитель
Сommit
b3ca8a3dcf

+ 1 - 0
hdApp/src/admin/billing/affirm.vue

@@ -116,6 +116,7 @@
 					<tui-list-cell class="line-cell" :hover="false" :arrow="false">
 						<view class="tui-title">结账方式</view>
 						<button @tap="form.hasPay = 1" class="admin-button-com middle" :class="form.hasPay == 1 ? 'blue' : 'default'">线下</button>
+            <button @click="form.hasPay = 0" class="admin-button-com middle" :class="form.hasPay == 0 ? 'blue' : 'default'">扫码付</button>
 						<button @click="form.hasPay = 2" class="admin-button-com middle" :class="form.hasPay == 2 ? 'blue' : 'default'">赊账</button>
 					</tui-list-cell>
 

+ 306 - 0
hdApp/src/admin/billing/toPay.vue

@@ -0,0 +1,306 @@
+<template>
+    <view class="app-content awaitPayYe awaitPayYe">
+    <view class="callback-wrap">
+      <view class="bg_01"></view>
+      <view class="callback-blo">
+        <block>
+          <view class="icon">
+            <i class="iconfont icondaizhifu"></i>
+          </view>
+        </block>
+        <view class="wait">待付款</view>
+        <block>
+          <view class="price">
+            <span class="app-size-36 app-bold">¥{{ parseFloat(actPrice)}}</span>
+          </view>
+        </block>
+        <view>
+          <view style="text-align:center;margin:10upx auto 10upx auto;">
+            <view class="balance" style="margin-bottom:25upx;" v-if="goPay == 0">请扫客户付款码</view>
+            <view class="balance" style="margin-bottom:25upx;" v-if="goPay == 1">请求中</view>
+            <view style="text-align:center;">
+              <image style="width:40upx;height:40upx;margin:0 auto;" :src="`${constant.imgUrl}/icon/loading.gif`" v-if="goPay == 1" mode="scaleToFill" />
+              <block v-if="goPay == 2">
+                <text style="color:red;font-weight:bold;font-size:28upx;">{{ remindText }}</text>
+                <view style="width:100%;text-align:center;" v-if="returnCode=='BBS11105' || returnCode=='BBS10000'">
+                  <button style="width:25vh;" class="admin-button-com big" @click="checkResult()">查询结果</button>
+                </view>
+              </block>
+            </view>
+            <view style="margin-top:20upx;">
+                <button style="width:25vh;" @click="beginScan()" class="admin-button-com big blue">点击扫码</button>
+            </view>
+            <view style="margin-top:20upx;">
+                <button style="width:25vh;" class="admin-button-com big blue" @click="gotoOrderDetail()">订单详情</button>
+            </view>
+            <view style="margin-top:20upx;">
+                <button style="width:25vh;" @click="changePayWay(2)" class="admin-button-com big default">记赊账</button>
+            </view>
+            <view style="margin-top:20upx;">
+                <button style="width:25vh;" @click="toCancel()" class="admin-button-com big default">取消</button>
+            </view>
+          </view>
+        </view>
+        <view style="margin-top:20upx;">
+            <button style="width:25vh;" @click="goBack()" class="admin-button-com big default">返回首页</button>
+        </view>
+        <view style="color:#CCCCCC;margin-top:20upx;">10分钟后未付款自动取消</view>
+      </view>
+    </view>
+  </view>
+</template>
+<script>
+import { cancel,debtPay,getDetail,codePay,codePayCheck} from "@/api/order";
+export default {
+  name: "toPay",
+  components: {
+  },
+  mixins: [],
+  computed: {},
+  data() {
+    return {
+      orderId:0,
+      actPrice:0,
+      orderSn:'',
+      showQrCode:false,
+      payQrCodeUrl:'',
+      payWay:0,
+      isCashier:false,
+      orderInfo:{orderType:0},
+      expire:0,
+      goPay:0,
+      textscan: '扫码',
+			typescan: 'scan-listener',
+      remindText:'',
+      returnCode:''
+    };
+  },
+  mounted() {
+  },
+	onUnload() {
+	},
+  onLoad(option) {
+    this.orderId = option.orderId
+    this.actPrice = option.actPrice
+    this.orderSn = option.orderSn
+    if(!this.$util.isEmpty(option.orderId)){
+      getDetail({ id: option.orderId }).then(res=>{
+        if(res.code == 1){
+          this.orderInfo = res.data
+        }
+      })
+    }
+
+    //在微信端,主动发起扫码
+    // #ifdef MP-WEIXIN
+    this.beginScan()
+    // #endif
+  },
+  methods: {
+    gotoOrderDetail() {
+      let id = this.option.orderId ? this.option.orderId : 0
+      this.$util.pageTo({url: "/admin/order/detail?id="+id,type:2})
+    },
+    beginScan(){
+      this.remindText = ''
+      this.returnCode = ''
+      // #ifdef MP-WEIXIN
+      this.toScan()
+      // #endif
+      // #ifdef APP-PLUS
+      let platformType = uni.getSystemInfoSync().platform
+      if(platformType == 'android'){
+        this.toScan()
+      }else if(platformType == 'ios'){
+        this.toScan()
+      }else{
+        this.$msg('系统错误')
+      }
+      // #endif
+    },
+    toScan(){
+      let that = this
+      uni.scanCode({
+        onlyFromCamera: true,
+        success: function (res) {
+          let payCode = res.result
+          let newPayCode = payCode.replace(/\s+/g, "")
+          if(that.$util.isEmpty(newPayCode)){
+          	that.$msg('没扫到,请重新扫哦')
+          	return false
+            return false
+          }
+          if(!that.isAllDigits(newPayCode)){
+            that.$msg('没扫到,请重新扫')
+            return false
+          }
+          that.requestCodePay(newPayCode)
+        }
+      })
+    },
+    isAllDigits(str) {
+      return /^\d+$/.test(str)
+    },
+    requestCodePay(authCode){
+        let that = this
+        this.goPay = 1
+        codePay({id:this.orderId,authCode:authCode}).then(res=>{
+            if(res.code == 1){
+                if(res.data.returnStatus == 'SUCCESS'){
+                    setTimeout(function(){
+                        that.payFinish()
+                    },1200)
+                }else{
+                  that.remindText = res.msg
+                  that.goPay = 2
+                  that.returnCode = res.data.returnCode ? res.data.returnCode : ''
+                }
+            }
+        })
+    },
+    init(){
+
+    },
+    payFinish(){
+      this.$util.pageTo({ url: '/admin/billing/result',type:2,query: {orderId:this.orderId}})
+    },
+    changePayWay(payWay){
+      this.payWay = payWay
+      let that = this
+      if(payWay == 2){
+        that.$util.confirmModal({content:'确认赊账?'},() => {
+            debtPay({id:this.orderId}).then(res=>{
+              if(res.code == 1){
+                that.$msg(res.msg)
+                setTimeout(function(){
+                  uni.navigateBack()
+                },1000)
+              }
+            })
+        })
+      }
+    },
+    checkResult(){
+      let that = this
+      uni.showLoading({mask:true})
+      getDetail({ id:this.orderId}).then(res=>{
+        uni.hideLoading()
+        if(res.code == 1){
+          if(res.data.payStatus == 1){
+            this.$msg('付款成功')
+            setTimeout(function(){
+                that.payFinish()
+            },1000)
+          }else{
+            this.$msg('没有付款成功')
+          }
+        }
+      })
+    },
+    goBack(){
+      uni.navigateBack()
+    },
+    toCancel(){
+      let that = this
+      let content = '确认取消?'
+      if(this.returnCode == 'BBS11105' || this.returnCode == 'BBS10000'){
+        content = '客户正在付款,提醒客户退出付款界面,再点确认'
+      }
+      that.$util.confirmModal({content:content,cancelText:'返回'},() => {
+          cancel({id:this.orderId}).then(res=>{
+            if(res.code == 1){
+              that.$msg(res.msg)
+              setTimeout(function(){
+                uni.navigateBack()
+              },1000)
+            }
+          })
+      })
+    }
+  },
+};
+</script>
+<style lang="scss" scoped>
+.app-content {
+  .callback-wrap {
+    padding-top: 30upx;
+    background-repeat: no-repeat;
+    background-size: 100% auto;
+    position: relative;
+    .bg_01 {
+      position: absolute;
+      top: 0;
+      left: 0;
+      /* 手机mobile屏幕小于1000px */
+      @media screen and (max-width: 1100px) {
+        width: 100vw;
+      }
+      /* 收银台cashier屏幕大于1000px */
+      @media screen and (min-width:1100px) {
+        width: 40vw;
+      }
+      height: 290upx;
+      background: #3385ff;
+      border-radius: 0upx 0upx 83upx 83upx;
+      z-index: 1;
+    }
+    .callback-blo {
+      position: absolute;
+      z-index: 9;
+      left: 50%;
+      transform: translateX(-50%);
+      width: 90%;
+      margin: 0 auto;
+      padding: 70upx 0;
+      background-color: #fff;
+      box-shadow: 2upx 2upx 16upx 0upx rgba(181, 181, 181, 0.29);
+      border-radius: 10upx;
+      text-align: center;
+      // 使用icon
+      .icon {
+        .iconfont {
+          font-size: 130upx;
+        }
+      }
+      // 一个按钮
+      .call-one-btn {
+        margin-top:50upx;
+        .mobile-scan{
+          color:#b3b1b1;
+          margin-top:30upx;
+          font-size:30upx;
+        }
+      }
+    }
+  }
+}
+// 待支付 - 公共
+.awaitPayWx,
+.awaitPayYe {
+  .status-text {
+    margin-top: 22upx;
+    margin-bottom: 52upx;
+    color: #ffa92e;
+  }
+  .surplus {
+    margin-top: 22upx;
+    margin-bottom: 38upx;
+  }
+  .icon {
+    .iconfont {
+      color: #ffa92e;
+    }
+  }
+}
+.wait {
+  color: #ffa92e;
+  font-size: 30upx;
+  font-weight: 700;
+  margin: 20upx 0;
+}
+.balance{
+  margin-top:30upx;
+  font-size:32upx;
+  font-weight: bold;
+}
+</style>

+ 6 - 0
hdApp/src/api/order/index.js

@@ -4,6 +4,12 @@ export const cancelOrder = data => {
 	return https.get("/order/cancel", data);
 };
 
+//微信和支付宝付款码支付
+export const codePay = data => https.get("/order/code-pay", data);
+
+//微信和支付宝付款码支付复查
+export const codePayCheck = data => https.get("/order/code-pay-check", data);
+
 export const updateOrder = data => {
 	return https.post("/order/update", data);
 };

+ 1 - 0
hdApp/src/pages.json

@@ -349,6 +349,7 @@
 				{ "path": "priceChange", "style": { "navigationBarTitleText": "改价", "enablePullDownRefresh": true } },
 				{ "path": "result", "style": { "navigationBarTitleText": "开单状态" } },
 				{ "path": "affirm", "style": { "navigationBarTitleText": "确认订单信息" } },
+				{ "path": "toPay", "style": { "navigationBarTitleText": "等待付款" } },
 				{ "path": "affirmGoods", "style": { "navigationBarTitleText": "确认订单信息" } },
 				{ "path": "affirmGhs", "style": { "navigationBarTitleText": "确认订单信息" } },
 				{ "path": "affirmGhsBook", "style": { "navigationBarTitleText": "确认订单信息" } },