jindouProduct.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. data: {
  24. page: 1,
  25. limit: 1000,
  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. navto(url) {
  50. uni.navigateTo({
  51. url:url
  52. })
  53. },
  54. loadData() {
  55. getUserInfo({})
  56. .then(({ data }) => {
  57. this.setUserInfo(data);
  58. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  59. })
  60. .catch(e => {
  61. console.log(e);
  62. });
  63. },
  64. getData() {
  65. const obj = this;
  66. getProducts({
  67. page: this.page,
  68. limit: this.limit,
  69. is_gold: 1
  70. })
  71. .then(function(res) {
  72. obj.data = res.data;
  73. })
  74. .catch(res => {});
  75. }
  76. }
  77. };
  78. </script>
  79. <style lang="scss" scoped>
  80. $grey: #95a0b1;
  81. $text: #333333;
  82. $red: #ff4c4c;
  83. .exchange {
  84. .bg {
  85. width: 100%;
  86. height: 400rpx;
  87. background-color: $red;
  88. image {
  89. width: 100%;
  90. }
  91. }
  92. .header {
  93. .data {
  94. padding-top: 120rpx;
  95. width: 100%;
  96. text-align: center;
  97. position: absolute;
  98. top: 0;
  99. color: #fff;
  100. height: 400rpx;
  101. .quantity,
  102. .title,
  103. .button {
  104. margin: 10rpx auto;
  105. }
  106. .title {
  107. font-size: 24rpx;
  108. }
  109. .quantity {
  110. font-size: 54rpx;
  111. font-weight: bold;
  112. }
  113. .button {
  114. padding: 10rpx;
  115. border: solid 1rpx #fff;
  116. border-radius: 40rpx;
  117. font-size: 24rpx;
  118. width: 160rpx;
  119. }
  120. }
  121. }
  122. .line {
  123. background-color: #fff;
  124. font-size: 28rpx;
  125. padding: 30rpx;
  126. color: $red;
  127. font-weight: bold;
  128. text-align: center;
  129. }
  130. .dataList {
  131. background-color: #fff;
  132. }
  133. }
  134. </style>