trade_list.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="records-page">
  3. <view class="tab-header">
  4. <view
  5. v-for="(tab, index) in tabs"
  6. :key="index"
  7. :class="['tab-item', { 'is-active': activeTab === tab.id }]"
  8. @click="changeTab(tab.id)"
  9. >
  10. {{ tab.name }}
  11. </view>
  12. </view>
  13. <z-paging
  14. ref="paging"
  15. v-model="dataList"
  16. @query="queryList"
  17. :use-page-scroll="true"
  18. :show-refresher-update-time="true"
  19. :empty-view-text="emptyText"
  20. :refresher-enabled="true"
  21. :loading-text-no-more="loadingNoMoreText"
  22. :hide-loading-more-when-no-more-by-default="true"
  23. >
  24. <view
  25. v-for="(item, index) in dataList"
  26. :key="index"
  27. class="record-item-wrapper"
  28. >
  29. <view class="record-item">
  30. <view class="item-left">
  31. <view class="top">
  32. <text class="item-title">{{ metalTypeMap[metalType] || '黄金' }}</text>
  33. <view
  34. :class="[
  35. 'status-tag',
  36. item.status === '待审核' ? 'status-pending' : 'status-live',
  37. ]"
  38. >
  39. {{ statusMap[item.status] }}
  40. </view>
  41. </view>
  42. <view class="time">
  43. <text class="item-time">{{ item.createTime }}</text>
  44. </view>
  45. </view>
  46. <view class="item-right">
  47. <text class="item-weight">{{ item.weight }}</text>
  48. </view>
  49. </view>
  50. </view>
  51. </z-paging>
  52. </view>
  53. </template>
  54. <script setup>
  55. import { ref, onMounted, nextTick, watch } from "vue";
  56. import { onLoad } from "@dcloudio/uni-app";
  57. import useZPaging from "@/uni_modules/z-paging/components/z-paging/js/hooks/useZPaging.js";
  58. import { useAppStore } from "@/stores/app";
  59. import { goldTradelist } from "@/api/vault";
  60. const paging = ref(null);
  61. useZPaging(paging)
  62. const appStore = useAppStore();
  63. const dataList = ref([]);
  64. const activeTab = ref(0);
  65. const emptyText = ref("");
  66. const loadingNoMoreText = ref("我也是有底线的");
  67. const statusMap = {
  68. 1: '已完成',
  69. 2: '待签收',
  70. 3: '待检测',
  71. 4: '待确认',
  72. 5: '待打款'
  73. }
  74. const tabs = [
  75. {
  76. id: 0,
  77. name: "存入记录",
  78. empty: "暂无存入记录",
  79. },
  80. {
  81. id: 1,
  82. name: "换款记录",
  83. empty: "暂无换款记录",
  84. },
  85. {
  86. id: 2,
  87. name: "出售记录",
  88. empty: "暂无出售记录",
  89. },
  90. ];
  91. const metalTypeMap = {
  92. 1: '黄金',
  93. 2: '铂金',
  94. 3: '白银'
  95. }
  96. const metalType = ref(1)
  97. onLoad((options) => {
  98. if (options?.metalType) {
  99. metalType.value = Number(options.metalType)
  100. uni.setNavigationBarTitle({
  101. title: metalTypeMap[options.metalType]+"明细"
  102. })
  103. }
  104. })
  105. const queryList = async (pageNo, pageSize) => {
  106. emptyText.value = tabs.find((tab) => tab.id === activeTab.value).empty;
  107. try {
  108. const tempParams = {
  109. page: pageNo,
  110. limit: pageSize,
  111. metalType: metalType.value,
  112. isDel: 0,
  113. userId: appStore.uid,
  114. }
  115. const params = Object.assign({}, tempParams, tabParams.value)
  116. console.log('params', params)
  117. const { data } = await goldTradelist(params);
  118. if (paging.value) {
  119. paging.value.complete(data.list);
  120. }
  121. } catch (error) {
  122. console.error("goldTradelist", error);
  123. paging.value.complete(false);
  124. }
  125. };
  126. const tabParams = ref({
  127. type: 1
  128. })
  129. const changeTab = (tabId) => {
  130. if (activeTab.value === tabId) return;
  131. activeTab.value = tabId;
  132. if (tabId === 0) {
  133. tabParams.value = { type: 1 }
  134. } else if (tabId === 1) {
  135. tabParams.value = { operationType: 2 }
  136. } else if (tabId === 2) {
  137. tabParams.value = { type: 0 }
  138. }
  139. nextTick(() => {
  140. if (paging.value) {
  141. paging.value.reload();
  142. }
  143. });
  144. };
  145. </script>
  146. <style lang="scss">
  147. $theme-color: #e9c279;
  148. $border-color: #f0f0f0;
  149. $text-color-light: #999;
  150. $text-color-dark: #333;
  151. $button-text-color: #fff;
  152. $gold-tag-bg: #ffeac7; // Light yellow for "直播间换金" tag
  153. $gold-tag-text: #e9c279; // Darker yellow for text
  154. $pending-tag-bg: #f0f0f0; // Light gray for "待审核" tag
  155. $pending-tag-text: #666; // Darker gray for text
  156. .records-page {
  157. display: flex;
  158. flex-direction: column;
  159. min-height: 100vh;
  160. }
  161. .tab-header {
  162. display: flex;
  163. justify-content: space-around;
  164. align-items: center;
  165. background-color: #fff;
  166. padding: 20rpx 0;
  167. position: sticky;
  168. top: 0;
  169. z-index: 10;
  170. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  171. .tab-item {
  172. flex: 1;
  173. text-align: center;
  174. font-size: 32rpx;
  175. color: $text-color-dark;
  176. padding: 15rpx 0;
  177. position: relative;
  178. cursor: pointer; // Indicate clickable
  179. &.is-active {
  180. color: $theme-color;
  181. font-weight: bold;
  182. &::after {
  183. content: "";
  184. position: absolute;
  185. bottom: -10rpx;
  186. left: 50%;
  187. transform: translateX(-50%);
  188. width: 60rpx;
  189. height: 6rpx;
  190. background-color: $theme-color;
  191. border-radius: 3rpx;
  192. }
  193. }
  194. }
  195. }
  196. /* z-paging specific styles (optional, but good to have some defaults) */
  197. :deep(.z-paging-content) {
  198. padding-top: 20rpx; // Space below the tabs
  199. }
  200. .record-item-wrapper {
  201. padding: 0 30rpx;
  202. margin-bottom: 20rpx; // Spacing between cards
  203. &:first-child {
  204. // No extra margin-top for the first item if needed
  205. }
  206. }
  207. .record-item {
  208. display: flex;
  209. justify-content: space-between;
  210. align-items: center;
  211. background-color: #fff;
  212. border-radius: 16rpx;
  213. padding: 30rpx;
  214. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  215. .item-left {
  216. .item-title {
  217. font-size: 32rpx;
  218. color: $text-color-dark;
  219. font-weight: bold;
  220. margin-right: 15rpx;
  221. }
  222. .status-tag {
  223. font-size: 24rpx;
  224. padding: 8rpx 16rpx;
  225. border-radius: 8rpx;
  226. display: inline-flex;
  227. align-items: center;
  228. justify-content: center;
  229. }
  230. .status-live {
  231. background-color: $header-color;
  232. color: #fff;
  233. }
  234. .status-pending {
  235. background-color: $pending-tag-bg;
  236. color: $pending-tag-text;
  237. }
  238. }
  239. .item-time {
  240. font-size: 26rpx;
  241. color: $text-color-light;
  242. }
  243. .item-right {
  244. flex-shrink: 0;
  245. margin-left: 20rpx;
  246. text-align: right;
  247. }
  248. .item-weight {
  249. font-size: 36rpx;
  250. font-weight: bold;
  251. color: $header-color;
  252. }
  253. }
  254. </style>