Browse Source

代码提交

LiuShu_0203 6 days ago
parent
commit
ae934eeb45

+ 3 - 0
pages/groupbuying/groupbuying.js

@@ -86,6 +86,9 @@ Page({
   loadMore() {
     // 加载更多数据的逻辑
     console.log('加载更多');
+    // this.getDatalist(this.data.types_ids, true);
+    if (this.data.isLoading || !this.data.hasMore) return;
+    this.setData({ isLoading: true });
     this.getDatalist(this.data.types_ids, true);
   },
 

+ 3 - 0
pages/shoppingcart/shoppingcart.js

@@ -68,6 +68,9 @@ Page({
   loadMore() {
     // 加载更多数据的逻辑
     console.log('加载更多');
+    // this.getdatalist(true);
+    if (this.data.isLoading || !this.data.hasMore) return;
+    this.setData({ isLoading: true });
     this.getdatalist(true);
   },
 

+ 3 - 0
subpackages/dahome/dahome.js

@@ -81,6 +81,9 @@ Page({
   loadMore() {
     // 加载更多数据的逻辑
     console.log('加载更多');
+    // this.getdatalist(true);
+    if (this.data.isLoading || !this.data.hasMore) return;
+    this.setData({ isLoading: true });
     this.getdatalist(true);
   },
 

+ 1 - 1
subpackages/details/details.wxml

@@ -2,7 +2,7 @@
   <view class="container">
     <view class="header">
       <text>{{ itemlist.name }}</text>
-      <text>{{itemlist.publisher}} • {{ itemlist.createdAtText }}</text>
+      <!-- <text>{{itemlist.publisher}} • {{ itemlist.createdAtText }}</text> -->
       <text>{{itemlist.type === 0 ? '视频' : itemlist.type === 1 ? '音频' : itemlist.type === 2 ? 'PDF' : itemlist.type === 3 ? 'PPT' : '图文'}} 适用于 {{ itemlist.dan === 0 ? '初级' : itemlist.dan === 1 ? '中级' : itemlist.dan === 2 ? '高级' : '' }} {{ itemlist.level }} 段</text>
     </view>
     <!-- 预览 -->

+ 147 - 121
subpackages/down/down.js

@@ -142,141 +142,167 @@ Page({
 
   // 下载
   handleDownloadFile() {
-    const url = this.data.itemtempFileURL;
-    if (!url) {
+    const link = this.data.itemtempFileURL;
+    if (!link) {
       wx.showToast({
-        title: '文件链接不存在',
+        title: '下载链接为空',
         icon: 'none'
       });
       return;
     }
   
-    wx.showLoading({
-      title: '下载中...',
-      mask: true
+    // 复制到剪贴板
+    wx.setClipboardData({
+      data: link,
+      success: () => {
+        wx.showModal({
+          title: '提示',
+          content: '下载链接已复制,请到浏览器粘贴并下载',
+          showCancel: false, // 不显示取消按钮
+          confirmText: '我知道了',
+          success(res) {
+            if (res.confirm) {
+              console.log('用户点击确定,弹框关闭');
+            }
+          }
+        });
+      }
     });
+    // const url = this.data.itemtempFileURL;
+    // if (!url) {
+    //   wx.showToast({
+    //     title: '文件链接不存在',
+    //     icon: 'none'
+    //   });
+    //   return;
+    // }
   
-    wx.downloadFile({
-      url: url,
-      success: (res) => {
-        wx.hideLoading();
+    // wx.showLoading({
+    //   title: '下载中...',
+    //   mask: true
+    // });
   
-        if (res.statusCode === 200) {
-          const tempFilePath = res.tempFilePath;
-          const fileExt = url.split('.').pop().toLowerCase();
-          const that = this; // 保存页面上下文
-          if (['pdf', 'ppt', 'pptx', 'doc', 'docx', 'xls', 'xlsx'].includes(fileExt)) {
-            // 打开文档
-            wx.openDocument({
-              filePath: tempFilePath,
-              showMenu: true,
-              success() {
-                console.log('打开文档成功');
-                that.getaddlishi()
-              },
-              fail(err) {
-                wx.showToast({
-                  title: '打开文档失败',
-                  icon: 'none'
-                });
-                console.error('文档打开失败', err);
-              }
-            });
+    // wx.downloadFile({
+    //   url: url,
+    //   success: (res) => {
+    //     wx.hideLoading();
   
-          } else if (['mp4', 'mov', 'avi'].includes(fileExt)) {
-            // 视频:先检查权限再保存
-            wx.getSetting({
-              success: (res) => {
-                if (!res.authSetting['scope.writePhotosAlbum']) {
-                  wx.authorize({
-                    scope: 'scope.writePhotosAlbum',
-                    success: () => {
-                      this.saveVideo(tempFilePath);
-                    },
-                    fail: () => {
-                      wx.showModal({
-                        title: '提示',
-                        content: '保存视频需要开启“保存到相册”权限,请前往设置开启。',
-                        showCancel: true,
-                        success(result) {
-                          if (result.confirm) {
-                            wx.openSetting();
-                          }
-                        }
-                      });
-                    }
-                  });
-                } else {
-                  this.saveVideo(tempFilePath);
-                }
-              }
-            });
+    //     if (res.statusCode === 200) {
+    //       const tempFilePath = res.tempFilePath;
+    //       const fileExt = url.split('.').pop().toLowerCase();
+    //       const that = this; // 保存页面上下文
+    //       if (['pdf', 'ppt', 'pptx', 'doc', 'docx', 'xls', 'xlsx'].includes(fileExt)) {
+    //         // 打开文档
+    //         wx.openDocument({
+    //           filePath: tempFilePath,
+    //           showMenu: true,
+    //           success() {
+    //             console.log('打开文档成功');
+    //             that.getaddlishi()
+    //           },
+    //           fail(err) {
+    //             wx.showToast({
+    //               title: '打开文档失败',
+    //               icon: 'none'
+    //             });
+    //             console.error('文档打开失败', err);
+    //           }
+    //         });
   
-          } else if (['mp3', 'wav', 'aac'].includes(fileExt)) {
-            // 音频保存到本地缓存
-            wx.saveFile({
-              tempFilePath,
-              success(result) {
-                wx.showToast({
-                  title: '音频已保存',
-                  icon: 'success'
-                });
-                that.getaddlishi()
-                console.log('音频保存路径:', result.savedFilePath);
-              },
-              fail(err) {
-                wx.showToast({
-                  title: '保存失败',
-                  icon: 'none'
-                });
-                console.error('音频保存失败:', err);
-              }
-            });
+    //       } else if (['mp4', 'mov', 'avi'].includes(fileExt)) {
+    //         // 视频:先检查权限再保存
+    //         wx.getSetting({
+    //           success: (res) => {
+    //             if (!res.authSetting['scope.writePhotosAlbum']) {
+    //               wx.authorize({
+    //                 scope: 'scope.writePhotosAlbum',
+    //                 success: () => {
+    //                   this.saveVideo(tempFilePath);
+    //                 },
+    //                 fail: () => {
+    //                   wx.showModal({
+    //                     title: '提示',
+    //                     content: '保存视频需要开启“保存到相册”权限,请前往设置开启。',
+    //                     showCancel: true,
+    //                     success(result) {
+    //                       if (result.confirm) {
+    //                         wx.openSetting();
+    //                       }
+    //                     }
+    //                   });
+    //                 }
+    //               });
+    //             } else {
+    //               this.saveVideo(tempFilePath);
+    //             }
+    //           }
+    //         });
   
-          } else {
-            wx.showToast({
-              title: '暂不支持的文件类型',
-              icon: 'none'
-            });
-          }
+    //       } else if (['mp3', 'wav', 'aac'].includes(fileExt)) {
+    //         // 音频保存到本地缓存
+    //         wx.saveFile({
+    //           tempFilePath,
+    //           success(result) {
+    //             wx.showToast({
+    //               title: '音频已保存',
+    //               icon: 'success'
+    //             });
+    //             that.getaddlishi()
+    //             console.log('音频保存路径:', result.savedFilePath);
+    //           },
+    //           fail(err) {
+    //             wx.showToast({
+    //               title: '保存失败',
+    //               icon: 'none'
+    //             });
+    //             console.error('音频保存失败:', err);
+    //           }
+    //         });
   
-        } else {
-          wx.showToast({
-            title: '下载失败',
-            icon: 'none'
-          });
-        }
-      },
-      fail: (err) => {
-        wx.hideLoading();
-        wx.showToast({
-          title: '下载失败',
-          icon: 'none'
-        });
-        console.error('下载出错:', err);
-      }
-    });
+    //       } else {
+    //         wx.showToast({
+    //           title: '暂不支持的文件类型',
+    //           icon: 'none'
+    //         });
+    //       }
+  
+    //     } else {
+    //       wx.showToast({
+    //         title: '下载失败',
+    //         icon: 'none'
+    //       });
+    //     }
+    //   },
+    //   fail: (err) => {
+    //     wx.hideLoading();
+    //     wx.showToast({
+    //       title: '下载失败',
+    //       icon: 'none'
+    //     });
+    //     console.error('下载出错:', err);
+    //   }
+    // });
   }, 
-  saveVideo(filePath) {
-    const that = this; // 保存页面上下文
-    wx.saveVideoToPhotosAlbum({
-      filePath,
-      success() {
-        wx.showToast({
-          title: '视频已保存',
-          icon: 'success'
-        });
-        that.getaddlishi()
-      },
-      fail(err) {
-        wx.showToast({
-          title: '保存失败',
-          icon: 'none'
-        });
-        console.error('视频保存失败:', err);
-      }
-    });
-  },
+  // saveVideo(filePath) {
+  //   const that = this; // 保存页面上下文
+  //   wx.saveVideoToPhotosAlbum({
+  //     filePath,
+  //     success() {
+  //       wx.showToast({
+  //         title: '视频已保存',
+  //         icon: 'success'
+  //       });
+  //       that.getaddlishi()
+  //     },
+  //     fail(err) {
+  //       wx.showToast({
+  //         title: '保存失败',
+  //         icon: 'none'
+  //       });
+  //       console.error('视频保存失败:', err);
+  //     }
+  //   });
+  // },
 
   // 新增下载历史
   async getaddlishi() {

+ 3 - 0
subpackages/imghome/imghome.js

@@ -58,6 +58,9 @@ Page({
   loadMore() {
     // 加载更多数据的逻辑
     console.log('加载更多');
+    // this.getdatalist(true);
+    if (this.data.isLoading || !this.data.hasMore) return;
+    this.setData({ isLoading: true });
     this.getdatalist(true);
   },
 

+ 3 - 0
subpackages/order/order.js

@@ -80,6 +80,9 @@ Page({
   loadMore() {
     // 加载更多数据的逻辑
     console.log('加载更多');
+    // this.getdatalist(true);
+    if (this.data.isLoading || !this.data.hasMore) return;
+    this.setData({ isLoading: true });
     this.getdatalist(true);
   },
 

+ 3 - 0
subpackages/purchasehistory/purchasehistory.js

@@ -55,6 +55,9 @@ Page({
   loadMore() {
     // 加载更多数据的逻辑
     console.log('加载更多');
+    // this.getcollect(true);
+    if (this.data.isLoading || !this.data.hasMore) return;
+    this.setData({ isLoading: true });
     this.getcollect(true);
   },