jindouProduct.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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" @click="navto('/pages/user/jindou')">查看明细</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. page: 1,
  24. limit: 1000,
  25. loadingType: 'loadmore',
  26. data: {
  27. page: 1,
  28. limit: 1000,
  29. loadingType: 'loadmore',
  30. data: []
  31. }
  32. };
  33. },
  34. components: {
  35. dataList
  36. },
  37. computed: {
  38. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  39. },
  40. onLoad() {
  41. this.loadData();
  42. this.getData();
  43. },
  44. methods: {
  45. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  46. // 點擊搜索框
  47. clickSearch() {
  48. uni.navigateTo({
  49. url: '/pages/product/search'
  50. });
  51. },
  52. navto(url) {
  53. uni.navigateTo({
  54. url:url
  55. })
  56. },
  57. loadData() {
  58. getUserInfo({})
  59. .then(({ data }) => {
  60. this.setUserInfo(data);
  61. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  62. })
  63. .catch(e => {
  64. console.log(e);
  65. });
  66. },
  67. getData() {
  68. let obj = this;
  69. getProducts({
  70. page: obj.page,
  71. limit: obj.limit,
  72. is_gold: 1
  73. })
  74. .then(function(res) {
  75. obj.data = res.data;
  76. })
  77. .catch(res => {});
  78. }
  79. }
  80. };
  81. </script>
  82. <style lang="scss" scoped>
  83. $grey: #95a0b1;
  84. $text: #333333;
  85. $red: #ff4c4c;
  86. .exchange {
  87. .bg {
  88. width: 100%;
  89. height: 400rpx;
  90. background-color: $red;
  91. image {
  92. width: 100%;
  93. }
  94. }
  95. .header {
  96. .data {
  97. padding-top: 120rpx;
  98. width: 100%;
  99. text-align: center;
  100. position: absolute;
  101. top: 0;
  102. color: #fff;
  103. height: 400rpx;
  104. .quantity,
  105. .title,
  106. .button {
  107. margin: 10rpx auto;
  108. }
  109. .title {
  110. font-size: 24rpx;
  111. }
  112. .quantity {
  113. font-size: 54rpx;
  114. font-weight: bold;
  115. }
  116. .button {
  117. padding: 10rpx;
  118. border: solid 1rpx #fff;
  119. border-radius: 40rpx;
  120. font-size: 24rpx;
  121. width: 160rpx;
  122. }
  123. }
  124. }
  125. .line {
  126. background-color: #fff;
  127. font-size: 28rpx;
  128. padding: 30rpx;
  129. color: $red;
  130. font-weight: bold;
  131. text-align: center;
  132. }
  133. .dataList {
  134. background-color: #fff;
  135. }
  136. }
  137. </style>