dhjilu.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div>
  3. <!-- 导航栏 -->
  4. <div class="nav-bar">
  5. <div class="back-btn" @click="$router.back()">
  6. <i class="arrow-left"></i>
  7. </div>
  8. <div class="title">兑换记录</div>
  9. </div>
  10. <!-- 主容器 -->
  11. <div class="dhjilu-container">
  12. <div class="content-wrapper">
  13. <!-- 记录列表 -->
  14. <div class="records-list">
  15. <div
  16. v-for="(record, index) in exchangeRecords"
  17. :key="record.id"
  18. class="record-item"
  19. >
  20. <div class="record-content">
  21. <div class="record-number">奖品{{ getChineseNumber(index + 1) }}</div>
  22. <div class="record-name">{{ record.productName }}</div>
  23. <div class="record-price">价值{{ record.value }}元</div>
  24. <div class="record-count">{{ record.count }}份</div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <!-- Toast 提示 -->
  31. <Toast ref="toast" />
  32. </div>
  33. </template>
  34. <script>
  35. import Toast from '@/components/Toast.vue';
  36. export default {
  37. name: 'DhjiluPage',
  38. components: {
  39. Toast
  40. },
  41. data() {
  42. return {
  43. exchangeRecords: [
  44. {
  45. id: 1,
  46. productName: '小米手机',
  47. value: 5999,
  48. count: 0,
  49. points: 100,
  50. exchangeTime: '2024-01-15 14:30:00',
  51. status: 'completed'
  52. },
  53. {
  54. id: 2,
  55. productName: '片仔癀',
  56. value: 18000,
  57. count: 0,
  58. points: 200,
  59. exchangeTime: '2024-01-14 16:20:00',
  60. status: 'pending'
  61. },
  62. {
  63. id: 3,
  64. productName: '野山参',
  65. value: 38888,
  66. count: 1,
  67. points: 300,
  68. exchangeTime: '2024-01-13 09:15:00',
  69. status: 'completed'
  70. },
  71. {
  72. id: 4,
  73. productName: '纪念金条',
  74. value: 78000,
  75. count: 0,
  76. points: 400,
  77. exchangeTime: '2024-01-12 11:45:00',
  78. status: 'pending'
  79. },
  80. {
  81. id: 5,
  82. productName: '劳力士金表',
  83. value: 88000,
  84. count: 0,
  85. points: 500,
  86. exchangeTime: '2024-01-11 15:30:00',
  87. status: 'pending'
  88. }
  89. ]
  90. }
  91. },
  92. mounted() {
  93. this.loadExchangeRecords();
  94. },
  95. methods: {
  96. // 加载兑换记录
  97. async loadExchangeRecords() {
  98. try {
  99. // 这里应该调用真实的API
  100. // const response = await getExchangeRecords();
  101. // this.exchangeRecords = response.data;
  102. // 当前使用模拟数据,实际开发时替换为API调用
  103. console.log('兑换记录加载完成');
  104. } catch (error) {
  105. console.error('加载兑换记录失败:', error);
  106. this.$refs.toast.show('加载记录失败', 'error');
  107. }
  108. },
  109. // 转换数字为中文
  110. getChineseNumber(num) {
  111. const chineseNumbers = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十'];
  112. return chineseNumbers[num - 1] || num;
  113. }
  114. }
  115. }
  116. </script>
  117. <style scoped>
  118. /* 导航栏样式 */
  119. .nav-bar {
  120. height: 44px;
  121. background-color: #fff;
  122. color: #000;
  123. display: flex;
  124. align-items: center;
  125. position: relative;
  126. padding: 0 15px;
  127. font-weight: bold;
  128. box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  129. }
  130. .back-btn {
  131. width: 24px;
  132. height: 44px;
  133. display: flex;
  134. align-items: center;
  135. cursor: pointer;
  136. }
  137. .arrow-left {
  138. width: 12px;
  139. height: 12px;
  140. border-left: 2px solid #000;
  141. border-bottom: 2px solid #000;
  142. transform: rotate(45deg);
  143. }
  144. .title {
  145. position: absolute;
  146. left: 50%;
  147. transform: translateX(-50%);
  148. font-size: 16px;
  149. }
  150. /* 主容器 */
  151. .dhjilu-container {
  152. min-height: calc(100vh - 44px);
  153. background: linear-gradient(135deg, #c94545 0%, #b43a39 100%);
  154. padding: 20px;
  155. padding-bottom: 100px;
  156. }
  157. .content-wrapper {
  158. background: white;
  159. border-radius: 12px;
  160. padding: 15px;
  161. box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  162. }
  163. /* 记录列表 */
  164. .records-list {
  165. display: flex;
  166. flex-direction: column;
  167. gap: 15px;
  168. }
  169. .record-item {
  170. background: linear-gradient(135deg, #f5a5a5 0%, #f0b8b8 100%);
  171. border-radius: 12px;
  172. padding: 20px 15px;
  173. box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  174. transition: transform 0.2s ease;
  175. }
  176. .record-item:active {
  177. transform: scale(0.98);
  178. }
  179. .record-content {
  180. display: grid;
  181. grid-template-columns: auto 1fr auto auto;
  182. align-items: center;
  183. gap: 15px;
  184. }
  185. .record-number {
  186. font-size: 16px;
  187. font-weight: 600;
  188. color: #d91d42;
  189. min-width: 50px;
  190. }
  191. .record-name {
  192. font-size: 16px;
  193. font-weight: 500;
  194. color: #333;
  195. text-align: left;
  196. }
  197. .record-price {
  198. font-size: 16px;
  199. font-weight: 600;
  200. color: #d91d42;
  201. text-align: right;
  202. min-width: 90px;
  203. }
  204. .record-count {
  205. font-size: 16px;
  206. font-weight: 600;
  207. color: #333;
  208. text-align: right;
  209. min-width: 30px;
  210. }
  211. /* 响应式优化 */
  212. @media screen and (max-width: 375px) {
  213. .dhjilu-container {
  214. padding: 15px;
  215. }
  216. .record-content {
  217. gap: 10px;
  218. }
  219. .record-number,
  220. .record-name,
  221. .record-price,
  222. .record-count {
  223. font-size: 14px;
  224. }
  225. .record-item {
  226. padding: 15px 12px;
  227. }
  228. }
  229. @media screen and (max-width: 320px) {
  230. .record-content {
  231. gap: 8px;
  232. }
  233. .record-number,
  234. .record-name,
  235. .record-price,
  236. .record-count {
  237. font-size: 13px;
  238. }
  239. .record-price {
  240. min-width: 80px;
  241. }
  242. }
  243. /* 空状态 */
  244. .empty-state {
  245. text-align: center;
  246. padding: 60px 20px;
  247. color: #999;
  248. }
  249. .empty-state .icon {
  250. font-size: 48px;
  251. margin-bottom: 15px;
  252. color: #ddd;
  253. }
  254. .empty-state .text {
  255. font-size: 16px;
  256. line-height: 1.5;
  257. }
  258. </style>