LiuShu_0203 преди 10 часа
родител
ревизия
4468245986
променени са 58 файла, в които са добавени 3207 реда и са изтрити 627 реда
  1. 34 1
      app.json
  2. 10 0
      components/float/float.js
  3. 4 0
      components/float/float.json
  4. 8 0
      components/float/float.wxml
  5. 16 0
      components/float/float.wxss
  6. 67 43
      pages/groupbuying/groupbuying.js
  7. 29 20
      pages/groupbuying/groupbuying.wxml
  8. 36 2
      pages/groupbuying/groupbuying.wxss
  9. 24 7
      pages/logins/logins.js
  10. 246 54
      pages/me/me.js
  11. 14 10
      pages/me/me.wxml
  12. 17 6
      pages/me/me.wxss
  13. 142 28
      pages/shoppingcart/shoppingcart.js
  14. 31 22
      pages/shoppingcart/shoppingcart.wxml
  15. 30 3
      pages/shoppingcart/shoppingcart.wxss
  16. 1 1
      project.private.config.json
  17. 169 0
      subpackages/address/address.js
  18. 4 0
      subpackages/address/address.json
  19. 25 0
      subpackages/address/address.wxml
  20. 44 0
      subpackages/address/address.wxss
  21. 95 9
      subpackages/addresslist/addresslist.js
  22. 7 3
      subpackages/addresslist/addresslist.wxml
  23. 77 47
      subpackages/changename/changename.js
  24. 3 3
      subpackages/changename/changename.wxml
  25. 103 40
      subpackages/dahome/dahome.js
  26. 18 6
      subpackages/dahome/dahome.wxml
  27. 25 2
      subpackages/dahome/dahome.wxss
  28. 237 0
      subpackages/details/details.js
  29. 6 0
      subpackages/details/details.json
  30. 84 0
      subpackages/details/details.wxml
  31. 298 0
      subpackages/details/details.wxss
  32. 47 0
      subpackages/detailsimg/detailsimg.js
  33. 6 0
      subpackages/detailsimg/detailsimg.json
  34. 10 0
      subpackages/detailsimg/detailsimg.wxml
  35. 20 0
      subpackages/detailsimg/detailsimg.wxss
  36. 302 0
      subpackages/down/down.js
  37. 7 0
      subpackages/down/down.json
  38. 28 0
      subpackages/down/down.wxml
  39. 60 0
      subpackages/down/down.wxss
  40. 69 44
      subpackages/imghome/imghome.js
  41. 14 5
      subpackages/imghome/imghome.wxml
  42. 23 1
      subpackages/imghome/imghome.wxss
  43. 89 22
      subpackages/logoff/logoff.js
  44. 13 11
      subpackages/logoff/logoff.wxml
  45. 115 32
      subpackages/order/order.js
  46. 36 27
      subpackages/order/order.wxml
  47. 22 1
      subpackages/order/order.wxss
  48. 9 1
      subpackages/orderdetails/orderdetails.js
  49. 17 11
      subpackages/orderdetails/orderdetails.wxml
  50. 115 22
      subpackages/productdetails/productdetails.js
  51. 21 16
      subpackages/productdetails/productdetails.wxml
  52. 8 0
      subpackages/productdetails/productdetails.wxss
  53. 203 86
      subpackages/purchasehistory/purchasehistory.js
  54. 23 14
      subpackages/purchasehistory/purchasehistory.wxml
  55. 11 1
      subpackages/purchasehistory/purchasehistory.wxss
  56. 31 23
      subpackages/submitorder/submitorder.js
  57. 2 2
      subpackages/submitorder/submitorder.wxml
  58. 2 1
      utils/cloudbase.js

+ 34 - 1
app.json

@@ -11,7 +11,8 @@
     "pages/shoppingcart/shoppingcart",
     "pages/me/me",
     "pages/login/login",
-    "pages/logins/logins"
+    "pages/logins/logins",
+    "components/float/float"
   ],
   "window": {
     "navigationBarTextStyle": "black",
@@ -114,8 +115,40 @@
       "pages": [
         "changename"
       ]
+    },
+    {
+      "root": "subpackages/details",
+      "pages": [
+        "details"
+      ]
+    },
+    {
+      "root": "subpackages/detailsimg",
+      "pages": [
+        "detailsimg"
+      ]
+    },
+    {
+      "root": "subpackages/down",
+      "pages": [
+        "down"
+      ]
+    },
+    {
+      "root": "subpackages/address",
+      "pages": [
+        "address"
+      ]
     }
   ],
+  "requiredPrivateInfos": [
+    "getLocation"
+  ],
+  "permission": {
+    "scope.userLocation": {
+      "desc": "你的位置信息将用于获取附近的地址信息"
+    }
+  },
   "style": "v2",
   "componentFramework": "glass-easel",
   "sitemapLocation": "sitemap.json",

+ 10 - 0
components/float/float.js

@@ -0,0 +1,10 @@
+// components/float-home/float-home.js
+Component({
+  methods: {
+    goHome() {
+      wx.switchTab({
+        url: '/pages/index/index'
+      });
+    }
+  }
+});

+ 4 - 0
components/float/float.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "component": true
+}

+ 8 - 0
components/float/float.wxml

@@ -0,0 +1,8 @@
+<view class="float-home" bindtap="goHome">
+  <view>
+    返回
+  </view>
+  <view>
+    首页
+  </view>
+</view>

+ 16 - 0
components/float/float.wxss

@@ -0,0 +1,16 @@
+.float-home {
+  position: fixed;
+  right: 30rpx;
+  bottom: 200rpx;
+  width: 100rpx;
+  height: 100rpx;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;  /* 垂直居中 */
+  align-items: center;      /* 水平居中 */
+  border-radius: 12rpx;
+  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.3);
+  background-color: #ffffff;
+  font-size: 28rpx;
+  z-index: 999;
+}

+ 67 - 43
pages/groupbuying/groupbuying.js

@@ -1,47 +1,20 @@
-import { models, db } from '../../utils/cloudbase.js'
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
   data: {
     categoriesindex: 1,
     categories: [],
-    goods: [
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '儿童大颗粒积木 安全无毒 益智玩具',
-        price: '68.00',
-        originalPrice: '88.00',
-        sold: 256
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '幼儿启蒙绘本 10册套装',
-        price: '68.00',
-        originalPrice: '88.00',
-        sold: 256
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '防摔儿童保温水杯 350ml',
-        price: '68.00',
-        originalPrice: '88.00',
-        sold: 256
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '可水洗儿童彩笔24色套装',
-        price: '68.00',
-        originalPrice: '88.00',
-        sold: 256
-      }
-    ],
+    goods: [],
     souimg: '',
     gouwucimg: '',
+    pageNumber: 1,
+    pageSize: 10,
+    hasMore: true, // 是否还有更多数据
+    isLoading: false, // 防止多次触发
+    types_ids: null, // 当前选中的分类 tag_id
   },
   onLoad(options) {
     // 获取tab数据
     this.getTabdata();
-    // const title = options.title ? decodeURIComponent(options.title) : '商品列表';
-    // this.setData({ title });
-    // wx.setNavigationBarTitle({ title });
 
     const fileIDs = [
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
@@ -70,28 +43,81 @@ Page({
       filter: {
         where: {
           position: 4, // 显示位置
-          // layout_type: 0, // 布局类型
         },
       },
-      // envType: pre 体验环境, prod 正式环境
       envType: "prod",
     });
     
     // 返回查询到的数据
-    console.log(data);
-
     const sortedRecords = data.records.sort((a, b) => {
       return a.sort - b.sort; // 升序排列
     });
     this.setData({
-      categories: sortedRecords
+      categories: sortedRecords,
+      goods: [],
+      pageNumber: 1,
+      hasMore: true,
+    }, () => {
+      this.getDatalist()
     })
   },
 
+  onReachBottom() {
+    // 上拉触底事件的处理函数
+    this.loadMore();
+  },
+
+  loadMore() {
+    // 加载更多数据的逻辑
+    console.log('加载更多');
+    this.getDatalist(this.data.types_ids, true);
+  },
+
+  // 列表数据
+  async getDatalist(tag_id = null, isLoadMore = false) {
+  
+    const userInfo = wx.getStorageSync('userInfo');
+  
+    // 构造 where 条件
+    const where = {
+      school_id: _.in(userInfo.school_id)
+    };
+  
+    if (tag_id) {
+      where.tag_id = tag_id; // 仅在 tag_id 有值时添加
+    }
+
+    const { pageNumber, pageSize } = this.data;
+    const { data } = await models.wx_merchandise.list({
+      filter: { where },
+      pageSize,
+      pageNumber,
+      getCount: true,
+      envType: "prod",
+    });
+
+    const collectList = data.records || [];
+    this.setData({
+      goods: isLoadMore ? this.data.goods.concat(collectList) : collectList, // ✅ 用 goods 拼接
+      pageNumber: pageNumber + 1,
+      hasMore: collectList.length === pageSize,
+      isLoading: false
+    });
+  },
+
+  // 点击tab分类 async
   tabcategories(e) {
-    const type = e.currentTarget.dataset.type;
+    const types = e.currentTarget.dataset.type;
+    const tagId = types.sort === 1 ? null : types._id;
+  
     this.setData({
-      categoriesindex: type
+      categoriesindex: types.sort,
+      types_ids: tagId,
+      goods: [],
+      pageNumber: 1,
+      hasMore: true
+    }, () => {
+      this.getDatalist(tagId, false); // ✅ 这里也改成直接传 tagId
     });
   },
 
@@ -101,7 +127,5 @@ Page({
     wx.navigateTo({
       url: '/subpackages/productdetails/productdetails?data=' + encodeURIComponent(JSON.stringify(item))
     });
-
-    console.log('走进来了');
   }
 });

+ 29 - 20
pages/groupbuying/groupbuying.wxml

@@ -7,31 +7,40 @@
     <view class="title_1">商品分类</view>
     <view class="category-tabs">
       <view wx:for="{{categories}}" wx:key="index">
-        <view class="category-tab {{item.sort === categoriesindex ? 'active' : ''}}" bindtap="tabcategories" data-type="{{item.sort}}">{{item.name}}</view>
+        <view class="category-tab {{item.sort === categoriesindex ? 'active' : ''}}" bindtap="tabcategories" data-type="{{item}}">{{item.name}}</view>
       </view>
     </view>
-    <view class="goods-list">
-      <block wx:for="{{goods}}" wx:key="index">
-        <view class="goods-item" bindtap="navigateToDetail" data-index="{{index}}">
-          <image class="goods-image" src="{{item.image}}" mode="aspectFill"></image>
-          <view class="goods-info">
-            <view class="goods-title">{{item.title}}</view>
-            <view class="goods-price">
-              <text>¥{{item.price}}</text>
-              <text class="goods-status">已拼 {{item.sold}}件</text>
-            </view>
-            <view class="original-price">¥{{item.originalPrice}}</view>
-            <view class="gw_boxs">
-              <view class="gw_imgboxs">
-                <image style="width: 55rpx;height: 55rpx;padding-top: 6rpx;" src="{{gouwucimg}}" />
+    <scroll-view
+      class="list_boxsss"
+      scroll-y="true"
+      bindscrolltolower="loadMore"
+      lower-threshold="100"
+    >
+      <view class="goods-list">
+        <block wx:for="{{goods}}" wx:key="index">
+          <view class="goods-item" bindtap="navigateToDetail" data-index="{{index}}">
+            <image class="goods-image" src="{{item.img}}" mode="aspectFill"></image>
+            <view class="goods-info">
+              <view class="goods-title">{{item.name}}</view>
+              <view class="goods-price">
+                <text>¥{{item.price}}</text>
+                <text class="goods-status">已拼 {{item.count}}件</text>
               </view>
-              <view class="gw_button">
-                <button class="buy-button">立即购买</button>
+              <view class="original-price">¥{{item.old_price}}</view>
+              <view class="gw_boxs">
+                <view class="gw_imgboxs">
+                  <image style="width: 55rpx;height: 55rpx;padding-top: 6rpx;" src="{{gouwucimg}}" />
+                </view>
+                <view class="gw_button">
+                  <button class="buy-button">立即购买</button>
+                </view>
               </view>
             </view>
           </view>
-        </view>
-      </block>
-    </view>
+        </block>
+      </view>
+      <view wx:if="{{ isLoading }}" class="loading-text">加载中...</view>
+      <view wx:elif="{{ !hasMore }}" class="no-more-text">没有更多了</view>
+    </scroll-view>
   </view>
 </view>

+ 36 - 2
pages/groupbuying/groupbuying.wxss

@@ -1,5 +1,7 @@
 .goodslist_boxs {
   margin: 0rpx 30rpx;
+  height: calc(100vh - 40rpx);
+  overflow: hidden;
   width: calc(100% - 60rpx);
 }
 
@@ -56,14 +58,25 @@
   border: 1rpx solid #d9ecff;
 }
 
+.list_boxsss {
+  width: 100%;
+  /* width: calc(100% - 60rpx); */
+  height: calc(100% - 280rpx);
+  position: fixed;
+  top: 260rpx;
+  left: 0;
+}
+
 .goods-list {
+  width: calc(100% - 60rpx);
+  /* margin: 0rpx 30rpx; */
   display: flex;
   flex-wrap: wrap;
   gap: 20rpx;
 }
 
 .goods-item {
-  width: calc(50% - 10rpx);
+  width: calc(50% - 11rpx);
   background-color: #fff;
   border-radius: 10rpx;
   overflow: hidden;
@@ -126,4 +139,25 @@
   font-size: 28rpx;
   border-radius: 40rpx;
   text-align: center;
-}
+}
+
+.list_boxsss {
+  /* width: calc( 100% - 60rpx); */
+  padding: 0rpx 30rpx;
+  height: calc(100% - 270rpx);
+  position: fixed;
+  top: 260rpx;
+  left: 0;
+}
+
+.loading-text {
+  padding-top: 20rpx;
+  width: 100%;
+  text-align: center;
+}
+
+.no-more-text {
+  padding-top: 20rpx;
+  width: 100%;
+  text-align: center;
+}

+ 24 - 7
pages/logins/logins.js

