From ac0b3ba41104180fd45cc94334bc3c760c2895a4 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 23 七月 2024 14:05:36 +0800
Subject: [PATCH] ''

---
 wechat_staff/pages/store/staff.js |   85 ++++++++++++++++++++++++++++++------------
 1 files changed, 60 insertions(+), 25 deletions(-)

diff --git a/wechat_staff/pages/store/staff.js b/wechat_staff/pages/store/staff.js
index 923677f..83549a1 100644
--- a/wechat_staff/pages/store/staff.js
+++ b/wechat_staff/pages/store/staff.js
@@ -1,6 +1,7 @@
-// pages/store/staff.jsdownloadImg
-import { getUserCard } from '../../api/index'
-import { downloadImg } from '../../utils/common'
+import {
+  getUserCard
+} from '../../api/index'
+// import { downloadImg } from '../../utils/common'
 Page({
 
   /**
@@ -8,10 +9,10 @@
    */
   data: {
     bottomLift: 0,
-    isShow: false,
-    userCard:'',
+    isShow: true,
+    userCard: '',
     isShow2: false,
-    userInfo:{}
+    userInfo: {}
   },
 
   /**
@@ -20,39 +21,73 @@
   onLoad(options) {
     var app = getApp().globalData
     var userType = options.userType
-   
-    if(userType == 1){
+
+    if (userType == 1) {
       //濡傛灉鏌ヨ鑷繁鐨勪俊鎭�
-      this.setData({userInfo: wx.getStorageSync('member')})
+      this.setData({
+        userInfo: wx.getStorageSync('member')
+      })
       console.log(this.data)
-    } 
+    }
     this.setData({
       bottomLift: app.bottomLift
     })
   },
-  showQrcode(){
-    this.setData({isShow:true}) 
+  showQrcode() {
+    this.setData({
+      isShow: true
+    })
   },
-  closeCard(){
-    this.setData({isShow2: false})
+  closeCard() {
+    this.setData({
+      isShow2: false
+    })
   },
-
-  
-  saveCard(){
-   downloadImg(this.data.userCard);
+  saveCard() {
+    wx.downloadFile({
+      url: this.data.userCard,
+      success: function (res) {
+        console.log('涓嬭浇鎴愬姛', res);
+        wx.saveImageToPhotosAlbum({
+          filePath: res.tempFilePath,
+          success(result) {
+            console.log(result)
+            wx.showToast({
+              title: '淇濆瓨鎴愬姛',
+              icon: 'success',
+              duration: 2000
+            })
+          }
+        })
+        // wx.saveFile({
+        //   tempFilePath: res.tempFilePath,
+        //   success: function (res) {
+        //     console.log(res.savedFilePath)
+        //   }
+        // })
+      }
+    })
   },
   openModal() {
-    if(this.data.userCard !=null && this.data.userCard != ''){
-      this.setData({isShow2: true})
+    if (this.data.userCard != null && this.data.userCard != '') {
+      this.setData({
+        isShow2: true
+      })
       return;
     }
-    getUserCard().then(res =>{
-      this.setData({userCard: res.data})
-      this.setData({isShow2: true})
-    }) 
+    getUserCard().then(res => {
+      this.setData({
+        userCard: res.data
+      })
+      this.setData({
+        isShow2: true
+      })
+    })
   },
   onClose() {
-    this.setData({isShow: false})
+    this.setData({
+      isShow: false
+    })
   },
 
   /**

--
Gitblit v1.9.3