exchange-item.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="exchange-item">
  3. <view class="pic" @tap="priview(item.img)">
  4. <image :src="item.img" mode="aspectFill"></image>
  5. <view class="bg"></view>
  6. </view>
  7. <view class="info" @tap="exchange">
  8. <view class="top">{{ item.name }}</view>
  9. <view class="mid">
  10. <text class="left">{{ item.surplus ? '限量' + item.total + '份' : '已抢完' }}</text>
  11. <text class="right" :style="{ color: item.exchanged ? '#999999' : '#FA6342' }">{{ item.exchanged ? '已兑换' : '未兑换' }}</text>
  12. </view>
  13. <view class="bot">
  14. <view class="exchanged">{{ item.total - item.surplus }}人已领</view>
  15. <view class="price">
  16. <text class="num">{{ item.price + ' ' }}</text>
  17. <text>奖学金</text>
  18. </view>
  19. <view class="exchangebtn none" v-if="!isCan">立即兑换</view>
  20. <view class="exchangebtn" v-else :class="item.surplus ? '' : 'none'">立即兑换</view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import store from '../store.js'
  27. export default {
  28. props: {
  29. item: Object,
  30. index: Number
  31. },
  32. computed: {
  33. isCan: () => {
  34. let { state } = store
  35. return (state.userServerInfo && state.userServerInfo.status === 3) ? true : false
  36. }
  37. },
  38. methods: {
  39. exchange () { //点击兑换礼品商品后
  40. if(!this.isCan) {
  41. uni.showModal({
  42. content: "兑换还未开始",
  43. showCancel: false
  44. })
  45. return false
  46. }
  47. if (this.item.surplus) { //如果有货
  48. getApp().globalData.detail = this.item //把兑换列表保存到 globalData 中
  49. uni.navigateTo({
  50. url: '../detail/detail' //去商品详情页面时
  51. })
  52. } else {
  53. uni.showModal({
  54. content: "来晚了!礼品已兑换完毕!再看看别的吧!",
  55. showCancel: false
  56. })
  57. }
  58. },
  59. priview(src) {
  60. uni.previewImage({ urls: [src] })
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .exchange-item {
  67. width: 100%;
  68. height: 260rpx;
  69. margin: 20rpx 0;
  70. display: flex;
  71. .pic {
  72. height: 100%;
  73. width: 260rpx;
  74. margin-right: 40rpx;
  75. position: relative;
  76. border-radius: 8rpx;
  77. overflow: hidden;
  78. image {
  79. width: 100%;
  80. height: 100%;
  81. }
  82. .bg {
  83. position: absolute;
  84. top: 0;
  85. left: 0;
  86. right: 0;
  87. bottom: 0;
  88. background: rgba(0, 0, 0, .05);
  89. }
  90. }
  91. .info {
  92. flex: 1;
  93. display: flex;
  94. flex-direction: column;
  95. .top {
  96. height: 70rpx;
  97. line-height: 70rpx;
  98. font-size: 28rpx;
  99. }
  100. .mid {
  101. height: 55rpx;
  102. display: flex;
  103. justify-content: space-between;
  104. align-items: center;
  105. font-size: 24rpx;
  106. .left {
  107. width: 140rpx;
  108. height: 36rpx;
  109. color: #FA6342;
  110. line-height: 36rpx;
  111. text-align: center;
  112. background: rgba(250,99,66,0);
  113. border: 1rpx solid #FA6342;
  114. border-radius: 6rpx;
  115. }
  116. }
  117. .bot {
  118. flex: 1;
  119. position: relative;
  120. .exchanged {
  121. position: absolute;
  122. left: 0;
  123. bottom: 73rpx;
  124. color: #999999;
  125. font-size: 24rpx;
  126. }
  127. .price {
  128. position: absolute;
  129. left: 0;
  130. bottom: 20rpx;
  131. color: #FA6342;
  132. font-size: 24rpx;
  133. .num {
  134. font-size: 36rpx;
  135. }
  136. }
  137. .exchangebtn {
  138. position: absolute;
  139. right: 0;
  140. bottom: 20rpx;
  141. width: 152rpx;
  142. height: 56rpx;
  143. line-height: 56rpx;
  144. text-align: center;
  145. color: #FA6342;
  146. background: rgba(255,235,232,1);
  147. border-radius: 28rpx;
  148. &.none {
  149. color: #999999;
  150. background: rgba(222,222,222,1);
  151. }
  152. }
  153. }
  154. }
  155. }
  156. </style>