@@ -55,27 +55,44 @@ Page({
       return;
     }
 
-    const { data } = await models.wx_user.get({
+    const { data } = await models.wx_user.list({
       filter: {
         where: {
           phone: this.data.phone
         }
       },
+      pageSize: 100, // 分页大小,建议指定,如需设置为其它值,需要和 pageNumber 配合使用,两者同时指定才会生效
+      pageNumber: 1, // 第几页
+      getCount: true, // 开启用来获取总数
       // envType: pre 体验环境, prod 正式环境
       envType: "prod",
     });
-    console.log('data',data);
-    if (!data || Object.keys(data).length === 0) {
+    const users = data.records || [];
+
+    // 如果查不到任何数据
+    if (users.length === 0) {
       wx.showToast({
-        title: '该手机号未注册,请换其他手机号进行登录',
+        title: '该手机号未注册,请换其他手机号登录',
         icon: 'none'
       });
       return;
     }
 
-    const user = data; // 取第一条用户数据
-    // 登录成功,存储用户信息
-    wx.setStorageSync('userInfo', user);
+    // ✅ 如果查到了,但全部都是 delete === 1,则视为无有效账号
+    const allDeleted = users.every(user => user.delete === 1);
+    if (allDeleted) {
+      wx.showToast({
+        title: '该手机号未注册,请换其他手机号登录',
+        icon: 'none'
+      });
+      return;
+    }
+
+    // ✅ 只要有一个 delete === 0,就继续登录
+    const validUser = users.find(user => user.delete === 0);
+
+    wx.setStorageSync('userInfo', validUser);
+
   
     wx.showToast({
       title: '登录成功',

+ 246 - 54
pages/me/me.js

@@ -1,31 +1,24 @@
 // pages/me/me.js
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
   data: {
       // role: "teacher",
-      userInfo: {
-          avatar: '../../image/imgs/avatar.jpg',
-          name: '',
-          role: '',
-          phone: ''
-      },
+      userInfo: {},
       orderStatus: [],
-      historyItems: [
-          {
-              id: 1,
-              thumbnail: '../../image/imgs/item1.jpg',
-              name: '趣味识字卡片',
-              date: '2023-10-15 14:30'
-          },
-          {
-              id: 2,
-              thumbnail: '../../image/imgs/item2.jpg',
-              name: '趣味识字卡片',
-              date: '2023-10-15 14:30'
-          },
-          // 更多历史记录...
-      ],
+      displayPhone: '',
+      xxdata: {},
+      historyItems: [],
       xiugaiimg: '',
       xiangjiimg: '',
+      xiazi: '',
+      // souchangs: '',
+  },
+
+  onShow() {
+    // 每次进入页面都会触发
+    this.getUserInfo();
+    // this.getcollect();
+    this.getpurchasehistory();
   },
 
   onLoad(options) {
@@ -44,7 +37,9 @@ Page({
         'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/ding_3.png',
         'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/ding_4.png',
         'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiugai.png',
-        'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiangji.png'
+        'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiangji.png',
+        'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiazi.png',
+        // 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/soucangs.png'
       ];
       
       // 并发下载多个 fileID
@@ -68,56 +63,253 @@ Page({
         this.setData({
           orderStatus: updatedOrderStatus,
           xiugaiimg: tempFilePaths[4],
-          xiangjiimg: tempFilePaths[5]
+          xiangjiimg: tempFilePaths[5],
+          xiazi: tempFilePaths[6],
+          // souchangs: tempFilePaths[7],
         });
       }).catch(err => {
         console.error('有文件下载失败:', err);
       });
   },
 
-  getUserInfo() {
-      // 模拟获取用户信息的逻辑
-      const userInfo = {
-          avatar: '../../image/imgs/avatar.jpg',
-          name: '琳琳家长',
-          role: '家长',
-          phone: '131****9345'
-      };
-      this.setData({ userInfo });
+  // 手机号加密
+  hidePhone(phone) {
+    if (!phone || phone.length !== 11) return phone || '未绑定';
+    return phone.substr(0, 3) + '****' + phone.substr(7, 4);
+  },
+
+  // 用户信息
+  async getUserInfo() {
+    // 获取用户信息
+    const userInfo = wx.getStorageSync('userInfo');
+    this.setData({ userInfo }, () => {
+      const phone = this.data.userInfo.phone;
+      this.setData({
+        displayPhone: this.hidePhone(phone)
+      });
+    });
+
+    try {
+      const { data } = await models.wx_school.get({
+        filter: {
+          where: {
+            school_id: userInfo.school_id
+          }
+        },
+        envType: "prod"
+      });
+
+      this.setData({
+        xxdata: data
+      });
+    } catch (err) {
+      console.error('获取学校数据失败:', err);
+    }
+  },
+
+  // 下载历史
+  async getpurchasehistory() {
+    const { data } = await models.parent_download_history.list({
+      filter: {
+        where: {
+          user_id: this.data.userInfo._id
+        }
+      },
+      pageSize: 2, // 分页大小,建议指定,如需设置为其它值,需要和 pageNumber 配合使用,两者同时指定才会生效
+      pageNumber: 1, // 第几页
+      getCount: true, // 开启用来获取总数
+      envType: "prod",
+    });
+
+    // 返回查询到的数据列表 records 和 总数 total
+    console.log(data);
+    const collectList = data.records || [];
+    if (collectList.length === 0) {
+      console.log('没有收藏记录');
+      this.setData({ historyItems: [] });
+      return;
+    }
+
+    // 第二步:提取 file_manage_id 列表
+    const fileManagerIds = collectList.map(item => item.file_manage_id);
+
+    // 第三步:逐个查询 file_manage 表详情
+    const fileDetailPromises = fileManagerIds.map(id => {
+      return models.file_manage.list({
+        filter: {
+          where: {
+            _id: id
+          }
+        },
+        envType: "prod"
+      })
+      .then(res => {
+        const record = res.data?.records?.[0];
+        if (!record) {
+          console.warn(`未找到 _id 为 ${id} 的文件`);
+        }
+        return record || null;
+      })
+      .catch(err => {
+        console.error(`获取文件 ${id} 失败`, err);
+        return null;
+      });
+    });
+
+    console.log(await Promise.all(fileDetailPromises), 'fileDetailPromises');
+    // 等待所有查询完成
+    const fileDetails = await Promise.all(fileDetailPromises);
+
+    // 第四步:更新页面数据(过滤掉失败项)
+    this.setData({
+      historyItems: fileDetails.filter(Boolean)
+    });
   },
 
+  // 收藏列表
+  // async getcollect() {
+  //   const { data } = await models.wx_collect.list({
+  //     filter: {
+  //       where: {
+  //         wx_user_id: this.data.userInfo._id
+  //       }
+  //     },
+  //     pageSize: 2, // 分页大小,建议指定,如需设置为其它值,需要和 pageNumber 配合使用,两者同时指定才会生效
+  //     pageNumber: 1, // 第几页
+  //     getCount: true, // 开启用来获取总数
+  //     envType: "prod",
+  //   });
+    
+  //   // 返回查询到的数据列表 records 和 总数 total
+  //   console.log(data);
+  //   const collectList = data.records || [];
+  //   if (collectList.length === 0) {
+  //     console.log('没有收藏记录');
+  //     this.setData({ collectFiles: [] });
+  //     return;
+  //   }
+
+  //   // 第二步:提取 file_manager_id 列表
+  //   const fileManagerIds = collectList.map(item => item.file_manager_id);
+
+  //   // 第三步:批量查询 file_manage 表中对应的文件数据
+  //   const fileRes = await models.file_manage.list({
+  //     filter: {
+  //       where: {
+  //         _id: { $in: fileManagerIds }  // 关键点:使用 $in 批量查询
+  //       }
+  //     },
+  //     envType: "prod",
+  //   });
+
+  //   // 第四步:更新页面数据
+  //   this.setData({
+  //     collectFiles: fileRes.data.records || []
+  //   });
+
+  //   console.log('收藏的文件数据:', fileRes.data.records);
+
+  // },
+
+  // 注销跳转
   handleLogout() {
+    wx.navigateTo({
+      url: `/subpackages/logoff/logoff`
+    });
+  },
 
+  // 修改用户名跳转
+  goToGoodsLists() {
     wx.navigateTo({
-          url: `/subpackages/logoff/logoff`
-        });
-      // 处理用户注销的逻辑
-      // wx.showModal({
-      //     title: '提示',
-      //     content: '确定要注销吗?',
-      //     success: (res) => {
-      //         if (res.confirm) {
-      //             // 注销成功后的处理逻辑
-      //             wx.showToast({
-      //                 title: '已注销',
-      //                 icon: 'success'
-      //             });
-      //         }
-      //     }
-      // });
+      url: '/subpackages/changename/changename?data=' + encodeURIComponent(JSON.stringify(this.data.userInfo))
+    });
   },
 
-  // 跳转
   goToGoodsList(e) {
-    const type = e.currentTarget.dataset.type;
+    const types = e.currentTarget.dataset.type
     wx.navigateTo({
-      url: `/subpackages/order/order?type=${type}`
+      url: '/subpackages/order/order?type=' + encodeURIComponent(types)
     });
   },
 
-  goToGoodsLists() {
-    wx.navigateTo({
-      url: `/subpackages/changename/changename`
+  // 点击相机修改用户头像
+  chooseAvatar() {
+    wx.showActionSheet({
+      itemList: ['拍照', '从相册选择'],
+      success: (res) => {
+        if (res.tapIndex === 0) {
+          this.chooseImage('camera');
+        } else if (res.tapIndex === 1) {
+          this.chooseImage('album');
+        }
+      }
     });
+  },
+
+  chooseImage(sourceType) {
+    wx.chooseMedia({
+      count: 1,
+      mediaType: ['image'],
+      sourceType: [sourceType], // 'camera' or 'album'
+      success: (res) => {
+        const tempFilePath = res.tempFiles[0].tempFilePath;
+        // 可选择上传到云存储,也可以直接更新 UI
+        this.uploadAvatar(tempFilePath);
+      },
+      fail: (err) => {
+        console.error('选择图片失败', err);
+      }
+    });
+  },
+
+  async uploadAvatar(filePath) {
+    const cloudPath = 'avatar/' + Date.now() + '-' + Math.floor(Math.random() * 1000) + '.png';
+    const uploadRes = await wx.cloud.uploadFile({
+      cloudPath,
+      filePath,
+    });
+
+    // 上传成功后更新用户头像
+    const avatarUrl = uploadRes.fileID;
+    console.log(avatarUrl, 'avatarUrl');
+
+    // 更新头像显示
+    this.setData({
+      'userInfo.img': avatarUrl
+    });
+
+    const cachedUserInfo = wx.getStorageSync('userInfo') || {};
+    cachedUserInfo.img = avatarUrl;
+    wx.setStorageSync('userInfo', cachedUserInfo);
+
+    console.log('缓存更新成功:', cachedUserInfo);
+
+    // TODO: 同步更新数据库中头像字段(可选)
+    const { data } = await models.wx_user.update({
+      data: {
+          img: avatarUrl,  // 头像
+        },
+      filter: {
+        where: {
+          _id: { $eq: this.data.userInfo._id }, // 推荐传入_id数据标识进行操作
+          delete: { $eq: 1 },
+        }
+      },
+      // envType: pre 体验环境, prod 正式环境
+      envType: "prod",
+    });
+    
+    if (data.count > 0) {
+      wx.showToast({
+        title: '头像修改成功',
+        icon: 'success'
+      });
+    } else {
+      wx.showToast({
+        title: '头像修改失败',
+        icon: 'none'
+      });
+    }
+
   }
 });

+ 14 - 10
pages/me/me.wxml

@@ -3,22 +3,24 @@
     <!-- 用户信息 -->
     <view class="user-info">
         <!-- <image class="avatar" src="{{userInfo.avatar}}" mode="aspectFill"></image> -->
-        <view class="avatar"></view>
-        <!-- <image style="width: 35rpx;height: 35rpx;margin-left: 20rpx;" src="{{xiangjiimg}}" mode=""/> -->
+        <view class="avatar">
+          <image style="width: 100%; height: 100%;border-radius: 50%;" src="{{userInfo.img}}" alt=""/>
+          <image bindtap="chooseAvatar" class="xiangjiimgs" src="{{xiangjiimg}}" mode=""/>
+        </view>
         <view class="info">
             <view style="display: flex; align-items: center;">
-              <text class="name">{{userInfo.name}}</text>
+              <text class="name">{{userInfo.user_name}}</text>
               <image bindtap="goToGoodsLists" style="width: 35rpx;height: 35rpx;margin-left: 20rpx;" src="{{xiugaiimg}}" mode=""/>
             </view>
             <view class="info_view2">
-              阳光幼儿园
+              {{xxdata.name}}
             </view>
         </view>
     </view>
 
     <!-- 绑定手机号 -->
     <view class="phone-binding">
-        <text style="margin-right: 20rpx;">绑定手机号:{{userInfo.phone ? userInfo.phone : '未绑定'}}</text>
+        <text style="margin-right: 20rpx;">绑定手机号:{{userInfo.phone ? displayPhone : '未绑定'}}</text>
         <navigator url="/subpackages/changephone/changephone" open-type="navigate" wx:if="{{userInfo.phone}}">更改手机号</navigator>
     </view>
 
@@ -44,14 +46,16 @@
             <block wx:for="{{historyItems}}" wx:key="id">
                 <view class="item">
                     <!-- <image mode="aspectFill"></image> -->
-                    <view class="thumbnail"></view>
+                    <view class="thumbnail">
+                      <image style="width: 100%; height: 100%;" src="{{item.cover}}" mode=""/>
+                    </view>
                     <view class="details">
                         <view class="name">{{item.name}}</view>
-                        <view class="date">{{item.date}}</view>
+                        <view class="date">{{item.createdAt}}</view>
+                    </view>
+                    <view class="xiazai_img">
+                      <image class="search-icon" src="{{souchangs}}" />
                     </view>
-                    <!-- <view class="xiazai_img">
-                      <image class="search-icon" src="../../image/imgs/xiazai.png" />
-                    </view> -->
                 </view>
             </block>
         </view>

+ 17 - 6
pages/me/me.wxss

@@ -8,15 +8,26 @@
 .user-info {
   display: flex;
   align-items: center;
-  margin-bottom: 20rpx;
+  margin-bottom: 40rpx;
 }
 
 .avatar {
-  width: 140rpx;
-  height: 140rpx;
+  width: 150rpx;
+  height: 150rpx;
   border-radius: 50%;
   margin-right: 20rpx;
-  background-color: palegreen
+  position: relative;
+}
+
+.avatar .xiangjiimgs {
+  position: absolute;
+  bottom: -25rpx;
+  left: 50%;
+  width: 60rpx;
+  height: 60rpx;
+  border-radius: 50%;
+  z-index: 9;
+  margin-left: -30rpx;
 }
 
 .info .name {
@@ -121,7 +132,7 @@ margin-top: 30rpx;
   width: 130rpx;
   height: 130rpx;
   margin-right: 20rpx;
-  background: palegreen;
+  overflow: hidden;
   border-radius: 12rpx;
 }
 
@@ -149,7 +160,7 @@ margin-top: 30rpx;
 
 .xiazai_img {
   width: 45rpx;
-  height: 35rpx;
+  height: 40rpx;
   float: right;
 }
 

+ 142 - 28
pages/shoppingcart/shoppingcart.js

@@ -1,30 +1,34 @@
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
   data: {
-    cartItems: [
-      {
-        id: '1',
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '幼儿启蒙绘本 10册套装',
-        description: '适合3-6岁儿童,培养创造力',
-        price: 134.00,
-        quantity: 1,
-        checked: true
-      },
-      {
-        id: '2',
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '幼儿启蒙绘本 10册套装',
-        description: '适合3-6岁儿童,培养创造力',
-        price: 134.00,
-        quantity: 1,
-        checked: true
-      }
-    ],
+    cartItems: [],
     souimg: '',
+    pageNumber: 1,
+    pageSize: 10,
+    hasMore: true, // 是否还有更多数据
+    isLoading: false, // 防止多次触发
+  },
+
+  onShow() {
+    // 列表数据
+    this.setData({
+      pageNumber: 1,
+      hasMore: true,
+      cartItems: []
+    }, () => {
+      this.getdatalist()
+    });
   },
 
   onLoad() {
-    this.updateTotalPrice();
+    // // 列表数据
+    // this.setData({
+    //   pageNumber: 1,
+    //   hasMore: true,
+    //   cartItems: []
+    // }, () => {
+    //   this.getdatalist()
+    // });
 
     const fileIDs = [
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
@@ -45,11 +49,108 @@ Page({
     });
   },
 
+  onReachBottom() {
+    // 上拉触底事件的处理函数
+    this.loadMore();
+  },
+
+  loadMore() {
+    // 加载更多数据的逻辑
+    console.log('加载更多');
+    this.getdatalist(true);
+  },
+
+  // 获取列表数据
+  async getdatalist(isLoadMore = false) {
+    if (this.data.isLoading || !this.data.hasMore) return;
+  
+    this.setData({ isLoading: true });
+  
+    const { pageNumber, pageSize } = this.data;
+    try {
+      const { data } = await models.shopping_cart.list({
+        filter: {
+          where: {}
+        },
+        pageSize,
+        pageNumber,
+        getCount: true, // 开启用来获取总数
+        // envType: pre 体验环境, prod 正式环境
+        envType: "prod",
+      });
+      
+      // 返回查询到的数据列表 records 和 总数 total
+      console.log(data);
+  
+      const collectList = data.records || [];
+      if (collectList.length === 0) {
+        this.setData({ hasMore: false, isLoading: false });
+        return;
+      }
+  
+      const fileManagerIds = collectList.map(item => item.merchandise_id);
+  
+      // 第二步:循环获取每个文件数据(单条查询)
+      const fileDetailPromises = fileManagerIds.map(id => {
+        return models.wx_merchandise.list({
+          filter: {
+            where: {
+              _id: id
+            }
+          },
+          envType: "prod"
+        }).then(res => {
+          const record = res.data?.records?.[0];
+          if (!record) {
+            console.warn(`未找到 _id 为 ${id} 的文件`);
+          }
+          return record || null;
+        })
+        .catch(err => {
+          console.error(`获取文件 ${id} 失败`, err);
+          return null;
+        });
+      });
+  
+      // 第三步:等待所有请求完成
+      const fileDetails = await Promise.all(fileDetailPromises);
+      console.log(fileDetails, 'fileDetails');
+  
+      // 第四步:过滤无效项,并添加 checked 字段
+      const newFiles = fileDetails
+      .filter(Boolean) // 去掉 null 或 undefined
+      .map((file, index) => {
+        const historyRecord = collectList[index]; // 获取原 download_history 的记录
+        if (!file) return null;
+        return {
+          ...file,
+          checked: false,
+          download_history_id: historyRecord._id,
+          specs_index: Number(historyRecord.specs_index),
+          num: historyRecord.num  // 关键:存 download_history 的 id
+        };
+      });
+  
+      this.setData({
+        cartItems: isLoadMore ? this.data.cartItems.concat(newFiles) : newFiles,
+        pageNumber: pageNumber + 1,
+        hasMore: collectList.length === pageSize, // 如果返回的数量小于 pageSize,说明已经到底
+        isLoading: false
+      }, () => {
+        this.updateTotalPrice();
+      });
+    } catch (err) {
+      console.error('获取收藏文件失败:', err);
+      this.setData({ isLoading: false });
+    }
+
+  },
+
   handleCheckboxChange(e) {
     const { value } = e.detail;
     const cartItems = this.data.cartItems.map(item => ({
       ...item,
-      checked: value.includes(item.id)
+      checked: value.includes(item.download_history_id)
     }));
     this.setData({ cartItems });
     this.updateTotalPrice();
@@ -69,7 +170,7 @@ Page({
   updateTotalPrice() {
     const totalPrice = this.data.cartItems.reduce((total, item) => {
       if (item.checked) {
-        return total + item.price * item.quantity;
+        return total + item.price * item.num;
       }
       return total;
     }, 0);
@@ -77,20 +178,33 @@ Page({
   },
 
   handleCheckout() {
-    // 处理结算逻辑
-    console.log('结算');
+    // 过滤出已选中的商品
+    const selectedItems = this.data.cartItems.filter(item => item.checked);
+    
+    if (selectedItems.length === 0) {
+      wx.showToast({
+        title: '请选择要结算的商品',
+        icon: 'none'
+      });
+      return;
+    }
+
+    // 将数据存入本地缓存
+    wx.setStorageSync('checkoutItems', selectedItems);
+
     wx.navigateTo({
       url: '/subpackages/submitorder/submitorder'
     });
   },
   
-
+  // 购买数量
   onChange(e) {
     const { id } = e.currentTarget.dataset;
     const { detail } = e;
+
     const cartItems = this.data.cartItems.map(item => {
-      if (item.id === id) {
-        return { ...item, quantity: detail };
+      if (item._id === id) {
+        return { ...item, num: detail };
       }
       return item;
     });

+ 31 - 22
pages/shoppingcart/shoppingcart.wxml

@@ -11,30 +11,39 @@
     </view>
 
     <!-- 商品列表 -->
-    <view class="cart-items">
-      <block wx:for="{{cartItems}}" wx:key="index">
-        <view class="cart-item">
-          <checkbox-group bindchange="handleCheckboxChange">
-            <label class="cart-checkbox">
-              <checkbox value="{{item.id}}" checked="{{item.checked}}" />
-            </label>
-          </checkbox-group>
-          <image class="cart-image" src="{{item.image}}" mode="aspectFill"></image>
-          <view class="cart-info">
-            <view class="cart-title">{{item.title}}</view>
-            <view class="cart-description">{{item.description}}</view>
-            <view style="display: flex;justify-content: space-between; margin-top: 30rpx;">
-              <view class="cart-price">¥{{item.price}}</view>
-              <van-stepper
-                value="{{item.quantity}}"
-                data-id="{{item.id}}"
-                bind:change="onChange"
-              />
+    <scroll-view
+      class="list_boxsss"
+      scroll-y="true"
+      bindscrolltolower="loadMore"
+      lower-threshold="100"
+    >
+      <checkbox-group bindchange="handleCheckboxChange">
+        <view class="cart-items">
+          <block wx:for="{{cartItems}}" wx:key="index">
+            <view class="cart-item">
+              <label class="cart-checkbox">
+                <checkbox value="{{item.download_history_id}}" checked="{{item.checked}}" />
+              </label>
+              <image class="cart-image" src="{{item.img}}" mode="aspectFill"></image>
+              <view class="cart-info">
+                <view class="cart-title">{{item.name}}</view>
+                <view class="cart-description">{{item.specs[item.specs_index]}}</view>
+                <view style="display: flex; justify-content: space-between; margin-top: 30rpx;">
+                  <view class="cart-price">¥{{item.price}}</view>
+                  <van-stepper
+                    value="{{item.num}}"
+                    data-id="{{item._id}}"
+                    bind:change="onChange"
+                  />
+                </view>
+              </view>
             </view>
-          </view>
+          </block>
         </view>
-      </block>
-    </view>
+      </checkbox-group>
+      <view wx:if="{{ isLoading }}" class="loading-text">加载中...</view>
+      <view wx:elif="{{ !hasMore }}" class="no-more-text">没有更多了</view>
+    </scroll-view>
 
     <!-- 底部工具栏 -->
     <view class="cart-footer">

+ 30 - 3
pages/shoppingcart/shoppingcart.wxss

@@ -1,16 +1,42 @@
 /* pages/shoppingcart/shoppingcart.wxss */
 .container {
   margin: 0rpx 30rpx;
+  height: calc(100vh - 40rpx);
+  overflow: hidden;
   width: calc(100% - 60rpx);
   padding: 0 0;
 }
 
 .cart-header {
-  width: 100%;
+  width: calc( 100% - 60rpx );
   display: flex;
   justify-content: space-between;
   align-items: center;
-  margin-bottom: 20rpx;
+  padding: 20rpx 30rpx;
+  position: fixed;
+  top: 0;
+  left: 0;
+  background: #f5f5f5;
+  z-index: 999;
+}
+
+.list_boxsss {
+  /* width: calc( 100% - 60rpx); */
+  height: calc(100% - 255rpx);
+  padding: 0rpx 30rpx;
+  position: fixed;
+  top: 120rpx;
+  left: 0;
+}
+
+.loading-text {
+  width: 100%;
+  text-align: center;
+}
+
+.no-more-text {
+  width: 100%;
+  text-align: center;
 }
 
 .search-bar {
@@ -50,7 +76,8 @@
 }
 
 .cart-items {
-  width: 100%;
+  width: calc(100% - 60rpx);
+  height: 100%;
   margin-bottom: 20rpx;
 }
 

+ 1 - 1
project.private.config.json

@@ -3,7 +3,7 @@
   "projectname": "jz-admin",
   "setting": {
     "compileHotReLoad": true,
-    "urlCheck": true,
+    "urlCheck": false,
     "coverView": true,
     "lazyloadPlaceholderEnable": false,
     "skylineRenderEnable": false,

+ 169 - 0
subpackages/address/address.js

@@ -0,0 +1,169 @@
+// const key = 'INCBZ-QYVK3-72F3B-RMOA2-OOIZ2-63BSR'; // 使用在腾讯位置服务申请的key
+// const referer = '红孩儿测试'; // 调用插件的app的名称
+// const hotCitys = ['北京', '上海', '广州', '深圳']; // 用户自定义的的热门城市
+// const accurate = '1'; // 是否使用getLocation进行定位
+
+// "permission": {
+//   "scope.userLocation": {
+//   "desc": "你的位置信息将用于小程序定位"
+//   }
+// },
+// "plugins": {
+//   "citySelector": {
+//     "version": "1.0.3",
+//     "provider": "wx63ffb7b7894e99ae"
+//   }
+// },
+Page({
+  data: {
+    latitude: 0, // 当前纬度
+    longitude: 0, // 当前经度
+    nearbyAddresses: [
+      {
+        name: '附近地址 1',
+        address: '详细地址 1',
+        checked: false
+      },
+      {
+        name: '附近地址 2',
+        address: '详细地址 2',
+        checked: false
+      }
+    ], // 附近地址列表
+    selectedAddress: null // 用户选中的地址
+  },
+
+  onShow() {
+    // wx.navigateTo({
+    //   url: `plugin://citySelector/index?key=${key}&referer=${referer}&hotCitys=${hotCitys}&accurate=${accurate}`,
+    // });
+  },
+  
+  onLoad() {
+    this.checkLocationAuthorization();
+  },
+
+  // 检查位置授权
+  checkLocationAuthorization() {
+    wx.getSetting({
+      success: (res) => {
+        if (!res.authSetting['scope.userLocation']) {
+          // 用户未授权,请求授权
+          wx.authorize({
+            scope: 'scope.userLocation',
+            success: () => {
+              this.getLocation();
+            },
+            fail: () => {
+              // 用户拒绝授权,提示用户手动开启位置服务
+              wx.showModal({
+                title: '提示',
+                content: '请在设置中开启位置服务授权',
+                showCancel: false,
+                confirmText: '去设置',
+                success: (res) => {
+                  if (res.confirm) {
+                    wx.openSetting({});
+                  }
+                }
+              });
+            }
+          });
+        } else {
+          // 用户已授权,直接获取位置信息
+          this.getLocation();
+        }
+      }
+    });
+  },
+
+  // 获取当前位置
+  getLocation() {
+    wx.getLocation({
+      type: 'wgs84',
+      success: (res) => {
+        const latitude = res.latitude;
+        const longitude = res.longitude;
+        this.setData({ latitude, longitude });
+        this.getNearbyAddresses(latitude, longitude);
+      },
+      fail: (err) => {
+        console.error('Failed to get location:', err);
+        wx.showToast({
+          title: '获取位置失败',
+          icon: 'none'
+        });
+      }
+    });
+  },
+
+  // 获取附近地址
+  getNearbyAddresses(latitude, longitude) {
+    const apiKey = 'INCBZ-QYVK3-72F3B-RMOA2-OOIZ2-63BSR'; // 替换为你的 API Key
+    const url = `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${apiKey}`;
+
+    wx.request({
+      url,
+      success: (res) => {
+        if (res.data.status === 0) {
+          const address = res.data.result.address;
+          const nearbyAddresses = [
+            {
+              name: '当前位置',
+              address: address,
+              checked: false
+            },
+            {
+              name: '附近地址 1',
+              address: '详细地址 1',
+              checked: false
+            },
+            {
+              name: '附近地址 2',
+              address: '详细地址 2',
+              checked: false
+            }
+          ];
+          this.setData({ nearbyAddresses });
+        } else {
+          console.error('Failed to get nearby addresses:', res.data.message);
+        }
+      },
+      fail: (err) => {
+        console.error('Request failed:', err);
+      }
+    });
+  },
+
+  // 选择地址
+  selectAddress(e) {
+    const index = e.currentTarget.dataset.index;
+    const nearbyAddresses = this.data.nearbyAddresses.map((item, i) => ({
+      ...item,
+      checked: i === index
+    }));
+    const selectedAddress = nearbyAddresses[index];
+    this.setData({ nearbyAddresses, selectedAddress });
+  },
+
+  // 取消
+  onCancel() {
+    wx.navigateBack();
+  },
+
+  // 确认
+  onConfirm() {
+    const { selectedAddress } = this.data;
+    if (selectedAddress) {
+      const pages = getCurrentPages();
+      const prevPage = pages[pages.length - 2]; // 上一页
+      prevPage.setData({ selectedAddress }); // 将选中的地址传递给上一页
+      wx.navigateBack();
+    } else {
+      wx.showToast({
+        title: '请选择一个地址',
+        icon: 'none'
+      });
+    }
+  }
+});

+ 4 - 0
subpackages/address/address.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "添加地址"
+}

+ 25 - 0
subpackages/address/address.wxml

@@ -0,0 +1,25 @@
+<view style="background: #f5f5f5; padding: 20rpx 0;">
+  <view class="goodslist_boxs">
+    <view class="top_boxs">
+      <view bindtap="onCancel">取消</view>
+      <view bindtap="onConfirm">确认</view>
+    </view>
+    <view class="search-bar">
+      <input type="text" placeholder="搜索地址" bindinput="onSearchInput" />
+    </view>
+    <!-- <map id="myMap" style="width: 100%; height: 300px; margin-top: 30rpx;" latitude="{{latitude}}" longitude="{{longitude}}" scale="15" bindtap="onMapTap"></map> -->
+    
+    <map id="qqMap" style="width: 100%; height: 300px; margin-top: 30rpx;" latitude="{{latitude}}" longitude="{{longitude}}" show-location></map>
+    <view class="address-list">
+      <block wx:for="{{nearbyAddresses}}" wx:key="index">
+        <view class="address-item" bindtap="selectAddress" data-index="{{index}}">
+          <view>
+            <view>{{item.name}}</view>
+            <view style="color: #9f9f9f;margin-top: 14rpx;">{{item.address}}</view>
+          </view>
+          <checkbox checked="{{item.checked}}"></checkbox>
+        </view>
+      </block>
+    </view>
+  </view>
+</view>

+ 44 - 0
subpackages/address/address.wxss

@@ -0,0 +1,44 @@
+.goodslist_boxs {
+  /* margin: 0rpx 30rpx; */
+  width: 100%;
+  height: calc(100vh - 40rpx);
+  overflow: hidden;
+}
+
+.top_boxs {
+  display: flex;
+  justify-content: space-between;
+  font-size: 34rpx;
+  margin: 0 30rpx;
+  width: calc(100% - 60rpx);
+}
+
+.search-bar {
+  margin: 0 30rpx;
+  width: calc(100% - 80rpx);
+  margin-top: 20rpx;
+  border: 1px solid #ccc;
+  padding: 10rpx;
+  border-radius: 10rpx;
+}
+
+.address-list {
+  margin: 0 30rpx;
+  width: calc(100% - 60rpx);
+  margin-top: 20rpx;
+  background-color: #fff;
+  border-radius: 10rpx;
+  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
+}
+
+.address-item {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding: 20rpx;
+  border-bottom: 1px solid #eee;
+}
+
+.address-item:last-child {
+  border-bottom: none;
+}

+ 95 - 9
subpackages/addresslist/addresslist.js

@@ -1,19 +1,17 @@
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
   data: {
-    addresses: [
-      {
-        address: '宁夏青铜峡市秦岭路846号'
-      },
-      {
-        address: '浙江省永康市红旗桥湖滨大道124号'
-      }
-    ],
+    addresses: [],
     souimg: '',
     shanchu: '',
     xiugaiimg: '',
     dingweiimg: '',
   },
 
+  onShow() {
+    this.getdatalist()
+  },
+
   onLoad(options) {
     // const title = options.title ? decodeURIComponent(options.title) : '商品列表';
     // this.setData({ title });
@@ -44,6 +42,26 @@ Page({
     });
   },
 
+  // 地址数据
+  async getdatalist() {
+    const { data } = await models.adresses.list({
+      filter: {
+        where: {}
+      },
+      pageSize: 100, // 分页大小,建议指定,如需设置为其它值,需要和 pageNumber 配合使用,两者同时指定才会生效
+      pageNumber: 1, // 第几页
+      getCount: true, // 开启用来获取总数
+      // envType: pre 体验环境, prod 正式环境
+      envType: "prod",
+    });
+    
+    // 返回查询到的数据列表 records 和 总数 total
+    console.log(data);
+    this.setData({
+      addresses: data.records
+    })
+  },
+
   handleEdit(e) {
     const index = e.currentTarget.dataset.index;
     // 处理编辑逻辑
@@ -54,7 +72,75 @@ Page({
     // 处理删除逻辑
   },
 
-  handleAddAddress() {
+  // 添加地址
+  async handleAddAddress() {
     // 处理添加地址逻辑
+    wx.navigateTo({
+      url: `/subpackages/address/address`
+    });
+
+    // const { data } = await models.adresses.create({
+    //   data: {
+    //       detailed_address: "沈阳国际软件园A区 A08栋 204",  // 详细地址
+    //       address: "辽宁省-沈阳市-浑南区-沈本大街-沈阳国际软件园A区 A08栋 204",  // 地址
+    //       municipality: "沈阳市",  // 市
+    //       default: 1,  // 默认
+    //       wx_user_id: "文本",  // 用户id
+    //       province: "辽宁省",  // 省
+    //       phone: "15376132110",  // 手机号
+    //       street: "沈本大街",  // 街道
+    //       district: "浑南区",  // 区县
+    //       name: "王五",  // 收货人
+    //     },
+    //   // envType: pre 体验环境, prod 正式环境
+    //   envType: "prod",
+    // });
+    
+    // // 返回创建的数据 id
+    // console.log(data);
+  },
+
+  // 删除地址
+  async onDelete(event) {
+    const _ids = event.currentTarget.dataset.id;
+    console.log(_ids, '_ids');
+    const { data } = await models.adresses.delete({
+      filter: {
+        where: {
+          $and: [
+            {
+              _id: {
+                $eq: _ids, // 推荐传入_id数据标识进行操作
+              },
+            },
+          ]
+        }
+      },
+      // envType: pre 体验环境, prod 正式环境
+      envType: "prod",
+    });
+    
+    // 返回删除成功的条数
+    console.log(data);
+    // 删除成功后,更新页面数据
+    if (data.count > 0) {
+      wx.showToast({
+        title: '删除成功',
+        icon: 'success',
+      });
+      this.getdatalist(); // 重新获取地址列表
+    } else {
+      wx.showToast({
+        title: '删除失败',
+        icon: 'none',
+      });
+    }
+  },
+
+  // 编辑
+  onEdit() {
+    wx.navigateTo({
+      url: `/subpackages/address/address`
+    });
   }
 });

+ 7 - 3
subpackages/addresslist/addresslist.wxml

@@ -12,10 +12,14 @@
       <block wx:for="{{addresses}}" wx:key="index">
         <view class="address_item">
           <image src="{{dingweiimg}}" class="location_icon"></image>
-          <text class="address_text">{{item.address}}</text>
+          <view class="address_text">
+            <view style="font-size: 25rpx; margin-bottom: 8rpx; color: #999999;">{{item.province}} {{item.municipality}} {{item.district}} {{item.street}}</view>
+            <view style="font-size: 34rpx; margin-bottom: 8rpx; font-weight: bold;">{{item.detailed_address}}</view>
+            <view style="font-size: 30rpx;">{{item.name}} {{item.phone}}</view>
+          </view>
           <view class="action_buttons">
-            <image class="search-icons" style="padding-right: 25rpx;" src="{{xiugaiimg}}" />
-            <image class="search-icons" src="{{shanchu}}" />
+            <image class="search-icons" style="padding-right: 25rpx;" src="{{xiugaiimg}}" bindtap="onEdit" data-id="{{item}}" />
+            <image class="search-icons" src="{{shanchu}}" bindtap="onDelete" data-id="{{item._id}}" />
           </view>
         </view>
       </block>

+ 77 - 47
subpackages/changename/changename.js

@@ -1,66 +1,96 @@
 // subpackages/changename/changename.js
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    userInfo: {},
+    newUserName: '', // 新用户名
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-
+    const itemData = decodeURIComponent(options.data);
+    const item = JSON.parse(itemData);
+    this.setData({
+      userInfo: item
+    });
+    console.log(this.data.userInfo, 'userInfo');
   },
 
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
+  // 获取新用户名输入
+  onInputNewName(e) {
+    this.setData({
+      newUserName: e.detail.value
+    });
   },
 
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
-
+  // 点击修改按钮
+  async onConfirmChange() {
+    const { userInfo, newUserName } = this.data;
+
+    if (!newUserName.trim()) {
+      wx.showToast({
+        title: '请输入新用户名',
+        icon: 'none'
+      });
+      return;
+    }
+
+    try {
+      const { data } = await models.wx_user.update({
+        data: {
+          user_name: newUserName
+        },
+        filter: {
+          where: {
+            $and: [
+              {
+                _id: {
+                  $eq: userInfo._id
+                }
+              }
+            ]
+          }
+        },
+        envType: "prod"
+      });
+
+
+    console.log(data, 'data');
+      // 判断是否更新成功(你可以根据实际返回结构调整判断逻辑)
+      if (data && (data.count > 0 || data.Count > 0)) {
+        // ✅ 更新本地缓存的 userInfo
+        const localUserInfo = wx.getStorageSync('userInfo') || {};
+        localUserInfo.user_name = newUserName;
+        wx.setStorageSync('userInfo', localUserInfo);
+
+        wx.showToast({
+          title: '修改成功',
+          icon: 'success',
+          duration: 1500
+        });
+  
+        // 1.5 秒后返回上一页
+        setTimeout(() => {
+          wx.navigateBack();
+        }, 1500);
+      } else {
+        wx.showToast({
+          title: '修改失败',
+          icon: 'none'
+        });
+      }
+    } catch (err) {
+      console.error('修改用户名失败', err);
+      wx.showToast({
+        title: '接口异常',
+        icon: 'none'
+      });
+    }
   }
 })

+ 3 - 3
subpackages/changename/changename.wxml

@@ -2,14 +2,14 @@
   <view class="goodslist_boxs">
     <view class="input-group">
       <label>原用户名</label>
-      <input type="text" placeholder="请输入原用户名" />
+      <input type="text" value="{{userInfo.user_name}}" disabled placeholder="请输入原用户名" />
     </view>
     <view class="input-group">
       <label>新用户名</label>
       <view>
-        <input type="text" placeholder="请输入用户名" />
+        <input type="text" placeholder="请输入用户名" bindinput="onInputNewName" />
       </view>
     </view>
-    <button class="confirm-btn">确定修改</button>
+    <button class="confirm-btn" bindtap="onConfirmChange">确定修改</button>
   </view>
 </view>

+ 103 - 40
subpackages/dahome/dahome.js

@@ -1,59 +1,33 @@
 // subpackages/dahome/dahome.js
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
   data: {
     levelOptions: ['初级', '中级', '高级'],
     selectedLevelIndex: 0,
     typeOptions: ['1', '2', '3'],
     selectedTypeIndex: 0,
-    items: [
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },{
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },{
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },{
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },
-    ],
+    items: [],
     souimg: '',
     xiaziimg: '',
     showimg: '',
     xialaimg: '',
-    goods_9: '',
+    pageNumber: 1,
+    pageSize: 10,
+    hasMore: true, // 是否还有更多数据
+    isLoading: false, // 防止多次触发
+    // goods_9: '',
   },
 
   onLoad() {
+    // 列表数据
+    this.getdatalist()
+    // 获取图片
     const fileIDs = [
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiazi.png',
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/show_1.png',
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiala.png',
-      'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/goods/goods_9.jpg'
+      // 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/goods/goods_9.jpg'
     ];
     
     // 并发下载多个 fileID
@@ -68,21 +42,110 @@ Page({
         xiaziimg: tempFilePaths[1],
         showimg: tempFilePaths[2],
         xialaimg: tempFilePaths[3],
-        goods_9: tempFilePaths[4],
+        // goods_9: tempFilePaths[4],
       });
     }).catch(err => {
       console.error('有文件下载失败:', err);
     });
   },
 
+  onReachBottom() {
+    // 上拉触底事件的处理函数
+    this.loadMore();
+  },
+
+  loadMore() {
+    // 加载更多数据的逻辑
+    console.log('加载更多');
+    this.getdatalist(true);
+  },
+
+
+  // 列表数据
+  async getdatalist(isLoadMore = false) {
+    console.log(Number(this.data.selectedTypeIndex) + 1, Number(this.data.selectedLevelIndex), 'this.data.selectedLevelIndex + 1');
+    const { pageNumber, pageSize } = this.data;
+    const { data } = await models.file_manage.list({
+      filter: {
+        where: {
+          tag_id: 'BULYBZSEY8',
+          level: Number(this.data.selectedTypeIndex) + 1,
+          dan: Number(this.data.selectedLevelIndex),
+        }
+      },
+      pageSize,
+      pageNumber,
+      getCount: true, // 开启用来获取总数
+      envType: "prod",
+    });
+    
+    const collectList = data.records || [];
+    // 返回查询到的数据列表 records 和 总数 total
+    console.log(data, '123123');
+    this.setData({
+      items: isLoadMore ? this.data.items.concat(collectList) : collectList,
+      pageNumber: pageNumber + 1,
+      hasMore: collectList.length === pageSize,
+      isLoading: false
+    })
+  },
+
   handleLevelChange(e) {
+    const index = Number(e.detail.value);
     this.setData({
-      selectedLevelIndex: e.detail.value
+      selectedLevelIndex: index,
+      pageNumber: 1, // 重置分页,从第一页查
+      hasMore: true,
+      isLoading: false,
+      items: [] // 可选:清空旧数据避免闪烁
     });
+    this.getdatalist(false)
   },
   handleTypeChange(e) {
+    const index = Number(e.detail.value);
     this.setData({
-      selectedTypeIndex: e.detail.value
+      selectedTypeIndex: index,
+      pageNumber: 1, // 重置分页,从第一页查
+      hasMore: true,
+      isLoading: false,
+      items: [] // 可选:清空旧数据避免闪烁
+    });
+    this.getdatalist(false)
+  },
+
+  goToGoodsList(event) {
+    // 获取绑定的数据
+    const item = event.currentTarget.dataset.item;
+    // 将数据转换为 JSON 字符串并传递
+    const itemStr = encodeURIComponent(JSON.stringify(item));
+    wx.navigateTo({
+      url: `/subpackages/details/details?item=${itemStr}`
     });
   }
+
+  // // 新增数据 async
+  // async dianji() {
+  //   const { data } = await models.file_manage.create({
+  //     data: {
+  //         level: 1,  // 级别
+  //         range: ['大班'],  // 适用范围
+  //         remark: "文本",  // 备注
+  //         type: 0,  // 文件类型
+  //         url: ['cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/123123.mp4'],  // 路径
+  //         download_count: 1,  // 下载人数
+  //         dan: 1,  // 段位
+  //         cover: "cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/未命名的设计.png",  // 封面
+  //         size: "123.12KB",  // 文件大小
+  //         name: "动手动脑图库5",  // 文件名
+  //         tag_id: "BULYF5VJ9W",  // 标签id
+  //         publisher: "李老师",  // 发布者
+  //         describe: "文本",  // 描述
+  //       },
+  //     // envType: pre 体验环境, prod 正式环境
+  //     envType: "prod",
+  //   });
+    
+  //   // 返回创建的数据 id
+  //   console.log(data);
+  // },
 })

+ 18 - 6
subpackages/dahome/dahome.wxml

@@ -16,16 +16,25 @@
         </picker>
       </view>
     </view>
+    <!-- <view>
+      <button bindtap="dianji" >新增数据</button>
+    </view> -->
     <!-- 列表 -->
-    <view class="list-box">
+    <scroll-view
+      class="list_boxsss"
+      scroll-y="true"
+      bindscrolltolower="loadMore"
+      lower-threshold="10"
+    >
+      <view class="list-box">
         <block wx:for="{{items}}" wx:key="index">
-          <view class="item">
-            <image class="item-image" src="{{goods_9}}" />
+          <view class="item" bindtap="goToGoodsList" data-item="{{item}}">
+            <image class="item-image" src="{{item.cover}}" />
             <view class="item-content">
-              <view class="item-title">{{item.title}}</view>
+              <view class="item-title">{{item.name}}</view>
               <view style="display: flex; justify-content: space-between;">
-                <view class="item-subtitle">{{item.subtitle}}</view>
-                <view class="item-download-count">已有{{item.downloadCount}}人下载</view>
+                <view class="item-subtitle">{{item.dan === 0 ? '初级' : item.dan === 1 ? '中级' : '高级'}}</view>
+                <view class="item-download-count">已有{{item.download_count}}人下载</view>
               </view>
               <view class="item-buttons">
                 <button class="preview-button"><image class="download-icons" src="{{showimg}}" />在线预览</button>
@@ -35,5 +44,8 @@
           </view>
         </block>
       </view>
+      <view wx:if="{{ isLoading }}" class="loading-text">加载中...</view>
+      <view wx:elif="{{ !hasMore }}" class="no-more-text">没有更多了</view>
+    </scroll-view>
   </view>
 </view>

+ 25 - 2
subpackages/dahome/dahome.wxss

@@ -1,6 +1,7 @@
 .container {
   margin: 0rpx 30rpx;
   width: calc(100% - 60rpx);
+  overflow: hidden;
   /* height: calc(100vh - 40rpx); */
   padding: 0 0;
 }
@@ -50,7 +51,7 @@
   background-color: #409eff;
   color: #fff;
   border-radius: 8rpx;
-  font-size: 32rpx;
+  font-size: 30rpx;
   display: flex;
   align-content: center;
   justify-content: center;
@@ -64,7 +65,8 @@
 }
 
 .list-box {
-  margin-top: 20rpx;
+  width: calc(100% - 60rpx);
+  /* margin-top: 20rpx; */
   display: flex;
   flex-wrap: wrap;
 }
@@ -141,3 +143,24 @@
   height: 40rpx;
   margin-right: 20rpx;
 }
+
+.list_boxsss {
+  /* width: calc( 100% - 60rpx); */
+  padding: 0rpx 30rpx;
+  height: calc(100% - 10rpx);
+  position: fixed;
+  top: 120rpx;
+  left: 0;
+}
+
+.loading-text {
+  padding-top: 20rpx;
+  width: 100%;
+  text-align: center;
+}
+
+.no-more-text {
+  padding-top: 20rpx;
+  width: 100%;
+  text-align: center;
+}

+ 237 - 0
subpackages/details/details.js

@@ -0,0 +1,237 @@
+// subpackagestow/details/details.js
+import { models, db, _ } from '../../utils/cloudbase.js'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    fileType: 'video',
+    viewType: 'grid',
+    courseList: [],
+    shouchang: '',
+    show_1: '',
+    xiazi: '',
+    xia: '',
+    itemlist: {},
+    // isCollected: false,
+    isPlaying: false,
+    isAudioPlaying: false,
+  },
+
+  onLoad(options) {
+    // 获取传递过来的数据
+    const itemStr = decodeURIComponent(options.item);
+    const item = JSON.parse(itemStr);
+    // 设置到页面数据中
+    this.setData({
+      itemlist: item
+    }, () => {
+      // 收藏
+      // this.getcollect()
+      // 相关推荐
+      this.getcourseList()
+    });
+    
+    // 获取图片
+    const fileIDs = [
+      'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/shouchang.png',
+      'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/show_1.png',
+      'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiazi.png',
+      'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xia_1.png'
+    ];
+    // 并发下载多个 fileID
+    Promise.all(
+      fileIDs.map(fileID => wx.cloud.downloadFile({ fileID }))
+    ).then(results => {
+      // 每个 result 对应一个下载结果
+      const tempFilePaths = results.map(r => r.tempFilePath);
+      console.log('全部下载成功:', tempFilePaths);
+      this.setData({
+        shouchang: tempFilePaths[0],
+        show_1: tempFilePaths[1],
+        xiazi: tempFilePaths[2],
+        xia: tempFilePaths[3],
+        shouchangs: tempFilePaths[4],
+      });
+    }).catch(err => {
+      console.error('有文件下载失败:', err);
+    });
+  },
+
+  // 相关课件推荐
+  async getcourseList() {
+    const { data } = await models.file_manage.list({
+      filter: {
+        where: {
+          level: this.data.itemlist.level,
+          dan: this.data.itemlist.dan, 
+          tag_id: this.data.itemlist.tag_id
+        }
+      },
+      pageSize: 20, // 分页大小,建议指定,如需设置为其它值,需要和 pageNumber 配合使用,两者同时指定才会生效
+      pageNumber: 1, // 第几页
+      getCount: true, // 开启用来获取总数
+      // envType: pre 体验环境, prod 正式环境
+      envType: "prod",
+    });
+    
+    // 返回查询到的数据列表 records 和 总数 total
+    console.log(data, 'data');
+    this.setData({
+      courseList: data.records
+    })
+  },
+
+  // 下载
+  goToGoodsLists(event) {
+    // 获取绑定的数据
+    const item = event.currentTarget.dataset.item;
+    // 将数据转换为 JSON 字符串并传递
+    const itemStr = encodeURIComponent(JSON.stringify(item));
+    wx.navigateTo({
+      url: `/subpackages/down/down?item=${itemStr}`
+    });
+  },
+
+    // 相关课件点击详情
+  goToGoodsList(event) {
+    // 获取绑定的数据
+    const item = event.currentTarget.dataset.item;
+    // 将数据转换为 JSON 字符串并传递
+    const itemStr = encodeURIComponent(JSON.stringify(item));
+    wx.navigateTo({
+      url: `/subpackagestow/details/details?item=${itemStr}`
+    });
+  },
+
+  // // 是否收藏
+  // async getcollect() {
+  //   const { data } = await models.wx_collect.get({
+  //     filter: {
+  //       where: {
+  //         file_manager_id: this.data.itemlist._id
+  //       }
+  //     },
+  //     // envType: pre 体验环境, prod 正式环境
+  //     envType: "prod",
+  //   });
+    
+  //   // 返回查询到的数据
+  //   console.log(data, '123321');
+  //   // 判断是否有值
+  //   if (data && Object.keys(data).length > 0) {
+  //     this.setData({
+  //       isCollected: true // 设置标志为 true
+  //     });
+  //   } else {
+  //     this.setData({
+  //       isCollected: false // 设置标志为 false
+  //     });
+  //   }
+  // },
+  // // 收藏
+  // async goTocollect() {
+  //   if (this.data.isCollected) {
+  //     const { data } = await models.wx_collect.delete({
+  //       filter: {
+  //         where: {
+  //           file_manager_id: _.eq(this.data.itemlist._id),  // 收藏文件id
+  //         }
+  //       },
+  //       // envType: pre 体验环境, prod 正式环境
+  //       envType: "prod",
+  //     });
+      
+  //     // 返回删除成功的条数
+  //     console.log(data, '删除');
+  //     wx.showToast({ title: '取消收藏成功', icon: 'success' });
+  //     this.setData({
+  //       isCollected: false
+  //     })
+
+  //   } else {
+  //     const userInfo = wx.getStorageSync('userInfo');
+  //     const { data } = await models.wx_collect.create({
+  //       data: {
+  //           wx_user_id: userInfo._id,  // 收藏人_id
+  //           file_manager_id: this.data.itemlist._id,  // 收藏文件id
+  //           remark: "备注备注备注备注备注备注",  // 备注
+  //         },
+  //       // envType: pre 体验环境, prod 正式环境
+  //       envType: "prod",
+  //     });
+      
+  //     // 返回创建的数据 id
+  //     console.log(data);
+  //     wx.showToast({ title: '收藏成功', icon: 'success' });
+  //     this.setData({
+  //       isCollected: true // 设置标志为 true
+  //     });
+  //   }
+  // },
+
+  // 预览
+  previewPDF() {
+    wx.cloud.downloadFile({
+      fileID: this.data.itemlist.url[0],
+      success: res => {
+        const filePath = res.tempFilePath;
+        const extension = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();
+        console.log('文件后缀:', extension);
+        // 根据文件类型处理
+        if (['pdf', 'ppt', 'pptx'].includes(extension)) {
+          wx.openDocument({
+            filePath: filePath,
+            fileType: extension,
+            success: () => {
+              console.log('文档打开成功');
+            },
+            fail: err => {
+              console.error('文档打开失败', err);
+            }
+          });
+        } else if (['mp3', 'aac', 'wav'].includes(extension)) {
+          console.log('这是一个音频文件,可以跳转到播放页面或使用音频组件');
+          // this.toggleAudio()
+        } else if (['mp4', 'mov'].includes(extension)) {
+          console.log('这是一个视频文件,可以跳转到视频播放页');
+          this.toggleVideo()
+        } else {
+          wx.showToast({
+            title: '暂不支持该文件类型预览',
+            icon: 'none'
+          });
+        }
+      },
+      fail: err => {
+        console.error('文件下载失败', err);
+      }
+    });
+  },
+
+  // 视频播放还是暂停
+  toggleVideo() {
+    const videoContext = wx.createVideoContext('myVideo', this);
+
+    if (this.data.isPlaying) {
+      videoContext.pause();
+      this.setData({ isPlaying: false });
+    } else {
+      videoContext.play();
+      this.setData({ isPlaying: true });
+    }
+  },
+  // 音频的播放暂停
+  toggleAudio() {
+    const audioContext = wx.createAudioContext('myAudio');
+  
+    if (this.data.isAudioPlaying) {
+      audioContext.pause();
+      this.setData({ isAudioPlaying: false });
+    } else {
+      audioContext.play();
+      this.setData({ isAudioPlaying: true });
+    }
+  }
+})

+ 6 - 0
subpackages/details/details.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "float": "/components/float/float"
+  },
+  "navigationBarTitleText": "详情"
+}

+ 84 - 0
subpackages/details/details.wxml

@@ -0,0 +1,84 @@
+<view style="background: #f5f5f5; padding: 20rpx 0;">
+  <view class="container">
+    <view class="header">
+      <text>{{ itemlist.name }}</text>
+      <text>{{itemlist.publisher}} • {{ itemlist.createdAt }}</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>
+    <!-- 预览 -->
+    <view class="{{itemlist.type === 1 ? '' : 'file-preview'}}">
+      <view class="file-preview" wx:if="{{itemlist.type === 0}}">
+        <video id="myVideo" class="course-videos" src="{{itemlist.url}}" controls></video>
+      </view>
+      <view class="file-previews" wx:elif="{{itemlist.type === 1}}">
+        <audio
+          class="course-videos"
+          src="{{itemlist.url}}"
+          controls
+          autoplay
+          loop
+          poster="{{itemlist.cover}}"
+          name="{{itemlist.name}}"
+          author="作者"
+        />
+      </view>
+      <view class="file-preview" wx:elif="{{itemlist.type === 2}}">
+        <image style="width: 100%; height: 100%;" src="{{itemlist.cover}}" alt="" class="file-placeholder"/>
+        <!-- <web-view src="{{itemlist.url}}"/> -->
+        <view class="play-button">点击下方按钮预览课件</view>
+      </view>
+      <view class="file-preview" wx:elif="{{itemlist.type === 3}}">
+        <image style="width: 100%; height: 100%;" src="{{itemlist.cover}}" alt="" class="file-placeholder"/>
+        <view class="play-button">点击下方按钮预览课件</view>
+      </view>
+      <view class="file-preview" wx:else>
+        <image style="width: 100%; height: 100%;" src="{{itemlist.cover}}" alt="" class="file-placeholder"/>
+      </view>
+    </view>
+    <view class="buttons">
+      <button bindtap="previewPDF" class="preview-btns yulan">
+        <image class="download-iconss" src="{{show_1}}" />
+        在线预览
+      </button>
+      <!-- <button class="preview-btns shoucang">
+        <image class="download-iconss" src="{{shouchang}}" />
+        收藏
+      </button> -->
+      <button bindtap="goToGoodsLists" data-item="{{itemlist}}" class="download-btn xiazai">
+        <image class="download-iconss" src="{{xia}}" />
+        下载
+      </button>
+    </view>
+    <view class="related-courses">相关课件推荐</view>
+    <!-- 列表 -->
+    <view class="course-list">
+      <block wx:for="{{courseList}}" wx:key="id">
+        <view class="card"  bindtap="goToGoodsList" data-item="{{item}}">
+          <view class="cardimg">
+            <image style="width: 100%; height: 100%;" src="{{item.cover}}" />
+            <view class="label {{item.type === 0 ? 'shipin' : item.type === 1 ? 'yinpin' : item.type === 2 ? 'PDF' : item.type === 3 ? 'PPT' : '图文'}} labelwg" >{{item.type === 0 ? '视频' : item.type === 1 ? '音频' : item.type === 2 ? 'PDF' : item.type === 3 ? 'PPT' : '图文'}}</view>
+          </view>
+          <view class="item-content">
+            <view class="item-title">{{item.name}}</view>
+            <view style="display: flex; justify-content: space-between;">
+              <view class="item-subtitle">
+                {{item.describe}}
+              </view>
+              <view class="item-download-count">
+               已有{{item.download_count}}人下载
+              </view>
+            </view>
+            <view class="item-buttons">
+              <button class="preview-btn"><image class="download-icons" src="{{show_1}}" />在线预览</button>
+              <image class="download-icon" src="{{xiazi}}" />
+            </view>
+          </view>
+          
+        </view>
+      </block>
+    </view>
+
+    
+    <float />
+  </view>
+</view>

+ 298 - 0
subpackages/details/details.wxss

@@ -0,0 +1,298 @@
+.container {
+  margin: 0rpx 30rpx;
+  width: calc(100% - 60rpx);
+  padding: 0 0;
+}
+
+.header {
+  width: calc(100% - 40rpx);
+  background-color: #fff;
+  padding: 20rpx;
+  border-radius: 10rpx;
+  margin-bottom: 20rpx;
+}
+
+.file-preview {
+  width: 100%;
+  height: 400rpx;
+  margin-bottom: 20rpx;
+  position: relative;
+}
+
+.file-previews {
+  width: 100%;
+  margin-bottom: 20rpx;
+  position: relative;
+}
+
+.play-button {
+  width: 100%;
+  text-align: center;
+  position: absolute;
+  top: 50%;
+  left: 50%;
+  transform: translate(-50%, -50%);
+  font-size: 38rpx;
+  font-weight: bold;
+  color: #333333;
+}
+
+.course-videos {
+  width: 100%;
+  height: 100%;
+  text-align: center;
+}
+
+video, audio {
+  width: 100%;
+  height: 100%;
+  object-fit: cover;
+  margin-bottom: 20rpx;
+}
+
+.header text {
+  display: block;
+  margin-bottom: 10rpx;
+}
+
+.video-preview {
+  width: 100%;
+  position: relative;
+  background-color: #ddd;
+  border-radius: 10rpx;
+  margin-bottom: 20rpx;
+}
+
+.video-placeholder {
+  width: 100%;
+  height: 100%;
+  object-fit: cover;
+}
+
+.buttons {
+  width: 100%;
+  display: flex;
+  justify-content: space-between;
+  margin-bottom: 20rpx;
+}
+
+.preview-btns, .download-btn {
+  /* background-color: #409eff; */
+  /* color: white; */
+  border: none;
+  padding: 15rpx 0 !important;
+  border-radius: 40rpx;
+  width: 30% !important;
+  height: 70rpx;
+  font-size: 28rpx;
+  font-weight: 500;
+}
+
+.yulan {
+  background: #409eff;
+  color: #fff;
+  border: 1rpx solid #409eff;
+}
+
+.shoucang {
+  background: #edecec !important;
+  border: 1rpx solid #edecec !important;
+}
+
+.shoucangs {
+  background: #ffaa2b;
+  border: 1rpx solid #ffaa2b;
+  color: #fff;
+}
+
+.xiazai {
+  background: #ecf5ff;
+  color: #409eff;
+  border: 1rpx solid #9fceff;
+}
+
+.related-courses {
+  width: 100%;
+  padding: 20rpx;
+  border-radius: 10rpx;
+  font-size: 34rpx;
+}
+
+.course-list{
+  width: 100%;
+  margin-top: 20rpx;
+  display: flex;
+  flex-wrap: wrap;
+}
+
+.card {
+  width: 48%;
+  margin-right: 4%;
+  margin-bottom: 20rpx;
+  background-color: #fff;
+  border-radius: 12rpx;
+  overflow: hidden;
+  box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1);
+}
+
+.card:nth-child(2n) {
+  margin-right: 0;
+}
+
+.label {
+  width: 60rpx;
+  height: 43rpx;
+  text-align: center;
+  line-height: 45rpx;
+  font-size: 26rpx;
+  padding: 5rpx 16rpx;
+  border-radius: 40rpx;
+}
+.label.PDF { background: #ffeaea; color: #ff4d4f; border: 1rpx solid #fde2e2;}
+.label.shipin { background: #e6f7ff; color: #1890ff; border: 1rpx solid #d9ecff;}
+.label.yinpin { background: #f6ffed; color: #52c41a; border: 1rpx solid #e1f3d8;}
+.label.PPT { background: #fff7e6; color: #faad14; border: 1rpx solid #fde2e2;}
+
+.preview-btn {
+  flex: 1;
+  background-color: #409eff;
+  color: #fff;
+  border: none;
+  border-radius: 40rpx;
+  padding: 12rpx 0;
+  font-size: 32rpx;
+  display: flex;
+  justify-content: center;
+  align-content: center;
+}
+
+.cardimg {
+  width: 100%;
+  height: 300rpx;
+  background: papayawhip;
+  border-radius: 12rpx;
+  position: relative;
+}
+
+.labelwg {
+  position: absolute;
+  top: 16rpx; 
+  left: 16rpx;
+}
+
+
+.info {
+  display: flex;
+  justify-content: space-between;
+  padding-top: 16rpx;
+  font-size: 26rpx;
+}
+
+.title_box.list {
+  width: 320rpx;
+  height: 100%;
+  margin-right: 80rpx;
+}
+
+.item-content {
+  padding: 20rpx;
+}
+
+.item-title {
+  font-size: 32rpx;
+  color: #333;
+  margin-bottom: 10rpx;
+}
+
+.item-subtitle {
+  font-size: 28rpx;
+  color: #666;
+  margin-bottom: 10rpx;
+}
+
+.item-download-count {
+  font-size: 24rpx;
+  color: #999;
+  margin-bottom: 20rpx;
+}
+
+.item-buttons {
+  display: flex;
+  align-items: center;
+  align-content: center;
+}
+
+.download-icon {
+  width: 45rpx;
+  height: 40rpx;
+  margin-left: 20rpx;
+}
+
+.download-icons {
+  width: 45rpx;
+  height: 40rpx;
+  margin-right: 20rpx;
+}
+
+.group-options {
+  display: flex;
+  justify-content: space-between;
+  margin-top: 20rpx;
+  width: 100%;
+}
+
+.option {
+  text-align: center;
+  margin-top: 20rpx;
+  display: flex; 
+  align-items: center; 
+  flex-direction: column;
+}
+
+.option-icon {
+  width: 80rpx;
+  height: 80rpx;
+  border-radius: 50%;
+}
+
+.option-text {
+  font-size: 28rpx;
+  color: #666;
+  margin-top: 16rpx;
+}
+
+.course-lists {
+  display: flex;
+  flex-direction: column;
+  gap: 20rpx;
+  margin-top: 20rpx;
+}
+
+.course-items {
+  background-color: #fff;
+  border-radius: 8rpx;
+  overflow: hidden;
+}
+
+.course-infos {
+  padding: 20rpx;
+}
+
+.course-titles {
+  font-size: 36rpx;
+  font-weight: bold;
+  color: #333;
+  margin-bottom: 10rpx;
+}
+
+.course-descriptions {
+  font-size: 28rpx;
+  color: #666;
+  line-height: 1.5;
+}
+
+.download-iconss {
+  width: 30rpx;
+  height: 30rpx;
+  margin-right: 15rpx;
+}

+ 47 - 0
subpackages/detailsimg/detailsimg.js

@@ -0,0 +1,47 @@
+// subpackages/detailsimg/detailsimg.js
+import { models, db, _ } from '../../utils/cloudbase.js'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    itemlist: {},
+    datalist: []
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    // 获取传递过来的数据
+    const itemStr = decodeURIComponent(options.item);
+    const item = JSON.parse(itemStr);
+    // 设置到页面数据中
+    this.setData({
+      itemlist: item
+    }, () => {
+      this.getdatalist()
+    });
+  },
+
+  async getdatalist() {
+    const { data } = await models.wx_details.list({
+      filter: {
+        where: {
+          file_manage_id: this.data.itemlist._id
+        }
+      },
+      pageSize: 10, // 分页大小,建议指定,如需设置为其它值,需要和 pageNumber 配合使用,两者同时指定才会生效
+      pageNumber: 1, // 第几页
+      getCount: true, // 开启用来获取总数
+      // envType: pre 体验环境, prod 正式环境
+      envType: "prod",
+    });
+    
+    // 返回查询到的数据列表 records 和 总数 total
+    this.setData({
+      datalist: data.records
+    })
+  },
+})

+ 6 - 0
subpackages/detailsimg/detailsimg.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "float": "/components/float/float"
+  },
+  "navigationBarTitleText": "详情"
+}

