rules-for-sellbooks.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view class="rules-page" v-if="!loading">
  3. <!-- 折叠面板 -->
  4. <view class="collapse-container">
  5. <u-collapse :accordion="true" @change="changeHandler">
  6. <u-collapse-item
  7. v-for="(item, index) in faqList"
  8. :key="index"
  9. :title="item.subTitle"
  10. :index="index"
  11. :arrow="true"
  12. :name="index"
  13. :class="{ 'active-item': selectedIndex == index }"
  14. >
  15. <template #title>
  16. <view class="custom-title">
  17. <view class="number-circle">{{ index + 1 }}</view>
  18. <text class="title-text">{{ item.subTitle }}</text>
  19. </view>
  20. </template>
  21. <view class="collapse-content">
  22. <u-parse :html="item.subContent" class="rich-text-style"></u-parse>
  23. <!-- <rich-text :nodes="item.subContent" class="rich-text-style"></rich-text> -->
  24. </view>
  25. </u-collapse-item>
  26. </u-collapse>
  27. </view>
  28. <!-- 空状态 -->
  29. <view v-if="faqList.length === 0" class="empty-state">
  30. <u-empty mode="data" text="暂无数据"></u-empty>
  31. </view>
  32. <!-- 客服按钮 -->
  33. <view class="customer-service">
  34. <button class="service-btn" open-type="contact">
  35. <view class="service-title">在线客服</view>
  36. <view class="service-time">需要帮助?联系在线客服,每日8:00-24:00在线</view>
  37. </button>
  38. </view>
  39. <!-- 加载中 -->
  40. <u-loading-page :loading="loading"></u-loading-page>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. pageTitle: "卖书规则",
  48. faqList: [], // FAQ列表数据
  49. loading: false,
  50. selectedIndex: -1,
  51. };
  52. },
  53. onLoad() {
  54. this.getFaqData();
  55. },
  56. methods: {
  57. // 获取FAQ数据
  58. getFaqData() {
  59. this.loading = true;
  60. this.$u.http
  61. .get("/token/getArticleTwo?code=faq")
  62. .then((res) => {
  63. if (res.code === 200) {
  64. // 根据接口返回的数据结构进行处理
  65. this.pageTitle = res.data.title || "卖书规则";
  66. // 根据接口返回的数据结构处理
  67. if (res.data.subArticleList && res.data.subArticleList.length > 0) {
  68. this.faqList = res.data.subArticleList;
  69. } else {
  70. this.faqList = [];
  71. }
  72. } else {
  73. this.$u.toast(res.msg || "获取数据失败");
  74. }
  75. })
  76. .catch((err) => {
  77. console.error("获取FAQ数据失败", err);
  78. this.$u.toast("获取数据失败");
  79. })
  80. .finally(() => {
  81. this.loading = false;
  82. });
  83. },
  84. // 折叠面板变化事件
  85. changeHandler(index) {
  86. console.log("当前打开的是第" + index + "个");
  87. this.selectedIndex = index;
  88. },
  89. },
  90. };
  91. </script>
  92. <style lang="scss" scoped>
  93. .rules-page {
  94. min-height: 100vh;
  95. background-color: #f5f5f5;
  96. padding: 20rpx 30rpx;
  97. padding-bottom: 120rpx;
  98. }
  99. .rules-container {
  100. padding: 30rpx;
  101. }
  102. .page-title {
  103. font-size: 36rpx;
  104. font-weight: bold;
  105. color: #333;
  106. margin-bottom: 30rpx;
  107. text-align: center;
  108. }
  109. .collapse-container {
  110. background-color: #f5f5f5;
  111. overflow: hidden;
  112. }
  113. .custom-title {
  114. display: flex;
  115. align-items: center;
  116. flex: 1;
  117. }
  118. .number-circle {
  119. width: 40rpx;
  120. height: 40rpx;
  121. border-radius: 50%;
  122. background-color: #38c148;
  123. color: white;
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. font-size: 28rpx;
  128. margin-right: 20rpx;
  129. flex-shrink: 0;
  130. }
  131. .title-text {
  132. font-size: 28rpx;
  133. color: #333;
  134. flex: 1;
  135. }
  136. .sub-content {
  137. font-size: 26rpx;
  138. color: #666;
  139. line-height: 1.6;
  140. }
  141. .empty-state {
  142. margin-top: 100rpx;
  143. }
  144. .customer-service {
  145. position: fixed;
  146. bottom: 0;
  147. left: 0;
  148. right: 0;
  149. padding: 24rpx;
  150. background-color: #fff;
  151. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  152. z-index: 10;
  153. padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
  154. }
  155. .service-btn {
  156. width: 100%;
  157. height: 90rpx;
  158. line-height: 32rpx;
  159. background-color: #4caf50;
  160. color: white;
  161. font-size: 36rpx;
  162. border-radius: 10rpx;
  163. text-align: center;
  164. margin-bottom: 15rpx;
  165. padding-top: 16rpx;
  166. }
  167. .service-time {
  168. font-size: 22rpx;
  169. color: #ffffff;
  170. text-align: center;
  171. }
  172. .collapse-content {
  173. color: #444444;
  174. font-size: 28rpx;
  175. padding: 10rpx 0;
  176. height: auto;
  177. overflow: visible;
  178. }
  179. .rich-text-style {
  180. width: 100%;
  181. }
  182. .rich-text-style img {
  183. max-width: 100%;
  184. height: auto !important;
  185. border-radius: 10rpx;
  186. margin-top: 10rpx;
  187. display: block;
  188. }
  189. /deep/ .u-collapse-item {
  190. margin-bottom: 20rpx;
  191. border-radius: 10rpx;
  192. overflow: visible;
  193. background-color: #ffffff;
  194. padding: 0 30rpx;
  195. }
  196. /deep/ .active-item .u-collapse-body {
  197. height: fit-content !important;
  198. }
  199. /* 添加rich-text内容样式 */
  200. /deep/ .rich-text-style {
  201. width: 100%;
  202. }
  203. </style>