LiuShu_0203 1 miesiąc temu
rodzic
commit
904a5ae9b0

+ 1 - 1
app.js

@@ -25,7 +25,7 @@ App({
           } else if (res.cancel) {
             // 老师:跳转到老师端小程序
             wx.navigateToMiniProgram({
-              appId: 'wx06f2b1b09ac5684f', // ⚠️ 替换成实际 appId
+              appId: 'wx19b14b10ee9d1571', // ⚠️ 替换成实际 appId
               path: 'pages/logins/logins',
             });
           }

+ 7 - 0
package-lock.json

@@ -10,6 +10,7 @@
       "license": "ISC",
       "dependencies": {
         "@cloudbase/wx-cloud-client-sdk": "^1.6.1",
+        "@vant/weapp": "^1.11.7",
         "vant-weapp": "^0.5.29"
       }
     },
@@ -18,6 +19,12 @@
       "resolved": "https://registry.npmmirror.com/@cloudbase/wx-cloud-client-sdk/-/wx-cloud-client-sdk-1.6.1.tgz",
       "integrity": "sha512-TeLhz+LMlTe1bZiCbwflU2nXX4FHXnLk1ojbrOfY9ki1gO1gYll9Snl2g3zBhiTGye/OfhzBEDCwVhGxzOxs4Q=="
     },
+    "node_modules/@vant/weapp": {
+      "version": "1.11.7",
+      "resolved": "https://registry.npmmirror.com/@vant/weapp/-/weapp-1.11.7.tgz",
+      "integrity": "sha512-Rwn9BBnb4kHSV4XmvBicwtd42J+amEUfnFDcXJsGNPNX4a9c/DoT6YLsm4X1wB2+sQbdiQsbFBLAvGRBxCkD8g==",
+      "license": "MIT"
+    },
     "node_modules/vant-weapp": {
       "version": "0.5.29",
       "resolved": "https://registry.npmmirror.com/vant-weapp/-/vant-weapp-0.5.29.tgz",

+ 1 - 0
package.json

@@ -5,6 +5,7 @@
   "main": "app.js",
   "dependencies": {
     "@cloudbase/wx-cloud-client-sdk": "^1.6.1",
+    "@vant/weapp": "^1.11.7",
     "vant-weapp": "^0.5.29"
   },
   "scripts": {

+ 15 - 0
pages/index/index.js

@@ -159,4 +159,19 @@ Page({
       console.log(err);
     })
   },
+
+  onShareAppMessage() {
+    return {
+      title: '红孩儿智慧教育',
+      path: '/pages/index/index', // 分享落地页
+      // imageUrl: // 可以自定义封面图
+    }
+  },
+  // 分享到朋友圈
+  onShareTimeline() {
+    return {
+      title: '红孩儿智慧教育',
+      query: 'from=timeline'
+    }
+  },
 })

+ 95 - 12
pages/logins/logins.js

@@ -1,7 +1,11 @@
 import { models, db } from '../../utils/cloudbase.js'
