exchange.vue 2.4 KB

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