mp_objList.html 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772
  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=20260823-session-switch3"></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. resolveListManagementValue(serviceName) {
  1111. return this.isBzrXyService(serviceName || this.service)
  1112. ? "99"
  1113. : "1";
  1114. },
  1115. formatBzrXyStudentNoDisplay(item, rawItem, serviceName) {
  1116. if (!this.isBzrXyService(serviceName || this.service)) {
  1117. return "";
  1118. }
  1119. const fieldName = String(
  1120. item?.second?.field?.name ||
  1121. rawItem?.second?.field?.name ||
  1122. ""
  1123. ).trim();
  1124. if (fieldName !== "ryh") {
  1125. return "";
  1126. }
  1127. const rawValue =
  1128. item?.secondDisplay ??
  1129. item?.second?.value ??
  1130. rawItem?.second?.value ??
  1131. rawItem?.ryh ??
  1132. "";
  1133. const studentNo = String(rawValue).trim();
  1134. if (!studentNo) {
  1135. return "";
  1136. }
  1137. if (/^学号[::]/.test(studentNo)) {
  1138. return studentNo;
  1139. }
  1140. return `学号:${studentNo}`;
  1141. },
  1142. async enrichBzrXyThumbs(list, serviceName) {
  1143. if (!Array.isArray(list) || list.length === 0) {
  1144. return list;
  1145. }
  1146. if (!this.isBzrXyService(serviceName || this.service)) {
  1147. return list;
  1148. }
  1149. const missingIds = list
  1150. .filter(
  1151. (item) =>
  1152. item &&
  1153. !item.thumbPath &&
  1154. item.ssObjId !== undefined &&
  1155. item.ssObjId !== null &&
  1156. String(item.ssObjId).trim() !== ""
  1157. )
  1158. .map((item) => String(item.ssObjId).trim());
  1159. if (missingIds.length === 0) {
  1160. return list;
  1161. }
  1162. try {
  1163. const managementValue =
  1164. this.resolveListManagementValue(serviceName);
  1165. const result = await request.post(
  1166. `/service?ssServ=bzrXy_selThumbMap&management=${managementValue}&isReady=1`,
  1167. {
  1168. ryids: [...new Set(missingIds)].join(","),
  1169. management: managementValue,
  1170. isReady: "1",
  1171. },
  1172. {
  1173. loading: false,
  1174. formData: true,
  1175. }
  1176. );
  1177. const thumbMap = this.unwrapResponseData(result?.data);
  1178. if (!thumbMap || typeof thumbMap !== "object") {
  1179. return list;
  1180. }
  1181. return list.map((item) => {
  1182. const ryid = String(item?.ssObjId || "").trim();
  1183. const thumbPath =
  1184. ryid && Object.prototype.hasOwnProperty.call(thumbMap, ryid)
  1185. ? String(thumbMap[ryid] || "").trim()
  1186. : "";
  1187. if (!thumbPath || item.thumbPath) {
  1188. return item;
  1189. }
  1190. return {
  1191. ...item,
  1192. thumbPath,
  1193. thumbUrl:
  1194. window.resolveListImageUrl?.(thumbPath) || thumbPath,
  1195. };
  1196. });
  1197. } catch (error) {
  1198. console.warn("⚠️ bzrXy 头像补取失败:", error);
  1199. return list;
  1200. }
  1201. },
  1202. // 处理buttonList按钮点击
  1203. handleButtonClick(button) {
  1204. console.log("🔘 按钮点击:", button);
  1205. if (this.hasButtonOptions(button)) {
  1206. return;
  1207. }
  1208. NavigationManager.goToFromButton(button);
  1209. },
  1210. // 跳转到目标页面
  1211. navigateToPage(button, destPage) {
  1212. const urlParams = new URLSearchParams(window.location.search);
  1213. // 添加按钮相关参数
  1214. if (button.function) {
  1215. urlParams.set("dest", destPage);
  1216. urlParams.set(
  1217. "title",
  1218. encodeURIComponent(button.function.desc || button.buttonName)
  1219. );
  1220. urlParams.set(
  1221. "service",
  1222. button.function.servName || button.service || ""
  1223. );
  1224. } else {
  1225. urlParams.set("dest", destPage);
  1226. urlParams.set("title", encodeURIComponent(button.buttonName));
  1227. urlParams.set("service", button.service || "");
  1228. }
  1229. const newUrl = `${destPage}.html?${urlParams.toString()}`;
  1230. console.log("� 跳转到:", newUrl);
  1231. window.location.href = newUrl;
  1232. },
  1233. // 根据fieldsList生成筛选选项
  1234. async generateFilterOptions() {
  1235. if (!this.fieldsList || this.fieldsList.length === 0) {
  1236. return;
  1237. }
  1238. for (const field of this.fieldsList) {
  1239. // 如果字段有cbName,生成下拉选项
  1240. if (field.cbName) {
  1241. try {
  1242. const options = await window.getDictOptions(
  1243. field.cbName,
  1244. this.dictCache
  1245. );
  1246. this.filterSelectOptions[field.name] = [
  1247. { n: "", v: "" },
  1248. ...options,
  1249. ];
  1250. } catch (error) {
  1251. console.error("获取筛选选项失败:", field.cbName, error);
  1252. }
  1253. }
  1254. }
  1255. console.log("🔽 生成筛选选项:", this.filterSelectOptions);
  1256. },
  1257. // 功能说明:统一处理卡片服务跳转,页面文件名按后端 dest 自动补 mp_,但传给业务页/后端的 dest 仍保持原始值 by xu 2026-03-06
  1258. openServicePage(action, item = {}) {
  1259. const target =
  1260. action && typeof action === "object" ? action : null;
  1261. if (!target) {
  1262. this.showToast("当前记录缺少操作配置", "warning");
  1263. return;
  1264. }
  1265. const serviceName = String(
  1266. target.servName || target.ssServ || ""
  1267. ).trim();
  1268. const rawDest = String(target.dest || "").trim();
  1269. const normalizedDest =
  1270. rawDest && rawDest.startsWith("mp_")
  1271. ? rawDest
  1272. : rawDest
  1273. ? `mp_${rawDest}`
  1274. : "";
  1275. const paramName = String(target.param_name || "").trim();
  1276. const paramValue = target.param_value;
  1277. const ssToken = String(target.ssToken || "").trim();
  1278. const paramText =
  1279. typeof target.parm === "string" ? target.parm : "";
  1280. if (!serviceName) {
  1281. this.showToast("缺少服务名", "warning");
  1282. return;
  1283. }
  1284. if (!normalizedDest) {
  1285. this.showToast("缺少目标页面", "warning");
  1286. return;
  1287. }
  1288. const managementValue =
  1289. this.resolveListManagementValue(serviceName);
  1290. NavigationManager.goTo(normalizedDest, {
  1291. title: target.desc || target.title || "处理",
  1292. service: serviceName,
  1293. dest: rawDest,
  1294. ssDest: rawDest,
  1295. param: paramText,
  1296. playParamName: paramName,
  1297. playParamValue: paramValue,
  1298. ssToken: ssToken,
  1299. ssObjId: item.ssObjId || "",
  1300. ssObjName: item.ssObjName || "",
  1301. management: managementValue,
  1302. [paramName || "param_value"]: paramValue,
  1303. });
  1304. },
  1305. // 卡片点击 - SsCard组件会自动传递item数据
  1306. handleCardClick(item) {
  1307. console.log("📄 卡片点击事件触发", item);
  1308. // 功能说明:卡片点击统一按 play 参数跳转到通用查看页 mp_objplay(兼容 play / service.play 两种结构) by xu 2026-03-04
  1309. const play =
  1310. (item && (item.play || (item.service && item.service.play))) ||
  1311. null;
  1312. this.openServicePage(play, item);
  1313. },
  1314. // 卡片操作 - SsCard组件的按钮点击事件
  1315. handleCardAction({ button, item, index }) {
  1316. console.log("⚡ 卡片操作:", button, item);
  1317. // 功能说明:左滑操作按钮按服务配置跳转(如 chg=变动),不再弹 Toast 占位 by xu 2026-03-06
  1318. this.openServicePage(button, item);
  1319. },
  1320. handleThumbError(event) {
  1321. const fallback =
  1322. window.resolveListImageUrl?.("") ||
  1323. "skin/easy/image/default-personalPhoto.png";
  1324. if (!event?.target) return;
  1325. if (event.target.dataset.fallbackApplied === "1") return;
  1326. event.target.dataset.fallbackApplied = "1";
  1327. event.target.src = fallback;
  1328. },
  1329. // 加载更多数据
  1330. async loadMore() {
  1331. if (!this.hasMore || this.isLoadingMore) {
  1332. console.log("🚫 无法加载更多:", {
  1333. hasMore: this.hasMore,
  1334. isLoadingMore: this.isLoadingMore,
  1335. });
  1336. return;
  1337. }
  1338. console.log("📄 加载更多数据...");
  1339. await this.loadData(this.currentPage + 1, true);
  1340. },
  1341. // 刷新数据
  1342. async refreshData() {
  1343. console.log("🔄 刷新数据...");
  1344. // 重置分页状态
  1345. this.currentPage = 1;
  1346. this.hasMore = true;
  1347. this.list = [];
  1348. this.originalList = [];
  1349. try {
  1350. await this.loadData(1, false);
  1351. this.showToast("刷新成功", "success");
  1352. } catch (error) {
  1353. this.showToast("刷新失败", "error");
  1354. }
  1355. },
  1356. // 获取字段描述
  1357. getFieldDesc(fieldName) {
  1358. const field = this.fieldsList.find((f) => f.name === fieldName);
  1359. return field ? field.desc : fieldName;
  1360. },
  1361. // 功能说明:统一按钮文案映射(兼容 rootFuncList/buttonList 不同字段) by xu 2026-02-28
  1362. getButtonText(button) {
  1363. if (!button || typeof button !== "object") return "";
  1364. return (
  1365. button.desc ||
  1366. button.title ||
  1367. button.buttonName ||
  1368. button.name ||
  1369. ""
  1370. );
  1371. },
  1372. getButtonOptions(button) {
  1373. if (!button || typeof button !== "object") return [];
  1374. const source =
  1375. Array.isArray(button.pluginList) && button.pluginList.length
  1376. ? button.pluginList
  1377. : Array.isArray(button.pageList)
  1378. ? button.pageList
  1379. : [];
  1380. return this.createNavOptions(source);
  1381. },
  1382. createNavOptions(buttonList) {
  1383. if (!Array.isArray(buttonList)) return [];
  1384. return buttonList
  1385. .filter((item) => item && typeof item === "object")
  1386. .map((item) => ({
  1387. text: this.getButtonText(item),
  1388. onclick: () => NavigationManager.goToFromButton(item),
  1389. }))
  1390. .filter((item) => item.text || item.onclick);
  1391. },
  1392. hasButtonOptions(button) {
  1393. return this.getButtonOptions(button).length > 0;
  1394. },
  1395. // 功能说明:提取有效筛选参数(过滤空串/null/undefined) by xu 2026-02-28
  1396. getActiveFilterParams(source) {
  1397. const params = {};
  1398. const obj = source && typeof source === "object" ? source : {};
  1399. Object.entries(obj).forEach(([key, value]) => {
  1400. if (value === "" || value === null || value === undefined)
  1401. return;
  1402. params[key] = value;
  1403. });
  1404. return params;
  1405. },
  1406. // 筛选选择器变化(立即搜索)
  1407. handleFilterChange(value) {
  1408. console.log("🔽 筛选条件变化,立即搜索:", value);
  1409. // 立即执行搜索
  1410. this.applyDynamicFilters();
  1411. },
  1412. // 应用动态筛选(重新调用API)
  1413. async applyDynamicFilters() {
  1414. try {
  1415. console.log("🔍 应用筛选条件:", this.selectedFilters);
  1416. // 功能说明:筛选参数先归一化,清理已取消的筛选条件 by xu 2026-02-28
  1417. const filterParams = this.getActiveFilterParams(
  1418. this.selectedFilters
  1419. );
  1420. // 功能说明:筛选后重置分页并走 list 服务 by xu 2026-02-28
  1421. this.currentPage = 1;
  1422. this.hasMore = true;
  1423. this.list = [];
  1424. this.originalList = [];
  1425. this.selectedFilters = { ...filterParams };
  1426. await this.loadData(1, false);
  1427. } catch (error) {
  1428. console.error("❌ 筛选失败:", error);
  1429. this.showToast("筛选失败", "error");
  1430. }
  1431. },
  1432. // 生成项目按钮
  1433. generateItemButtons(service) {
  1434. if (!service || !service.play) return [];
  1435. return [
  1436. {
  1437. title: service.play.name || "查看",
  1438. icon: "icon-chakan",
  1439. onclick: () => {
  1440. console.log("点击查看按钮:", service.play);
  1441. // 这里可以跳转到详情页面
  1442. this.showToast(`查看: ${service.play.title}`, "info");
  1443. },
  1444. },
  1445. ];
  1446. },
  1447. // 设置页面刷新监听
  1448. setupRefreshListener() {
  1449. // 监听子页面返回时的刷新通知
  1450. this.refreshCleanup = NavigationManager.onRefreshNotify(
  1451. (refreshData) => {
  1452. console.log("📢 收到刷新通知,重新加载数据");
  1453. this.refreshData();
  1454. }
  1455. );
  1456. },
  1457. // 设置滚动监听
  1458. setupScrollListener() {
  1459. let isThrottled = false;
  1460. const handleScroll = () => {
  1461. if (isThrottled) return;
  1462. isThrottled = true;
  1463. setTimeout(() => {
  1464. isThrottled = false;
  1465. }, 200); // 节流200ms
  1466. // 检查是否滚动到底部
  1467. const scrollTop =
  1468. window.pageYOffset || document.documentElement.scrollTop;
  1469. const windowHeight = window.innerHeight;
  1470. const documentHeight = document.documentElement.scrollHeight;
  1471. // 控制回到顶部按钮显示:滚动超过300px时显示
  1472. this.showBackToTop = scrollTop > 300;
  1473. // 距离底部50px时触发加载更多
  1474. if (scrollTop + windowHeight >= documentHeight - 50) {
  1475. console.log("📄 滚动到底部,尝试加载更多...");
  1476. this.loadMore();
  1477. }
  1478. };
  1479. // 添加滚动监听
  1480. window.addEventListener("scroll", handleScroll);
  1481. // 保存清理函数
  1482. this.scrollCleanup = () => {
  1483. window.removeEventListener("scroll", handleScroll);
  1484. };
  1485. },
  1486. // 返回顶部
  1487. scrollToTop() {
  1488. window.scrollTo({
  1489. top: 0,
  1490. behavior: "smooth",
  1491. });
  1492. },
  1493. // 处理回到顶部按钮点击
  1494. handleBackToTopClick() {
  1495. // 如果不是长按触发的搜索,则执行返回顶部
  1496. if (!this.isLongPress) {
  1497. this.scrollToTop();
  1498. }
  1499. // 重置长按标志
  1500. this.isLongPress = false;
  1501. },
  1502. // 长按开始
  1503. handleLongPressStart(event) {
  1504. if (this.hasKeyWord) {
  1505. // 有输入关键字才显示,否则不处理长按
  1506. this.isLongPress = false;
  1507. // 设置长按定时器(500ms)
  1508. this.longPressTimer = setTimeout(() => {
  1509. this.isLongPress = true;
  1510. this.openSearchModal();
  1511. // 震动反馈(如果支持)
  1512. if (navigator.vibrate) {
  1513. navigator.vibrate(50);
  1514. }
  1515. }, 500);
  1516. }
  1517. },
  1518. // 长按结束
  1519. handleLongPressEnd(event) {
  1520. // 清除长按定时器
  1521. if (this.longPressTimer) {
  1522. clearTimeout(this.longPressTimer);
  1523. this.longPressTimer = null;
  1524. }
  1525. },
  1526. // 长按取消(手指移出按钮区域)
  1527. handleLongPressCancel(event) {
  1528. // 清除长按定时器
  1529. if (this.longPressTimer) {
  1530. clearTimeout(this.longPressTimer);
  1531. this.longPressTimer = null;
  1532. }
  1533. this.isLongPress = false;
  1534. },
  1535. // 打开搜索弹窗
  1536. openSearchModal() {
  1537. this.showSearchModal = true;
  1538. this.searchKeyword = "";
  1539. // 延迟聚焦输入框,确保DOM已渲染和动画完成
  1540. this.$nextTick(() => {
  1541. // 使用 setTimeout 确保在移动端也能正常触发键盘
  1542. setTimeout(() => {
  1543. if (this.$refs.searchInput) {
  1544. // 先点击再聚焦,确保移动端键盘弹出
  1545. this.$refs.searchInput.click();
  1546. this.$refs.searchInput.focus();
  1547. console.log("✅ 输入框已聚焦");
  1548. }
  1549. }, 100); // 等待动画完成后再聚焦
  1550. });
  1551. },
  1552. // 关闭搜索弹窗
  1553. closeSearchModal() {
  1554. this.showSearchModal = false;
  1555. this.searchKeyword = "";
  1556. },
  1557. // 执行搜索
  1558. async performSearch() {
  1559. const keyword = this.searchKeyword.trim();
  1560. // 无关键词时,直接关闭弹窗,什么都不做
  1561. if (!keyword) {
  1562. // this.closeSearchModal();
  1563. return;
  1564. }
  1565. console.log("🔍 执行关键词搜索:", keyword);
  1566. // 关闭搜索弹窗
  1567. this.closeSearchModal();
  1568. // 设置 keyword 到筛选条件中
  1569. this.selectedFilters.ssKeyword = keyword;
  1570. // 调用 API 搜索
  1571. await this.applyDynamicFilters();
  1572. },
  1573. // 显示提示
  1574. showToast(message, type = "info") {
  1575. console.log(`${type.toUpperCase()}: ${message}`);
  1576. // 使用浏览器原生alert,后续可以替换为更好的提示组件
  1577. alert(message);
  1578. },
  1579. },
  1580. });
  1581. });
  1582. </script>
  1583. </body>
  1584. </html>