+ 10 - 0
subpackages/detailsimg/detailsimg.wxml

@@ -0,0 +1,10 @@
+<view style="background: #f5f5f5; padding: 20rpx 0;">
+  <view class="container">
+    <view wx:for="{{datalist}}" wx:key="id" class="boxs">
+      <view>描述:{{ item.describe }}</view>
+      <image class="item-image" src="{{item.url}}" />
+    </view>
+
+    <float />
+  </view>
+</view>

+ 20 - 0
subpackages/detailsimg/detailsimg.wxss

@@ -0,0 +1,20 @@
+.container {
+  margin: 0rpx 30rpx;
+  width: calc(100% - 60rpx);
+  /* height: calc(100vh - 40rpx); */
+  padding: 0 0;
+}
+
+.boxs {
+  width: calc( 100% - 20rpx );
+  padding: 20rpx;
+  margin: 20rpx 0;
+  background: #fff;
+  border-radius: 16rpx;
+}
+
+.item-image {
+  width: 100%;
+  height: 400rpx;
+  margin-top: 20rpx;
+}

+ 302 - 0
subpackages/down/down.js

@@ -0,0 +1,302 @@
+// subpackagestow/down/down.js
+import { models, db, _ } from '../../utils/cloudbase.js'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    fuzhi: '',
+    itemlist: {},
+    itemtempFileURL: '',
+    countdown: '00:05:00', // 倒计时文本
+    countdownTime: 300,    // 倒计时秒数(5分钟)
+    timer: null            // 定时器句柄
+  },
+
+  onLoad(options) {
+
+    // 获取传递过来的数据
+    const itemStr = decodeURIComponent(options.item);
+    const item = JSON.parse(itemStr);
+    // 设置到页面数据中
+    this.setData({
+      itemlist: item
+    }, () => {
+      wx.cloud.getTempFileURL({
+        fileList: [
+          {
+            fileID: this.data.itemlist.url[0]
+          }
+        ],
+        maxAge: 300  // 5分钟,单位秒
+      })
+      .then(res => {
+        console.log(res.fileList, 'fileList');
+        this.setData({
+          itemtempFileURL: res.fileList[0].tempFileURL
+        })
+        this.startCountdown(); // 启动倒计时
+      })
+      .catch(err => {
+        console.error(err);
+      });      
+    });
+
+    const fileIDs = [
+      'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/fuzhi.png',
+    ];
+    
+    // 并发下载多个 fileID
+    Promise.all(
+      fileIDs.map(fileID => wx.cloud.downloadFile({ fileID }))
+    ).then(results => {
+      // 每个 result 对应一个下载结果
+      const tempFilePaths = results.map(r => r.tempFilePath);
+      console.log('全部下载成功:', tempFilePaths);
+      this.setData({
+        fuzhi: tempFilePaths[0],
+      });
+    }).catch(err => {
+      console.error('有文件下载失败:', err);
+    });
+
+  },
+
+  // 五分钟倒计时
+  startCountdown() {
+    const interval = setInterval(() => {
+      let time = this.data.countdownTime;
+      if (time <= 0) {
+        clearInterval(interval);
+        this.setData({
+          countdown: '00:00:00',
+          timer: null
+        });
+        return;
+      }
+  
+      time--;
+      const min = String(Math.floor(time / 60)).padStart(2, '0');
+      const sec = String(time % 60).padStart(2, '0');
+      const formatted = `00:${min}:${sec}`;
+  
+      this.setData({
+        countdown: formatted,
+        countdownTime: time,
+        timer: interval
+      });
+    }, 1000);
+  },
+
+  // 分享到微信
+  onShareAppMessage() {
+    return {
+      title: this.data.itemlist.name || '文件分享',
+      path: `/subpackagestow/down/down?item=${encodeURIComponent(JSON.stringify(this.data.itemlist))}`,
+      imageUrl: this.data.itemlist.cover, // 可选:自定义分享图
+    }
+  },
+  handleShareTap() {
+    wx.showToast({
+      title: '请点击右上角“···”分享',
+      icon: 'none',
+      duration: 3000
+    });
+    this.getaddlishi()
+  },
+
+  // 保存链接地址
+  handleCopyLink() {
+    const link = this.data.itemtempFileURL;
+    if (!link) {
+      wx.showToast({
+        title: '暂无可复制链接',
+        icon: 'none'
+      });
+      return;
+    }
+
+    const that = this; // 保存页面上下文
+  
+    wx.setClipboardData({
+      data: link,
+      success() {
+        that.getaddlishi()
+        wx.showToast({
+          title: '链接已复制',
+          icon: 'success'
+        });
+      },
+      fail() {
+        wx.showToast({
+          title: '复制失败',
+          icon: 'none'
+        });
+      }
+    });
+  },
+
+  // 下载
+  handleDownloadFile() {
+    const url = this.data.itemtempFileURL;
+    if (!url) {
+      wx.showToast({
+        title: '文件链接不存在',
+        icon: 'none'
+      });
+      return;
+    }
+  
+    wx.showLoading({
+      title: '下载中...',
+      mask: true
+    });
+  
+    wx.downloadFile({
+      url: url,
+      success: (res) => {
+        wx.hideLoading();
+  
+        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 (['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 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'
+            });
+          }
+  
+        } 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);
+      }
+    });
+  },
+
+  // 新增下载历史
+  async getaddlishi() {
+    const userInfo = wx.getStorageSync('userInfo')
+    const { data } = await models.parent_download_history.create({
+      data: {
+          wx_user_id: userInfo._id,  // 用户id
+          delete: 0,  // 逻辑删除
+          file_manage_id: this.data.itemlist._id,  // 课件id
+        },
+      // envType: pre 体验环境, prod 正式环境
+      envType: "prod",
+    });
+    
+    // 返回更新成功的条数
+    console.log(this.data.itemlist._id, 'this.data.itemlist._id');    
+  },
+
+  // 清除定时器
+  onUnload() {
+    if (this.data.timer) {
+      clearInterval(this.data.timer);
+      this.setData({ timer: null });
+    }
+  }
+})

