integral-store.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <view class="store">
  3. <view class="store_bg">
  4. <image src="../../static/store_bg.png" class="bg_img"></image>
  5. <view class="bg_con">
  6. <text>我的积分</text>
  7. <view>{{integral?integral:0}}</view>
  8. </view>
  9. </view>
  10. <view class="exchange">
  11. <view class="record flexB">
  12. <view @click="skipDetail(0)">
  13. <image src="../../static/gift_detail.png" class="gift_icon"></image>
  14. <text>礼品详情</text>
  15. </view>
  16. <view @click="skipDetail(1)">
  17. <image src="../../static/record.png" class="record_icon"></image>
  18. <text>兑换记录</text>
  19. </view>
  20. </view>
  21. <view class="exchange_con flexT" v-for="item in giftList" :key="item.id">
  22. <!-- <view class="change_icon">已兑换{{item.exchange_num}}</view> -->
  23. <image :src="item.imgurl" class="exchange_img" mode="aspectFill" @click="previewImg(item.imgurl)">
  24. </image>
  25. <view style="flex:1">
  26. <view class="exchange_name">{{ item.name }}</view>
  27. <view class="limit_box flexC">限量{{item.gift_num}}</view>
  28. <view class="flexB" style="width: 100%;">
  29. <view class="exchange_inte">
  30. <text>{{ item.integral }}</text>
  31. <text>积分</text>
  32. </view>
  33. <view class="exchange_btn flexC"
  34. @click="item.gift_num-item.exchange_num==0?noChange():skipDetail(2,item)"
  35. :class="item.gift_num-item.exchange_num==0?'disable_change':''">
  36. {{item.gift_num-item.exchange_num==0?'已兑完':'立即兑换'}}
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="noData" v-if="giftList.length==0">
  42. <image src="../../../static/imgs/default/no_card.png" mode=""></image>
  43. <view>--暂无可兑换礼品--</view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. getInteGifts
  51. } from '@/apis/shop.js'
  52. export default {
  53. data() {
  54. return {
  55. giftList: [],
  56. integral: 0,
  57. is_exc: '' //是否能兑换 0不能 1能
  58. };
  59. },
  60. onShow() {
  61. this.getList()
  62. },
  63. methods: {
  64. previewImg(img) {
  65. uni.previewImage({
  66. current: `${img}`,
  67. urls: [`${img}`],
  68. success: res => {
  69. console.log(res);
  70. },
  71. fail: err => {
  72. console.log(err)
  73. }
  74. })
  75. },
  76. //已兑完
  77. noChange() {
  78. uni.showModal({
  79. content: '礼品已兑完,下次早点来~',
  80. showCancel: false
  81. })
  82. },
  83. //获取礼品列表
  84. getList() {
  85. getInteGifts().then(res => {
  86. if (res.code == 200) {
  87. const {
  88. integral,
  89. gifts,
  90. is_exc
  91. } = res.data;
  92. this.integral = integral;
  93. this.giftList = is_exc == 1 ? gifts : [];
  94. this.is_exc = is_exc;
  95. } else {
  96. uni.showModal({
  97. content: res.msg || '获取数据失败',
  98. showCancel: false
  99. })
  100. }
  101. })
  102. },
  103. skipDetail(type, item) {
  104. let url = '';
  105. let gift = encodeURIComponent(JSON.stringify(item))
  106. switch (type) {
  107. case 0:
  108. url = '../../../pages/shop-gift-detail/shop-gift-detail';
  109. break;
  110. case 1:
  111. url = '../../../pages/shop-gift-record/shop-gift-record';
  112. break;
  113. case 2:
  114. url = '../../../pages/shop-gift-exchange/shop-gift-exchange?gift=' + gift
  115. break;
  116. }
  117. uni.navigateTo({
  118. url
  119. })
  120. },
  121. }
  122. };
  123. </script>
  124. <style lang="scss" scoped>
  125. .store {
  126. width: 100%;
  127. min-height: 100vh;
  128. background: #f9f9fb;
  129. .store_bg {
  130. width: 100%;
  131. height: 414rpx;
  132. position: relative;
  133. .bg_img {
  134. width: 100%;
  135. height: 100%;
  136. }
  137. .bg_con {
  138. position: absolute;
  139. top: 80rpx;
  140. left: 315rpx;
  141. text-align: center;
  142. text,
  143. view {
  144. color: #fff;
  145. }
  146. text {
  147. font-size: 32rpx;
  148. }
  149. view {
  150. font-size: 56rpx;
  151. margin-top: 20rpx;
  152. }
  153. }
  154. }
  155. .exchange {
  156. margin-top: -100rpx;
  157. position: relative;
  158. .record {
  159. width: 690rpx;
  160. margin: 0 auto;
  161. >view {
  162. width: 330rpx;
  163. height: 168rpx;
  164. background: #fff;
  165. border-radius: 18rpx;
  166. display: flex;
  167. justify-content: center;
  168. align-items: center;
  169. margin-bottom: 30rpx;
  170. text {
  171. font-size: 32rpx;
  172. font-weight: bold;
  173. margin-left: 10rpx;
  174. }
  175. }
  176. .gift_icon {
  177. width: 94rpx;
  178. height: 98rpx;
  179. }
  180. .record_icon {
  181. width: 85rpx;
  182. height: 93rpx;
  183. }
  184. }
  185. .exchange_con {
  186. width: 690rpx;
  187. margin: 0 auto 30rpx;
  188. padding: 20rpx;
  189. box-sizing: border-box;
  190. background: #fff;
  191. border-radius: 24rpx;
  192. position: relative;
  193. .change_icon {
  194. position: absolute;
  195. top: 0;
  196. right: 0;
  197. width: 154rpx;
  198. text-align: center;
  199. height: 44rpx;
  200. line-height: 44rpx;
  201. background: linear-gradient(226deg, #FFE9C2 0%, #FFCD81 100%);
  202. opacity: 1;
  203. border-radius: 0 24rpx 0 24rpx;
  204. color: #CE7E06;
  205. font-weight: bold;
  206. }
  207. .exchange_img {
  208. width: 260rpx;
  209. height: 260rpx;
  210. border-radius: 16rpx;
  211. flex-shrink: 0;
  212. margin-right: 20rpx;
  213. }
  214. .exchange_name {
  215. font-size: 30rpx;
  216. font-weight: bold;
  217. margin-top: 20rpx;
  218. }
  219. .limit_box {
  220. width: 170rpx;
  221. background: #FFF4F3;
  222. border-radius: 8rpx;
  223. height: 48rpx;
  224. color: $base-color;
  225. margin: 35rpx 0;
  226. }
  227. .exchange_inte {
  228. text {
  229. color: $base-color;
  230. }
  231. text:first-child {
  232. font-size: 36rpx;
  233. }
  234. text:last-child {
  235. font-size: 28rpx;
  236. }
  237. }
  238. .exchange_btn {
  239. width: 160rpx;
  240. height: 64rpx;
  241. background: $base-line-bg;
  242. border-radius: 34rpx;
  243. color: #fff;
  244. font-size: 28rpx;
  245. }
  246. .disable_change {
  247. background: #F8F8F8;
  248. color: #CCCCCC;
  249. }
  250. }
  251. }
  252. }
  253. </style>