+import Dialog from '@vant/weapp/dialog/dialog';
 Page({
   data: {
     phone: '', // 用户输入的手机号码
+    name: '',
+    yuan: '',
+    falog: false,
   },
 
   // 监听手机号码输入
@@ -11,6 +15,18 @@ Page({
     });
   },
 
+  onInputName(e) {
+    this.setData({
+      name: e.detail.value
+    });
+  },
+
+  onInputYuan(e) {
+    this.setData({
+      yuan: e.detail.value
+    });
+  },
+
   // 确定按钮点击事件
   async onConfirm() {
     const { phone } = this.data;
@@ -50,12 +66,12 @@ Page({
       // envType: pre 体验环境, prod 正式环境
       envType: "prod",
     });
-    const users = data.records || [];
+    let users = data.records || [];
 
     // 如果查不到任何数据
     if (users.length === 0) {
       wx.showToast({
-        title: '该手机号绑定,请换其他手机号登录',
+        title: '未查询该用户,请换其他手机号登录',
         icon: 'none'
       });
       return;
@@ -75,18 +91,67 @@ Page({
     const validUser = users.find(user => user.delete === 0);
     
     if (validUser.bound === 0) {
-      // 第一次登录去绑定
-      wx.showToast({
-        title: '首次登录,请先绑定信息',
-        icon: 'none',
-        duration: 1500
+
+      console.log(users[0].school_id, 'users._idusers._idusers._id');
+
+      const { datass } = await models.wx_teacher_user.update({
+        data: {
+            bound: 1,  // 是否绑定
+          },
+        filter: {
+          where: {
+            $and: [
+              {
+                _id: {
+                  $eq: users[0]._id, // 推荐传入_id数据标识进行操作
+                },
+              },
+            ]
+          }
+        },
+        envType: "prod",
       });
       
-      setTimeout(() => {
-        wx.navigateTo({
-          url: `/pages/login/login?phone=${encodeURIComponent(this.data.phone)}`
-        });
-      }, 1500); // 等提示展示完再跳转
+      const schoolRes = await models.wx_school.get({
+        filter: {
+          where: {
+            _id: users[0].school_id
+          }
+        },
+        envType: "prod",
+      });
+      
+      console.log(schoolRes, 'schoolRes');
+      const school = schoolRes.data; // 这里才是你要的园所信息
+
+      this.setData({
+        name: users[0].name,
+        yuan: school.name,
+        falog: true,
+      })
+
+      // onConfirm 成功时
+      wx.setStorageSync('userInfo', validUser);
+
+      // Dialog.confirm({
+      //   title: '用户信息',
+      //   message: `姓名:${validUser.name}\n园所:${school.name || '未知园所'}`,
+      //   showCancelButton: false,
+      // }).then(() => {
+      //   wx.setStorageSync('userInfo', {
+      //     ...validUser,
+      //     bound: 1
+      //   });
+      //   wx.switchTab({
+      //     url: '/pages/index/index'
+      //   });
+      // });
+      
+      // setTimeout(() => {
+      //   wx.navigateTo({
+      //     url: `/pages/login/login?phone=${encodeURIComponent(this.data.phone)}`
+      //   });
+      // }, 1500); // 等提示展示完再跳转
     } else {
       // 登录成功,存储用户信息
       wx.setStorageSync('userInfo', validUser);
@@ -100,5 +165,23 @@ Page({
         url: '/pages/index/index'
       });
     }
+  },
+
+  gotuhome() {
+    const validUser = wx.getStorageSync('userInfo');
+    if (!validUser) {
+      wx.showToast({
+        title: '用户信息丢失,请重新登录',
+        icon: 'none'
+      });
+      return;
+    }
+    wx.showToast({
+      title: '登录成功',
+      icon: 'success'
+    });
+    wx.switchTab({
+      url: '/pages/index/index'
+    });
   }
 })

+ 2 - 1
pages/logins/logins.json

@@ -1,6 +1,7 @@
 {
   "usingComponents": {
-    "captcha": "/components/captcha/captcha"
+    "captcha": "/components/captcha/captcha",
+    "van-dialog": "@vant/weapp/dialog/index"
   },
   "navigationBarTitleText": "登录"
 }

+ 18 - 4
pages/logins/logins.wxml

@@ -13,11 +13,25 @@
     <view class="input-group">
       <label>手机号码</label>
       <view>
-        <input bindinput="onInputPhone" type="text" placeholder="请输入常用的手机号码" />
+        <input bindinput="onInputPhone" value="{{phone}}" type="text" placeholder="请输入常用的手机号码" />
       </view>
     </view>
-    <captcha id="loginCaptcha" phone="{{phone}}" />
-    <navigator url="/pages/login/login" open-type="navigate">您还没有绑定,去绑定</navigator>
-    <button bindtap="onConfirm" class="confirm-btn">登录</button>
+    <captcha wx:if="{{falog === false}}" id="loginCaptcha" phone="{{phone}}" />
+    <view class="input-group" wx:if="{{falog === true}}">
+      <label>姓名</label>
+      <view>
+        <input bindinput="onInputName" value="{{name}}"  type="text" placeholder="请输入常用的手机号码" readonly />
+      </view>
+    </view>
+    <view class="input-group" wx:if="{{falog === true}}">
+      <label>园所</label>
+      <view>
+        <input bindinput="onInputYuan" value="{{yuan}}" type="text" placeholder="请输入常用的手机号码" readonly />
+      </view>
+    </view>
+    <!-- <navigator url="/pages/login/login" open-type="navigate">您还没有绑定,去绑定</navigator> -->
+    <button wx:if="{{falog === false }}" bindtap="onConfirm" class="confirm-btn">登录</button>
+    <button wx:if="{{falog === true}}" bindtap="gotuhome" class="confirm-btn">进入首页</button>
   </view>
+  <van-dialog id="van-dialog" />
 </view>

+ 45 - 0
pages/logins/logins.wxss

@@ -43,4 +43,49 @@ navigator {
   font-size: 24rpx;
   color: #007aff;
   margin-top: 50rpx;
+}
+
+/* 标题样式 */
+.van-dialog__header {
+  text-align: center !important;
+  font-size: 18px !important;
+  font-weight: bold !important;
+}
+
+/* 内容样式 */
+.van-dialog__message-text {
+  width: 100% !important;
+  /* text-align: center !important; */
+  font-size: 18px !important;
+  color: #333 !important;
+}
+
+/* 确认按钮样式 */
+.van-dialog__confirm {
+  color: #1989fa !important; /* 蓝色 */
+  font-size: 16px !important;
+}
+
+wx-button:not([size=mini]) {
+  margin-left: auto;
+  margin-right: auto;
+  width: 100%; /* 根据内容自适应 */
+}
+
+.van-dialog__button {
+  flex: 1;
+  text-align: center;
+}
+
+/* 按钮容器居中 */
+.van-dialog__footer {
+  align-content: center !important;
+  display: flex !important;
+  justify-content: center !important;
+}
+
+.van-dialog__message {
+  text-align: left !important;
+  padding: 14rpx 60rpx 30rpx 60rpx !important;
+  line-height: 1.8 !important; /* 调大行距 */
 }

+ 33 - 0
pages/me/me.js

@@ -303,5 +303,38 @@ Page({
       });
     }
 
+  },
+
+  // 退出登录
+  handleTuichu() {
+    wx.showModal({
+      title: '提示',
+      content: '确定要退出登录吗?',
+      success: (res) => {
+        if (res.confirm) {
+          // 1. 清空本地缓存
+          wx.removeStorageSync('userInfo');
+
+          // 2. 给全局 app.js 里也同步清除(如果有保存全局数据)
+          const app = getApp();
+          if (app.globalData) {
+            app.globalData.userInfo = null;
+          }
+
+          // 3. 提示退出成功
+          wx.showToast({
+            title: '已退出登录',
+            icon: 'success'
+          });
+
+          // 4. 跳转回登录页(比如你的小程序登录页是 /pages/login/login)
+          setTimeout(() => {
+            wx.reLaunch({
+              url: '/pages/logins/logins'
+            });
+          }, 800);
+        }
+      }
+    });
   }
 });