+ 7 - 0
subpackages/down/down.json

@@ -0,0 +1,7 @@
+{
+  "usingComponents": {
+    "float": "/components/float/float"
+  },
+  "navigationBarTitleText": "下载",
+  "enableShareAppMessage": true
+}

+ 28 - 0
subpackages/down/down.wxml

@@ -0,0 +1,28 @@
+<view style="background: #f5f5f5; padding: 20rpx 0;">
+  <view class="container">
+    <view class="top_boxs">
+     <view class="title">{{itemlist.name}}</view>
+     <view>文件大小:{{itemlist.size}}</view>
+     <view class="item_boxs">连接有效期剩余:{{countdown}}</view>
+    </view>
+    <view style="width: 100%;">
+      <button class="preview-btn" bindtap="handleDownloadFile">立即下载</button>
+    </view>
+    <view class="top_boxs">
+     <view class="title">分享下载链接</view>
+     <view style="display: flex; padding: 20rpx 0; justify-content: space-between;">
+      <view style="display: flex; width: 90%; border: 1rpx solid #e4e7ed; height: 80rpx; line-height: 80rpx; border-radius: 12rpx;">
+        <!-- <view style="width: 30%; text-align: center;border-right: 1rpx solid #e4e7ed; background: #f5f7fa; font-weight: 600; color: #606266;">Https: //</view> -->
+        <view style="width: 100%; padding-left: 20rpx; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">{{ itemtempFileURL ? itemtempFileURL : '暂无' }}</view>
+      </view>
+      <image style="width: 50rpx;height: 50rpx; margin-top: 15rpx;" src="{{fuzhi}}" mode=""/>
+     </view>
+     <view class="dowm_boxs">
+      <button class="dowm_boxs-btn" bindtap="handleShareTap">分享到微信</button>
+      <button class="dowm_boxs-btns" bindtap="handleCopyLink">保存链接地址</button>
+     </view>
+    </view>
+
+    <float />
+  </view>
+</view>

