jindouProduct.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="exchange">
  3. <view class="bg"><!-- <image src="@/static/img/bargainBg.jpg" mode=""></image> --></view>
  4. <view class="header">
  5. <view class="data">
  6. <view class="title">我的金豆</view>
  7. <view class="quantity">{{ userInfo.gold }}</view>
  8. <view class="button">查看明细</view>
  9. </view>
  10. </view>
  11. <view class="line">热门兑换</view>
  12. <view class="dataList"><data-list :data="data"></data-list></view>
  13. </view>
  14. </template>
  15. <script>
  16. import { getProducts } from '@/api/product.js';
  17. import dataList from '@/components/datalist.vue';
  18. import { mapState, mapMutations } from 'vuex';
  19. import { getUserInfo } from '@/api/user.js';
  20. export default {
  21. data() {
  22. return {
  23. data: {
  24. page: 1,
  25. limit: 10,
  26. loadingType: 'loadmore',
  27. data: []
  28. }
  29. };
  30. },
  31. components: {
  32. dataList
  33. },
  34. computed: {
  35. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  36. },
  37. onLoad() {
  38. this.loadData();
  39. this.getData();
  40. },
  41. methods: {
  42. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  43. // 點擊搜索框
  44. clickSearch() {
  45. uni.navigateTo({
  46. url: '/pages/product/search'
  47. });
  48. },
  49. loadData() {
  50. getUserInfo({})
  51. .then(({ data }) => {
  52. this.setUserInfo(data);
  53. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  54. })
  55. .catch(e => {
  56. console.log(e);
  57. });
  58. },
  59. getData() {
  60. const obj = this;
  61. getProducts({
  62. page: this.page,
  63. limit: this.limit,
  64. is_gold: 1
  65. })
  66. .then(function(res) {
  67. obj.data = res.data;
  68. })
  69. .catch(res => {});
  70. }
  71. }
  72. };
  73. </script>
  74. <style lang="scss" scoped>
  75. $grey: #95a0b1;
  76. $text: #333333;
  77. $red: #ff4c4c;
  78. .exchange {
  79. .bg {
  80. width: 100%;
  81. height: 400rpx;
  82. background-color: $red;
  83. image {
  84. width: 100%;
  85. }
  86. }
  87. .header {
  88. .data {
  89. padding-top: 120rpx;
  90. width: 100%;
  91. text-align: center;
  92. position: absolute;
  93. top: 0;
  94. color: #fff;
  95. height: 400rpx;
  96. .quantity,
  97. .title,
  98. .button {
  99. margin: 10rpx auto;
  100. }
  101. .title {
  102. font-size: 24rpx;
  103. }
  104. .quantity {
  105. font-size: 54rpx;
  106. font-weight: bold;
  107. }
  108. .button {
  109. padding: 10rpx;
  110. border: solid 1rpx #fff;
  111. border-radius: 40rpx;
  112. font-size: 24rpx;
  113. width: 160rpx;
  114. }
  115. }
  116. }
  117. .line {
  118. background-color: #fff;
  119. font-size: 28rpx;
  120. padding: 30rpx;
  121. color: $red;
  122. font-weight: bold;
  123. text-align: center;
  124. }
  125. .dataList {
  126. background-color: #fff;
  127. }
  128. }
  129. </style>