From 0945357a90167c10cdc56ac8a6859b5ae39b7413 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 23 七月 2024 17:57:22 +0800
Subject: [PATCH] 提交

---
 wechat_staff/pages/promotion/index.js |  149 +++++++++++++++++++++++++++++++++++++++++++++----
 wechat_staff/package-lock.json        |   10 +++
 wechat_staff/package.json             |    4 +
 wechat_staff/pages/store/staff.js     |    7 --
 wechat_staff/utils/request.js         |    3 
 5 files changed, 152 insertions(+), 21 deletions(-)

diff --git a/wechat_staff/package-lock.json b/wechat_staff/package-lock.json
index 93912f0..6a01a9b 100644
--- a/wechat_staff/package-lock.json
+++ b/wechat_staff/package-lock.json
@@ -21,6 +21,16 @@
       "requires": {
         "jsbn": "^1.1.0"
       }
+    },
+    "moment": {
+      "version": "2.30.1",
+      "resolved": "https://registry.npmmirror.com/moment/-/moment-2.30.1.tgz",
+      "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how=="
+    },
+    "mp-html": {
+      "version": "2.5.0",
+      "resolved": "https://registry.npmmirror.com/mp-html/-/mp-html-2.5.0.tgz",
+      "integrity": "sha512-uvBH5tIaDIlj8qaxsvNXU3RKX0jvXOo3J6FAi/notUv/ds6j79UUTE82aDkxxUk0eLUU0CiCqMrR7WWnytk30Q=="
     }
   }
 }