+ 4 - 1
pages/me/me.wxml

@@ -85,7 +85,10 @@
     </view>
 
     <!-- 用户注销 -->
-    <button class="logout-btn" size="default" bindtap="handleLogout">用户注销</button>
+    <view style="display: flex; justify-content: space-between;">
+      <button class="logout-btn logout-btnons" size="default" bindtap="handleTuichu">退出登录</button>
+      <button class="logout-btn logout-btns" size="default" bindtap="handleLogout">用户注销</button>
+    </view>
 
     <!-- <custom-tabbar role="{{role}}" selected="{{2}}" /> -->
 </view>

+ 14 - 3
pages/me/me.wxss

@@ -149,14 +149,25 @@ margin-top: 30rpx;
 }
 
 .logout-btn {
-  width: 100% !important;
+  margin: 0 20rpx !important;
+  /* width: 100% !important; */
   height: 80rpx;
-  background-color: #007aff;
-  color: #fff;
   font-size: 32rpx;
   border-radius: 40rpx;
 }
 
+.logout-btns {
+  background-color: #007aff;
+  border: 1rpx solid #007aff;
+  color: #fff;
+}
+
+.logout-btnons {
+  border: 1rpx solid #007aff;
+  background-color: #fff;
+  color: #007aff;
+}
+
 .xiazai_img {
   width: 45rpx;
   height: 40rpx;

+ 6 - 1
project.config.json

@@ -3,7 +3,12 @@
   "cloudfunctionRoot": "cloud/",
   "libVersion": "3.8.11",
   "packOptions": {
-    "ignore": [],
+    "ignore": [
+      {
+        "type": "folder",
+        "value": "cloud"
+      }
+    ],
     "include": []
   },
   "setting": {

+ 3 - 3
subpackages/jxhome/jxhome.wxml

@@ -14,20 +14,20 @@
 
     <!-- 课程分类按钮 -->
     <view class="course-buttons">
-      <view class="course-button1" style="background-image: url({{homepage_7}}); background-size: cover;" bindtap="goToGoodsList" data-type="1" >
+      <view class="course-button1" style="background-image: url({{homepage_7}}); background-size: cover;" bindtap="goToGoodsList" data-type="7" >
         <view class="nr_boxs">
           <text>卡尔阅读</text>
           <text>course</text>
         </view>
       </view>
       <view class="course-buttonstow">
-        <view class="course-button2" style="background-image: url({{homepage_6}}); background-size: cover;"  bindtap="goToGoodsList" data-type="2">
+        <view class="course-button2" style="background-image: url({{homepage_6}}); background-size: cover;"  bindtap="goToGoodsList" data-type="8">
           <view class="nr_boxs">
             <text>卡尔思维</text>
             <text>course</text>
           </view>
         </view>
-        <view class="course-button2" bindtap="goToGoodsList" data-type="3" style="margin-top: 20rpx; background-image: url({{homepage_5}}); background-size: cover;">
+        <view class="course-button2" bindtap="goToGoodsList" data-type="9" style="margin-top: 20rpx; background-image: url({{homepage_5}}); background-size: cover;">
           <view class="nr_boxs">
             <text>动手动脑</text>
             <text>course</text>

+ 3 - 3
subpackages/zshome/zshome.wxml

@@ -14,20 +14,20 @@
 
     <!-- 课程分类按钮 -->
     <view class="course-buttons">
-      <view class="course-button1" style="background-image: url({{homepage_7}}); background-size: cover;" bindtap="goToGoodsList" data-type="1" >
+      <view class="course-button1" style="background-image: url({{homepage_7}}); background-size: cover;" bindtap="goToGoodsList" data-type="10" >
         <view class="nr_boxs">
           <text>卡尔阅读</text>
           <text>course</text>
         </view>
       </view>
       <view class="course-buttonstow">
-        <view class="course-button2" style="background-image: url({{homepage_6}}); background-size: cover;"  bindtap="goToGoodsList" data-type="2">
+        <view class="course-button2" style="background-image: url({{homepage_6}}); background-size: cover;"  bindtap="goToGoodsList" data-type="11">
           <view class="nr_boxs">
             <text>卡尔思维</text>
             <text>course</text>
           </view>
         </view>
-        <view class="course-button2" bindtap="goToGoodsList" data-type="3" style="margin-top: 20rpx; background-image: url({{homepage_5}}); background-size: cover;">
+        <view class="course-button2" bindtap="goToGoodsList" data-type="12" style="margin-top: 20rpx; background-image: url({{homepage_5}}); background-size: cover;">
           <view class="nr_boxs">
             <text>动手动脑</text>
             <text>course</text>

+ 1 - 1
subpackagestow/course/course.wxml

@@ -34,7 +34,7 @@
           <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 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' : item.type === 4 ? '图文' : 'Excel'}}</view>
             </view>
             <view class="item-content">
               <view class="item-title">{{item.name}}</view>

+ 64 - 1
subpackagestow/details/details.js

@@ -18,9 +18,17 @@ Page({
     isCollected: false,
     isPlaying: false,
     isAudioPlaying: false,
+    enterTime: null, // 进入时间
   },
 
   onLoad(options) {
+
+    // 进入时间
+    const now = new Date();
+    this.setData({
+      enterTime: now
+    });
+
     // 获取传递过来的数据
     const itemStr = decodeURIComponent(options.item);
     const item = JSON.parse(itemStr);
@@ -226,7 +234,7 @@ Page({
           const tempUrl = res.fileList[0].tempFileURL;
           const extension = tempUrl.substring(tempUrl.lastIndexOf('.') + 1).toLowerCase();
   
-          if (['pdf', 'ppt', 'pptx'].includes(extension)) {
+          if (['pdf', 'ppt', 'pptx', 'xls', 'xlsx'].includes(extension)) {
             // 先下载到本地
             wx.downloadFile({
               url: tempUrl,
@@ -399,4 +407,59 @@ Page({
       console.log("创建成功", newData);
     }
   },
+
+  async onUnload() {
+    await this.saveUserBehavior();
+    if (this.audioContext) {
+      this.audioContext.stop();
+      this.audioContext.destroy();
+      this.audioContext = null;
+    }
+  },
+
+  async onHide() {
+    await this.saveUserBehavior();
+    if (this.audioContext) {
+      this.audioContext.pause();
+    }
+  },
+
+  async saveUserBehavior() {
+    try {
+      const userInfo = wx.getStorageSync('userInfo');
+      const userId = userInfo && userInfo._id ? userInfo._id : '';
+      
+      const startTime = this.data.enterTime;
+      if (!startTime) return; // 如果没进入过,不存
+
+      const endTime = new Date();
+      // 转换为时间戳(毫秒 → 秒)
+      const startTimestamp = new Date(startTime).getTime();
+      const endTimestamp = new Date().getTime();
+
+      const duration = endTimestamp - startTimestamp;
+
+      await models.monitor_behavior.create({
+        data: {
+          start_time: startTimestamp, // 数字
+          end_time: endTimestamp,     // 数字
+          duration: duration,         // 数字
+          type: 0,                    // 固定 0
+          user_id: userId || 'guest'
+        },
+        envType: "prod",
+      });
+  
+      console.log("监控数据保存成功:", {
+        start_time: startTimestamp,
+        end_time: endTimestamp,
+        duration,
+        type: 0,
+        user_id: userId || 'guest'
+      });
+    } catch (err) {
+      console.error("监控数据保存失败", err);
+    }
+  }
+
 })

+ 1 - 1
subpackagestow/details/details.wxml

@@ -50,7 +50,7 @@
         <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 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' : item.type === 4 ? '图文' : 'Excel'}}</view>
           </view>
           <view class="item-content">
             <view class="item-title">{{item.name}}</view>

+ 50 - 1
subpackagestow/down/down.js

@@ -11,7 +11,9 @@ Page({
     itemtempFileURL: '',
     countdown: '00:05:00', // 倒计时文本
     countdownTime: 300,    // 倒计时秒数(5分钟)
-    timer: null            // 定时器句柄
+    timer: null,            // 定时器句柄
+    downloadTimestamps: [], // 记录下载时间戳
+    hasAlarmed: false,      // 防止重复报警
   },
 
   onLoad(options) {
@@ -139,6 +141,30 @@ Page({
 
   // 下载
   handleDownloadFile() {
+
+    const now = Date.now(); // 当前时间戳 毫秒
+    let timestamps = this.data.downloadTimestamps || [];
+
+    // 5分钟 = 5*60*1000 毫秒
+    const FIVE_MINUTES = 5 * 60 * 1000;
+
+    // 过滤掉超过5分钟的点击
+    timestamps = timestamps.filter(ts => now - ts <= FIVE_MINUTES);
+
+    // 加入当前点击
+    timestamps.push(now);
+
+    this.setData({
+      downloadTimestamps: timestamps
+    });
+
+    // 超过10次 && 未报警 → 静默存一次
+    if (timestamps.length >= 10 && !this.data.hasAlarmed) {
+      this.setData({ hasAlarmed: true });
+      this.saveAbnormalBehavior();
+    }
+
+
     const link = this.data.itemtempFileURL;
     if (!link) {
       wx.showToast({
@@ -385,5 +411,28 @@ Page({
       clearInterval(this.data.timer);
       this.setData({ timer: null });
     }
+  },
+
+  async saveAbnormalBehavior() {
+    const userInfo = wx.getStorageSync('userInfo');
+    const userId = userInfo && userInfo._id ? userInfo._id : '';
+    const schoolId = userInfo && userInfo.school_id ? userInfo.school_id : '';
+    const fileName = this.data.itemlist.name || '';
+
+    try {
+      await models.abnormal_behavior_alarm.create({
+        data: {
+          school_id: schoolId,
+          reason: '五分钟内点击下载超过10次',
+          type: 0,           // 可自行定义数字类型,表示下载异常
+          file_name: fileName,
+          user_id: userId
+        },
+        envType: 'prod'
+      });
+      console.log('异常行为已记录');
+    } catch (err) {
+      console.error('记录异常行为失败', err);
+    }
   }
 })

+ 17 - 3
subpackagestow/show/show.js

@@ -65,7 +65,7 @@ Page({
     const { data } = await models.tab.list({
       filter: {
         where: {
-          position: 3, // 显示位置
+          position: Number(this.options.type), // 显示位置
           // layout_type: 0, // 布局类型
         },
       },
@@ -77,10 +77,24 @@ Page({
     const sortedRecords = data.records.sort((a, b) => {
       return a.sort - b.sort; // 升序排列
     });
+
+    // 截取 name 中 "- " 后面的部分
+    const processedRecords = sortedRecords.map(item => {
+      let newName = item.name;
+      if (newName.includes('-')) {
+        // 按照 '-' 分割,并取第二段(去掉前后空格)
+        newName = newName.split('-')[1].trim();
+      }
+      return {
+        ...item,
+        name: newName
+      };
+    });
+
     this.setData({
-      categories: sortedRecords
+      categories: processedRecords
     }, () => {
-      const type = Number(this.options.type) || 1;
+      const type = 1;
       this.data.categories.forEach((item, index) => {
         if (item.sort === type) {
           this.setData({

+ 1 - 1
subpackagestow/show/show.wxml

@@ -54,7 +54,7 @@
           <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 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' : item.type === 4 ? '图文' : 'Excel'}}</view>
             </view>
             <view class="item-content">
               <view class="item-title">{{item.name}}</view>

+ 17 - 3
subpackagestow/teaching/teaching.js

@@ -55,7 +55,7 @@ Page({
     const { data } = await models.tab.list({
       filter: {
         where: {
-          position: 2, // 显示位置
+          position: Number(this.options.type), // 显示位置
           // layout_type: 0, // 布局类型
         },
       },
@@ -67,10 +67,24 @@ Page({
     const sortedRecords = data.records.sort((a, b) => {
       return a.sort - b.sort; // 升序排列
     });
+
+    // 截取 name 中 "- " 后面的部分
+    const processedRecords = sortedRecords.map(item => {
+      let newName = item.name;
+      if (newName.includes('-')) {
+        // 按照 '-' 分割,并取第二段(去掉前后空格)
+        newName = newName.split('-')[1].trim();
+      }
+      return {
+        ...item,
+        name: newName
+      };
+    });
+
     this.setData({
-      categories: sortedRecords
+      categories: processedRecords
     }, () => {
-      const type = Number(this.options.type) || 1;
+      const type = 1;
       this.data.categories.forEach((item, index) => {
         if (item.sort === type) {
           this.setData({

+ 17 - 3
subpackagestow/training/training.js

@@ -55,7 +55,7 @@ Page({
     const { data } = await models.tab.list({
       filter: {
         where: {
-          position: 1, // 显示位置
+          position: Number(this.options.type), // 显示位置
           // layout_type: 0, // 布局类型
         },
       },
@@ -69,10 +69,24 @@ Page({
     const sortedRecords = data.records.sort((a, b) => {
       return a.sort - b.sort; // 升序排列
     });
+
+    // 截取 name 中 "- " 后面的部分
+    const processedRecords = sortedRecords.map(item => {
+      let newName = item.name;
+      if (newName.includes('-')) {
+        // 按照 '-' 分割,并取第二段(去掉前后空格)
+        newName = newName.split('-')[1].trim();
+      }
+      return {
+        ...item,
+        name: newName
+      };
+    });
+
     this.setData({
-      categories: sortedRecords
+      categories: processedRecords
     }, () => {
-      const type = Number(this.options.type) || 1;
+      const type = 1;
       this.data.categories.forEach((item, index) => {
         if (item.sort === type) {
           this.setData({