index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <view class="wrap">
  3. <u-navbar title="礼品兑换" :placeholder="true" bgColor="rgba(255,255,255,0.3)" leftText="返回" :autoBack="true" titleStyle="font-weight:bold;color:#7a5831"></u-navbar>
  4. <!-- 暂时注释3月12 -->
  5. <!-- <view class="main"> -->
  6. <view class="main" v-if="hasLoad">
  7. <view class="user-data" :style="'background-image:url(' + topImage + ')'">
  8. <view class="b-chance">
  9. <view class="s-tit">积分余额</view>
  10. <view class="s-num">{{ score.score }}</view>
  11. <view class="s-unit">个</view>
  12. </view>
  13. <view class="b-action" @click="onJumpOrder">
  14. <view class="s-btn">兑换订单</view>
  15. </view>
  16. <view class="b-state">
  17. <view class="s-tit f-wait" v-if="giftData.gift_state == 0">兑奖未开始</view>
  18. <view class="s-tit f-ing" v-else-if="giftData.gift_state == 1">兑奖进行中</view>
  19. <view class="s-tit f-end" v-else-if="giftData.gift_state == 2">兑奖已结束</view>
  20. </view>
  21. </view>
  22. <view class="all-gifts">
  23. <view class="b-items" v-if="allList.length > 0">
  24. <view class="b-item" v-for="(item, index) in allList" :key="index" @click="onJumpGift(item.id)">
  25. <view class="b-left">
  26. <image :src="item.cover_url" mode="aspectFill"></image>
  27. </view>
  28. <view class="b-main">
  29. <view class="b-title too-long">{{ item.name }}</view>
  30. <view class="b-center">
  31. <view class="b-fund">
  32. <view class="s-worth" v-if="item.worth > 0">价值 {{ item.worth }}元</view>
  33. </view>
  34. <view class="b-action">
  35. <view class="s-action" v-if="item.count_left > 0">兑换</view>
  36. <view class="s-action f-disable" v-else>已兑换完</view>
  37. </view>
  38. </view>
  39. <view class="b-amount">
  40. <view class="s-left">库存 {{ item.count_left }}</view>
  41. <view class="s-gain">已兑 {{ item.count_gain }}</view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="b-empty" v-else>暂无奖品</view>
  47. </view>
  48. </view>
  49. <!-- 加载中 -->
  50. <load-more :loadingType="loadingType" :loadingText="loadingText" :top="300"></load-more>
  51. </view>
  52. </template>
  53. <script>
  54. import { getWrapData } from '@/service/api/gift.js';
  55. // import mixinsCommon from '@/mixins/common.js';
  56. // import mixinsAuth from '../../mixins/auth.js';
  57. // import loadMore from '@/components/load-more/load-more.vue';
  58. export default {
  59. // mixins: [mixinsCommon, mixinsAuth],
  60. data() {
  61. return {
  62. giftData: {},
  63. userInfo: {},
  64. score: {},
  65. allList: [],
  66. hasLoad: false,
  67. loadingType: 1,
  68. loadingText: '',
  69. display: {
  70. avatarChange: false
  71. }
  72. };
  73. },
  74. onShow() {
  75. // 暂时注释3月12
  76. this.loadWrapData();
  77. },
  78. computed: {
  79. topImage() {
  80. // return this.$store.getters.globalConfig.gift_top_img || 'https://huli-app.wenlvti.net/app_static/wuyuan/static/static/imgs/gift_top_bg.jpg'
  81. return 'https://huli-app.wenlvti.net/app_static/wuyuan/static/static/imgs/gift_top_bg.jpg';
  82. }
  83. },
  84. methods: {
  85. loadWrapData() {
  86. getWrapData().then(([err, res]) => {
  87. console.log('getWrapData', err, res);
  88. if (!err) {
  89. this.hasLoad = true;
  90. this.loadingType = -1;
  91. this.giftData = res.giftData;
  92. this.userInfo = res.userInfo;
  93. this.allList = res.giftList;
  94. } else {
  95. this.loadingType = 3;
  96. this.loadingText = err.data.msg || '加载失败';
  97. }
  98. // 积分信息
  99. // this.getScore();
  100. });
  101. },
  102. onJumpOrder() {
  103. uni.navigateTo({
  104. url: '/answer_pages/gift/order'
  105. });
  106. },
  107. onJumpGift(giftId) {
  108. uni.navigateTo({
  109. url: '/answer_pages/gift/detail?gift_id=' + giftId
  110. });
  111. },
  112. getScore() {
  113. this.$api.getWuyuanUser({}, (val) => {
  114. console.log(val);
  115. this.score = val.data.user;
  116. // val.data.score;
  117. // val.data.exp;
  118. });
  119. }
  120. }
  121. };
  122. </script>
  123. <style lang="scss">
  124. .user-data {
  125. padding: 160upx 40upx 30upx 40upx;
  126. background: #fff;
  127. background-image: url('https://huli-app.wenlvti.net/app_static/wuyuan/static/static/imgs/gift_top_bg.jpg');
  128. background-repeat: no-repeat;
  129. background-size: cover;
  130. display: flex;
  131. flex-direction: column;
  132. align-items: center;
  133. .b-chance {
  134. margin-top: 50upx;
  135. display: flex;
  136. align-items: center;
  137. .s-tit {
  138. font-size: 28upx;
  139. color: #eee;
  140. }
  141. .s-num {
  142. margin: 0 20upx;
  143. font-size: 60upx;
  144. font-weight: bold;
  145. color: #fbc315;
  146. }
  147. .s-unit {
  148. font-size: 28upx;
  149. color: #eee;
  150. }
  151. }
  152. .b-action {
  153. margin-top: 30upx;
  154. border: 2upx solid #fff;
  155. color: #fff;
  156. font-size: 28upx;
  157. padding: 0 50upx;
  158. height: 60upx;
  159. line-height: 60upx;
  160. border-radius: 30upx;
  161. }
  162. .b-state {
  163. margin-top: 50upx;
  164. display: flex;
  165. align-items: center;
  166. .s-tit {
  167. color: #fff;
  168. font-size: 24upx;
  169. padding: 0 20upx;
  170. background: #fbc315;
  171. height: 60upx;
  172. line-height: 60upx;
  173. border-radius: 10upx;
  174. &.f-wait {
  175. background: #444c69;
  176. }
  177. &.f-ing {
  178. background: #ffc300;
  179. }
  180. &.f-end {
  181. background: #c4c4c4;
  182. }
  183. }
  184. }
  185. }
  186. .all-gifts {
  187. background: #fff;
  188. .b-empty {
  189. height: 100upx;
  190. line-height: 100upx;
  191. text-align: center;
  192. color: #999;
  193. font-size: 28upx;
  194. }
  195. .b-items {
  196. .b-item {
  197. padding: 30upx;
  198. border-bottom: 1upx solid #eee;
  199. display: flex;
  200. &:last-child {
  201. border-bottom: none;
  202. }
  203. .b-left {
  204. width: 160upx;
  205. height: 160upx;
  206. image {
  207. width: 160upx;
  208. height: 160upx;
  209. }
  210. }
  211. .b-main {
  212. margin-left: 30upx;
  213. flex: 1;
  214. display: flex;
  215. flex-direction: column;
  216. .b-title {
  217. font-size: 28upx;
  218. color: #333;
  219. width: 500upx;
  220. }
  221. .b-center {
  222. margin-top: 20upx;
  223. display: flex;
  224. justify-content: space-between;
  225. .b-fund {
  226. display: flex;
  227. align-items: baseline;
  228. .s-worth {
  229. font-size: 24upx;
  230. color: #999;
  231. }
  232. }
  233. .b-action {
  234. .s-action {
  235. background: #da5650;
  236. color: #fff;
  237. font-size: 24upx;
  238. padding: 0 30upx;
  239. border-radius: 30upx;
  240. height: 60upx;
  241. line-height: 60upx;
  242. &.f-disable {
  243. background: rgba(218, 86, 80, 0.8);
  244. }
  245. }
  246. }
  247. }
  248. .b-amount {
  249. margin-top: 10upx;
  250. display: flex;
  251. justify-content: space-between;
  252. .s-left {
  253. font-size: 24upx;
  254. color: #999;
  255. }
  256. .s-gain {
  257. font-size: 24upx;
  258. color: #999;
  259. }
  260. }
  261. }
  262. }
  263. }
  264. }
  265. </style>