From a75b18a4157ab486e0b51c438ac165ab3a08e3e0 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 25 七月 2024 18:10:00 +0800
Subject: [PATCH] 代码提交
---
wechat_staff/pages/promotion/index.js | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 151 insertions(+), 17 deletions(-)
diff --git a/wechat_staff/pages/promotion/index.js b/wechat_staff/pages/promotion/index.js
index 8d4d780..f03927a 100644
--- a/wechat_staff/pages/promotion/index.js
+++ b/wechat_staff/pages/promotion/index.js
@@ -1,23 +1,42 @@
-// pages/promotion/index.js
+import { newsPage,saveShareRecord } from '../../api/index'
+import moment from "moment";
Page({
/**
* 椤甸潰鐨勫垵濮嬫暟鎹�
*/
data: {
-
+ capacity: 10,
+ page: 1,
+ list: [],
+ total: 0,
},
/**
* 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
*/
onLoad(options) {
-
+ this.getList()
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
- */
+ getList() {
+ newsPage({capacity:this.data.capacity,
+ page:this.data.page,
+ model:{type:0}})
+ .then(res =>{
+ wx.stopPullDownRefresh()
+ if(this.data.page ==1){
+ this.setData({list:[]})
+ }
+ 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() {
},
@@ -28,7 +47,127 @@
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;
+ saveShareRecord(item.id)
+ 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: '瑙嗛涓嬭浇澶辫触鍝�'
+ })
+ }
+ })
+ }
+ })
+ }
+ },
/**
* 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
*/
@@ -47,16 +186,11 @@
* 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
*/
onPullDownRefresh() {
-
+ console.log('涓嬫媺鍒锋柊')
+ this.setData({ page: 1 })
+ this.getList()
},
-
- /**
- * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
- */
- onReachBottom() {
-
- },
-
+
/**
* 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
*/
--
Gitblit v1.9.3