rules-for-sellbooks.vue 6.1 KB

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