diff --git a/wechat_staff/package.json b/wechat_staff/package.json
index 92336ca..9f4b08b 100644
--- a/wechat_staff/package.json
+++ b/wechat_staff/package.json
@@ -4,7 +4,9 @@
   "main": ".eslintrc.js",
   "dependencies": {
     "@vant/weapp": "^1.11.6",
-    "miniprogram-sm-crypto": "^0.3.13"
+    "miniprogram-sm-crypto": "^0.3.13",
+    "moment": "^2.30.1",
+    "mp-html": "^2.5.0"
   },
   "devDependencies": {},
   "scripts": {
diff --git a/wechat_staff/pages/promotion/index.js b/wechat_staff/pages/promotion/index.js
index 21a867e..e3638d0 100644
--- a/wechat_staff/pages/promotion/index.js
+++ b/wechat_staff/pages/promotion/index.js
@@ -1,4 +1,5 @@
 import { newsPage } from '../../api/index'
+import moment from "moment";
 Page({
 
   /**
@@ -6,7 +7,7 @@
    */
   data: {
     capacity: 10,
-    page: 0,
+    page: 1,
     list: [],
     total: 0,
   },
@@ -15,10 +16,22 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
-
+    this.getList()
   },
   getList() {
-    newsPage() 
+    newsPage({capacity:this.data.capacity,
+      page:this.data.page,
+      model:{type:0}})
+      .then(res =>{
+        if(this.data.page == res.data.page){ 
+          res.data.records.forEach(element => { 
+            element.createDate = moment(element.createDate).format("yyyy/MM/DD")  
+          })
+          this.setData({list: [...this.data.list, ...res.data.records || []],
+            total:res.data.total})  
+        }          
+        console.log(this.data)
+    }) 
   },
   onReady() {
 
@@ -30,7 +43,126 @@
   onShow() {
 
   },
-
+  onReachBottom() {
+    console.log('瑙﹀簳浜嬩欢');
+    const { total, list, page } = this.data
+    if(total > list.length){
+      this.setData({ page: page + 1 })
+      this.getList()
+    }else{
+      wx.showToast({
+        title: '鏆傛棤鏇村鏁版嵁',
+        icon: 'none'
+      })
+    }
+  },
+  downfile(e){
+    const item =  e.currentTarget.dataset.index;
+    const files = []
+    if(item.fileType ==1 && item.fileList && item.fileList.length && item.fileList[0].fileurlFull  ){
+      files.push(item.fileList[0].fileurlFull)
+    }
+    if(item.fileType !=1 && item.fileList && item.fileList.length  ){
+      item.fileList.forEach(ee => { 
+         if(ee.fileurlFull){ 
+           files.push(ee.fileurlFull)
+         }
+      }) 
+    }
+    if(item.fileType ==1){
+      this.downloadVideoFileDo(files,item.title)
+    }else{
+      this.downloadImageFileDo(files,item.title)
+    } 
+  },
+  downloadImageFileDo(files,title){
+    wx.showLoading({
+      title: '姝e湪涓嬭浇',
+    })
+   let temp = 0;
+    if(files.length){
+      for(let i = 0;i<files.length;i++){        
+        let filePath = wx.env.USER_DATA_PATH + '/' + new Date().valueOf()+i + '.jpg'  ;
+        wx.downloadFile({
+          url: files[i],
+          filePath: filePath,
+          timeout:180000,
+          success: function (res) { 
+            var tempFp = res.filePath
+            wx.saveImageToPhotosAlbum({
+              filePath: tempFp,
+              success(result) {
+                temp ++;
+                console.log(result) 
+                if(temp == files.length){
+                    wx.hideLoading();
+                    wx.setClipboardData({
+                      data:  title,
+                      success: function (res) {
+                        wx.getClipboardData({
+                          success: function (res) {
+                            wx.showToast({
+                              title: '鏂囨宸插鍒舵垚鍔燂紝鍘诲垎浜惂'
+                            })
+                          }
+                        })
+                      }
+                  })
+                } 
+              }, fail(err) { 
+                wx.showToast({
+                  title: '鍥剧墖涓嬭浇澶辫触鍝�'
+                })
+              }
+            })
+          } , fail(err) { 
+            wx.showToast({
+              title: '鍥剧墖涓嬭浇澶辫触鍝�'
+            })
+          }
+        })
+      } 
+    } 
+  },
+  downloadVideoFileDo(files,title){
+    wx.showLoading({
+      title: '姝e湪涓嬭浇',
+    }) 
+    if(files.length){  
+      let filePath = wx.env.USER_DATA_PATH + '/' + new Date().valueOf() + '0.mp4';
+      wx.downloadFile({
+        url: files[0],
+        filePath: filePath,
+        timeout:180000,
+        success: function (res) { 
+          var tempFp = res.filePath
+          wx.saveVideoToPhotosAlbum({
+            filePath: tempFp,
+            success(result) { 
+              console.log(result)  
+                  wx.hideLoading();
+                  wx.setClipboardData({
+                    data:  title,
+                    success: function (res) {
+                      wx.getClipboardData({
+                        success: function (res) {
+                          wx.showToast({
+                            title: '鏂囨宸插鍒舵垚鍔燂紝鍘诲垎浜惂'
+                          })
+                        }
+                      })
+                    }
+                }) 
+            }, fail(err) { 
+              wx.showToast({
+                title: '瑙嗛涓嬭浇澶辫触鍝�'
+              })
+            }
+          })
+        } 
+      }) 
+    } 
+  },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
    */
@@ -51,14 +183,7 @@
   onPullDownRefresh() {
 
   },
-
-  /**
-   * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
-   */
-  onReachBottom() {
-
-  },
-
+ 
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */
diff --git a/wechat_staff/pages/store/staff.js b/wechat_staff/pages/store/staff.js
index 83549a1..30c5c7f 100644
--- a/wechat_staff/pages/store/staff.js
+++ b/wechat_staff/pages/store/staff.js
@@ -59,12 +59,7 @@
             })
           }
         })
-        // wx.saveFile({
-        //   tempFilePath: res.tempFilePath,
-        //   success: function (res) {
-        //     console.log(res.savedFilePath)
-        //   }
-        // })
+      
       }
     })
   },
diff --git a/wechat_staff/utils/request.js b/wechat_staff/utils/request.js
index 61723df..2eda17e 100644
--- a/wechat_staff/utils/request.js
+++ b/wechat_staff/utils/request.js
@@ -1,5 +1,4 @@
-import { baseUrl } from "./config"
-
+import { baseUrl } from "./config" 
 export function request(options){
   let loading = options.loading || '1' // 榛樿鍊�1鏄剧ず锛屽惁鍒欎笉鏄剧ず
   if(loading == '1'){

--
Gitblit v1.9.3