rate-config.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="rate-config-container">
  3. <NavBar title="平台费率配置" @back="goBack" />
  4. <!-- 模板列表 -->
  5. <view class="config-list">
  6. <view
  7. v-for="item in rateList"
  8. :key="item.id"
  9. class="config-item"
  10. @click="navigateToEditConfig(item.id)"
  11. >
  12. <view class="config-info">
  13. <text class="config-name">{{ item.name }}</text>
  14. <text class="config-desc">平台费率: {{ (item.feeRate * 100).toFixed(2) }}% | 提现手续费: {{ (item.withdrawalFeeRate * 100).toFixed(2) }}%</text>
  15. </view>
  16. <view class="config-status">
  17. <text class="status-text active">ID: {{ item.id }}</text>
  18. <AppIcon name="chevron-right" size="18" color="#CCCCCC" />
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 空状态 -->
  23. <view class="empty-state" v-if="rateList.length === 0 && !loading">
  24. <view class="empty-icon-wrapper">
  25. <AppIcon name="dollar" size="48" color="#BFBFBF" />
  26. </view>
  27. <text class="empty-text">暂无价格模板</text>
  28. <text class="empty-desc">点击右上角添加模板</text>
  29. </view>
  30. <!-- 悬浮添加按钮 -->
  31. <view class="fab-add" @click="navigateToAddConfig">
  32. <AppIcon name="plus" size="28" color="#FFFFFF" />
  33. </view>
  34. <!-- 加载状态 -->
  35. <view class="loading-overlay" v-if="loading">
  36. <view class="loading-spinner"></view>
  37. <text class="loading-text">加载中...</text>
  38. </view>
  39. </view>
  40. </template>
  41. <script setup>
  42. import { ref, onMounted } from 'vue'
  43. import { getPlatformFeeRateList } from '../../api/rate.js'
  44. import { showToast } from '../../utils/index.js'
  45. const rateList = ref([])
  46. const loading = ref(false)
  47. // 加载费率模板列表
  48. const loadRateConfigs = async () => {
  49. loading.value = true
  50. try {
  51. const res = await getPlatformFeeRateList({
  52. page: 1,
  53. pageSize: 100
  54. })
  55. if (res && res.code === 200) {
  56. const data = res.data
  57. rateList.value = data.list || data.records || (Array.isArray(data) ? data : [])
  58. } else {
  59. showToast('获取费率模板失败')
  60. }
  61. } catch (error) {
  62. console.error('加载费率模板失败:', error)
  63. showToast('加载费率模板失败')
  64. } finally {
  65. loading.value = false
  66. }
  67. }
  68. // 导航到添加页面
  69. const navigateToAddConfig = () => {
  70. uni.navigateTo({
  71. url: '/pages/setting/rate-config-detail'
  72. })
  73. }
  74. // 导航到编辑页面
  75. const navigateToEditConfig = (id) => {
  76. uni.navigateTo({
  77. url: `/pages/setting/rate-config-detail?id=${id}`
  78. })
  79. }
  80. // 返回上一页
  81. const goBack = () => {
  82. uni.navigateBack()
  83. }
  84. onMounted(() => {
  85. loadRateConfigs()
  86. })
  87. </script>
  88. <style scoped>
  89. .rate-config-container {
  90. min-height: 100vh;
  91. background-color: #F5F7FA;
  92. padding-bottom: 180rpx;
  93. box-sizing: border-box;
  94. }
  95. /* 悬浮添加按钮 */
  96. .fab-add {
  97. position: fixed;
  98. left: 50%;
  99. transform: translateX(-50%);
  100. bottom: 60rpx;
  101. width: 110rpx;
  102. height: 110rpx;
  103. background: #C6171E;
  104. border-radius: 50%;
  105. display: flex;
  106. align-items: center;
  107. justify-content: center;
  108. box-shadow: 0 10rpx 30rpx rgba(198, 23, 30, 0.4);
  109. z-index: 99;
  110. transition: all 0.3s;
  111. }
  112. .fab-add:active {
  113. transform: translateX(-50%) scale(0.9);
  114. box-shadow: 0 4rpx 15rpx rgba(198, 23, 30, 0.3);
  115. }
  116. /* 列表 */
  117. .config-list {
  118. margin: 20rpx;
  119. background-color: #FFFFFF;
  120. border-radius: 16rpx;
  121. box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  122. }
  123. .config-item {
  124. display: flex;
  125. justify-content: space-between;
  126. align-items: center;
  127. padding: 24rpx 30rpx;
  128. border-bottom: 1rpx solid #F0F0F0;
  129. }
  130. .config-item:last-child {
  131. border-bottom: none;
  132. }
  133. .config-info {
  134. flex: 1;
  135. }
  136. .config-name {
  137. font-size: 30rpx;
  138. color: #1A1A1A;
  139. font-weight: 600;
  140. margin-bottom: 8rpx;
  141. display: block;
  142. }
  143. .config-desc {
  144. font-size: 24rpx;
  145. color: #999999;
  146. display: block;
  147. }
  148. .config-status {
  149. display: flex;
  150. align-items: center;
  151. }
  152. .status-text {
  153. font-size: 22rpx;
  154. color: #C6171E;
  155. background-color: rgba(198, 23, 30, 0.1);
  156. padding: 4rpx 12rpx;
  157. border-radius: 12rpx;
  158. margin-right: 12rpx;
  159. }
  160. .status-text.active {
  161. color: #52C41A;
  162. background-color: rgba(82, 196, 26, 0.1);
  163. }
  164. /* 空状态 */
  165. .empty-state {
  166. display: flex;
  167. flex-direction: column;
  168. align-items: center;
  169. justify-content: center;
  170. padding: 120rpx 0;
  171. color: #999999;
  172. }
  173. .empty-text {
  174. font-size: 28rpx;
  175. margin-bottom: 16rpx;
  176. }
  177. .empty-desc {
  178. font-size: 24rpx;
  179. }
  180. /* 加载状态 */
  181. .loading-overlay {
  182. position: fixed;
  183. top: 0;
  184. left: 0;
  185. right: 0;
  186. bottom: 0;
  187. background-color: rgba(0, 0, 0, 0.4);
  188. backdrop-filter: blur(2px);
  189. display: flex;
  190. flex-direction: column;
  191. align-items: center;
  192. justify-content: center;
  193. z-index: 999;
  194. }
  195. .loading-text {
  196. font-size: 28rpx;
  197. color: #fff;
  198. }
  199. </style>