+ 60 - 0
subpackages/down/down.wxss

@@ -0,0 +1,60 @@
+.container {
+  margin: 0rpx 30rpx;
+  width: calc(100% - 60rpx);
+  padding: 0 0;
+}
+
+.top_boxs {
+  width: calc(100% - 40rpx);
+  padding: 20rpx;
+  background: #fff;
+  border-radius: 16rpx;
+  font-size: 32rpx;
+}
+
+.title {
+  font-size: 36rpx;
+  margin-bottom: 20rpx;
+}
+
+.item_boxs {
+  width: calc(100% - 40rpx);
+  background: #ffe2e2;
+  padding: 16rpx;
+  margin-top: 20rpx;
+  color: #ea0000;
+  border-radius: 12rpx;
+}
+
+.preview-btn {
+  background: #409eff;
+  font-weight: 500;
+  color: #fff;
+  width: 100% !important;
+  height: 80rpx !important;
+  margin: 50rpx;
+  border-radius: 40rpx;
+}
+
+.dowm_boxs {
+  display: flex;
+  padding-top: 20rpx;
+}
+
+.dowm_boxs-btn {
+  width: 45% !important;
+  background: #409eff;
+  border: 1rpx solid #409eff;
+  font-weight: 500;
+  color: #fff;
+  border-radius: 40rpx;
+}
+
+.dowm_boxs-btns {
+  width: 45% !important;
+  background: #ecf5ff;
+  border: 1rpx solid #409eff;
+  font-weight: 500;
+  color: #409eff;
+  border-radius: 40rpx;
+}

