Browse Source

2024.07.18
- 商家收款码页增加更新收款码功能;

zweiqin 8 months ago
parent
commit
39d342396f
3 changed files with 34 additions and 6 deletions
  1. 1 0
      .eslintignore
  2. 10 3
      src/api/shop.js
  3. 23 3
      src/views/shop/paymentCode/index.vue

+ 1 - 0
.eslintignore

@@ -3,3 +3,4 @@ src/assets
 public
 dist
 canvas-container
+src/views/shop/paymentCode

+ 10 - 3
src/api/shop.js

@@ -82,7 +82,7 @@ export function updateSource(data) {
   })
 }
 
-export const copy = msg => {
+export const copy = (msg) => {
   if (msg) {
     const oInput = document.createElement('input') // 创建一个隐藏input(重要!)
     oInput.value = msg // 赋值
@@ -94,7 +94,6 @@ export const copy = msg => {
   }
 }
 
-
 //  生成商家二维码
 export function getQrcode(data) {
   return request({
@@ -102,4 +101,12 @@ export function getQrcode(data) {
     method: 'post',
     data
   })
-}
+}
+// 更新收款码
+export function updatePaymentCodeGenerate(data) {
+  return request({
+    url: '/paymentCode/updateGenerateCode',
+    method: 'post',
+    data
+  })
+}

+ 23 - 3
src/views/shop/paymentCode/index.vue

@@ -27,7 +27,10 @@
                 </div>
                 <div class="open-text">打开微信扫一扫可付款</div>
             </div>
-            <div class="paymentCode-btn" @click="downloadCode">下载收款码</div>
+						<div style="display: flex;align-items: center;justify-content: space-between;">
+							<div class="paymentCode-btn" @click="downloadCode">下载收款码</div>
+							<div v-if="codeInfo.codeId" class="paymentCode-btn" @click="handleRenewCode">更新收款码</div>
+						</div>
         </div>
         <div class="paymentCode-right">
             <div class="paymentCode-explain">
@@ -50,7 +53,7 @@
 </template>
 
 <script>
-import { getQrcode } from "@/api/shop"
+import { getQrcode, updatePaymentCodeGenerate } from "@/api/shop"
 import html2canvas from 'html2canvas'
 export default {
     created() {
@@ -135,6 +138,22 @@ export default {
                 });
             });
         },
+        handleRenewCode() {
+            this.$confirm('您确定需要更新商家二维码吗?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(async () => {
+							await updatePaymentCodeGenerate({ codeId: this.codeInfo.codeId })
+        			this.generateCode()
+          		this.$message({ message: '操作成功!', type: 'success' })
+            }).catch(() => {
+                this.$message({
+                    type: 'info',
+                    message: '取消更新成功'
+                });
+            });
+        },
         //  设置图片大小
         setImgSize(width, height) {
             const canvas = document.createElement('canvas')
@@ -287,8 +306,9 @@ img {
         }
 
         .paymentCode-btn {
-            width: 315px;
+            width: 215px;
             height: 67px;
+						margin: 0 8px;
             background-color: #EF530E;
             color: #fff;
             border-radius: 10px;