rules-for-sellbooks.vue 5.0 KB

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