+ 69 - 44
subpackages/imghome/imghome.js

@@ -1,55 +1,29 @@
 // subpackages/dahome/dahome.js
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
   data: {
     // levelOptions: ['初级', '中级', '高级'],
     // selectedLevelIndex: 0,
     typeOptions: ['1段', '2段', '3段'],
     selectedTypeIndex: 0,
-    items: [
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },{
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },{
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },{
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '全脑智能开发答案',
-        subtitle: '初级1',
-        downloadCount: 128
-      },
-    ],
+    items: [],
     souimg: '',
     xialaimg: '',
-    goods_9: '',
+    pageNumber: 1,
+    pageSize: 10,
+    hasMore: true, // 是否还有更多数据
+    isLoading: false, // 防止多次触发
+    // goods_9: '',
   },
 
   onLoad() {
+    // 列表数据
+    this.getdatalist()
+    // 获取图片
     const fileIDs = [
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiala.png',
-      'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/goods/goods_9.jpg'
+      // 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/goods/goods_9.jpg'
     ];
     
     // 并发下载多个 fileID
@@ -62,21 +36,72 @@ Page({
       this.setData({
         souimg: tempFilePaths[0],
         xialaimg: tempFilePaths[1],
-        goods_9: tempFilePaths[2],
+        // goods_9: tempFilePaths[2],
       });
     }).catch(err => {
       console.error('有文件下载失败:', err);
     });
   },
 
-  // handleLevelChange(e) {
-  //   this.setData({
-  //     selectedLevelIndex: e.detail.value
-  //   });
-  // },
+  onReachBottom() {
+    // 上拉触底事件的处理函数
+    this.loadMore();
+  },
+
+  loadMore() {
+    // 加载更多数据的逻辑
+    console.log('加载更多');
+    this.getdatalist(true);
+  },
+
+  // 列表数据
+  async getdatalist(isLoadMore = false) {
+    const { pageNumber, pageSize } = this.data;
+    const { data } = await models.file_manage.list({
+      filter: {
+        where: {
+          tag_id: 'BULYF5VJ9W',
+          level: Number(this.data.selectedTypeIndex) + 1,
+          // dan: 1,
+        }
+      },
+      pageSize,
+      pageNumber,
+      getCount: true, // 开启用来获取总数
+      envType: "prod",
+    });
+    
+    // 返回查询到的数据列表 records 和 总数 total
+    const collectList = data.records || [];
+    this.setData({
+      items: isLoadMore ? this.data.items.concat(collectList) : collectList,
+      pageNumber: pageNumber + 1,
+      hasMore: collectList.length === pageSize,
+      isLoading: false
+    })
+  },
+
+  goToGoodsList(event) {
+    // 获取绑定的数据
+    const item = event.currentTarget.dataset.item;
+    // 将数据转换为 JSON 字符串并传递
+    const itemStr = encodeURIComponent(JSON.stringify(item));
+    wx.navigateTo({
+      url: `/subpackages/detailsimg/detailsimg?item=${itemStr}`
+    });
+  },
+
   handleTypeChange(e) {
+    const index = Number(e.detail.value);
+
     this.setData({
-      selectedTypeIndex: e.detail.value
+      selectedTypeIndex: index,
+      pageNumber: 1, // 重置分页,从第一页查
+      hasMore: true,
+      isLoading: false,
+      items: [] // 可选:清空旧数据避免闪烁
     });
+
+    this.getdatalist(false);
   }
 })

+ 14 - 5
subpackages/imghome/imghome.wxml

@@ -18,18 +18,27 @@
     </view>
 
     <!-- 列表 -->
-    <view class="list-box">
+    <scroll-view
+      class="list_boxsss"
+      scroll-y="true"
+      bindscrolltolower="loadMore"
+      lower-threshold="100"
+    >
+      <view class="list-box">
         <block wx:for="{{items}}" wx:key="index">
-          <view class="item">
-            <image class="item-image" src="{{goods_9}}" />
+          <view class="item" bindtap="goToGoodsList" data-item="{{item}}">
+            <image class="item-image" src="{{item.cover}}" />
             <view class="item-content">
-              <view class="item-title">{{item.title}}</view>
+              <view class="item-title">{{item.name}}</view>
               <view style="display: flex; justify-content: space-between;">
-                <view class="item-subtitle">{{item.subtitle}}</view>
+                <view class="item-subtitle">{{item.level}}</view>
               </view>
             </view>
           </view>
         </block>
       </view>
+      <view wx:if="{{ isLoading }}" class="loading-text">加载中...</view>
+      <view wx:elif="{{ !hasMore }}" class="no-more-text">没有更多了</view>
+    </scroll-view>
   </view>
 </view>

+ 23 - 1
subpackages/imghome/imghome.wxss

@@ -3,6 +3,7 @@
   width: calc(100% - 60rpx);
   /* height: calc(100vh - 40rpx); */
   padding: 0 0;
+  overflow: hidden;
 }
 
 .container {
@@ -71,7 +72,7 @@
 }
 
 .list-box {
-  margin-top: 20rpx;
+  width: calc(100% - 60rpx);
   display: flex;
   flex-wrap: wrap;
 }
@@ -124,3 +125,24 @@
   align-content: center;
 }
 
+.list_boxsss {
+  /* width: calc( 100% - 60rpx); */
+  padding: 0rpx 30rpx;
+  height: calc(100% - 160rpx);
+  position: fixed;
+  top: 120rpx;
+  left: 0;
+}
+
+.loading-text {
+  padding-top: 20rpx;
+  width: 100%;
+  text-align: center;
+}
+
+.no-more-text {
+  padding-top: 20rpx;
+  width: 100%;
+  text-align: center;
+}
+

+ 89 - 22
subpackages/logoff/logoff.js

