LiuShu_0203 vor 1 Monat
Ursprung
Commit
768027be1b
38 geänderte Dateien mit 1230 neuen und 207 gelöschten Zeilen
  1. 17 7
      app.js
  2. 11 2
      app.json
  3. 66 0
      components/custom-tab-bar/index.js
  4. 2 0
      components/custom-tab-bar/index.wxml
  5. 92 0
      custom-tab-bar/index.js
  6. 3 0
      custom-tab-bar/index.json
  7. 8 0
      custom-tab-bar/index.wxml
  8. 33 0
      custom-tab-bar/index.wxss
  9. 45 9
      pages/groupbuying/groupbuying.js
  10. 2 2
      pages/groupbuying/groupbuying.wxml
  11. 1 1
      pages/groupbuying/groupbuying.wxss
  12. 17 3
      pages/index/index.js
  13. 2 2
      pages/index/index.wxml
  14. 11 6
      pages/me/me.js
  15. 1 1
      pages/me/me.wxml
  16. 4 3
      pages/me/me.wxss
  17. 53 7
      pages/shoppingcart/shoppingcart.js
  18. 2 2
      pages/shoppingcart/shoppingcart.wxml
  19. 2 2
      pages/shoppingcart/shoppingcart.wxss
  20. 28 3
      subpackages/addresslist/addresslist.js
  21. 1 1
      subpackages/addresslist/addresslist.wxml
  22. 145 0
      subpackages/afterservice/afterservice.js
  23. 4 0
      subpackages/afterservice/afterservice.json
  24. 51 0
      subpackages/afterservice/afterservice.wxml
  25. 122 0
      subpackages/afterservice/afterservice.wxss
  26. 63 26
      subpackages/dahome/dahome.js
  27. 1 1
      subpackages/dahome/dahome.wxml
  28. 81 9
      subpackages/details/details.js
  29. 5 12
      subpackages/details/details.wxml
  30. 46 23
      subpackages/imghome/imghome.js
  31. 1 1
      subpackages/imghome/imghome.wxml
  32. 207 73
      subpackages/order/order.js
  33. 6 5
      subpackages/order/order.wxml
  34. 47 1
      subpackages/orderdetails/orderdetails.js
  35. 4 4
      subpackages/orderdetails/orderdetails.wxml
  36. 43 0
      subpackages/productdetails/productdetails.js
  37. 2 1
      subpackages/productdetails/productdetails.wxml
  38. 1 0
      subpackages/purchasehistory/purchasehistory.js

+ 17 - 7
app.js

