From 26fb0b3e76f52212a2cef49a0bc0b94e7425880c Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期一, 29 七月 2024 10:55:10 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/zbomyoujia
---
wechat_staff/pages/download/index.js | 161 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 144 insertions(+), 17 deletions(-)
diff --git a/wechat_staff/pages/download/index.js b/wechat_staff/pages/download/index.js
index 0f6771e..5bcb799 100644
--- a/wechat_staff/pages/download/index.js
+++ b/wechat_staff/pages/download/index.js
@@ -1,11 +1,22 @@
-// pages/download/index.js
+import {
+ getContentShareImg
+} from '../../api/index'
+import {
+ checkAuth,
+ downloadSaveFile
+} from '../../utils/downloadSaveFile'
Page({
/**
* 椤甸潰鐨勫垵濮嬫暟鎹�
*/
data: {
- bottomLift: ''
+ bottomLift: '',
+ downloadList: [],
+ downloadConfig: {},
+ checkedAll: false,
+ showParam: false,
+ takeQrcode: true
},
/**
@@ -17,24 +28,140 @@
bottomLift: app.bottomLift
})
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
- */
- onReady() {
-
+ subDownload() {
+ let that = this
+ const downloadList = this.data.downloadList
+ const downloadConfig = this.data.downloadConfig
+ checkAuth(() => {
+ wx.showLoading({
+ title: '姝e湪涓嬭浇',
+ mask: true
+ })
+ downloadList.forEach(item => {
+ if (item.checked) {
+ item.paddingStatus = 2
+ }
+ })
+ this.setData({ downloadList })
+ downloadList.forEach(item => {
+ if (item.checked) {
+ getContentShareImg({
+ articleId: `${downloadConfig.id}_${downloadConfig.path}`,
+ type: this.takeQrcode ? 0 : 1,
+ imgurl: item.url
+ }).then(res => {
+ wx.downloadFile({
+ url: res.data,
+ success: res => {
+ if (res.statusCode === 200) {
+ wx.saveImageToPhotosAlbum({
+ filePath: res.tempFilePath,
+ success: res => {
+ item.paddingStatus = 3
+ item.checked = false
+ that.setData({ downloadList })
+ wx.showToast({
+ title: '淇濆瓨鎴愬姛',
+ icon: "none"
+ })
+ },
+ fail: res => {
+ item.paddingStatus = 4
+ item.checked = false
+ that.setData({ downloadList })
+ wx.showToast({
+ title: '淇濆瓨澶辫触',
+ icon: "none"
+ })
+ }
+ })
+
+ }
+ }
+ })
+ })
+ }
+ })
+ })
+ this.setData({
+ showParam: false
+ })
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
- */
onShow() {
-
+ const downloadList = wx.getStorageSync('downloadList') || []
+ const downloadConfig = wx.getStorageSync('downloadConfig') || {}
+ let temp = downloadList.map(i => {
+ // paddingStatus锛� 0鏈笅杞�1姝e湪涓嬭浇2绛夊緟涓嬭浇3涓嬭浇瀹屾垚
+ return {
+ url: i,
+ paddingStatus: 0,
+ checked: false
+ }
+ })
+ this.setData({
+ downloadList: temp,
+ downloadConfig
+ })
+ setTimeout(() => {
+ wx.setStorageSync('downloadList', [])
+ wx.setStorageSync('downloadConfig', {})
+ }, 500)
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
- */
+ openParam() {
+ const downloadList = this.data.downloadList.filter(i => i.checked)
+ if (downloadList.length === 0) return wx.showToast({
+ title: '璇峰厛閫夋嫨瑕佷笅杞界殑娴锋姤',
+ icon: 'none'
+ })
+ this.setData({
+ showParam: true
+ })
+ },
+ onClose() {
+ this.setData({
+ showParam: false
+ })
+ },
+ downCheck(e) {
+ const takeQrcode = e.currentTarget.dataset.flag
+ console.log('takeQrcode', takeQrcode);
+ this.setData({
+ takeQrcode
+ })
+ },
+ itemCheck(e) {
+ const i = e.currentTarget.dataset.i
+ const {
+ downloadList,
+ checkedAll
+ } = this.data
+ let count = 0
+ downloadList.forEach((item, index) => {
+ if (index === i) {
+ item.checked = !item.checked
+ }
+ if (item.checked) {
+ count++
+ }
+ })
+ this.setData({
+ checkedAll: count == downloadList.length,
+ downloadList
+ })
+ },
+ allCheck() {
+ const {
+ downloadList,
+ checkedAll
+ } = this.data
+ downloadList.forEach(item => {
+ item.checked = !checkedAll
+ })
+ this.setData({
+ checkedAll: !checkedAll,
+ downloadList
+ })
+ },
onHide() {
},
--
Gitblit v1.9.3