@@ -1,6 +1,8 @@
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
   data: {
-    selectedReasons: []
+    selectedReasons: [],
+    feedback: '' // 新增 feedback 字段
   },
 
   onLoad(options) {
@@ -8,24 +10,21 @@ Page({
   },
 
   handleCheckboxChange(e) {
-    const { value } = e.detail;
-    let selectedReasons = this.data.selectedReasons;
-
-    if (value.includes('use_inconvenience')) {
-      selectedReasons.includes('use_inconvenience') ? selectedReasons.splice(selectedReasons.indexOf('use_inconvenience'), 1) : selectedReasons.push('use_inconvenience');
-    }
-    if (value.includes('security_privacy')) {
-      selectedReasons.includes('security_privacy') ? selectedReasons.splice(selectedReasons.indexOf('security_privacy'), 1) : selectedReasons.push('security_privacy');
-    }
-    if (value.includes('other_reasons')) {
-      selectedReasons.includes('other_reasons') ? selectedReasons.splice(selectedReasons.indexOf('other_reasons'), 1) : selectedReasons.push('other_reasons');
-    }
+    console.log('checkbox change:', e.detail.value); // e.detail.value 是一个数组
+    this.setData({
+      selectedReasons: e.detail.value
+    });
+  },
 
-    this.setData({ selectedReasons });
+  handleFeedbackInput(e) {
+    this.setData({
+      feedback: e.detail.value
+    });
   },
 
-  confirmLogout() {
-    const { selectedReasons } = this.data;
+  async confirmLogout() {
+    const { selectedReasons, feedback } = this.data;
+  
     if (selectedReasons.length === 0) {
       wx.showToast({
         title: '请选择注销原因',
@@ -33,16 +32,84 @@ Page({
       });
       return;
     }
-
+  
+    if (!feedback.trim()) {
+      wx.showToast({
+        title: '请输入意见或建议',
+        icon: 'none'
+      });
+      return;
+    }
+  
+    // 弹出确认框
+    const that = this; // 保证作用域正确
     wx.showModal({
       title: '提示',
       content: '确定要注销吗?',
-      success(res) {
+      success: async function (res) {
         if (res.confirm) {
-          // 执行注销操作
-          console.log('用户点击确定');
-        } else if (res.cancel) {
-          console.log('用户点击取消');
+          // 获取本地用户信息
+          const userInfo = wx.getStorageSync('userInfo');
+          if (!userInfo || !userInfo._id) {
+            wx.showToast({
+              title: '用户信息异常',
+              icon: 'none'
+            });
+            return;
+          }
+  
+          const reasonStr = that.data.selectedReasons.join(',');
+  
+          try {
+            const { data } = await models.wx_user.update({
+              data: {
+                delete: 1, // 逻辑删除
+                log_off: reasonStr,
+              },
+              filter: {
+                where: {
+                  _id: {
+                    $eq: userInfo._id,
+                  }
+                }
+              },
+              envType: "prod"
+            });
+  
+            if (data.count > 0) {
+              // 注销成功,清除本地缓存
+              wx.removeStorageSync('userInfo');
+  
+              wx.showToast({
+                title: '注销成功',
+                icon: 'success',
+                duration: 2000
+              });
+  
+              // 可选:跳转到登录页
+              setTimeout(() => {
+                wx.redirectTo({
+                  url: '/pages/logins/logins'
+                });
+              }, 2000);
+  
+            } else {
+              wx.showToast({
+                title: '注销失败',
+                icon: 'none'
+              });
+            }
+  
+          } catch (err) {
+            console.error('注销失败:', err);
+            wx.showToast({
+              title: '服务器错误',
+              icon: 'none'
+            });
+          }
+  
+        } else {
+          console.log('用户取消注销');
         }
       }
     });

+ 13 - 11
subpackages/logoff/logoff.wxml

@@ -10,23 +10,25 @@
     <!-- 请选择注销用户的原因 -->
     <view class="reasons">
       <view class="title">请选择注销用户的原因</view>
-      <label class="checkbox-item">
-        <checkbox value="use_inconvenience" /> 使用不便
-      </label>
-      <label class="checkbox-item">
-        <checkbox value="security_privacy" /> 安全或隐私顾虑
-      </label>
-      <label class="checkbox-item">
-        <checkbox value="other_reasons" /> 其他原因
-      </label>
+      <checkbox-group bindchange="handleCheckboxChange">
+        <label class="checkbox-item">
+          <checkbox value="使用不便" /> 使用不便
+        </label>
+        <label class="checkbox-item">
+          <checkbox value="安全或隐私顾虑" /> 安全或隐私顾虑
+        </label>
+        <label class="checkbox-item">
+          <checkbox value="其他原因" /> 其他原因
+        </label>
+      </checkbox-group>
     </view>
 
     <!-- 请输入您的意见或建议 -->
     <view class="feedback">
-      <textarea placeholder="请输入您的意见或建议" />
+      <textarea placeholder="请输入您的意见或建议" bindinput="handleFeedbackInput" />
     </view>
 
     <!-- 确认注销按钮 -->
-    <button class="confirm-button">确认注销</button>
+    <button class="confirm-button" bindtap="confirmLogout">确认注销</button>
   </view>
 </view>

+ 115 - 32
subpackages/order/order.js

@@ -1,3 +1,4 @@
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
   data: {
     categoriesindex: 1,
@@ -19,36 +20,12 @@ Page({
         type: 4,
       }
     ],
-    orders: [
-      {
-        status: 1,
-        date: '2023-05-01',
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '幼儿启蒙绘本 10册套装',
-        description: '适合3-6岁儿童,培养创造力',
-        price: 134.00,
-        actionText: '确认收货'
-      },
-      {
-        status: 2,
-        date: '2023-05-01',
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '幼儿启蒙绘本 10册套装',
-        description: '适合3-6岁儿童,培养创造力',
-        price: 134.00,
-        actionText: '立即支付'
-      },
-      {
-        status: 3,
-        date: '2023-05-01',
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '幼儿启蒙绘本 10册套装',
-        description: '适合3-6岁儿童,培养创造力',
-        price: 134.00,
-        actionText: '再来一单'
-      }
-    ],
+    orders: [],
     souimg: '',
+    pageNumber: 1,
+    pageSize: 10,
+    hasMore: true, // 是否还有更多数据
+    isLoading: false, // 防止多次触发
   },
 
   onLoad(options) {
@@ -57,6 +34,8 @@ Page({
     // 根据 type 加载数据
     this.setData({
       categoriesindex: type
+    }, () => {
+      this.getdatalist(); // 确保 this 指向正确
     });
     const fileIDs = [
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
@@ -75,11 +54,112 @@ Page({
       console.error('有文件下载失败:', err);
     });
   },
+  
+  onReachBottom() {
+    // 上拉触底事件的处理函数
+    this.loadMore();
+  },
+
+  loadMore() {
+    // 加载更多数据的逻辑
+    console.log('加载更多');
+    this.getdatalist(true);
+  },
+
+  async getdatalist(isLoadMore = false) {
+    if (this.data.isLoading || !this.data.hasMore) return;
+  
+    this.setData({ isLoading: true });
+    const { pageNumber, pageSize } = this.data;
+    try {
+      // 根据 categoriesindex 的值动态设置 filter
+      const filter = {};
+      if (this.data.categoriesindex !== 1) {
+        filter.where = {
+          status: this.data.categoriesindex - 2, // 减去 2
+        };
+      }
+
+      const { data } = await models.orders.list({
+        filter, // 动态传递 filter
+        pageSize,
+        pageNumber,
+        getCount: true, // 开启用来获取总数
+        envType: 'prod', // 正式环境
+      });
+
+      // 返回查询到的数据列表 records 和 总数 total
+      const collectList = data.records || [];
+      if (collectList.length === 0) {
+        this.setData({ hasMore: false, isLoading: false });
+        return;
+      }
+      console.log(collectList, 'collectList');
+
+      const fileManagerIds = collectList.map(item => item.merchandise_id);
+
+      console.log(fileManagerIds, 'fileManagerIds');
+      // 第二步:循环获取每个文件数据(单条查询)
+      const fileDetailPromises = fileManagerIds.map(id => {
+        return models.wx_merchandise.list({
+          filter: {
+            where: {
+              _id: id
+            }
+          },
+          envType: "prod"
+        }).then(res => {
+          const record = res.data?.records?.[0];
+          if (!record) {
+            console.warn(`未找到 _id 为 ${id} 的文件`);
+          }
+          return record || null;
+        })
+        .catch(err => {
+          console.error(`获取文件 ${id} 失败`, err);
+          return null;
+        });
+      });
+
+      // 第三步:等待所有请求完成
+      const fileDetails = await Promise.all(fileDetailPromises);
+      console.log(fileDetails, 'fileDetails');
+
+      // 第四步:过滤无效项,并添加 checked 字段
+      const newFiles = fileDetails
+      .filter(Boolean) // 去掉 null 或 undefined
+      .map((file, index) => {
+        const historyRecord = collectList[index]; // 获取原 download_history 的记录
+        if (!file) return null;
+        return {
+          ...file,
+          ...historyRecord
+        };
+      });
+
+      this.setData({
+        orders: isLoadMore ? this.data.orders.concat(newFiles) : newFiles,
+        pageNumber: pageNumber + 1,
+        hasMore: collectList.length === pageSize, // 如果返回的数量小于 pageSize,说明已经到底
+        isLoading: false
+      });
+  } catch (err) {
+    console.error('获取失败:', err);
+    this.setData({ isLoading: false });
+  }
+  },
 
   tabcategories(e) {
     const type = e.currentTarget.dataset.type;
+    console.log('type:', type);
     this.setData({
-      categoriesindex: type
+      categoriesindex: type,
+      pageNumber: 1, // 重置页码
+      hasMore: true, // 重置是否有更多数据
+      orders: [], // 清空旧数据
+    }, () => {
+      console.log('categoriesindex:', this.data.categoriesindex);
+      this.getdatalist(false);
     });
   },
 
@@ -137,9 +217,12 @@ Page({
       }
   },
 
-  goToGoodsList () {
+  goToGoodsList (e) {
+    const index = e.currentTarget.dataset.type;
+    const item = this.data.orders[index];
+    // console.log(e.currentTarget, 'item');
     wx.navigateTo({
-      url: '/subpackages/orderdetails/orderdetails'
+      url: '/subpackages/orderdetails/orderdetails?data=' + encodeURIComponent(JSON.stringify(item))
     });
   }
 });

+ 36 - 27
subpackages/order/order.wxml

@@ -14,35 +14,44 @@
     </view>
 
     <!-- 列表 -->
-    <view class="order-list">
-      <block wx:for="{{orders}}" wx:key="order_id">
-        <view class="order-item" bindtap="goToGoodsList">
-          <view class="order-status">
-            <view class="{{ item.status === 1 ? 'dsh' : item.status === 2 ? 'dfk' : 'ywc' }}">{{item.status === 1 ? "待收货" : item.status === 2 ? "待付款" : "已完成"}}</view>
-            <view>{{item.date}}</view>
-          </view>
-          <view>订单号: {{item.price}}</view>
-          <view class="order-detail">
-            <image class="order-image" src="{{item.image}}" mode="aspectFill"></image>
-            <view class="order-info">
-              <view class="order-title">{{item.title}}</view>
-              <view style="display: flex; justify-content: space-between;">
-                <view class="order-description">{{item.description}}</view>
-                <view class="order-price">¥{{item.price}}</view>
+    <scroll-view
+      class="list_boxsss"
+      scroll-y="true"
+      bindscrolltolower="loadMore"
+      lower-threshold="100"
+    >
+      <view class="order-list">
+        <block wx:for="{{orders}}" wx:key="order_id">
+          <view class="order-item" bindtap="goToGoodsList" data-type="{{index}}">
+            <view class="order-status">
+              <view class="{{ item.status === 1 ? 'dsh' : item.status === 0 ? 'dfk' : 'ywc' }}">{{item.status === 1 ? "待收货" : item.status === 0 ? "待付款" : "已完成"}}</view>
+              <view>{{item.createdAt}}</view>
+            </view>
+            <view>订单号: {{item.order_id}}</view>
+            <view class="order-detail">
+              <image class="order-image" src="{{item.img}}" mode="aspectFill"></image>
+              <view class="order-info">
+                <view class="order-title">{{item.name}}</view>
+                <view style="display: flex; justify-content: space-between;">
+                  <view class="order-description">简单描述</view>
+                  <view class="order-price">¥{{item.real_money}}</view>
+                </view>
+                <view class="order-description">数量: 购买数量这个到时候要看怎么获取</view>
               </view>
-              <view class="order-description">数量: 1</view>
+            </view>
+            <view class="order-actions">
+              <button class="order-action-btn1" bindtap="handleAction1" data-index="{{index}}">
+                  {{ item.status === 1 ? "查看详情" : item.status === 0 ? "取消订单" : "申请售后" }}
+              </button>
+              <button class="order-action-btn2" bindtap="handleAction2" data-index="{{index}}">
+                  {{ item.status === 1 ? "确认收货" : item.status === 0 ? "立即支付" : "再来一单" }}
+              </button>
             </view>
           </view>
-          <view class="order-actions">
-            <button class="order-action-btn1" bindtap="handleAction1" data-index="{{index}}">
-                {{ item.status === 1 ? "查看详情" : item.status === 2 ? "取消订单" : "申请售后" }}
-            </button>
-            <button class="order-action-btn2" bindtap="handleAction2" data-index="{{index}}">
-                {{ item.status === 1 ? "确认收货" : item.status === 2 ? "立即支付" : "再来一单" }}
-            </button>
-          </view>
-        </view>
-      </block>
-    </view>
+        </block>
+      </view>
+      <view wx:if="{{ isLoading }}" class="loading-text">加载中...</view>
+      <view wx:elif="{{ !hasMore }}" class="no-more-text">没有更多了</view>
+    </scroll-view>
   </view>
 </view>

+ 22 - 1
subpackages/order/order.wxss

@@ -2,6 +2,7 @@
   margin: 0rpx 30rpx;
   width: calc(100% - 60rpx);
   padding: 0 0;
+  overflow: hidden;
 }
 
 .search-bar {
@@ -53,7 +54,8 @@
 }
 
 .order-list {
-  width: 100%;
+  width: calc(100% - 60rpx);
+  padding: 0 30rpx;
   margin-top: 20rpx;
 }
 
@@ -157,3 +159,22 @@
   padding: 7rpx 20rpx;
   border-radius: 25rpx;
 }
+
+.list_boxsss {
+  width: 100%;
+  /* width: calc(100% - 60rpx); */
+  height: calc(100% - 200rpx);
+  position: fixed;
+  top: 180rpx;
+  left: 0;
+}
+
+.loading-text {
+  width: 100%;
+  text-align: center;
+}
+
+.no-more-text {
+  width: 100%;
+  text-align: center;
+}

+ 9 - 1
subpackages/orderdetails/orderdetails.js

@@ -8,9 +8,17 @@ Page({
     dingwei: '',
     fuzhi: '',
     yesbaoguo: '',
+    item: {}
   },
 
-  onLoad() {
+  onLoad(options) {
+    const itemData = decodeURIComponent(options.data);
+    // console.log(itemData, 'itemData');
+    const item = JSON.parse(itemData);
+    this.setData({
+      item: item
+    });
+
     const fileIDs = [
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/dingwei.png',
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/fuzhi.png',

+ 17 - 11
subpackages/orderdetails/orderdetails.wxml

@@ -23,44 +23,50 @@
       <view class="product_info">
         <image src="https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500" alt="" class="product_image"/>
         <view class="product_details">
-          <view class="product_name">幼儿启蒙绘本10册套装</view>
-          <view class="product_description">适合3-6岁儿童,培养创造力</view>
-          <view class="product_quantity">数量: 1套</view>
+          <view class="product_name">{{item.name}}</view>
+          <view class="product_description">
+            暂无暂无暂无
+          </view>
+          <view class="product_quantity">数量: 还不知道怎么获取 后续要加 套</view>
         </view>
-        <view class="product_price">¥134.00</view>
+        <view class="product_price">¥{{item.price}}</view>
       </view>
       <view class="order_info">
         <view class="order_item">
           <text>订单编号</text>
           <view>
-            <text>20231115143012345</text>
+            <text>{{item.order_id}}</text>
             <image style="width: 35rpx; height: 35rpx;margin-left: 16rpx;" src="{{fuzhi}}" alt=""/></view>
         </view>
         <view class="order_item">
           <text>下单时间</text>
-          <text>2023-11-15 14:30:22</text>
+          <text>{{item.createdAt}}</text>
         </view>
         <view class="order_item">
           <text>支付金额</text>
-          <text>¥134.00</text>
+          <text>¥{{item.real_money}}</text>
         </view>
         <view class="order_item">
           <text>邮寄方式</text>
-          <text>自提</text>
+          <text>{{item.way === 0 ? "邮寄" : "自提"}}</text>
         </view>
-        <view class="order_item">
+        <view class="order_item" wx:if="{{item.way === 0}}">
           <view>物流单号</view>
           <view>
-            <text>SF123123123123</text>
+            <text>{{item.tracking_number}}</text>
             <image style="width: 35rpx; height: 35rpx;margin-left: 16rpx;" src="{{fuzhi}}" alt=""/>
           </view>
         </view>
       </view>
     </view>
     <!-- 底部栏 -->
-    <view class="button_boxs">
+    <view class="button_boxs" wx:if="{{item.status === 1 || item.status === 2}}">
       <button class="buttons">申请售后</button>
       <button class="buttons2">再次购买</button>
     </view>
+    <view class="button_boxs" wx:if="{{item.status === 0}}">
+      <button class="buttons">取消订单</button>
+      <button class="buttons2">立即支付</button>
+    </view>
   </view>
 </view>

+ 115 - 22
subpackages/productdetails/productdetails.js

@@ -1,18 +1,19 @@
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
   data: {
     item: {},
-    selectedSpec: '基础款(50粒)',
     quantity: 1,
     showimg: '',
     gouwucimg: '',
+    gaoliao: 0,
+    steppernum: 1,
   },
   onLoad(options) {
-    console.log('进了');
-    // const itemData = decodeURIComponent(options.data);
-    // const item = JSON.parse(itemData);
-    // this.setData({
-    //   item: item
-    // });
+    const itemData = decodeURIComponent(options.data);
+    const item = JSON.parse(itemData);
+    this.setData({
+      item: item
+    });
 
     const fileIDs = [
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/show.png',
@@ -35,25 +36,117 @@ Page({
     });
   },
 
-  handleSpecSelect(e) {
-    const spec = e.currentTarget.dataset.spec;
-    this.setData({ selectedSpec: spec });
+  // 跳转购物车
+  gotogwc() {
+    wx.switchTab({
+      url: `/pages/shoppingcart/shoppingcart`
+    });
   },
-  
-  handleQuantityChange(e) {
-    const action = e.currentTarget.dataset.action;
-    let quantity = this.data.quantity;
-    if (action === 'plus') {
-      quantity++;
-    } else if (action === 'minus' && quantity > 1) {
-      quantity--;
-    }
-    this.setData({ quantity });
+
+  // 规格选择
+  setspecs(e) {
+    const index = e.currentTarget.dataset.item;
+    this.setData({
+      gaoliao: index
+    })
+  },
+
+  // 购买数量
+  onChange(e) {
+    const num = e.detail
+    this.setData({
+      steppernum:num
+    })
   },
   
-  addToCart() {
+  // 加入购物车
+  async addToCart() {
     // 加入购物车逻辑
-    console.log('加入购物车');
+    console.log('加入购物车', this.data.item, this.data.item._id);
+    const { data } = await models.shopping_cart.get({
+      filter: {
+        where: {
+          merchandise_id: { $eq: this.data.item._id }, // 推荐传入_id数据标识进行操作
+          specs_index: { $eq: this.data.gaoliao }
+        }
+      },
+      envType: "prod",
+    });
+    
+    // 返回查询到的数据
+    console.log(data);
+    const datalist = data || {}
+
+    if (!datalist || Object.keys(datalist).length === 0) {
+      console.log('购物车中没有该商品,准备新增');
+      // 执行插入操作
+      const { data } = await models.shopping_cart.create({
+        data: {
+            merchandise_id: this.data.item._id,  
+            num: this.data.steppernum,  // 商品数量
+            specs_index: this.data.gaoliao,  // 规格下标
+          },
+        envType: "prod",
+      });
+      
+      // 判断是否有 id 返回
+      if (data && (data.id || data.Id)) {
+        console.log('加入购物车成功:', data);
+        wx.showToast({
+          title: '加入购物车成功',
+          icon: 'success',
+          duration: 1500
+        });
+      } else {
+        // 数据结构异常,视为失败
+        console.error('加入购物车失败:无返回 id', data);
+        wx.showToast({
+          title: '加入失败',
+          icon: 'error',
+          duration: 1500
+        });
+      }
+    } else {
+      console.log('购物车已有该商品,准备更新数量');
+      // 执行更新操作
+      const { data } = await models.shopping_cart.update({
+        data: {
+            num: datalist.num + 1,  // 商品数量
+          },
+        filter: {
+          where: {
+            $and: [
+              {
+                _id: {
+                  $eq: datalist._id, // 推荐传入_id数据标识进行操作
+                },
+              },
+            ]
+          }
+        },
+        envType: "prod",
+      });
+      
+      // 返回更新成功的条数
+      console.log(data);
+      // 判断是否有 id 返回
+      if (data.count > 0) {
+        console.log('加入购物车成功:', data);
+        wx.showToast({
+          title: '加入购物车成功',
+          icon: 'success',
+          duration: 1500
+        });
+      } else {
+        // 数据结构异常,视为失败
+        console.error('加入购物车失败:无返回 id', data);
+        wx.showToast({
+          title: '加入失败',
+          icon: 'error',
+          duration: 1500
+        });
+      }
+    }
   },
   
   buyNow() {

+ 21 - 16
subpackages/productdetails/productdetails.wxml

@@ -1,30 +1,36 @@
 <view style="background: #f5f5f5; padding: 20rpx 0;">
   <view class="goodslist_boxs">
     <!-- 商品图片 -->
-    <image class="goods-image" src="https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500" mode="aspectFill"></image>
+    <view class="empty-space">
+      <swiper style="width: 100%; height: 100%;" autoplay="true" interval="3000" circular>
+        <block wx:for="{{item.detail_images}}" wx:key="index">
+          <swiper-item>
+            <image style="width: 100%; height: 100%;" src="{{item}}" mode="aspectFill" />
+          </swiper-item>
+        </block>
+      </swiper>
+    </view>
     
     <!-- 商品价格和浏览量 -->
     <view class="price-and-views">
       <view>
-        <text class="price">¥68.00</text>
-        <text class="original-price">¥99.00</text>
+        <text class="price">¥{{item.price}}</text>
+        <text class="original-price">¥{{item.old_price}}</text>
       </view>
       <view style="display: flex; align-content: center;">
         <image style="width: 30rpx; height: 30rpx;" src="{{showimg}}" />
-        <text style="margin-left: 16rpx;" class="views">256人浏览</text>
+        <text style="margin-left: 16rpx;" class="views">{{item.browse}}人浏览</text>
       </view>
     </view>
     
     <!-- 商品标题 -->
-    <view class="goods-title">儿童益智积木玩具套装 大颗粒安全无毒</view>
+    <view class="goods-title">{{item.name}}</view>
     
     <!-- 选择规格 -->
     <view class="specifications">
       <text style="font-size: 38rpx;">选择规格</text>
       <view class="specifications_boxs">
-        <button class="spec-btn active">基础款(50粒)</button>
-        <button class="spec-btn">进阶款(100粒)</button>
-        <button class="spec-btn">豪华款(200粒)</button>
+        <button wx:for="{{item.specs}}" wx:key="index" class="spec-btn {{gaoliao === index ? 'active' : ''}}"  bindtap="setspecs" data-item="{{index}}">{{item}}</button>
       </view>
     </view>
     
@@ -33,7 +39,7 @@
       <text style="font-size: 38rpx;">购买数量</text>
 
       <van-stepper
-        value="1"
+        value="{{steppernum}}"
         bind:change="onChange"
       />
     </view>
@@ -42,21 +48,20 @@
     <view class="product-details">
       <text style="font-size: 38rpx;">产品详情</text>
       <view class="details-list">
-        <text>• 安全材质:采用环保ABS塑料,无毒无味,通过国际安全认证</text>
-        <text>• 大颗粒设计:专为3-6岁儿童设计,防止误吞</text>
-        <text>• 益智启蒙:培养孩子空间想象力、创造力和手眼协调能力</text>
-        <text>• 丰富配件:包含多种形状积木、数字和字母积木</text>
+        <text wx:for="{{item.details}}" wx:key="index">• {{item}}</text>
       </view>
     </view>
     
     <!-- 按钮区域 -->
     <view class="buttons">
     <view style="width: 10%; text-align: center;">
-      <image class="search-icon" src="{{gouwucimg}}" />
-      <view style="font-size: 24rpx;">购物车</view>
+      <view bindtap="gotogwc">
+        <image class="search-icon" src="{{gouwucimg}}" />
+        <view style="font-size: 24rpx;">购物车</view>
+      </view>
     </view>
       <view style="display: flex; justify-content: space-between; width: 74%;">
-        <button class="cart-btn">加入购物车</button>
+        <button class="cart-btn" bindtap="addToCart">加入购物车</button>
         <button class="buy-btn">立即购买</button>
       </view>
     </view>

+ 8 - 0
subpackages/productdetails/productdetails.wxss

@@ -3,6 +3,14 @@
   width: calc(100% - 60rpx);
 }
 
+.empty-space {
+  width: 100%;
+  height: 500rpx;
+  background-color: #e0e0e0;
+  margin-top: 20rpx;
+  border-radius: 12rpx;
+}
+
 .goods-image {
   width: 100%;
   height: 400rpx;

+ 203 - 86
subpackages/purchasehistory/purchasehistory.js

@@ -1,86 +1,44 @@
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
   data: {
     role: "teacher",
-    historyList: [
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      {
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        title: '趣味识字卡片',
-        date: '2023-10-15 14:30',
-        checked: false
-      },
-      // 其他列表项...
-    ],
-    isManaging: false
+    historyList: [],
+    isManaging: false,
+    xiazi: '',
+    pageNumber: 1,
+    pageSize: 10,
+    hasMore: true, // 是否还有更多数据
+    isLoading: false, // 防止多次触发
   },
 
   onLoad(options) {
+    // 列表数据
+    this.setData({
+      pageNumber: 1,
+      hasMore: true,
+      historyList: []
+    }, () => {
+      this.getcollect();
+    });
     // 页面加载时的初始化操作
+    const fileIDs = [
+      'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiazi.png',
+    ];
+    
+    // 并发下载多个 fileID
+    Promise.all(
+      fileIDs.map(fileID => wx.cloud.downloadFile({ fileID }))
+    ).then(results => {
+      // 每个 result 对应一个下载结果
+      const tempFilePaths = results.map(r => r.tempFilePath);
+      console.log('全部下载成功:', tempFilePaths);
+
+      this.setData({
+        xiazi: tempFilePaths[0],
+      });
+    }).catch(err => {
+      console.error('有文件下载失败:', err);
+    });
   },
 
   onReachBottom() {
@@ -91,8 +49,96 @@ Page({
   loadMore() {
     // 加载更多数据的逻辑
     console.log('加载更多');
+    this.getcollect(true);
+  },
+
+  // 收藏列表
+  async getcollect(isLoadMore = false) {
+
+    if (this.data.isLoading || !this.data.hasMore) return;
+  
+    this.setData({ isLoading: true });
+  
+    const userInfo = wx.getStorageSync('userInfo');
+    const { pageNumber, pageSize } = this.data;
+  
+    try {
+      const { data } = await models.parent_download_history.list({
+        filter: {
+          where: {
+            wx_user_id: userInfo._id
+          }
+        },
+        pageSize,
+        pageNumber,
+        getCount: true,
+        envType: "prod",
+      });
+
+      const collectList = data.records || [];
+      if (collectList.length === 0) {
+        this.setData({ hasMore: false, isLoading: false });
+        return;
+      }
+      console.log(collectList, 'collectList');
+  
+      const fileManagerIds = collectList.map(item => item.file_manage_id);
+
+      console.log(fileManagerIds, 'fileManagerIds');
+      // 第二步:循环获取每个文件数据(单条查询)
+      const fileDetailPromises = fileManagerIds.map(id => {
+        return models.file_manage.list({
+          filter: {
+            where: {
+              _id: id
+            }
+          },
+          envType: "prod"
+        }).then(res => {
+          const record = res.data?.records?.[0];
+          if (!record) {
+            console.warn(`未找到 _id 为 ${id} 的文件`);
+          }
+          return record || null;
+        })
+        .catch(err => {
+          console.error(`获取文件 ${id} 失败`, err);
+          return null;
+        });
+      });
+
+      // 第三步:等待所有请求完成
+      const fileDetails = await Promise.all(fileDetailPromises);
+      console.log(fileDetails, 'fileDetails');
+
+      // 第四步:过滤无效项,并添加 checked 字段
+      const newFiles = fileDetails
+        .filter(Boolean) // 去掉 null 或 undefined
+        .map((file, index) => {
+          const historyRecord = collectList[index]; // 获取原 download_history 的记录
+          if (!file) return null;
+          return {
+            ...file,
+            checked: false,
+            download_history_id: historyRecord._id  // 关键:存 download_history 的 id
+          };
+        });
+
+
+      this.setData({
+        historyList: isLoadMore ? this.data.historyList.concat(newFiles) : newFiles,
+        pageNumber: pageNumber + 1,
+        hasMore: collectList.length === pageSize, // 如果返回的数量小于 pageSize,说明已经到底
+        isLoading: false
+      });
+  
+    } catch (err) {
+      console.error('获取收藏文件失败:', err);
+      this.setData({ isLoading: false });
+    }
   },
 
+  // 收藏管理是否编辑 
   toggleManageMode() {
     const { isManaging, historyList } = this.data;
     if (isManaging) {
@@ -105,20 +151,91 @@ Page({
     }
   },
 
+  // 全选按钮
   selectAll() {
     const { historyList } = this.data;
-    if (historyList && historyList.length > 0) {
-      const allChecked = historyList.every(item => item.checked);
-      historyList.forEach(item => item.checked = !allChecked);
-      this.setData({ historyList });
-    }
+    if (!historyList || historyList.length === 0) return;
+  
+    const allChecked = historyList.every(item => item.checked);
+    const updatedList = historyList.map(item => ({
+      ...item,
+      checked: !allChecked
+    }));
+  
+    this.setData({ historyList: updatedList });
+  },
+  // 单选
+  onCheckboxGroupChange(e) {
+    const selectedIds = e.detail.value;
+    const updatedList = this.data.historyList.map(item => ({
+      ...item,
+      checked: selectedIds.includes(item.download_history_id),
+    }));
+    this.setData({ historyList: updatedList });
   },
 
-  deleteItems() {
+  // 删除
+  async deleteItems() {
     const { historyList } = this.data;
-    if (historyList && historyList.length > 0) {
-      const newList = historyList.filter(item => !item.checked);
-      this.setData({ historyList: newList });
+    const selectedItems = historyList.filter(item => item.checked);
+    const fileids = selectedItems.map(item => item.download_history_id);
+    const userInfo = wx.getStorageSync('userInfo')
+
+    if (fileids.length === 0) {
+      wx.showToast({ title: '请先选择要删除的数据', icon: 'none' });
+      return;
+    }
+
+    console.log(userInfo._id, 'userInfo._id');
+    const { data } = await models.parent_download_history.deleteMany({
+      filter: {
+        where: {
+          where: {
+            user_id: _.eq(userInfo._id)
+          }
+        }
+      },
+      // envType: pre 体验环境, prod 正式环境
+      envType: "prod",
+    });
+    
+    // 更新页面数据
+    const updatedList = historyList.filter(item => !fileids.includes(item.download_history_id));
+
+    this.setData({
+      historyList: updatedList,
+      isManaging: false
+    }, () => {
+       // 回调中触发插入逻辑
+       this.insertNewItems();
+    });
+  },
+
+  async insertNewItems() {
+    try {
+      const userInfo = wx.getStorageSync('userInfo');
+  
+      const { historyList } = this.data;
+
+      if (!historyList.length) {
+        // wx.showToast({ title: '没有收藏的记录数据', icon: 'none' });
+        return;
+      }
+
+      const newItems = historyList.map(item => ({
+        file_manage_id: item._id,
+        user_id: userInfo._id
+      }));
+
+      const { data } = await models.parent_download_history.createMany({
+        data: newItems,
+        envType: 'prod'
+      });
+
+      console.log('插入成功:', data);
+    } catch (err) {
+      console.error('插入失败:', err);
+      wx.showToast({ title: '插入失败', icon: 'none' });
     }
-  }
+  } 
 });

+ 23 - 14
subpackages/purchasehistory/purchasehistory.wxml

@@ -1,25 +1,34 @@
 <view style="background: #f5f5f5; padding: 20rpx 0;">
   <view class="container">
     <view class="title_1" bindtap="toggleManageMode">
-      {{ isManaging ? '退出管理' : '购买历史管理' }}
+      {{ isManaging ? '退出管理' : '下载管理' }}
     </view>
     <!-- 列表 -->
     <view class="lishi_list {{ isManaging ? 'ones' : ''}}">
-      <block wx:for="{{ historyList }}" wx:key="index">
-        <view class="lishi_item">
-          <checkbox wx:if="{{ isManaging }}" class="checkbox" value="{{ index }}" checked="{{ item.checked }}" />
-          <image src="{{ item.image }}" mode="aspectFill" class="item_image"></image>
-          <view class="item_info">
-            <view class="item_title">{{ item.title }}</view>
-            <view class="item_date">{{ item.date }}</view>
+      <checkbox-group bindchange="onCheckboxGroupChange">
+        <block wx:for="{{ historyList }}" wx:key="index">
+          <view class="lishi_item">
+            <checkbox
+              wx:if="{{ isManaging }}"
+              class="checkbox"
+              value="{{ item.download_history_id }}"
+              checked="{{ item.checked }}"
+              data-id="{{ item.download_history_id }}"
+            />
+            <image src="{{ item.cover }}" mode="aspectFill" class="item_image"></image>
+            <view class="item_info">
+              <view class="item_title">{{ item.name }}</view>
+              <view class="item_date">{{ item.createdAt }}</view>
+            </view>
+            <view class="xiazai_img">
+              <image class="search-icon" src="{{xiazi}}" />
+            </view>
           </view>
-          <!-- <view class="xiazai_img">
-            <image class="search-icon" src="../../image/imgs/xiazai.png" />
-          </view> -->
-        </view>
-      </block>
+        </block>
+      </checkbox-group>
+      <view wx:if="{{ isLoading }}" class="loading-text">加载中...</view>
+      <view wx:elif="{{ !hasMore }}" class="no-more-text">没有更多了</view>
     </view>
-    <!-- <button class="load_more_button" wx:if="{{ !isManaging }}">加载更多</button> -->
     <view class="bottom_bar" wx:if="{{ isManaging }}">
       <view class="select_all" >
         <checkbox  bindtap="selectAll" />

+ 11 - 1
subpackages/purchasehistory/purchasehistory.wxss

@@ -108,4 +108,14 @@
   padding: 23rpx 0;
   font-size: 28rpx;
   margin: 0 !important;
-}
+}
+
+.loading-text {
+  width: 100%;
+  text-align: center;
+}
+
+.no-more-text {
+  width: 100%;
+  text-align: center;
+}

+ 31 - 23
subpackages/submitorder/submitorder.js

@@ -1,32 +1,24 @@
 Page({
   data: {
-    products: [
-      {
-        id: 1,
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        name: '幼儿启蒙绘本10册套装',
-        desc: '适合3-6岁儿童,培养创造力',
-        price: 134.00,
-        quantity: 1
-      },
-      {
-        id: 1,
-        image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        name: '幼儿启蒙绘本10册套装',
-        desc: '适合3-6岁儿童,培养创造力',
-        price: 134.00,
-        quantity: 1
-      }
-    ],
-    totalAmount: 134.00,
+    products: [],
+    totalAmount: 0,
     dingweiimg: '',
     youjiantouimg: '',
   },
 
-  onLoad(options) {
-    // const title = options.title ? decodeURIComponent(options.title) : '商品列表';
-    // this.setData({ title });
-    // wx.setNavigationBarTitle({ title });
+  onLoad() {
+    const selectedItems = wx.getStorageSync('checkoutItems') || [];
+
+    // 标准化 quantity 字段
+    const products = selectedItems.map(item => ({
+      ...item,
+      quantity: item.num
+    }));
+    console.log(123123);
+
+    this.setData({ products }, () => {
+      this.calculateTotal();
+    });
 
     const fileIDs = [
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/dingwei.png',
@@ -67,6 +59,22 @@ Page({
     this.calculateTotal();
   },
 
+  onChange(e) {
+    const { id } = e.currentTarget.dataset;
+    const { detail } = e;
+  
+    const products = this.data.products.map(item => {
+      if (item._id === id) {
+        return { ...item, quantity: detail };
+      }
+      return item;
+    });
+  
+    this.setData({ products }, () => {
+      this.calculateTotal();
+    });
+  },
+
   calculateTotal() {
     let totalAmount = 0;
     this.data.products.forEach(item => {

+ 2 - 2
subpackages/submitorder/submitorder.wxml

@@ -19,10 +19,10 @@
     <view class="product_list">
       <block wx:for="{{products}}" wx:key="index">
         <view class="product_item">
-          <image src="{{item.image}}" class="product_image"></image>
+          <image src="{{item.img}}" class="product_image"></image>
           <view class="product_details">
             <view class="product_name">{{item.name}}</view>
-            <view class="product_desc">{{item.desc}}</view>
+            <view class="product_desc">{{item.specs[item.specs_index]}}</view>
             <view class="price_and_quantity">
               <text class="product_price">¥{{item.price}}</text>
               <view class="quantity_selector">

+ 2 - 1
utils/cloudbase.js

@@ -9,5 +9,6 @@ wx.cloud.init({
 const client = init(wx.cloud)
 const db = client.database()
 const models = client.models
+const _ = db.command // ✅ 添加这行,导出查询操作符
 
-export { db, models }
+export { db, models, _ }