@@ -6,23 +6,33 @@ App({
   // 检查登录状态并弹出提示框
   checkLoginStatus() {
     const isLoggedIn = wx.getStorageSync('userInfo') || false;
+  
     if (!isLoggedIn) {
       wx.showModal({
-        title: '绑定手机号',
-        content: '防止账号丢失以及方便找回,建议您绑定手机号码',
-        confirmText: '立即绑定',
-        cancelText: '取消',
+        title: '登录身份选择',
+        content: '请选择您的身份以完成登录',
+        confirmText: '我是家长',
+        cancelText: '我是老师',
         success: (res) => {
           if (res.confirm) {
-            // 跳转到绑定手机号页面
+            // 家长:跳转本小程序登录页
             wx.navigateTo({
               url: '/pages/logins/logins',
             });
+          } else if (res.cancel) {
+            // 老师:跳转到老师端小程序
+            wx.navigateToMiniProgram({
+              appId: 'wx06f2b1b09ac5684f', // ⚠️ 替换成实际 appId
+              path: 'pages/logins/logins',
+            });
           }
-        },
+        }
       });
+  
+      return false;
     }
-    return isLoggedIn;
+  
+    return true;
   },
   
   onLaunch() {

+ 11 - 2
app.json

@@ -12,15 +12,18 @@
     "pages/me/me",
     "pages/login/login",
     "pages/logins/logins",
-    "components/float/float"
+    "components/float/float",
+    "components/custom-tab-bar/index"
   ],
   "window": {
     "navigationBarTextStyle": "black",
     "navigationBarTitleText": "红孩儿智慧教育",
     "navigationBarBackgroundColor": "#ffffff"
   },
+  "custom-tab-bar": "custom-tab-bar",
   "tabBar": {
-    "custom": false,
+    "custom": true,
+    "color": "#7A7E83",
     "selectedColor": "#409eff",
     "list": [
       {
@@ -139,6 +142,12 @@
       "pages": [
         "address"
       ]
+    },
+    {
+      "root": "subpackages/afterservice",
+      "pages": [
+        "afterservice"
+      ]
     }
   ],
   "requiredPrivateInfos": [

+ 66 - 0
components/custom-tab-bar/index.js

@@ -0,0 +1,66 @@
+// components/custom-tab-bar/index.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 2 - 0
components/custom-tab-bar/index.wxml

@@ -0,0 +1,2 @@
+<!--components/custom-tab-bar/index.wxml-->
+<text>components/custom-tab-bar/index.wxml</text>

+ 92 - 0
custom-tab-bar/index.js

@@ -0,0 +1,92 @@
+const app = getApp();
+
+Component({
+  data: {
+    selected: 0,
+    list: [
+      {
+        pagePath: "/pages/index/index",
+        text: "教学",
+        iconPath: "/image/shouye.png",
+        selectedIconPath: "/image/shouye_1.png"
+      },
+      {
+        pagePath: "/pages/groupbuying/groupbuying",
+        text: "团购",
+        iconPath: "/image/tuangou.png",
+        selectedIconPath: "/image/tuangou_1.png"
+      },
+      {
+        pagePath: "/pages/shoppingcart/shoppingcart",
+        text: "购物车",
+        iconPath: "/image/gouwuche.png",
+        selectedIconPath: "/image/gouwuche_1.png"
+      },
+      {
+        pagePath: "/pages/me/me",
+        text: "我的",
+        iconPath: "/image/me.png",
+        selectedIconPath: "/image/my_1.png"
+      }
+    ]
+  },
+  methods: {
+    onTabTap(e) {
+      const index = e.currentTarget.dataset.index;
+      const target = this.data.list[index];
+
+      // 判断登录状态
+      // const isLoggedIn = wx.getStorageSync('userInfo');
+      // if (!isLoggedIn && index !== 0) {
+      //   // 非首页才拦截
+      //   wx.showModal({
+      //     title: '去登录',
+      //     content: '防止账号丢失以及方便找回,建议您绑定手机号码',
+      //     confirmText: '去绑定',
+      //     cancelText: '取消',
+      //     success(res) {
+      //       if (res.confirm) {
+      //         wx.navigateTo({
+      //           url: '/pages/logins/logins'
+      //         });
+      //       }
+      //     }
+      //   });
+      //   return;
+      // }
+      const isLoggedIn = wx.getStorageSync('userInfo');
+      if (!isLoggedIn && index !== 0) {
+        wx.showModal({
+          title: '登录身份选择',
+          content: '请选择您的身份以完成登录',
+          confirmText: '我是家长',
+          cancelText: '我是老师',
+          success: (res) => {
+            if (res.confirm) {
+              wx.navigateTo({
+                url: '/pages/logins/logins'
+              });
+            } else if (res.cancel) {
+              wx.navigateToMiniProgram({
+                appId: 'wx06f2b1b09ac5684f',
+                path: 'pages/logins/logins',
+              });
+            }
+          }
+        });
+        return;
+      }
+
+      // 切换 tab 页
+      wx.switchTab({
+        url: target.pagePath
+      });
+      this.setData({ selected: index });
+    },
+
+    // 支持外部更新选中项
+    setSelected(index) {
+      this.setData({ selected: index });
+    }
+  }
+});

+ 3 - 0
custom-tab-bar/index.json

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

+ 8 - 0
custom-tab-bar/index.wxml

@@ -0,0 +1,8 @@
+<view class="tab-bar">
+  <block wx:for="{{list}}" wx:key="index">
+    <view class="tab-item {{selected === index ? 'active' : ''}}" bindtap="onTabTap" data-index="{{index}}">
+      <image class="tab-icon" src="{{selected === index ? item.selectedIconPath : item.iconPath}}" />
+      <text class="tab-text">{{item.text}}</text>
+    </view>
+  </block>
+</view>

+ 33 - 0
custom-tab-bar/index.wxss

@@ -0,0 +1,33 @@
+.tab-bar {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  height: 100rpx;
+  background-color: #ffffff;
+  display: flex;
+  justify-content: space-around;
+  align-items: center;
+  border-top: 1rpx solid #e5e5e5;
+  z-index: 1000;
+}
+
+.tab-item {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+  flex: 1;
+  padding: 10rpx 0;
+  color: #7A7E83;
+  font-size: 24rpx;
+}
+
+.tab-item.active {
+  color: #409eff; /* 可自定义为 app.json 中配置的 selectedColor */
+}
+
+.tab-icon {
+  width: 54rpx;
+  height: 54rpx;
+}

+ 45 - 9
pages/groupbuying/groupbuying.js

@@ -1,4 +1,5 @@
 import { models, db, _ } from '../../utils/cloudbase.js'
+const app = getApp();
 Page({
   data: {
     categoriesindex: 1,
@@ -11,11 +12,19 @@ Page({
     hasMore: true, // 是否还有更多数据
     isLoading: false, // 防止多次触发
     types_ids: null, // 当前选中的分类 tag_id
+    searchText: '', // 搜索内容
   },
-  onLoad(options) {
+
+  onShow() {
+    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
+      this.getTabBar().setSelected(1); // 比如首页就是 0
+    }
     // 获取tab数据
     this.getTabdata();
 
+  },
+
+  onLoad(options) {
     const fileIDs = [
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
       'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/gouwuc_img.png'
@@ -36,7 +45,6 @@ Page({
       console.error('有文件下载失败:', err);
     });
   },
-  
   // tab数据
   async getTabdata() {
     const { data } = await models.tab.list({
@@ -73,21 +81,48 @@ Page({
     this.getDatalist(this.data.types_ids, true);
   },
 
+   //模糊搜搜
+   onSearchInput(e) {
+    const searchText = e.detail.value.trim();
+    this.setData({
+      searchText,
+      goods: [],
+      pageNumber: 1,
+      hasMore: true
+    }, () => {
+      this.getDatalist(this.data.types_ids);
+    });
+  },
+  // 点击搜搜
+  onSearchConfirm() {
+    this.setData({
+      goods: [],
+      pageNumber: 1,
+      hasMore: true
+    }, () => {
+      this.getDatalist(this.data.types_ids);
+    });
+  },
+
   // 列表数据
   async getDatalist(tag_id = null, isLoadMore = false) {
-  
     const userInfo = wx.getStorageSync('userInfo');
+    const { pageNumber, pageSize, searchText } = this.data;
   
-    // 构造 where 条件
     const where = {
       school_id: _.in(userInfo.school_id)
     };
   
     if (tag_id) {
-      where.tag_id = tag_id; // 仅在 tag_id 有值时添加
+      where.tag_id = tag_id;
     }
-
-    const { pageNumber, pageSize } = this.data;
+  
+    if (searchText) {
+      where.name = {
+        $regex_ci: searchText
+      };
+    }
+  
     const { data } = await models.wx_merchandise.list({
       filter: { where },
       pageSize,
@@ -95,10 +130,11 @@ Page({
       getCount: true,
       envType: "prod",
     });
-
+  
     const collectList = data.records || [];
+  
     this.setData({
-      goods: isLoadMore ? this.data.goods.concat(collectList) : collectList, // ✅ 用 goods 拼接
+      goods: isLoadMore ? this.data.goods.concat(collectList) : collectList,
       pageNumber: pageNumber + 1,
       hasMore: collectList.length === pageSize,
       isLoading: false

+ 2 - 2
pages/groupbuying/groupbuying.wxml

@@ -1,8 +1,8 @@
 <view style="background: #f5f5f5; padding: 20rpx 0;">
   <view class="goodslist_boxs">
     <view class="search-bar">
-      <input class="search-input" placeholder="搜索商品" />
-      <image class="search-icon" src="{{souimg}}" />
+      <input class="search-input" placeholder="搜索商品" bindinput="onSearchInput" value="{{searchText}}" />
+      <image class="search-icon" src="{{souimg}}"  bindtap="onSearchConfirm" />
     </view>
     <view class="title_1">商品分类</view>
     <view class="category-tabs">

+ 1 - 1
pages/groupbuying/groupbuying.wxss

@@ -144,7 +144,7 @@
 .list_boxsss {
   /* width: calc( 100% - 60rpx); */
   padding: 0rpx 30rpx;
-  height: calc(100% - 270rpx);
+  height: calc(100% - 380rpx);
   position: fixed;
   top: 260rpx;
   left: 0;

+ 17 - 3
pages/index/index.js

@@ -12,13 +12,17 @@ Page({
   },
 
   onShow() {
+    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
+      this.getTabBar().setSelected(0); // 首页索引是0
+    }
+
+    // 获取轮播图数据
+    this.getBanner();
     // 检查登录状态
-    app.checkLoginStatus();
+    // app.checkLoginStatus();
   },
 
   onLoad() {
-    // 获取轮播图数据
-    this.getBanner();
     // 获取图片
     const fileIDs = [
       // 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/banner/carousel_1.jpg',
@@ -67,6 +71,9 @@ Page({
 
   // 页面跳转  二级页面
   selectGroupOption(e) {
+    const isLoggedIn = app.checkLoginStatus(); // 检查是否登录
+    if (!isLoggedIn) return; // 未登录已跳转,不继续
+
     const option = e.currentTarget.dataset.option;
     let url = '';
   
@@ -92,6 +99,13 @@ Page({
     });
   },
 
+  // 搜索框跳转
+  goSearchPage() {
+    wx.navigateTo({
+      url: '/subpackages/dahome/dahome?autofocus=1'
+    });
+  }, 
+
   // 上传轮播图  存储轮播图图片地址 和展示位置  后续需要存一个上传的图片名字
   // async getData() {
   //   try {

+ 2 - 2
pages/index/index.wxml

@@ -2,8 +2,8 @@
   <view class="container">
   <!-- <button bindtap="getData">点击</button> -->
     <!-- 搜索 -->
-    <view class="search-bar">
-      <input class="search-input" placeholder="搜索课件" />
+    <view class="search-bar" bindtap="goSearchPage">
+      <input class="search-input" placeholder="搜索课件" disabled />
       <image class="search-icon" src="{{souimg}}" />
     </view>
     

+ 11 - 6
pages/me/me.js

@@ -15,6 +15,10 @@ Page({
   },
 
   onShow() {
+    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
+      this.getTabBar().setSelected(3); // 比如首页就是 0
+    }
+
     // 每次进入页面都会触发
     this.getUserInfo();
     // this.getcollect();
@@ -32,10 +36,10 @@ Page({
     ]
 
       const fileIDs = [
-        'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/ding_1.png',
-        'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/ding_2.png',
-        '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/qvanbu.png',
+        'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/daifukuan.png',
+        'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/daishouhuo.png',
+        'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/yiwancheng.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/xiazi.png',
@@ -109,10 +113,11 @@ Page({
 
   // 下载历史
   async getpurchasehistory() {
+    const userInfo = wx.getStorageSync('userInfo');
     const { data } = await models.parent_download_history.list({
       filter: {
         where: {
-          user_id: this.data.userInfo._id
+          wx_user_id: userInfo._id
         }
       },
       pageSize: 2, // 分页大小,建议指定,如需设置为其它值,需要和 pageNumber 配合使用,两者同时指定才会生效
@@ -122,7 +127,7 @@ Page({
     });
 
     // 返回查询到的数据列表 records 和 总数 total
-    console.log(data);
+    console.log(data,'data');
     const collectList = data.records || [];
     if (collectList.length === 0) {
       console.log('没有收藏记录');

+ 1 - 1
pages/me/me.wxml

@@ -31,7 +31,7 @@
               <view class="circle">
                 <image style="width: 100%; height: 100%;" src="{{item.url}}" mode=""/>
               </view>
-              <view style="margin-top: 16rpx;">{{item.text}}</view>
+              <view>{{item.text}}</view>
             </view>
         </view>
     </view>

+ 4 - 3
pages/me/me.wxss

@@ -86,8 +86,9 @@
 }
 
 .circle {
-  width: 110rpx;
-  height: 110rpx;
+  width: calc(100rpx - 40rpx);
+  height: calc(100rpx - 40rpx);
+  padding: 20rpx;
   overflow: hidden;
   /* background-color: #ccc; */
   border-radius: 50%;
@@ -98,7 +99,7 @@
   background-color: #fff;
   padding: 20rpx;
   border-radius: 16rpx;
-  margin-bottom: 20rpx;
+  margin-bottom: 40rpx;
 }
 
 .title {

+ 53 - 7
pages/shoppingcart/shoppingcart.js

@@ -7,9 +7,14 @@ Page({
     pageSize: 10,
     hasMore: true, // 是否还有更多数据
     isLoading: false, // 防止多次触发
+    searchText: '', // 输入的搜索内容
   },
 
   onShow() {
+    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
+      this.getTabBar().setSelected(2); // 比如首页就是 0
+    }
+
     // 列表数据
     this.setData({
       pageNumber: 1,
@@ -60,17 +65,51 @@ Page({
     this.getdatalist(true);
   },
 
+  // 模糊搜索
+  onSearchInput(e) {
+    const searchText = e.detail.value.trim();
+    this.setData({
+      searchText,
+      pageNumber: 1,
+      cartItems: [],
+      hasMore: true
+    }, () => {
+      this.getdatalist();
+    });
+  },
+  onSearchConfirm() {
+    this.setData({
+      pageNumber: 1,
+      cartItems: [],
+      hasMore: true
+    }, () => {
+      this.getdatalist();
+    });
+  },
+
   // 获取列表数据
   async getdatalist(isLoadMore = false) {
     if (this.data.isLoading || !this.data.hasMore) return;
   
     this.setData({ isLoading: true });
   
-    const { pageNumber, pageSize } = this.data;
+    const { pageNumber, pageSize, searchText  } = this.data;
+
+    // 获取本地存储的用户信息
+    const userInfo = wx.getStorageSync('userInfo');
+    const userId = userInfo && userInfo._id ? userInfo._id : ''; // 根据你的userInfo结构取ID
+
+    const cartWhere = {
+      user_id: userId  // 每次必传
+    };
+
+    if (searchText) {
+      cartWhere.name = { $regex_ci: searchText };
+    }
     try {
       const { data } = await models.shopping_cart.list({
         filter: {
-          where: {}
+          where: cartWhere
         },
         pageSize,
         pageNumber,
@@ -117,19 +156,26 @@ Page({
       console.log(fileDetails, 'fileDetails');
   
       // 第四步:过滤无效项,并添加 checked 字段
-      const newFiles = fileDetails
-      .filter(Boolean) // 去掉 null 或 undefined
+      let newFiles = fileDetails
+      .filter(Boolean)
       .map((file, index) => {
-        const historyRecord = collectList[index]; // 获取原 download_history 的记录
+        const historyRecord = collectList[index];
         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
+          num: historyRecord.num
         };
-      });
+      })
+      .filter(Boolean);
+
+      // ✅ 如果搜索内容不为空,在本地进行模糊匹配过滤
+      if (searchText) {
+      const pattern = new RegExp(searchText, 'i'); // 不区分大小写
+      newFiles = newFiles.filter(item => pattern.test(item.name));
+      }
   
       this.setData({
         cartItems: isLoadMore ? this.data.cartItems.concat(newFiles) : newFiles,

+ 2 - 2
pages/shoppingcart/shoppingcart.wxml

@@ -4,8 +4,8 @@
     <view class="cart-header">
       <text style="font-size: 36rpx;">购物车 <text style="font-size: 24rpx;">({{cartItems.length}})</text></text>
       <view class="search-bar">
-        <input class="search-input" placeholder="搜索购物车商品" />
-        <image class="search-icon" src="{{souimg}}" />
+        <input class="search-input" placeholder="搜索购物车商品" bindinput="onSearchInput" value="{{searchText}}" />
+        <image class="search-icon" src="{{souimg}}" bindtap="onSearchConfirm" />
       </view>
       <button class="manage-btn">管理</button>
     </view>

+ 2 - 2
pages/shoppingcart/shoppingcart.wxss

@@ -1,7 +1,7 @@
 /* pages/shoppingcart/shoppingcart.wxss */
 .container {
   margin: 0rpx 30rpx;
-  height: calc(100vh - 40rpx);
+  height: calc(100vh - 125rpx);
   overflow: hidden;
   width: calc(100% - 60rpx);
   padding: 0 0;
@@ -152,7 +152,7 @@
   background-color: #fff;
   padding: 20rpx;
   position: fixed;
-  bottom: 0;
+  bottom: 105rpx;
   left: 0;
   right: 0;
   font-size: 38rpx;

+ 28 - 3
subpackages/addresslist/addresslist.js

@@ -6,6 +6,7 @@ Page({
     shanchu: '',
     xiugaiimg: '',
     dingweiimg: '',
+    keyword: '', // 搜索关键词
   },
 
   onShow() {
@@ -42,12 +43,36 @@ Page({
     });
   },
 
+  // 模糊搜索
+  onSearchInput(e) {
+    const keyword = e.detail.value.trim();
+    this.setData({ keyword });
+    this.getdatalist(); // 每次输入更新列表(也可节流优化)
+  },
+
   // 地址数据
   async getdatalist() {
+    const keyword = this.data.keyword;
+
+    // 构建模糊查询
+    const filter = {
+      where: {}
+    };
+
+    if (keyword) {
+      filter.where.$or = [
+        { province: { $regex_ci: keyword } },
+        { municipality: { $regex_ci: keyword } },
+        { district: { $regex_ci: keyword } },
+        { street: { $regex_ci: keyword } },
+        { detailed_address: { $regex_ci: keyword } },
+        { name: { $regex_ci: keyword } },
+        { phone: { $regex_ci: keyword } },
+      ];
+    }
+
     const { data } = await models.adresses.list({
-      filter: {
-        where: {}
-      },
+      filter,
       pageSize: 100, // 分页大小,建议指定,如需设置为其它值,需要和 pageNumber 配合使用,两者同时指定才会生效
       pageNumber: 1, // 第几页
       getCount: true, // 开启用来获取总数

+ 1 - 1
subpackages/addresslist/addresslist.wxml

@@ -2,7 +2,7 @@
   <view class="top_boxs">
     <view class="diz">北京市 ▼</view>
     <view class="search-bar">
-      <input class="search-input" placeholder="搜索商品" />
+      <input class="search-input" placeholder="搜索地址/联系人/电话"  bindinput="onSearchInput" />
       <image class="search-icon" src="{{souimg}}" />
     </view>
   </view>

+ 145 - 0
subpackages/afterservice/afterservice.js

@@ -0,0 +1,145 @@
+import { models, db, _ } from '../../utils/cloudbase.js'
+Page({
+  data: {
+    item: {},
+    imgList: [],   // 本地或云端可预览的图片 URL
+    fileIDs: [],   // 云端 fileID
+    description: '',   // 新增描述字段
+  },
+
+  onLoad(options) {
+    const itemData = decodeURIComponent(options.data);
+    const item = JSON.parse(itemData);
+    this.setData({ item });
+
+  },
+
+  // 上传图片
+  chooseImage() {
+    if (this.data.imgList.length >= 6) {
+      wx.showToast({ title: '最多上传6张图片', icon: 'none' });
+      return;
+    }
+
+    wx.chooseImage({
+      count: 6 - this.data.imgList.length, // 剩余可上传数
+      sizeType: ['original', 'compressed'],
+      sourceType: ['album', 'camera'],
+      success: (res) => {
+        res.tempFilePaths.forEach(filePath => {
+          const cloudPath = 'aftersales/' + Date.now() + '-' + Math.floor(Math.random() * 1000) + filePath.match(/\.[^.]+?$/)[0];
+          wx.cloud.uploadFile({
+            cloudPath,
+            filePath,
+            success: uploadRes => {
+              // 上传成功,更新列表
+              this.setData({
+                imgList: [...this.data.imgList, uploadRes.fileID],
+                fileIDs: [...this.data.fileIDs, uploadRes.fileID]
+              });
+            },
+            fail: () => {
+              wx.showToast({ title: '上传失败', icon: 'none' });
+            }
+          });
+        });
+      }
+    });
+  },
+
+  // 删除图片
+  deleteImage(e) {
+    const index = e.currentTarget.dataset.index;
+    const fileID = this.data.imgList[index]; // 直接取字符串
+  
+    wx.cloud.deleteFile({
+      fileList: [fileID]
+    }).then(res => {
+      console.log('删除结果', res);
+  
+      // 前端同步移除
+      const imgList = [...this.data.imgList];
+      imgList.splice(index, 1);
+      this.setData({ imgList });
+  
+      // 如果你还要同步更新 fileIDs,也要处理
+      const fileIDs = [...this.data.fileIDs];
+      fileIDs.splice(index, 1);
+      this.setData({ fileIDs });
+    }).catch(err => {
+      console.error('删除文件失败', err);
+    });
+  },
+
+  // 预览图片
+  previewImage(e) {
+    const currentUrl = e.currentTarget.dataset.url;
+    wx.previewImage({
+      current: currentUrl,
+      urls: this.data.imgList
+    });
+  },
+
+  // 问题描述
+  onDescriptionInput(e) {
+    this.setData({ description: e.detail.value });
+  },
+
+  // 提交表单
+  async submitForm() {
+    const { description, fileIDs } = this.data;
+  
+    if (!description.trim()) {
+      wx.showToast({ title: '请输入问题描述', icon: 'none' });
+      return;
+    }
+  
+    if (fileIDs.length === 0) {
+      wx.showToast({ title: '请先上传图片', icon: 'none' });
+      return;
+    }
+  
+    wx.showLoading({ title: '提交中...' });
+  
+    try {
+      // 这里替换成你真实的参数
+      const goods_id = this.data.item.merchandise_id || "";
+      const school_id = this.data.item.schools_id || "";
+      const user_id = this.data.item.user_id || "";
+      const order_id = this.data.item.orders_id || "";
+      console.log(this.data.item, 'goods_id',);
+  
+      const { data } = await models.wx_afterservice.create({
+        data: {
+          goods_id,
+          url: fileIDs,
+          des: description,
+          school_id,
+          user_id,
+          state: 0,
+          order_id,
+        },
+        envType: "prod",
+      });
+  
+      console.log('创建成功,id:', data.id);
+  
+      wx.hideLoading();
+      wx.showToast({ title: '提交成功', icon: 'success' });
+      this.setData({
+        imgList: [],   // 本地或云端可预览的图片 URL
+        fileIDs: [],   // 云端 fileID
+        description: '',   // 新增描述字段
+      })
+      setTimeout(() => {
+        wx.navigateBack();
+      }, 1000);
+  
+      // 提交成功后可以清空表单或者跳转页面
+    } catch (error) {
+      wx.hideLoading();
+      wx.showToast({ title: '提交失败,请重试', icon: 'none' });
+      console.error('提交接口失败', error);
+    }
+  }
+});

+ 4 - 0
subpackages/afterservice/afterservice.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "售后申请"
+}

+ 51 - 0
subpackages/afterservice/afterservice.wxml

@@ -0,0 +1,51 @@
+<view style="background: #f5f5f5; padding: 20rpx 0;">
+  <view class="container">
+    <!-- 问题描述 -->
+    <view class="section">
+      <view class="section-title">其他</view>
+      <view class="field-title">
+        <text>问题描述</text>
+        <text class="word-limit">还可以输入100字</text>
+      </view>
+      <textarea
+        class="textarea"
+        placeholder="请输入问题描述"
+        maxlength="100"
+        bindinput="onDescriptionInput"
+        value="{{description}}"
+      ></textarea>
+    </view>
+
+    <!-- 上传图片 -->
+    <view class="section">
+      <view class="section-title">
+        <text>上传图片</text>
+      </view>
+      <view class="img-container">
+        <!-- 已上传的图片 -->
+        <block wx:for="{{imgList}}" wx:key="*this" wx:for-index="index">
+          <view class="img-wrapper">
+            <image 
+              src="{{item}}" 
+              class="img-thumb" 
+              mode="aspectFill" 
+              data-url="{{item}}" 
+              bindtap="previewImage"
+            />
+            <view class="delete-btn" data-index="{{index}}" bindtap="deleteImage">×</view>
+          </view>
+        </block>
+
+        <!-- 上传按钮 -->
+        <view wx:if="{{imgList.length < 6}}" class="upload-btn" bindtap="chooseImage">
+          <text>+</text>
+        </view>
+      </view>
+
+      <text class="upload-tip">* 有助于我们更快解决问题</text>
+    </view>
+
+    <!-- 提交按钮 -->
+    <button class="submit-btn" bindtap="submitForm">提交</button>
+  </view>
+</view>

+ 122 - 0
subpackages/afterservice/afterservice.wxss

@@ -0,0 +1,122 @@
+.container {
+  margin: 0rpx 30rpx;
+  width: calc(100% - 60rpx);
+  padding: 0 0;
+  height: calc(100% - 60rpx);
+  overflow: hidden;
+  overflow-y: hidden;
+}
+
+.section {
+  border-radius: 13rpx;
+  width: calc(100% - 60rpx);
+  background: #fff;
+  margin-top: 20rpx;
+  padding: 30rpx;
+}
+
+.section-title {
+  font-size: 38rpx;
+  font-weight: bold;
+  margin-bottom: 20rpx;
+  padding-bottom: 20rpx;
+  border-bottom: 1rpx solid #e7e7e7;
+}
+
+.field-title {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  font-size: 34rpx;
+  color: #333;
+  margin-bottom: 20rpx;
+}
+
+.word-limit {
+  color: #999;
+  font-size: 24rpx;
+}
+
+.textarea {
+  width: calc(100% - 60rpx);
+  border-radius: 8rpx;
+  height: 200rpx;
+  border: 1px solid #eee;
+  padding: 20rpx;
+  font-size: 26rpx;
+  background: #fafafa;
+}
+
+.upload-box {
+  width: 160rpx;
+  height: 160rpx;
+  border: 2rpx dashed #ccc;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+  color: #999;
+}
+
+.upload-icon {
+  width: 60rpx;
+  height: 60rpx;
+  margin-bottom: 10rpx;
+}
+
+.upload-text {
+  font-size: 24rpx;
+}
+
+.upload-tip {
+  margin-top: 10rpx;
+  font-size: 22rpx;
+  color: #409eff;
+}
+
+.submit-btn {
+  margin: 40rpx 30rpx 0;
+  background: #409eff;
+  color: #fff;
+  font-size: 32rpx;
+  border-radius: 8rpx;
+}
+
+.img-container {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 20rpx;
+}
+.img-wrapper {
+  position: relative;
+}
+.img-thumb {
+  width: 195rpx;
+  height: 195rpx;
+  border-radius: 8rpx;
+}
+.delete-btn {
+  position: absolute;
+  top: -10rpx;
+  right: -10rpx;
+  background: rgba(0,0,0,0.6);
+  color: white;
+  border-radius: 50%;
+  width: 40rpx;
+  height: 40rpx;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  font-size: 28rpx;
+}
+.upload-btn {
+  width: 195rpx;
+  height: 195rpx;
+  background: #f0f0f0;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  border-radius: 8rpx;
+  font-size: 48rpx;
+  color: #999;
+}

+ 63 - 26
subpackages/dahome/dahome.js

@@ -15,10 +15,22 @@ Page({
     pageSize: 10,
     hasMore: true, // 是否还有更多数据
     isLoading: false, // 防止多次触发
+    searchText: '', // 搜索关键词
+    inputFocus: false,
     // goods_9: '',
   },
 
-  onLoad() {
+  onLoad(options) {
+    // 存储 options 到 this 中
+    this.options = options;
+    if (options.autofocus === '1') {
+      // 延迟设置 focus,让页面完成渲染
+      setTimeout(() => {
+        this.setData({
+          inputFocus: true
+        });
+      }, 300); // 300ms 通常足够
+    }
     // 列表数据
     this.getdatalist()
     // 获取图片
@@ -60,34 +72,59 @@ Page({
     this.getdatalist(true);
   },
 
+  // 输入即搜索
+  onSearchInput(e) {
+    const searchText = e.detail.value;
+    this.setData({
+      searchText,
+      pageNumber: 1,
+      items: [],
+      hasMore: true,
+      isLoading: false
+    });
+    this.getdatalist(false);
+  },
 
   // 列表数据
   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
-    })
+    const { pageNumber, pageSize, selectedLevelIndex, selectedTypeIndex, searchText } = this.data;
+  
+    // 构造过滤条件
+    const whereFilter = {
+      tag_id: 'BULYBZSEY8',
+      level: Number(selectedTypeIndex) + 1,
+      dan: Number(selectedLevelIndex),
+    };
+  
+    // 添加模糊搜索
+    if (searchText.trim()) {
+      whereFilter.name = {
+        $regex_ci: searchText
+      };
+    }
+  
+    try {
+      const { data } = await models.file_manage.list({
+        filter: {
+          where: whereFilter
+        },
+        pageSize,
+        pageNumber,
+        getCount: true,
+        envType: "prod",
+      });
+  
+      const collectList = data.records || [];
+  
+      this.setData({
+        items: isLoadMore ? this.data.items.concat(collectList) : collectList,
+        pageNumber: pageNumber + 1,
+        hasMore: collectList.length === pageSize,
+        isLoading: false
+      });
+    } catch (err) {
+      console.error('数据获取失败:', err);
+    }
   },
 
   handleLevelChange(e) {

+ 1 - 1
subpackages/dahome/dahome.wxml

@@ -3,7 +3,7 @@
     <view class="top_boxs">
       <!-- 搜索 -->
       <view class="search-bar">
-        <input class="search-input" placeholder="搜索课件" />
+        <input class="search-input" placeholder="搜索课件" bindinput="onSearchInput" value="{{searchText}}" focus="{{inputFocus}}" />
         <image class="search-icon" src="{{souimg}}" />
       </view>
       <!-- 下拉框 -->

+ 81 - 9
subpackages/details/details.js

@@ -14,7 +14,7 @@ Page({
     xiazi: '',
     xia: '',
     itemlist: {},
-    // isCollected: false,
+    isCollected: false,
     isPlaying: false,
     isAudioPlaying: false,
   },
@@ -27,6 +27,23 @@ Page({
     this.setData({
       itemlist: item
     }, () => {
+        // 转换云文件ID为临时链接
+      if (item.url && item.url.length > 0) {
+        wx.cloud.getTempFileURL({
+          fileList: [item.url[0]],
+          success: res => {
+            if (res.fileList && res.fileList.length > 0) {
+              this.setData({
+                'itemlist.playUrl': res.fileList[0].tempFileURL
+              });
+            }
+          },
+          fail: err => {
+            console.error('获取临时链接失败', err);
+          }
+        });
+      }
+
       // 收藏
       // this.getcollect()
       // 相关推荐
@@ -193,7 +210,7 @@ Page({
           });
         } else if (['mp3', 'aac', 'wav'].includes(extension)) {
           console.log('这是一个音频文件,可以跳转到播放页面或使用音频组件');
-          // this.toggleAudio()
+          this.toggleAudio()
         } else if (['mp4', 'mov'].includes(extension)) {
           console.log('这是一个视频文件,可以跳转到视频播放页');
           this.toggleVideo()
@@ -224,14 +241,69 @@ Page({
   },
   // 音频的播放暂停
   toggleAudio() {
-    const audioContext = wx.createAudioContext('myAudio');
-  
+    // 如果已经有临时播放链接,直接用它
+    if (this.data.itemlist.playUrl) {
+      this._playAudio(this.data.itemlist.playUrl);
+    } else {
+      // 否则判断 url 是否是 cloud:// 开头,需要转临时链接
+      const cloudUrl = this.data.itemlist.url[0];
+      if (cloudUrl && cloudUrl.startsWith('cloud://')) {
+        wx.cloud.getTempFileURL({
+          fileList: [cloudUrl],
+          success: res => {
+            if (res.fileList && res.fileList.length > 0) {
+              const tempUrl = res.fileList[0].tempFileURL;
+              this.setData({ 'itemlist.playUrl': tempUrl }, () => {
+                this._playAudio(tempUrl);
+              });
+            }
+          },
+          fail: err => {
+            wx.showToast({ title: '获取播放链接失败', icon: 'none' });
+            console.error('获取临时链接失败', err);
+          }
+        });
+      } else {
+        // 不是 cloud:// 开头,直接播放原链接
+        this._playAudio(cloudUrl);
+      }
+    }
+  },
+
+  _playAudio(url) {
+    if (!this.audioContext) {
+      this.audioContext = wx.createInnerAudioContext();
+      this.audioContext.onPlay(() => this.setData({ isAudioPlaying: true }));
+      this.audioContext.onPause(() => this.setData({ isAudioPlaying: false }));
+      this.audioContext.onStop(() => this.setData({ isAudioPlaying: false }));
+      this.audioContext.onEnded(() => this.setData({ isAudioPlaying: false }));
+      this.audioContext.onError((res) => {
+        wx.showToast({ title: '音频播放错误', icon: 'none' });
+        this.setData({ isAudioPlaying: false });
+        console.error('音频播放错误', res);
+      });
+    }
+    
     if (this.data.isAudioPlaying) {
-      audioContext.pause();
-      this.setData({ isAudioPlaying: false });
+      this.audioContext.pause();
     } else {
-      audioContext.play();
-      this.setData({ isAudioPlaying: true });
+      this.audioContext.src = url;
+      this.audioContext.play();
+    }
+  },
+
+  onUnload() {
+    if (this.audioContext) {
+      this.audioContext.stop();
+      this.audioContext.destroy();
+      this.audioContext = null;
     }
-  }
+  },
+
+  onHide() {
+    if (this.audioContext) {
+      this.audioContext.pause();
+    }
+  },
+
 })

+ 5 - 12
subpackages/details/details.wxml

@@ -6,21 +6,14 @@
       <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="{{itemlist.type === 1 ? 'file-preview' : '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 class="file-preview" wx:elif="{{itemlist.type === 1}}">
+        <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 === 2}}">
         <image style="width: 100%; height: 100%;" src="{{itemlist.cover}}" alt="" class="file-placeholder"/>

+ 46 - 23
subpackages/imghome/imghome.js

@@ -13,6 +13,7 @@ Page({
     pageSize: 10,
     hasMore: true, // 是否还有更多数据
     isLoading: false, // 防止多次触发
+    searchText: '',
     // goods_9: '',
   },
 
@@ -54,31 +55,53 @@ Page({
     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 || [];
+  // 模糊搜搜
+  onSearchInput(e) {
+    const searchText = e.detail.value;
     this.setData({
-      items: isLoadMore ? this.data.items.concat(collectList) : collectList,
-      pageNumber: pageNumber + 1,
-      hasMore: collectList.length === pageSize,
+      searchText,
+      pageNumber: 1,
+      items: [],
+      hasMore: true,
       isLoading: false
-    })
+    });
+    this.getdatalist(false);
+  },
+
+  // 列表数据
+  async getdatalist(isLoadMore = false) {
+    const { pageNumber, pageSize, selectedTypeIndex, searchText } = this.data;
+  
+    const where = {
+      tag_id: 'BULYF5VJ9W',
+      level: Number(selectedTypeIndex) + 1,
+    };
+  
+    if (searchText.trim()) {
+      where.name = {
+        $regex_ci: searchText
+      };
+    }
+  
+    try {
+      const { data } = await models.file_manage.list({
+        filter: { where },
+        pageSize,
+        pageNumber,
+        getCount: true,
+        envType: "prod",
+      });
+  
+      const collectList = data.records || [];
+      this.setData({
+        items: isLoadMore ? this.data.items.concat(collectList) : collectList,
+        pageNumber: pageNumber + 1,
+        hasMore: collectList.length === pageSize,
+        isLoading: false
+      });
+    } catch (err) {
+      console.error('获取数据失败:', err);
+    }
   },
 
   goToGoodsList(event) {

+ 1 - 1
subpackages/imghome/imghome.wxml

@@ -3,7 +3,7 @@
     <view class="top_boxs">
       <!-- 搜索 -->
       <view class="search-bar">
-        <input class="search-input" placeholder="搜索课件" />
+        <input class="search-input" placeholder="搜索课件" bindinput="onSearchInput" value="{{searchText}}" />
         <image class="search-icon" src="{{souimg}}" />
       </view>
       <!-- 下拉框 -->

+ 207 - 73
subpackages/order/order.js

@@ -20,6 +20,7 @@ Page({
         type: 4,
       }
     ],
+    searchText: '', // 搜索关键词
     orders: [],
     souimg: '',
     pageNumber: 1,
@@ -66,87 +67,132 @@ Page({
     this.getdatalist(true);
   },
 
+  // 模糊搜索
+  onSearchInput(e) {
+    const value = e.detail.value.trim();
+    this.setData({
+      searchText: value,
+      pageNumber: 1,
+      hasMore: true,
+      orders: []
+    }, () => {
+      this.getdatalist();
+    });
+  },
+
   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 { pageNumber, pageSize, categoriesindex, searchText, orders } = this.data;
+  
+    let dbRegExp = null;
+    let jsRegExp = null;
+  
+    if (searchText) {
+      dbRegExp = db.RegExp({
+        regexp: searchText,
+        options: 'i'
+      });
+      jsRegExp = new RegExp(searchText, 'i');
+    }
+  
+    // 构造订单表的筛选条件
+    // 获取本地存储的用户信息
+    const userInfo = wx.getStorageSync('userInfo');
+    const userId = userInfo && userInfo._id ? userInfo._id : ''; // 根据你的userInfo结构取ID
+    const schoolId = userInfo && userInfo.school_id ? userInfo.school_id : ''; // 根据你的userInfo结构取ID
 
+    let orderWhere = {
+      user_id: userId,  // 每次必传
+      school_id: schoolId
+    };
+    if (categoriesindex !== 1) {
+      orderWhere.status = categoriesindex - 2;
+    }
+    if (dbRegExp) {
+      orderWhere = _.and([
+        orderWhere,
+        { order_id: dbRegExp }
+      ]);
+    }
+  
+    try {
+      // 第一步:查订单表
       const { data } = await models.orders.list({
-        filter, // 动态传递 filter
+        filter: { where: orderWhere },
         pageSize,
         pageNumber,
-        getCount: true, // 开启用来获取总数
-        envType: 'prod', // 正式环境
+        getCount: true,
+        envType: 'prod'
       });
-
-      // 返回查询到的数据列表 records 和 总数 total
-      const collectList = data.records || [];
-      if (collectList.length === 0) {
+  
+      const orderList = data.records || [];
+      if (orderList.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 fileManagerIds = orderList.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;
-        });
+          filter: { where: { _id: id } },
+          envType: 'prod'
+        }).then(res => res.data?.records?.[0] || 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
+  
+      // 第三步:合并数据,并进行模糊搜索筛选(匹配一个就保留)
+      const mergedOrders = [];
+  
+      for (let i = 0; i < orderList.length; i++) {
+        const order = orderList[i];
+        const merch = fileDetails[i];
+  
+        if (!merch) continue;
+  
+        if (jsRegExp) {
+          const matchOrderId = jsRegExp.test(order._id || '');
+          const matchName = jsRegExp.test(merch.name || '');
+  
+          if (!matchOrderId && !matchName) {
+            continue; // 都没匹配上,跳过
+          }
+        }
+  
+        // 先把 _id 改名为 order_id
+        const { _id, school_id, ...restOrder } = order;
+        const orderRenamed = {
+          ...restOrder,
+          orders_id: _id,
+          schools_id: school_id
         };
-      });
 
+        mergedOrders.push({
+          ...orderRenamed,
+          ...merch
+        });
+      }
+  
+      // 第四步:更新数据
       this.setData({
-        orders: isLoadMore ? this.data.orders.concat(newFiles) : newFiles,
+        orders: isLoadMore ? orders.concat(mergedOrders) : mergedOrders,
         pageNumber: pageNumber + 1,
-        hasMore: collectList.length === pageSize, // 如果返回的数量小于 pageSize,说明已经到底
+        hasMore: orderList.length === pageSize,
         isLoading: false
       });
-  } catch (err) {
-    console.error('获取失败:', err);
-    this.setData({ isLoading: false });
-  }
+    } catch (err) {
+      console.error('获取数据失败:', err);
+      this.setData({ isLoading: false });
+    }
   },
 
   tabcategories(e) {
@@ -154,6 +200,7 @@ Page({
     console.log('type:', type);
     this.setData({
       categoriesindex: type,
+      searchText: '', // ✅ 清空搜索关键词
       pageNumber: 1, // 重置页码
       hasMore: true, // 重置是否有更多数据
       orders: [], // 清空旧数据
@@ -162,15 +209,7 @@ Page({
       this.getdatalist(false);
     });
   },
-
-  handleAction1(e) {
-    console.log('查看详情', e);
-  },
-
-  handleAction2(e) {
-    console.log('处理其他操作', e);
-  },
-
+  
   // 处理第一个按钮的点击事件
   handleAction1: function (event) {
       const index = event.currentTarget.dataset.index; // 获取点击的订单索引
@@ -179,15 +218,24 @@ Page({
       switch (status) {
           case 1:
               console.log("查看详情", index);
+              const item = this.data.orders[index];
+              wx.navigateTo({
+                url: '/subpackages/orderdetails/orderdetails?data=' + encodeURIComponent(JSON.stringify(item))
+              });
               // 执行查看详情的逻辑
               break;
-          case 2:
+          case 0:
               console.log("取消订单", index);
               // 执行取消订单的逻辑
               break;
-          case 3:
+          case 2:
               console.log("申请售后", index);
               // 执行申请售后的逻辑
+              const items = this.data.orders[index];
+              console.log(items, 'itemsitemsitemsitems');
+              wx.navigateTo({
+                url: '/subpackages/afterservice/afterservice?data=' + encodeURIComponent(JSON.stringify(items))
+              });
               break;
           default:
               console.log("未知状态");
@@ -202,13 +250,14 @@ Page({
       switch (status) {
           case 1:
               console.log("确认收货", index);
+              this.getyesordels(this.data.orders[index])
               // 执行确认收货的逻辑
               break;
-          case 2:
+          case 0:
               console.log("立即支付", index);
               // 执行立即支付的逻辑
               break;
-          case 3:
+          case 2:
               console.log("再来一单", index);
               // 执行再来一单的逻辑
               break;
@@ -217,6 +266,64 @@ Page({
       }
   },
 
+  // 确认收货
+  async getyesordels (list) {
+    console.log(list, 'list');
+    const userInfo = wx.getStorageSync('userInfo');
+    const userId = userInfo && userInfo._id ? userInfo._id : ''; // 根据你的userInfo结构取ID
+    const schoolId = userInfo && userInfo.school_id ? userInfo.school_id : ''; // 根据你的userInfo结构取ID
+
+    const { data } = await models.orders.update({
+      data: {
+          status: 2,  // 状态
+        },
+      filter: {
+        where: {
+          $and: [
+            {
+              merchandise_id: {
+                $eq: list._id, // 推荐传入_id数据标识进行操作
+              },
+            },
+            {
+              user_id: {
+                $eq: userId, // 推荐传入_id数据标识进行操作
+              },
+            },
+            {
+              school_id: {
+                $eq: schoolId, // 推荐传入_id数据标识进行操作
+              },
+            },
+          ]
+        }
+      },
+      envType: "prod",
+    });
+    console.log(data.count, 'data.count');
+    if (Number(data.count) > 0) {
+      wx.showToast({
+        title: '确认收货成功',
+        icon: 'success',
+        duration: 1500
+      });
+      // ✅ 重新获取数据
+      this.setData({
+        pageNumber: 1,
+        hasMore: true,
+        orders: []
+      }, () => {
+        this.getdatalist(false);
+      });
+    } else {
+      wx.showToast({
+        title: '确认收货失败',
+        icon: 'error',
+        duration: 1500
+      });
+    }
+  },
+
   goToGoodsList (e) {
     const index = e.currentTarget.dataset.type;
     const item = this.data.orders[index];
@@ -224,5 +331,32 @@ Page({
     wx.navigateTo({
       url: '/subpackages/orderdetails/orderdetails?data=' + encodeURIComponent(JSON.stringify(item))
     });
-  }
+  },
+
+  // async adds () {
+  //   const { data } = await models.orders.create({
+  //     data: {
+  //         adresses_id: "BWSLJAGVZA",  // 地址id
+  //         sys_updateby_id: "",  // 更新人
+  //         merchandise_id: "BULGAD2DA8",  // 商品id
+  //         real_money: 223.12,  // 实际付款金额
+  //         updat_adress: "",  // 修改后地址
+  //         update_phone: "",  // 修改后电话
+  //         delete: 0,  // 逻辑删除
+  //         way: 1,  // 收货方式
+  //         update_name: "",  // 修改后收货人
+  //         school_id: "BU5N9CFX2Q",  // 学校_id
+  //         user_id: "BWYRRKQVNY",  // 用户_id
+  //         num_index: 1,  // 商品数据
+  //         tracking_number: "物流单号888",  // 物流单号
+  //         order_id: "订单号888",  // 订单号
+  //         status: 2,  // 状态
+  //       },
+  //     // envType: pre 体验环境, prod 正式环境
+  //     envType: "prod",
+  //   });
+    
+  //   // 返回创建的数据 id
+  //   console.log(data);
+  // }
 });

+ 6 - 5
subpackages/order/order.wxml

@@ -2,9 +2,10 @@
   <view class="container">
     <!-- 搜索框 -->
     <view class="search-bar">
-      <input class="search-input" placeholder="搜索订单号或商品名称" />
+      <input class="search-input" placeholder="搜索订单号或商品名称" bindinput="onSearchInput" value="{{searchText}}" />
       <image class="search-icon" src="{{souimg}}" />
     </view>
+    <!-- <button bindtap="adds">123123</button> -->
 
     <!-- 分类 -->
     <view class="category-tabs">
@@ -22,7 +23,7 @@
     >
       <view class="order-list">
         <block wx:for="{{orders}}" wx:key="order_id">
-          <view class="order-item" bindtap="goToGoodsList" data-type="{{index}}">
+          <view class="order-item" catchtap="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>
@@ -39,11 +40,11 @@
                 <view class="order-description">数量: 购买数量这个到时候要看怎么获取</view>
               </view>
             </view>
-            <view class="order-actions">
-              <button class="order-action-btn1" bindtap="handleAction1" data-index="{{index}}">
+            <view class="order-actions" style="z-index: 22;">
+              <button class="order-action-btn1" catchtap="handleAction1" data-index="{{index}}">
                   {{ item.status === 1 ? "查看详情" : item.status === 0 ? "取消订单" : "申请售后" }}
               </button>
-              <button class="order-action-btn2" bindtap="handleAction2" data-index="{{index}}">
+              <button class="order-action-btn2" catchtap="handleAction2" data-index="{{index}}">
                   {{ item.status === 1 ? "确认收货" : item.status === 0 ? "立即支付" : "再来一单" }}
               </button>
             </view>

+ 47 - 1
subpackages/orderdetails/orderdetails.js

@@ -1,4 +1,5 @@
 // subpackages/orderdetails/orderdetails.js
+import { models, db, _ } from '../../utils/cloudbase.js'
 Page({
 
   /**
@@ -8,7 +9,8 @@ Page({
     dingwei: '',
     fuzhi: '',
     yesbaoguo: '',
-    item: {}
+    item: {},
+    adresseslist: {}
   },
 
   onLoad(options) {
@@ -17,6 +19,8 @@ Page({
     const item = JSON.parse(itemData);
     this.setData({
       item: item
+    }, () => {
+      this.getadresses()
     });
 
     const fileIDs = [
@@ -41,4 +45,46 @@ Page({
       console.error('有文件下载失败:', err);
     });
   },
+
+  async getadresses() {
+    const { data } = await models.adresses.get({
+      filter: {
+        where: {
+          $and: [
+            {
+              _id: {
+                $eq: this.data.item.adresses_id, // 推荐传入_id数据标识进行操作
+              },
+            },
+          ]
+        }
+      },
+      // envType: pre 体验环境, prod 正式环境
+      envType: "prod",
+    });
+    
+    // 返回查询到的数据
+    this.setData({
+      adresseslist: data
+    })
+  },
+
+  copyText(e) {
+    const copyText = e.currentTarget.dataset.copytext;
+    wx.setClipboardData({
+      data: copyText,
+      success: function () {
+        wx.showToast({
+          title: '复制成功',
+          icon: 'success'
+        });
+      },
+      fail: function () {
+        wx.showToast({
+          title: '复制失败',
+          icon: 'none'
+        });
+      }
+    });
+  }
 })

+ 4 - 4
subpackages/orderdetails/orderdetails.wxml

@@ -12,8 +12,8 @@
           <image src="{{dingwei}}" alt=""/>
         </view>
         <view class="right">
-          <view>苏州市姑苏区江平路186号枕河人家小区</view>
-          <view>周白芷  153***0508</view>
+          <view>{{ item.updat_adress ? item.updat_adress : adresseslist.address }}</view>
+          <view>{{ item.update_name ? item.update_name : adresseslist.name }}  {{ item.update_phone ? item.update_phone : adresseslist.phone}}</view>
         </view>
       </view>
     </view>
@@ -36,7 +36,7 @@
           <text>订单编号</text>
           <view>
             <text>{{item.order_id}}</text>
-            <image style="width: 35rpx; height: 35rpx;margin-left: 16rpx;" src="{{fuzhi}}" alt=""/></view>
+            <image bindtap="copyText" data-copytext="{{item.order_id}}" style="width: 35rpx; height: 35rpx;margin-left: 16rpx;" src="{{fuzhi}}" alt=""/></view>
         </view>
         <view class="order_item">
           <text>下单时间</text>
@@ -54,7 +54,7 @@
           <view>物流单号</view>
           <view>
             <text>{{item.tracking_number}}</text>
-            <image style="width: 35rpx; height: 35rpx;margin-left: 16rpx;" src="{{fuzhi}}" alt=""/>
+            <image bindtap="copyText" data-copytext="{{item.tracking_number}}" style="width: 35rpx; height: 35rpx;margin-left: 16rpx;" src="{{fuzhi}}" alt=""/>
           </view>
         </view>
       </view>

+ 43 - 0
subpackages/productdetails/productdetails.js

@@ -13,6 +13,8 @@ Page({
     const item = JSON.parse(itemData);
     this.setData({
       item: item
+    }, () => {
+      this.getbrowse()
     });
 
     const fileIDs = [
@@ -36,6 +38,43 @@ Page({
     });
   },
 
+  // 新增浏览量
+  async getbrowse() {
+    const { data } = await models.wx_merchandise.update({
+      data: {
+          browse: this.data.item.browse + 1,  // 浏览数
+        },
+      filter: {
+        where: {
+          $and: [
+            {
+              _id: {
+                $eq: this.data.item._id, // 推荐传入_id数据标识进行操作
+              },
+            },
+          ]
+        }
+      },
+      // envType: pre 体验环境, prod 正式环境
+      envType: "prod",
+    });
+    
+    // 返回更新成功的条数
+    console.log(data, 'datadata');
+    this.setData({
+      'item.browse': this.data.item.browse + 1
+    })
+  },
+
+  previewImage(e) {
+    const index = e.currentTarget.dataset.index;
+    const images = this.data.item.detail_images;
+    wx.previewImage({
+      current: images[index],  // 当前预览的图片
+      urls: images             // 所有可预览的图片列表
+    });
+  },
+
   // 跳转购物车
   gotogwc() {
     wx.switchTab({
@@ -63,9 +102,12 @@ Page({
   async addToCart() {
     // 加入购物车逻辑
     console.log('加入购物车', this.data.item, this.data.item._id);
+    const userInfo = wx.getStorageSync('userInfo');
+    const userId = userInfo && userInfo._id ? userInfo._id : ''; // 根据你的userInfo结构取ID
     const { data } = await models.shopping_cart.get({
       filter: {
         where: {
+          user_id: { $eq: userId },
           merchandise_id: { $eq: this.data.item._id }, // 推荐传入_id数据标识进行操作
           specs_index: { $eq: this.data.gaoliao }
         }
@@ -82,6 +124,7 @@ Page({
       // 执行插入操作
       const { data } = await models.shopping_cart.create({
         data: {
+            user_id: userId,
             merchandise_id: this.data.item._id,  
             num: this.data.steppernum,  // 商品数量
             specs_index: this.data.gaoliao,  // 规格下标

+ 2 - 1
subpackages/productdetails/productdetails.wxml

@@ -5,7 +5,8 @@
       <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" />
+            <image style="width: 100%; height: 100%;" src="{{item}}" mode="aspectFill"
+            bindtap="previewImage" data-index="{{index}}" />
           </swiper-item>
         </block>
       </swiper>

+ 1 - 0
subpackages/purchasehistory/purchasehistory.js

@@ -76,6 +76,7 @@ Page({
       });
 
       const collectList = data.records || [];
+      console.log(collectList, 'collectList');
       if (collectList.length === 0) {
         this.setData({ hasMore: false, isLoading: false });
         return;