mp_objList.html 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width, initial-scale=1.0, user-scalable=no"
  8. />
  9. <title>列表</title>
  10. <!-- 引入基础依赖(统一由 base.js 动态注入其他依赖) -->
  11. <script src="/js/mp_base/base.js?v=20261126-auth-recovery-v1"></script>
  12. <style>
  13. #app {
  14. background: #f5f5f5;
  15. min-height: 100vh;
  16. }
  17. /* 防止Vue模板闪烁 */
  18. [v-cloak] {
  19. display: none !important;
  20. }
  21. /* 搜索筛选区域 */
  22. .search-filter-container {
  23. background: #f5f5f5;
  24. padding: 15px;
  25. position: sticky;
  26. top: 0;
  27. z-index: 100;
  28. display: flex;
  29. justify-content: flex-end;
  30. flex-wrap: wrap;
  31. gap: 10px;
  32. }
  33. .search-filter-container .ss-select-container {
  34. border: 1px solid #ccc;
  35. border-radius: 4px;
  36. padding: 0 10px;
  37. height: 34px;
  38. box-sizing: border-box;
  39. }
  40. /* 加载状态 */
  41. .loading-container {
  42. display: flex;
  43. flex-direction: column;
  44. align-items: center;
  45. justify-content: center;
  46. height: 200px;
  47. color: #666;
  48. }
  49. .loading-spinner {
  50. width: 40px;
  51. height: 40px;
  52. border: 4px solid #f3f3f3;
  53. border-top: 4px solid #40ac6d;
  54. border-radius: 50%;
  55. animation: spin 1s linear infinite;
  56. margin-bottom: 15px;
  57. }
  58. @keyframes spin {
  59. 0% {
  60. transform: rotate(0deg);
  61. }
  62. 100% {
  63. transform: rotate(360deg);
  64. }
  65. }
  66. .loading-text {
  67. font-size: 14px;
  68. }
  69. /* 列表容器 */
  70. .list-container {
  71. padding: 0 15px;
  72. }
  73. /* 空状态 */
  74. .empty-state {
  75. text-align: center;
  76. padding: 60px 20px;
  77. color: #999;
  78. }
  79. .empty-icon {
  80. font-size: 48px;
  81. margin-bottom: 15px;
  82. }
  83. .empty-text {
  84. font-size: 16px;
  85. }
  86. /* 卡片内容样式 - 按照小程序list.vue转换 */
  87. .card-content {
  88. display: flex;
  89. align-items: flex-start;
  90. gap: 12px;
  91. }
  92. .card-media {
  93. flex: 0 0 68px;
  94. }
  95. .card-avatar {
  96. width: 68px;
  97. height: 90px;
  98. display: block;
  99. object-fit: cover;
  100. border-radius: 8px;
  101. background: #eef2f3;
  102. }
  103. .card-body {
  104. min-width: 0;
  105. flex: 1;
  106. }
  107. .card-content .card-header {
  108. margin-bottom: 10px; /* 20rpx -> 10px */
  109. }
  110. .card-content .card-title {
  111. font-size: 16px; /* 32rpx -> 16px */
  112. font-weight: bold;
  113. color: #333;
  114. }
  115. .card-content .card-description {
  116. font-size: 14px; /* 28rpx -> 14px */
  117. color: #666;
  118. margin-bottom: 8px; /* 15rpx -> 8px */
  119. }
  120. .card-content .attribute-group {
  121. display: flex;
  122. flex-wrap: wrap;
  123. column-gap: 10px; /* 20rpx -> 10px */
  124. }
  125. .card-content .attribute-item {
  126. display: flex;
  127. margin-bottom: 5px; /* 10rpx -> 5px */
  128. }
  129. .card-content .attr-label {
  130. font-size: 13px; /* 26rpx -> 13px */
  131. color: #999;
  132. }
  133. .card-content .attr-value {
  134. font-size: 13px; /* 26rpx -> 13px */
  135. color: #333;
  136. flex: 1;
  137. }
  138. /* 状态文本样式 */
  139. .status-text {
  140. font-weight: bold;
  141. }
  142. /* 加载更多提示样式 */
  143. .load-more-container {
  144. text-align: center;
  145. padding: 20px;
  146. color: #999;
  147. font-size: 14px;
  148. }
  149. .load-more-loading {
  150. color: #007aff;
  151. }
  152. .load-more-end {
  153. color: #999;
  154. }
  155. .load-more-tip {
  156. color: #ccc;
  157. }
  158. /* 回到顶部按钮 */
  159. .back-to-top-btn {
  160. width: 50px;
  161. height: 50px;
  162. border-radius: 50%;
  163. background: rgba(87, 93, 109, 0.5);
  164. display: flex;
  165. justify-content: center;
  166. align-items: center;
  167. position: fixed;
  168. bottom: 200px;
  169. right: 15px;
  170. cursor: pointer;
  171. transition: all 0.3s ease;
  172. z-index: 999;
  173. }
  174. .back-to-top-btn:active {
  175. transform: scale(0.9);
  176. }
  177. .back-to-top-inner {
  178. width: 42px;
  179. height: 42px;
  180. border-radius: 50%;
  181. background: rgba(87, 93, 109, 0.5);
  182. display: flex;
  183. justify-content: center;
  184. align-items: center;
  185. }
  186. /* 搜索弹窗 */
  187. .search-modal-mask {
  188. position: fixed;
  189. top: 0;
  190. left: 0;
  191. right: 0;
  192. bottom: 0;
  193. background: rgba(0, 0, 0, 0.5);
  194. z-index: 1000;
  195. display: flex;
  196. align-items: flex-end;
  197. }
  198. .search-modal-content {
  199. width: 100%;
  200. background: white;
  201. animation: slideUp 0.3s ease-out;
  202. /* 让键盘弹起时自动上移 */
  203. position: relative;
  204. }
  205. @keyframes slideUp {
  206. from {
  207. transform: translateY(100%);
  208. }
  209. to {
  210. transform: translateY(0);
  211. }
  212. }
  213. .search-input-container {
  214. display: flex;
  215. align-items: center;
  216. height: 50px;
  217. background: white;
  218. border-top: 1px solid #e5e5e5;
  219. /* 适配iPhone底部安全区域 */
  220. /* padding-bottom: env(safe-area-inset-bottom); */
  221. }
  222. .search-input {
  223. flex: 1;
  224. height: 100%;
  225. border: none;
  226. padding: 0 15px;
  227. font-size: 16px;
  228. outline: none;
  229. background: transparent;
  230. }
  231. .search-divider {
  232. width: 1px;
  233. height: 30px;
  234. background: #d5d8dc;
  235. }
  236. .search-icon-btn {
  237. width: 60px;
  238. height: 100%;
  239. display: flex;
  240. align-items: center;
  241. justify-content: center;
  242. cursor: pointer;
  243. background: transparent;
  244. border: none;
  245. padding: 0;
  246. }
  247. .search-icon-btn:active {
  248. background: #f5f5f5;
  249. }
  250. </style>
  251. </head>
  252. <body>
  253. <div id="app" v-cloak>
  254. <!-- 搜索和筛选区域 -->
  255. <div class="search-filter-container">
  256. <!-- 动态下拉选择器 -->
  257. <template
  258. v-for="(options, fieldName) in filterSelectOptions"
  259. :key="fieldName"
  260. >
  261. <ss-select
  262. v-model="selectedFilters[fieldName]"
  263. :placeholder="`选择${getFieldDesc(fieldName)}`"
  264. :options="options"
  265. width="132px"
  266. inp="true"
  267. @change="handleFilterChange"
  268. >
  269. </ss-select>
  270. </template>
  271. <!-- 完全由buttonList决定的动态按钮组 -->
  272. <ss-search-button
  273. v-for="(button, index) in buttonList"
  274. :key="index"
  275. :text="getButtonText(button)"
  276. :options="getButtonOptions(button)"
  277. :suffix-icon="getButtonOptions(button).length > 1 ? 'icon-xiala' : ''"
  278. @click="handleButtonClick(button)"
  279. >
  280. </ss-search-button>
  281. </div>
  282. <!-- 加载状态 -->
  283. <div v-if="loading" class="loading-container">
  284. <div class="loading-spinner"></div>
  285. <div class="loading-text">加载中...</div>
  286. </div>
  287. <!-- 列表区域 -->
  288. <div v-else class="list-container">
  289. <!-- 空状态 -->
  290. <div v-if="list.length === 0" class="empty-state">
  291. <div class="empty-text">暂无数据</div>
  292. </div>
  293. <!-- 数据列表 -->
  294. <div v-else>
  295. <ss-card
  296. v-for="(item, index) in list"
  297. :key="index"
  298. :item="item"
  299. @click="handleCardClick(item)"
  300. @button-click="handleCardAction"
  301. >
  302. <!-- 卡片内容 - 按照小程序list.vue的结构,使用API数据 -->
  303. <div class="card-content">
  304. <div v-if="item.thumbPath" class="card-media">
  305. <img
  306. class="card-avatar"
  307. :src="item.thumbUrl"
  308. :alt="item.firstDisplay || '头像'"
  309. @error="handleThumbError"
  310. />
  311. </div>
  312. <div class="card-body">
  313. <!-- 主标题 (first) -->
  314. <div class="card-header" v-if="item.firstDisplay">
  315. <div class="card-title">{{ item.firstDisplay }}</div>
  316. </div>
  317. <!-- 描述 (second) -->
  318. <div class="card-description" v-if="item.secondDisplay">
  319. {{ item.secondDisplay }}
  320. </div>
  321. <!-- 属性列表 (third) -->
  322. <div
  323. class="card-attributes"
  324. v-if="item.thirdDisplay && item.thirdDisplay.length > 0"
  325. >
  326. <div
  327. v-for="(group, groupIndex) in item.thirdDisplay"
  328. :key="groupIndex"
  329. class="attribute-group"
  330. >
  331. <div
  332. v-for="(attr, attrIndex) in group"
  333. :key="attrIndex"
  334. class="attribute-item"
  335. >
  336. <span class="attr-label">{{ attr.field.desc }}:</span>
  337. <span class="attr-value">{{ attr.displayValue }}</span>
  338. </div>
  339. </div>
  340. </div>
  341. </div>
  342. </div>
  343. </ss-card>
  344. </div>
  345. </div>
  346. <!-- 加载更多提示 -->
  347. <div class="load-more-container" v-if="list.length > 0">
  348. <div v-if="isLoadingMore" class="load-more-loading">
  349. <span>正在加载更多...</span>
  350. </div>
  351. <div v-else-if="!hasMore" class="load-more-end">
  352. <span>没有更多数据了</span>
  353. </div>
  354. <div v-else class="load-more-tip">
  355. <span>滚动到底部加载更多</span>
  356. </div>
  357. </div>
  358. <!-- 回到顶部按钮 -->
  359. <div
  360. v-if="showBackToTop"
  361. class="back-to-top-btn"
  362. @touchstart="handleLongPressStart"
  363. @touchend="handleLongPressEnd"
  364. @touchcancel="handleLongPressCancel"
  365. @click.prevent="handleBackToTopClick"
  366. >
  367. <div class="back-to-top-inner">
  368. <Icon name="icon-huidaodingbu" size="40" color="#fff"></Icon>
  369. </div>
  370. </div>
  371. <!-- 搜索弹窗 -->
  372. <div
  373. v-if="showSearchModal"
  374. class="search-modal-mask"
  375. @click="closeSearchModal"
  376. >
  377. <div class="search-modal-content" @click.stop>
  378. <div class="search-input-container">
  379. <input
  380. ref="searchInput"
  381. v-model="searchKeyword"
  382. type="search"
  383. inputmode="search"
  384. class="search-input"
  385. placeholder="请输入关键词"
  386. @keyup.enter="performSearch"
  387. autocomplete="off"
  388. />
  389. <div class="search-divider"></div>
  390. <button class="search-icon-btn" @click="performSearch">
  391. <Icon name="icon-chazhao" size="24" color="#575d6d"></Icon>
  392. </button>
  393. </div>
  394. </div>
  395. </div>
  396. </div>
  397. <script>
  398. // 等待SS框架加载完成
  399. window.SS.ready(function () {
  400. // 使用SS框架的方式创建Vue实例
  401. window.SS.dom.initializeFormApp({
  402. el: "#app",
  403. data() {
  404. return {
  405. // 加载状态
  406. loading: true,
  407. // 列表数据
  408. list: [],
  409. originalList: [], // 原始数据,用于筛选
  410. // 分页相关
  411. currentPage: 1,
  412. pageSize: 10,
  413. hasMore: true,
  414. isLoadingMore: false,
  415. // 页面参数
  416. pageParams: {},
  417. service: "", // init服务名称
  418. // 功能说明:对接PC两段式接口(init 返回 home/list 服务名) by xu 2026-02-28
  419. ssSearchPobjHomeServName: "",
  420. ssSearchPobjListServName: "",
  421. // API返回的动态配置
  422. buttonList: [],
  423. fieldsList: [],
  424. ssPaging: null,
  425. // 动态搜索筛选选项
  426. filterOptions: [],
  427. sortOptions: [],
  428. // 下拉选择器数据
  429. selectedFilters: {}, // 动态筛选条件
  430. filterSelectOptions: {}, // 各个筛选字段的选项
  431. // 字典缓存
  432. dictCache: new Map(),
  433. // 显示字段配置 - 根据service动态设置
  434. displayFields: [],
  435. // 卡片操作按钮
  436. cardActions: [
  437. { text: "查看", name: "view" },
  438. { text: "编辑", name: "edit" },
  439. ],
  440. // 回到顶部按钮
  441. showBackToTop: false,
  442. // 是否存在关键词搜索
  443. hasKeyWord: false,
  444. // 搜索相关
  445. showSearchModal: false,
  446. searchKeyword: "",
  447. // 长按相关
  448. longPressTimer: null,
  449. isLongPress: false,
  450. };
  451. },
  452. mounted() {
  453. // 页面加载时初始化
  454. this.initPage();
  455. // 监听页面刷新通知
  456. this.setupRefreshListener();
  457. // 监听滚动事件,实现滚动加载
  458. this.setupScrollListener();
  459. // 开发模式:加载Mock数据(测试用)
  460. // this.loadMockData();
  461. },
  462. beforeUnmount() {
  463. // 清理刷新监听器
  464. if (this.refreshCleanup) {
  465. this.refreshCleanup();
  466. }
  467. // 清理滚动监听器
  468. if (this.scrollCleanup) {
  469. this.scrollCleanup();
  470. }
  471. },
  472. methods: {
  473. // 加载Mock数据(用于开发测试)
  474. loadMockData() {
  475. console.log("🎭 加载Mock数据...");
  476. const mockData = [
  477. {
  478. firstDisplay: "张三 - 2024级计算机科学与技术1班",
  479. secondDisplay: "学号:2024001 | 手机:138****1234",
  480. thirdDisplay: [
  481. [
  482. { field: { desc: "性别" }, displayValue: "男" },
  483. { field: { desc: "年龄" }, displayValue: "20" },
  484. { field: { desc: "状态" }, displayValue: "在读" },
  485. ],
  486. [
  487. {
  488. field: { desc: "入学时间" },
  489. displayValue: "2024-09-01",
  490. },
  491. { field: { desc: "辅导员" }, displayValue: "王老师" },
  492. ],
  493. ],
  494. },
  495. {
  496. firstDisplay: "李四 - 2024级软件工程2班",
  497. secondDisplay: "学号:2024002 | 手机:139****5678",
  498. thirdDisplay: [
  499. [
  500. { field: { desc: "性别" }, displayValue: "女" },
  501. { field: { desc: "年龄" }, displayValue: "19" },
  502. { field: { desc: "状态" }, displayValue: "在读" },
  503. ],
  504. [
  505. {
  506. field: { desc: "入学时间" },
  507. displayValue: "2024-09-01",
  508. },
  509. { field: { desc: "辅导员" }, displayValue: "李老师" },
  510. ],
  511. ],
  512. },
  513. {
  514. firstDisplay: "王五 - 2023级人工智能1班",
  515. secondDisplay: "学号:2023003 | 手机:136****9012",
  516. thirdDisplay: [
  517. [
  518. { field: { desc: "性别" }, displayValue: "男" },
  519. { field: { desc: "年龄" }, displayValue: "21" },
  520. { field: { desc: "状态" }, displayValue: "在读" },
  521. ],
  522. [
  523. {
  524. field: { desc: "入学时间" },
  525. displayValue: "2023-09-01",
  526. },
  527. { field: { desc: "辅导员" }, displayValue: "赵老师" },
  528. ],
  529. ],
  530. },
  531. {
  532. firstDisplay: "赵六 - 2024级数据科学与大数据技术1班",
  533. secondDisplay: "学号:2024004 | 手机:137****3456",
  534. thirdDisplay: [
  535. [
  536. { field: { desc: "性别" }, displayValue: "女" },
  537. { field: { desc: "年龄" }, displayValue: "20" },
  538. { field: { desc: "状态" }, displayValue: "在读" },
  539. ],
  540. [
  541. {
  542. field: { desc: "入学时间" },
  543. displayValue: "2024-09-01",
  544. },
  545. { field: { desc: "辅导员" }, displayValue: "刘老师" },
  546. ],
  547. ],
  548. },
  549. {
  550. firstDisplay: "钱七 - 2023级网络工程1班",
  551. secondDisplay: "学号:2023005 | 手机:135****7890",
  552. thirdDisplay: [
  553. [
  554. { field: { desc: "性别" }, displayValue: "男" },
  555. { field: { desc: "年龄" }, displayValue: "21" },
  556. { field: { desc: "状态" }, displayValue: "休学" },
  557. ],
  558. [
  559. {
  560. field: { desc: "入学时间" },
  561. displayValue: "2023-09-01",
  562. },
  563. { field: { desc: "辅导员" }, displayValue: "周老师" },
  564. ],
  565. ],
  566. },
  567. {
  568. firstDisplay: "孙八 - 2024级信息安全1班",
  569. secondDisplay: "学号:2024006 | 手机:133****2468",
  570. thirdDisplay: [
  571. [
  572. { field: { desc: "性别" }, displayValue: "女" },
  573. { field: { desc: "年龄" }, displayValue: "19" },
  574. { field: { desc: "状态" }, displayValue: "在读" },
  575. ],
  576. [
  577. {
  578. field: { desc: "入学时间" },
  579. displayValue: "2024-09-01",
  580. },
  581. { field: { desc: "辅导员" }, displayValue: "吴老师" },
  582. ],
  583. ],
  584. },
  585. {
  586. firstDisplay: "周九 - 2023级物联网工程1班",
  587. secondDisplay: "学号:2023007 | 手机:188****1357",
  588. thirdDisplay: [
  589. [
  590. { field: { desc: "性别" }, displayValue: "男" },
  591. { field: { desc: "年龄" }, displayValue: "22" },
  592. { field: { desc: "状态" }, displayValue: "在读" },
  593. ],
  594. [
  595. {
  596. field: { desc: "入学时间" },
  597. displayValue: "2023-09-01",
  598. },
  599. { field: { desc: "辅导员" }, displayValue: "郑老师" },
  600. ],
  601. ],
  602. },
  603. {
  604. firstDisplay: "吴十 - 2024级云计算1班",
  605. secondDisplay: "学号:2024008 | 手机:189****2468",
  606. thirdDisplay: [
  607. [
  608. { field: { desc: "性别" }, displayValue: "女" },
  609. { field: { desc: "年龄" }, displayValue: "20" },
  610. { field: { desc: "状态" }, displayValue: "在读" },
  611. ],
  612. [
  613. {
  614. field: { desc: "入学时间" },
  615. displayValue: "2024-09-01",
  616. },
  617. { field: { desc: "辅导员" }, displayValue: "冯老师" },
  618. ],
  619. ],
  620. },
  621. {
  622. firstDisplay: "郑十一 - 2023级区块链工程1班",
  623. secondDisplay: "学号:2023009 | 手机:180****3691",
  624. thirdDisplay: [
  625. [
  626. { field: { desc: "性别" }, displayValue: "男" },
  627. { field: { desc: "年龄" }, displayValue: "21" },
  628. { field: { desc: "状态" }, displayValue: "在读" },
  629. ],
  630. [
  631. {
  632. field: { desc: "入学时间" },
  633. displayValue: "2023-09-01",
  634. },
  635. { field: { desc: "辅导员" }, displayValue: "陈老师" },
  636. ],
  637. ],
  638. },
  639. {
  640. firstDisplay: "王十二 - 2024级电子商务1班",
  641. secondDisplay: "学号:2024010 | 手机:181****4802",
  642. thirdDisplay: [
  643. [
  644. { field: { desc: "性别" }, displayValue: "女" },
  645. { field: { desc: "年龄" }, displayValue: "19" },
  646. { field: { desc: "状态" }, displayValue: "在读" },
  647. ],
  648. [
  649. {
  650. field: { desc: "入学时间" },
  651. displayValue: "2024-09-01",
  652. },
  653. { field: { desc: "辅导员" }, displayValue: "褚老师" },
  654. ],
  655. ],
  656. },
  657. {
  658. firstDisplay: "陈十三 - 2023级金融科技1班",
  659. secondDisplay: "学号:2023011 | 手机:182****5913",
  660. thirdDisplay: [
  661. [
  662. { field: { desc: "性别" }, displayValue: "男" },
  663. { field: { desc: "年龄" }, displayValue: "22" },
  664. { field: { desc: "状态" }, displayValue: "毕业" },
  665. ],
  666. [
  667. {
  668. field: { desc: "入学时间" },
  669. displayValue: "2023-09-01",
  670. },
  671. { field: { desc: "辅导员" }, displayValue: "卫老师" },
  672. ],
  673. ],
  674. },
  675. {
  676. firstDisplay: "刘十四 - 2024级数字媒体技术1班",
  677. secondDisplay: "学号:2024012 | 手机:183****6024",
  678. thirdDisplay: [
  679. [
  680. { field: { desc: "性别" }, displayValue: "女" },
  681. { field: { desc: "年龄" }, displayValue: "20" },
  682. { field: { desc: "状态" }, displayValue: "在读" },
  683. ],
  684. [
  685. {
  686. field: { desc: "入学时间" },
  687. displayValue: "2024-09-01",
  688. },
  689. { field: { desc: "辅导员" }, displayValue: "蒋老师" },
  690. ],
  691. ],
  692. },
  693. ];
  694. // 设置数据
  695. this.list = mockData;
  696. this.originalList = [...mockData];
  697. this.loading = false;
  698. this.hasMore = false;
  699. console.log("✅ Mock数据加载完成,共", mockData.length, "条");
  700. },
  701. // 初始化页面
  702. async initPage() {
  703. try {
  704. console.log("🔄 初始化列表页面...");
  705. // 获取URL参数
  706. this.pageParams = this.getUrlParams();
  707. this.service = this.pageParams.service || "default";
  708. console.log("📋 页面参数:", this.pageParams);
  709. if (typeof window.ensureMiniProgramSessionFresh === "function") {
  710. try {
  711. await window.ensureMiniProgramSessionFresh({
  712. page: "mp_objList",
  713. service: this.service,
  714. force: this.isBzrXyService(this.service),
  715. });
  716. } catch (authError) {
  717. console.error("❌ H5会话刷新失败,停止加载列表:", authError);
  718. const message =
  719. "当前登录状态已过期,请重新登录后再进入学员列表。";
  720. if (typeof showToastEffect !== "undefined") {
  721. showToastEffect(message, 3000, "error");
  722. } else {
  723. this.showToast(message, "error");
  724. }
  725. return;
  726. }
  727. }
  728. // 功能说明:先调 init,再按 init 返回的 home/list 服务继续拉取数据 by xu 2026-02-28
  729. await this.loadInitAndHomeData();
  730. } catch (error) {
  731. console.log("❌ 页面初始化失败:", error);
  732. // this.showToast('页面初始化失败', 'error');
  733. } finally {
  734. this.loading = false;
  735. }
  736. },
  737. // 功能说明:调用 init 接口并解析 ssSearchPobjHomeServName/ssSearchPobjListServName by xu 2026-02-28
  738. async loadInitAndHomeData() {
  739. const initService = (this.service || "").trim();
  740. if (!initService) {
  741. await this.loadData(1, false);
  742. return;
  743. }
  744. const managementValue =
  745. this.resolveListManagementValue(initService);
  746. const initParams = {
  747. pageNo: 1,
  748. rowNumPer: this.pageSize,
  749. management: managementValue,
  750. isReady: "1",
  751. };
  752. const initResult = await request.post(
  753. `/service?ssServ=${initService}&management=${managementValue}&isReady=1`,
  754. initParams,
  755. {
  756. loading: false,
  757. formData: true,
  758. }
  759. );
  760. const initPayload = this.unwrapResponseData(
  761. this.extractResponseData(initResult)
  762. );
  763. this.ssSearchPobjHomeServName = String(
  764. initPayload?.ssSearchPobjHomeServName || ""
  765. ).trim();
  766. this.ssSearchPobjListServName = String(
  767. initPayload?.ssSearchPobjListServName || ""
  768. ).trim();
  769. if (
  770. !this.ssSearchPobjHomeServName &&
  771. !this.ssSearchPobjListServName
  772. ) {
  773. const derivedServices =
  774. this.deriveSearchServiceNames(initService);
  775. this.ssSearchPobjHomeServName = derivedServices.homeService;
  776. this.ssSearchPobjListServName = derivedServices.listService;
  777. }
  778. console.log("✅ init返回服务名:", {
  779. initService,
  780. ssSearchPobjHomeServName: this.ssSearchPobjHomeServName,
  781. ssSearchPobjListServName: this.ssSearchPobjListServName,
  782. });
  783. if (this.hasListPayload(initPayload)) {
  784. console.log("ℹ️ init接口直接返回列表数据,按列表结果处理");
  785. await this.processApiData(initPayload, false, initService);
  786. return;
  787. }
  788. const homeService = this.ssSearchPobjHomeServName || initService;
  789. await this.loadDataByService(homeService, 1, false);
  790. },
  791. // 功能说明:统一处理 /service 返回结构(兼容 {ssData} 与平铺结构) by xu 2026-02-28
  792. unwrapResponseData(data) {
  793. if (!data || typeof data !== "object") {
  794. return {};
  795. }
  796. const visited = new Set();
  797. let current = data;
  798. while (
  799. current &&
  800. typeof current === "object" &&
  801. !visited.has(current)
  802. ) {
  803. visited.add(current);
  804. if (current.ssData && typeof current.ssData === "object") {
  805. return current.ssData;
  806. }
  807. if (
  808. current.data &&
  809. typeof current.data === "object" &&
  810. current.data !== current
  811. ) {
  812. current = current.data;
  813. continue;
  814. }
  815. if (
  816. current.result &&
  817. typeof current.result === "object" &&
  818. !Array.isArray(current.result) &&
  819. current.result !== current
  820. ) {
  821. current = current.result;
  822. continue;
  823. }
  824. return current;
  825. }
  826. return {};
  827. },
  828. extractResponseData(result) {
  829. if (
  830. result &&
  831. typeof result === "object" &&
  832. Object.prototype.hasOwnProperty.call(result, "data")
  833. ) {
  834. return result.data;
  835. }
  836. return result;
  837. },
  838. hasListPayload(payload) {
  839. if (!payload || typeof payload !== "object") {
  840. return false;
  841. }
  842. return (
  843. Array.isArray(payload.objectList) ||
  844. Array.isArray(payload.objList) ||
  845. Array.isArray(payload.draftList)
  846. );
  847. },
  848. deriveSearchServiceNames(initService) {
  849. const normalized = String(initService || "").trim();
  850. if (!/_cx$/.test(normalized)) {
  851. return {
  852. homeService: "",
  853. listService: "",
  854. };
  855. }
  856. return {
  857. homeService: normalized.replace(/_cx$/, "_cxsy"),
  858. listService: normalized.replace(/_cx$/, "_cxlb"),
  859. };
  860. },
  861. // 功能说明:封装按指定 ssServ 拉取列表数据(home/list 共用) by xu 2026-02-28
  862. async loadDataByService(ssServ, pageNo = 1, isLoadMore = false) {
  863. const serviceName = String(ssServ || "").trim();
  864. if (!serviceName) {
  865. console.warn("⚠️ 缺少服务名,跳过请求");
  866. return;
  867. }
  868. // 防止重复加载:只有在非首次加载且正在加载时才阻止
  869. if (this.loading && !isLoadMore && this.list.length > 0) return;
  870. if (this.isLoadingMore && isLoadMore) return;
  871. try {
  872. console.log(
  873. `🔄 加载列表数据... 服务: ${serviceName}, 页码: ${pageNo}, 加载更多: ${isLoadMore}`
  874. );
  875. if (isLoadMore) {
  876. this.isLoadingMore = true;
  877. } else {
  878. this.loading = true;
  879. }
  880. const managementValue =
  881. this.resolveListManagementValue(serviceName);
  882. const requestParams = {
  883. pageNo: pageNo,
  884. rowNumPer: this.pageSize,
  885. management: managementValue,
  886. isReady: "1",
  887. // 功能说明:请求参数只保留有效筛选项(避免空值/旧值污染查询) by xu 2026-02-28
  888. ...this.getActiveFilterParams(this.selectedFilters),
  889. };
  890. const result = await request.post(
  891. `/service?ssServ=${serviceName}&management=${managementValue}&isReady=1`,
  892. requestParams,
  893. {
  894. loading: false,
  895. formData: true,
  896. }
  897. );
  898. console.log("✅ API响应数据:", result);
  899. const responseData = this.extractResponseData(result);
  900. if (responseData !== undefined && responseData !== null) {
  901. await this.processApiData(
  902. responseData,
  903. isLoadMore,
  904. serviceName
  905. );
  906. } else {
  907. console.warn("⚠️ API返回数据格式异常:", result);
  908. }
  909. } catch (error) {
  910. console.error("❌ 数据加载失败:", error);
  911. } finally {
  912. if (isLoadMore) {
  913. this.isLoadingMore = false;
  914. } else {
  915. this.loading = false;
  916. }
  917. }
  918. },
  919. // 加载数据
  920. async loadData(pageNo = 1, isLoadMore = false) {
  921. // 功能说明:翻页/筛选/搜索统一走 list 服务;未返回时回退 home/init by xu 2026-02-28
  922. const listService =
  923. this.ssSearchPobjListServName ||
  924. this.ssSearchPobjHomeServName ||
  925. this.service;
  926. await this.loadDataByService(listService, pageNo, isLoadMore);
  927. },
  928. // 处理API返回的数据
  929. async processApiData(
  930. data,
  931. isLoadMore = false,
  932. serviceName = ""
  933. ) {
  934. try {
  935. const payload = this.unwrapResponseData(data);
  936. const objectList = Array.isArray(payload.objectList)
  937. ? payload.objectList
  938. : Array.isArray(payload.objList)
  939. ? payload.objList
  940. : [];
  941. const draftList = Array.isArray(payload.draftList)
  942. ? payload.draftList
  943. : [];
  944. const combinedObjectList = draftList.concat(objectList);
  945. console.log("🔄 处理API数据...", {
  946. isLoadMore,
  947. objectListLength: combinedObjectList.length,
  948. fromObjList: Array.isArray(payload.objList),
  949. });
  950. // 保存API返回的配置信息
  951. if (!isLoadMore) {
  952. // 功能说明:列表接口通常不返回按钮/搜索字段,缺省时保留首屏(home)已加载配置,避免筛选后按钮消失 by xu 2026-02-28
  953. if (
  954. Array.isArray(payload.buttonList) ||
  955. Array.isArray(payload.rootFuncList)
  956. ) {
  957. this.buttonList =
  958. payload.buttonList || payload.rootFuncList || [];
  959. }
  960. if (
  961. Array.isArray(payload.fieldsList) ||
  962. Array.isArray(payload.searchFieldList)
  963. ) {
  964. this.fieldsList =
  965. payload.fieldsList || payload.searchFieldList || [];
  966. }
  967. }
  968. // ssPaging信息每次都要更新,因为包含当前页信息
  969. this.ssPaging = payload.ssPaging || this.ssPaging || null;
  970. // 功能说明:list接口未返回 hasKeyword 时沿用首屏值,避免长按搜索入口被错误隐藏 by xu 2026-02-28
  971. if (
  972. Object.prototype.hasOwnProperty.call(payload, "hasKeyWord") ||
  973. Object.prototype.hasOwnProperty.call(payload, "hasKeyword")
  974. ) {
  975. this.hasKeyWord =
  976. payload.hasKeyWord || payload.hasKeyword || false;
  977. }
  978. // 处理objectList数据
  979. if (combinedObjectList.length > 0) {
  980. // 使用field-formatter.js格式化列表数据
  981. const formattedList = await window.formatObjectList(
  982. combinedObjectList,
  983. this.dictCache
  984. );
  985. // 功能说明:把后端 chg/chgRootFuncList 映射成卡片左滑操作按钮,标题取 desc,供 ss-card 左滑动作区使用 by xu 2026-03-06
  986. const enhancedList = formattedList.map((item, index) => {
  987. const rawItem = combinedObjectList[index] || {};
  988. const rawActions =
  989. Array.isArray(rawItem.chgRootFuncList) &&
  990. rawItem.chgRootFuncList.length > 0
  991. ? rawItem.chgRootFuncList
  992. : rawItem.chg
  993. ? [rawItem.chg]
  994. : [];
  995. const thumbPath =
  996. item.thumbPath ||
  997. window.pickObjectThumbPath?.(rawItem) ||
  998. "";
  999. const studentNoDisplay =
  1000. this.formatBzrXyStudentNoDisplay(
  1001. item,
  1002. rawItem,
  1003. serviceName
  1004. );
  1005. return {
  1006. ...item,
  1007. ...(studentNoDisplay
  1008. ? { secondDisplay: studentNoDisplay }
  1009. : {}),
  1010. ssObjId:
  1011. item.ssObjId ||
  1012. rawItem.ssObjId ||
  1013. rawItem.serviceParamData?.ssObjId ||
  1014. rawItem.play?.param_value ||
  1015. rawItem.ryid ||
  1016. rawItem.dxid ||
  1017. rawItem.id ||
  1018. "",
  1019. ssObjName:
  1020. item.ssObjName ||
  1021. rawItem.ssObjName ||
  1022. rawItem.dxm ||
  1023. "",
  1024. thumbPath,
  1025. thumbUrl: thumbPath
  1026. ? item.thumbUrl ||
  1027. window.resolveListImageUrl?.(thumbPath) ||
  1028. thumbPath
  1029. : "",
  1030. swipeActions: rawActions.map((action) => ({
  1031. ...action,
  1032. title: action.desc || action.title || "操作",
  1033. })),
  1034. };
  1035. });
  1036. const finalList = await this.enrichBzrXyThumbs(
  1037. enhancedList,
  1038. serviceName
  1039. );
  1040. if (isLoadMore) {
  1041. // 加载更多:追加到现有列表
  1042. this.list = [...this.list, ...finalList];
  1043. this.originalList = [...this.originalList, ...finalList];
  1044. } else {
  1045. // 首次加载或刷新:替换列表
  1046. this.originalList = finalList;
  1047. this.list = [...this.originalList];
  1048. }
  1049. console.log("✅ 列表数据处理完成:", this.list.length, "条");
  1050. // 更新分页状态
  1051. this.currentPage = isLoadMore ? this.currentPage + 1 : 1;
  1052. // 根据ssPaging信息判断是否还有更多数据
  1053. if (this.ssPaging && this.ssPaging.rowNum !== undefined) {
  1054. const totalRecords = this.ssPaging.rowNum;
  1055. const currentRecords = this.list.length;
  1056. this.hasMore = currentRecords < totalRecords;
  1057. console.log("📊 分页信息:", {
  1058. totalRecords,
  1059. currentRecords,
  1060. hasMore: this.hasMore,
  1061. currentPage: this.currentPage,
  1062. });
  1063. } else {
  1064. // 降级处理:根据当前页数据量判断
  1065. this.hasMore = formattedList.length >= this.pageSize;
  1066. console.log("⚠️ 使用降级分页判断:", {
  1067. returnedCount: formattedList.length,
  1068. pageSize: this.pageSize,
  1069. hasMore: this.hasMore,
  1070. });
  1071. }
  1072. } else {
  1073. // 没有更多数据
  1074. this.hasMore = false;
  1075. console.log("❌ 没有返回数据,设置hasMore为false");
  1076. }
  1077. // 根据fieldsList生成筛选选项(只在首次加载时生成)
  1078. if (!isLoadMore) {
  1079. await this.generateFilterOptions();
  1080. }
  1081. } catch (error) {
  1082. console.error("❌ 数据处理失败:", error);
  1083. throw error;
  1084. }
  1085. },
  1086. // 获取URL参数
  1087. getUrlParams() {
  1088. const params = {};
  1089. const urlSearchParams = new URLSearchParams(
  1090. window.location.search
  1091. );
  1092. for (const [key, value] of urlSearchParams) {
  1093. params[key] = decodeURIComponent(value);
  1094. }
  1095. return params;
  1096. },
  1097. isBzrXyService(serviceName) {
  1098. const candidateList = [
  1099. serviceName,
  1100. this.service,
  1101. this.pageParams?.service,
  1102. this.pageParams?.ssServ,
  1103. this.ssSearchPobjHomeServName,
  1104. this.ssSearchPobjListServName,
  1105. ];
  1106. return candidateList.some((candidate) =>
  1107. /^bzrXy(?:_|$)/.test(String(candidate || "").trim())
  1108. );
  1109. },
  1110. isSchoolRecordService(serviceName) {
  1111. const candidateList = [
  1112. serviceName,
  1113. this.service,
  1114. this.pageParams?.service,
  1115. this.pageParams?.ssServ,
  1116. this.ssSearchPobjHomeServName,
  1117. this.ssSearchPobjListServName,
  1118. ];
  1119. return candidateList.some((candidate) =>
  1120. /^(?:fjyrjc|xx(?:wj|hj)jl)(?:_|$)/.test(String(candidate || "").trim())
  1121. );
  1122. },
  1123. resolveListManagementValue(serviceName) {
  1124. return this.isBzrXyService(serviceName || this.service) ||
  1125. this.isSchoolRecordService(serviceName || this.service)
  1126. ? "99"
  1127. : "1";
  1128. },
  1129. formatBzrXyStudentNoDisplay(item, rawItem, serviceName) {
  1130. if (!this.isBzrXyService(serviceName || this.service)) {
  1131. return "";
  1132. }
  1133. const fieldName = String(
  1134. item?.second?.field?.name ||
  1135. rawItem?.second?.field?.name ||
  1136. ""
  1137. ).trim();
  1138. if (fieldName !== "ryh") {
  1139. return "";
  1140. }
  1141. const rawValue =
  1142. item?.secondDisplay ??
  1143. item?.second?.value ??
  1144. rawItem?.second?.value ??
  1145. rawItem?.ryh ??
  1146. "";
  1147. const studentNo = String(rawValue).trim();
  1148. if (!studentNo) {
  1149. return "";
  1150. }
  1151. if (/^学号[::]/.test(studentNo)) {
  1152. return studentNo;
  1153. }
  1154. return `学号:${studentNo}`;
  1155. },
  1156. async enrichBzrXyThumbs(list, serviceName) {
  1157. if (!Array.isArray(list) || list.length === 0) {
  1158. return list;
  1159. }
  1160. if (!this.isBzrXyService(serviceName || this.service)) {
  1161. return list;
  1162. }
  1163. const missingIds = list
  1164. .filter(
  1165. (item) =>
  1166. item &&
  1167. !item.thumbPath &&
  1168. item.ssObjId !== undefined &&
  1169. item.ssObjId !== null &&
  1170. String(item.ssObjId).trim() !== ""
  1171. )
  1172. .map((item) => String(item.ssObjId).trim());
  1173. if (missingIds.length === 0) {
  1174. return list;
  1175. }
  1176. try {
  1177. const managementValue =
  1178. this.resolveListManagementValue(serviceName);
  1179. const result = await request.post(
  1180. `/service?ssServ=bzrXy_selThumbMap&management=${managementValue}&isReady=1`,
  1181. {
  1182. ryids: [...new Set(missingIds)].join(","),
  1183. management: managementValue,
  1184. isReady: "1",
  1185. },
  1186. {
  1187. loading: false,
  1188. formData: true,
  1189. }
  1190. );
  1191. const thumbMap = this.unwrapResponseData(result?.data);
  1192. if (!thumbMap || typeof thumbMap !== "object") {
  1193. return list;
  1194. }
  1195. return list.map((item) => {
  1196. const ryid = String(item?.ssObjId || "").trim();
  1197. const thumbPath =
  1198. ryid && Object.prototype.hasOwnProperty.call(thumbMap, ryid)
  1199. ? String(thumbMap[ryid] || "").trim()
  1200. : "";
  1201. if (!thumbPath || item.thumbPath) {
  1202. return item;
  1203. }
  1204. return {
  1205. ...item,
  1206. thumbPath,
  1207. thumbUrl:
  1208. window.resolveListImageUrl?.(thumbPath) || thumbPath,
  1209. };
  1210. });
  1211. } catch (error) {
  1212. console.warn("⚠️ bzrXy 头像补取失败:", error);
  1213. return list;
  1214. }
  1215. },
  1216. // 处理buttonList按钮点击
  1217. handleButtonClick(button) {
  1218. console.log("🔘 按钮点击:", button);
  1219. if (this.hasButtonOptions(button)) {
  1220. return;
  1221. }
  1222. NavigationManager.goToFromButton(button);
  1223. },
  1224. // 跳转到目标页面
  1225. navigateToPage(button, destPage) {
  1226. const urlParams = new URLSearchParams(window.location.search);
  1227. // 添加按钮相关参数
  1228. if (button.function) {
  1229. urlParams.set("dest", destPage);
  1230. urlParams.set(
  1231. "title",
  1232. encodeURIComponent(button.function.desc || button.buttonName)
  1233. );
  1234. urlParams.set(
  1235. "service",
  1236. button.function.servName || button.service || ""
  1237. );
  1238. } else {
  1239. urlParams.set("dest", destPage);
  1240. urlParams.set("title", encodeURIComponent(button.buttonName));
  1241. urlParams.set("service", button.service || "");
  1242. }
  1243. const newUrl = `${destPage}.html?${urlParams.toString()}`;
  1244. console.log("� 跳转到:", newUrl);
  1245. window.location.href = newUrl;
  1246. },
  1247. // 根据fieldsList生成筛选选项
  1248. async generateFilterOptions() {
  1249. if (!this.fieldsList || this.fieldsList.length === 0) {
  1250. return;
  1251. }
  1252. for (const field of this.fieldsList) {
  1253. // 如果字段有cbName,生成下拉选项
  1254. if (field.cbName) {
  1255. try {
  1256. const options = await window.getDictOptions(
  1257. field.cbName,
  1258. this.dictCache
  1259. );
  1260. this.filterSelectOptions[field.name] = [
  1261. { n: "", v: "" },
  1262. ...options,
  1263. ];
  1264. } catch (error) {
  1265. console.error("获取筛选选项失败:", field.cbName, error);
  1266. }
  1267. }
  1268. }
  1269. console.log("🔽 生成筛选选项:", this.filterSelectOptions);
  1270. },
  1271. // 功能说明:统一处理卡片服务跳转,页面文件名按后端 dest 自动补 mp_,但传给业务页/后端的 dest 仍保持原始值 by xu 2026-03-06
  1272. openServicePage(action, item = {}) {
  1273. const target =
  1274. action && typeof action === "object" ? action : null;
  1275. if (!target) {
  1276. this.showToast("当前记录缺少操作配置", "warning");
  1277. return;
  1278. }
  1279. const serviceName = String(
  1280. target.servName || target.ssServ || ""
  1281. ).trim();
  1282. const rawDest = String(target.dest || "").trim();
  1283. const normalizedDest =
  1284. rawDest && rawDest.startsWith("mp_")
  1285. ? rawDest
  1286. : rawDest
  1287. ? `mp_${rawDest}`
  1288. : "";
  1289. const paramName = String(target.param_name || "").trim();
  1290. const paramValue = target.param_value;
  1291. const ssToken = String(target.ssToken || "").trim();
  1292. const paramText =
  1293. typeof target.parm === "string" ? target.parm : "";
  1294. if (!serviceName) {
  1295. this.showToast("缺少服务名", "warning");
  1296. return;
  1297. }
  1298. if (!normalizedDest) {
  1299. this.showToast("缺少目标页面", "warning");
  1300. return;
  1301. }
  1302. const managementValue =
  1303. this.resolveListManagementValue(serviceName);
  1304. NavigationManager.goTo(normalizedDest, {
  1305. title: target.desc || target.title || "处理",
  1306. service: serviceName,
  1307. dest: rawDest,
  1308. ssDest: rawDest,
  1309. param: paramText,
  1310. playParamName: paramName,
  1311. playParamValue: paramValue,
  1312. ssToken: ssToken,
  1313. ssObjId: item.ssObjId || "",
  1314. ssObjName: item.ssObjName || "",
  1315. management: managementValue,
  1316. [paramName || "param_value"]: paramValue,
  1317. });
  1318. },
  1319. // 卡片点击 - SsCard组件会自动传递item数据
  1320. handleCardClick(item) {
  1321. console.log("📄 卡片点击事件触发", item);
  1322. // 功能说明:卡片点击统一按 play 参数跳转到通用查看页 mp_objplay(兼容 play / service.play 两种结构) by xu 2026-03-04
  1323. const play =
  1324. (item && (item.play || (item.service && item.service.play))) ||
  1325. null;
  1326. this.openServicePage(play, item);
  1327. },
  1328. // 卡片操作 - SsCard组件的按钮点击事件
  1329. handleCardAction({ button, item, index }) {
  1330. console.log("⚡ 卡片操作:", button, item);
  1331. // 功能说明:左滑操作按钮按服务配置跳转(如 chg=变动),不再弹 Toast 占位 by xu 2026-03-06
  1332. this.openServicePage(button, item);
  1333. },
  1334. handleThumbError(event) {
  1335. const fallback =
  1336. window.resolveListImageUrl?.("") ||
  1337. "skin/easy/image/default-personalPhoto.png";
  1338. if (!event?.target) return;
  1339. if (event.target.dataset.fallbackApplied === "1") return;
  1340. event.target.dataset.fallbackApplied = "1";
  1341. event.target.src = fallback;
  1342. },
  1343. // 加载更多数据
  1344. async loadMore() {
  1345. if (!this.hasMore || this.isLoadingMore) {
  1346. console.log("🚫 无法加载更多:", {
  1347. hasMore: this.hasMore,
  1348. isLoadingMore: this.isLoadingMore,
  1349. });
  1350. return;
  1351. }
  1352. console.log("📄 加载更多数据...");
  1353. await this.loadData(this.currentPage + 1, true);
  1354. },
  1355. // 刷新数据
  1356. async refreshData() {
  1357. console.log("🔄 刷新数据...");
  1358. // 重置分页状态
  1359. this.currentPage = 1;
  1360. this.hasMore = true;
  1361. this.list = [];
  1362. this.originalList = [];
  1363. try {
  1364. await this.loadData(1, false);
  1365. this.showToast("刷新成功", "success");
  1366. } catch (error) {
  1367. this.showToast("刷新失败", "error");
  1368. }
  1369. },
  1370. // 获取字段描述
  1371. getFieldDesc(fieldName) {
  1372. const field = this.fieldsList.find((f) => f.name === fieldName);
  1373. return field ? field.desc : fieldName;
  1374. },
  1375. // 功能说明:统一按钮文案映射(兼容 rootFuncList/buttonList 不同字段) by xu 2026-02-28
  1376. getButtonText(button) {
  1377. if (!button || typeof button !== "object") return "";
  1378. return (
  1379. button.desc ||
  1380. button.title ||
  1381. button.buttonName ||
  1382. button.name ||
  1383. ""
  1384. );
  1385. },
  1386. getButtonOptions(button) {
  1387. if (!button || typeof button !== "object") return [];
  1388. const source =
  1389. Array.isArray(button.pluginList) && button.pluginList.length
  1390. ? button.pluginList
  1391. : Array.isArray(button.pageList)
  1392. ? button.pageList
  1393. : [];
  1394. return this.createNavOptions(source);
  1395. },
  1396. createNavOptions(buttonList) {
  1397. if (!Array.isArray(buttonList)) return [];
  1398. return buttonList
  1399. .filter((item) => item && typeof item === "object")
  1400. .map((item) => ({
  1401. text: this.getButtonText(item),
  1402. onclick: () => NavigationManager.goToFromButton(item),
  1403. }))
  1404. .filter((item) => item.text || item.onclick);
  1405. },
  1406. hasButtonOptions(button) {
  1407. return this.getButtonOptions(button).length > 0;
  1408. },
  1409. // 功能说明:提取有效筛选参数(过滤空串/null/undefined) by xu 2026-02-28
  1410. getActiveFilterParams(source) {
  1411. const params = {};
  1412. const obj = source && typeof source === "object" ? source : {};
  1413. Object.entries(obj).forEach(([key, value]) => {
  1414. if (value === "" || value === null || value === undefined)
  1415. return;
  1416. params[key] = value;
  1417. });
  1418. return params;
  1419. },
  1420. // 筛选选择器变化(立即搜索)
  1421. handleFilterChange(value) {
  1422. console.log("🔽 筛选条件变化,立即搜索:", value);
  1423. // 立即执行搜索
  1424. this.applyDynamicFilters();
  1425. },
  1426. // 应用动态筛选(重新调用API)
  1427. async applyDynamicFilters() {
  1428. try {
  1429. console.log("🔍 应用筛选条件:", this.selectedFilters);
  1430. // 功能说明:筛选参数先归一化,清理已取消的筛选条件 by xu 2026-02-28
  1431. const filterParams = this.getActiveFilterParams(
  1432. this.selectedFilters
  1433. );
  1434. // 功能说明:筛选后重置分页并走 list 服务 by xu 2026-02-28
  1435. this.currentPage = 1;
  1436. this.hasMore = true;
  1437. this.list = [];
  1438. this.originalList = [];
  1439. this.selectedFilters = { ...filterParams };
  1440. await this.loadData(1, false);
  1441. } catch (error) {
  1442. console.error("❌ 筛选失败:", error);
  1443. this.showToast("筛选失败", "error");
  1444. }
  1445. },
  1446. // 生成项目按钮
  1447. generateItemButtons(service) {
  1448. if (!service || !service.play) return [];
  1449. return [
  1450. {
  1451. title: service.play.name || "查看",
  1452. icon: "icon-chakan",
  1453. onclick: () => {
  1454. console.log("点击查看按钮:", service.play);
  1455. // 这里可以跳转到详情页面
  1456. this.showToast(`查看: ${service.play.title}`, "info");
  1457. },
  1458. },
  1459. ];
  1460. },
  1461. // 设置页面刷新监听
  1462. setupRefreshListener() {
  1463. // 监听子页面返回时的刷新通知
  1464. this.refreshCleanup = NavigationManager.onRefreshNotify(
  1465. (refreshData) => {
  1466. console.log("📢 收到刷新通知,重新加载数据");
  1467. this.refreshData();
  1468. }
  1469. );
  1470. },
  1471. // 设置滚动监听
  1472. setupScrollListener() {
  1473. let isThrottled = false;
  1474. const handleScroll = () => {
  1475. if (isThrottled) return;
  1476. isThrottled = true;
  1477. setTimeout(() => {
  1478. isThrottled = false;
  1479. }, 200); // 节流200ms
  1480. // 检查是否滚动到底部
  1481. const scrollTop =
  1482. window.pageYOffset || document.documentElement.scrollTop;
  1483. const windowHeight = window.innerHeight;
  1484. const documentHeight = document.documentElement.scrollHeight;
  1485. // 控制回到顶部按钮显示:滚动超过300px时显示
  1486. this.showBackToTop = scrollTop > 300;
  1487. // 距离底部50px时触发加载更多
  1488. if (scrollTop + windowHeight >= documentHeight - 50) {
  1489. console.log("📄 滚动到底部,尝试加载更多...");
  1490. this.loadMore();
  1491. }
  1492. };
  1493. // 添加滚动监听
  1494. window.addEventListener("scroll", handleScroll);
  1495. // 保存清理函数
  1496. this.scrollCleanup = () => {
  1497. window.removeEventListener("scroll", handleScroll);
  1498. };
  1499. },
  1500. // 返回顶部
  1501. scrollToTop() {
  1502. window.scrollTo({
  1503. top: 0,
  1504. behavior: "smooth",
  1505. });
  1506. },
  1507. // 处理回到顶部按钮点击
  1508. handleBackToTopClick() {
  1509. // 如果不是长按触发的搜索,则执行返回顶部
  1510. if (!this.isLongPress) {
  1511. this.scrollToTop();
  1512. }
  1513. // 重置长按标志
  1514. this.isLongPress = false;
  1515. },
  1516. // 长按开始
  1517. handleLongPressStart(event) {
  1518. if (this.hasKeyWord) {
  1519. // 有输入关键字才显示,否则不处理长按
  1520. this.isLongPress = false;
  1521. // 设置长按定时器(500ms)
  1522. this.longPressTimer = setTimeout(() => {
  1523. this.isLongPress = true;
  1524. this.openSearchModal();
  1525. // 震动反馈(如果支持)
  1526. if (navigator.vibrate) {
  1527. navigator.vibrate(50);
  1528. }
  1529. }, 500);
  1530. }
  1531. },
  1532. // 长按结束
  1533. handleLongPressEnd(event) {
  1534. // 清除长按定时器
  1535. if (this.longPressTimer) {
  1536. clearTimeout(this.longPressTimer);
  1537. this.longPressTimer = null;
  1538. }
  1539. },
  1540. // 长按取消(手指移出按钮区域)
  1541. handleLongPressCancel(event) {
  1542. // 清除长按定时器
  1543. if (this.longPressTimer) {
  1544. clearTimeout(this.longPressTimer);
  1545. this.longPressTimer = null;
  1546. }
  1547. this.isLongPress = false;
  1548. },
  1549. // 打开搜索弹窗
  1550. openSearchModal() {
  1551. this.showSearchModal = true;
  1552. this.searchKeyword = "";
  1553. // 延迟聚焦输入框,确保DOM已渲染和动画完成
  1554. this.$nextTick(() => {
  1555. // 使用 setTimeout 确保在移动端也能正常触发键盘
  1556. setTimeout(() => {
  1557. if (this.$refs.searchInput) {
  1558. // 先点击再聚焦,确保移动端键盘弹出
  1559. this.$refs.searchInput.click();
  1560. this.$refs.searchInput.focus();
  1561. console.log("✅ 输入框已聚焦");
  1562. }
  1563. }, 100); // 等待动画完成后再聚焦
  1564. });
  1565. },
  1566. // 关闭搜索弹窗
  1567. closeSearchModal() {
  1568. this.showSearchModal = false;
  1569. this.searchKeyword = "";
  1570. },
  1571. // 执行搜索
  1572. async performSearch() {
  1573. const keyword = this.searchKeyword.trim();
  1574. // 无关键词时,直接关闭弹窗,什么都不做
  1575. if (!keyword) {
  1576. // this.closeSearchModal();
  1577. return;
  1578. }
  1579. console.log("🔍 执行关键词搜索:", keyword);
  1580. // 关闭搜索弹窗
  1581. this.closeSearchModal();
  1582. // 设置 keyword 到筛选条件中
  1583. this.selectedFilters.ssKeyword = keyword;
  1584. // 调用 API 搜索
  1585. await this.applyDynamicFilters();
  1586. },
  1587. // 显示提示
  1588. showToast(message, type = "info") {
  1589. console.log(`${type.toUpperCase()}: ${message}`);
  1590. // 使用浏览器原生alert,后续可以替换为更好的提示组件
  1591. alert(message);
  1592. },
  1593. },
  1594. });
  1595. });
  1596. </script>
  1597. </body>
  1598. </html>