shish 2 years ago
parent
commit
e23b9bbc60
2 changed files with 47 additions and 9 deletions
  1. 4 0
      hdApp/src/api/purchase/index.js
  2. 43 9
      hdApp/src/pagesPurchase/wechatPay.vue

+ 4 - 0
hdApp/src/api/purchase/index.js

@@ -1,5 +1,9 @@
 import https from "@/plugins/luch-request_0.0.7/request";
 
+export const getAliPayCode = data => {
+	return https.get("/purchase/get-ali-pay-code", data);
+};
+
 export const saveCgPrice = data => {
 	return https.post("/cg-item/save-cg-price", data);
 };

+ 43 - 9
hdApp/src/pagesPurchase/wechatPay.vue

@@ -38,8 +38,13 @@
             <button v-if="getPayType == 1" class="button-com pay-wx" :class="[remainPayTime >0 ? 'green':'default']" :disabled="remainPayTime >0 ? false : true" @click="wxPayFn">微信支付</button>
             <button v-else class="button-com pay-wx" :class="[remainPayTime >0 ? 'green':'default']" :disabled="remainPayTime >0 ? false : true" @click="wxPayFnOld">微信支付</button>
           </view>
-          <button class="button-com pay-wx" :class="[remainPayTime >0 ? 'ali-btn':'default']" :disabled="remainPayTime >0 ? false : true" @click="appAliPayFn">支付宝支付</button>
           <button class="button-com pay-wx" :class="[remainPayTime >0 ? 'green':'default']" :disabled="remainPayTime >0 ? false : true" @click="debtPay" v-if="hasDebtPay === '1'">赊账</button>
+
+          <view style="margin-top:30upx;text-align: center;">
+            <image :src="aliPayCodeImg" mode="heightFix" style="width:300upx;height:300upx;margin:0 auto;"></image>
+            <view style="margin-top:10upx;font-size:26upx;">支付宝扫此二维码付款</view>
+          </view>
+          <button class="button-com ali-btn" @click="savePayCode" style="margin-top:10upx;">保存二维码</button>
         </div>
         <!-- #endif -->
         <!-- #ifdef APP-PLUS -->
@@ -71,6 +76,7 @@ import { mapGetters } from "vuex";
 import wexinPay from "@/utils/pay/wxPay";
 import { postWxCode } from '@/api/mini'
 import { updateMiniOpenId } from '@/api/admin'
+import { getAliPayCode } from '@/api/purchase'
 export default {
   name: "wechatPay",
   components: {
@@ -95,11 +101,13 @@ export default {
       getPayType:1,
       info:[],
       hasRequestApi:false,
-      needCheck:0
+      needCheck:0,
+      aliPayCodeImg:''
     };
   },
   onLoad (options) {
     this.id = options.id
+    this.aliPayCodeImg = `${this.$constant.imgUrl}/default-img.png`
   },
   computed: {
     ...mapGetters(["getLoginInfo"]),
@@ -115,6 +123,31 @@ export default {
     }
   },
   methods: {
+    savePayCode(){
+      let url = this.aliPayCodeImg
+      uni.downloadFile({
+        url: url,
+        success: (res) => {
+          if (res.statusCode === 200) {
+            uni.saveImageToPhotosAlbum({
+              filePath: res.tempFilePath,
+              success: function (data) {
+                uni.showToast({title:'下载成功'})
+              }
+            });
+          }
+        }
+      })
+    },
+    getAliPayCodeFn(orderSn){
+      getAliPayCode({orderSn:orderSn}).then(res=>{
+        if(res.code == 1){
+          if(res.data.imgUrl){
+            this.aliPayCodeImg = res.data.imgUrl
+          }
+        }
+      })
+    },
     init(){
       let that = this
       getDetail({id:this.option.id}).then(res=>{
@@ -135,6 +168,7 @@ export default {
               }
             },1000);
           }
+          that.getAliPayCodeFn(this.orderSn)
         }
       })
     },
@@ -157,8 +191,7 @@ export default {
     appAliPayFn(){
       let that = this
       // #ifdef MP-WEIXIN
-      this.$util.confirmModal({content:'支付宝付款,请到【应用市场】下载花掌柜,登录即可支付'},() => { })
-      return false
+
       // #endif
       // #ifdef APP-PLUS
       uni.showLoading()
@@ -241,7 +274,8 @@ export default {
                 if(res.code == 1){
                     this.pageId = res.data.id
                     this.orderSn = res.data.orderSn
-                    wexinPay(res.data, this.getSuccess, this.getError)                         
+                    wexinPay(res.data, this.getSuccess, this.getError)
+                    this.getAliPayCodeFn(this.orderSn)
                 }
               })
             }
@@ -382,17 +416,17 @@ export default {
       // 使用icon
       .icon {
         .iconfont {
-          font-size: 170upx;
+          font-size: 150upx;
         }
       }
       // 一个按钮
       .call-one-btn {
         .button-com {
           width: 80%;
-          padding-top: 32upx;
-          padding-bottom: 32upx;
+          padding-top:28upx;
+          padding-bottom:28upx;
           font-size: 33upx;
-          margin-top: 50upx;
+          margin-top:30upx;
         }
       }
     }