exchange.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <view class="giftContainer">
  3. <view class="message">
  4. <view class="icon"><text>通知</text></view>
  5. <view class="text"><view class="scroll">奖学金兑换自结算日起2天内开启兑换,超过时限奖学金将自动清零。</view></view>
  6. </view>
  7. <view class="banner">
  8. <view class="num">
  9. <text class="spec" v-if="userServerInfo">{{ userServerInfo.bonus }}</text>
  10. <text>奖学金</text>
  11. </view>
  12. <view class="num">兑换礼包,福利优人一步</view>
  13. </view>
  14. <view class="fixedHeader">
  15. <view class="num">
  16. <text>奖学金:</text>
  17. <text class="spec" v-if="userServerInfo">{{ userServerInfo.bonus }}</text>
  18. </view>
  19. <view v-if="userServerInfo">
  20. <view v-if="userServerInfo.type === 1 || userServerInfo.type === 2" class="title" @tap="exchangerecord">
  21. <text>{{ userServerInfo.type === 2 ? '兑换记录' : '我的礼品' }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="list" v-if="list.length > 0">
  26. <view v-for="item in list" :key="item.id" class="item" @click="exchange(item)">
  27. <view class="avatar" :style="{ backgroundImage: `url(${item.img})` }" @click.stop="priview(item.img)">
  28. <view v-if="!Number(item.surplus)" class="none"><text>已兑完</text></view>
  29. </view>
  30. <view class="info">
  31. <view class="title">{{ item.name }}</view>
  32. <view class="info-num">
  33. <view class="info-other">限量{{ item.total }}份</view>
  34. <view class="info-status" v-if="item.exchanged">已兑换</view>
  35. </view>
  36. <view class="bottom">
  37. <view class="money">
  38. <text class="spec">{{ item.price }}</text>
  39. <text>奖学金</text>
  40. </view>
  41. <view class="btn" :class="Number(item.surplus) && isCan ? '' : 'disabled'">立即兑换</view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import { api_getExchangeList } from '../../api.js';
  50. export default {
  51. data() {
  52. return {
  53. pageTitle: '礼品兑换',
  54. scrollViewHeight: 0,
  55. list: []
  56. };
  57. },
  58. computed: {
  59. userServerInfo() {
  60. //用户服务器信息
  61. return this.$store.state.userServerInfo;
  62. },
  63. isCan() {
  64. return this.$store.state.userServerInfo && this.$store.state.userServerInfo.status === 3 ? true : false;
  65. }
  66. },
  67. onShow() {
  68. this.getGiftList();
  69. },
  70. methods: {
  71. getGiftList() {
  72. uni.showLoading();
  73. this.$ajax.get(api_getExchangeList).then(([, { data: res }]) => {
  74. //获取兑换礼品列表
  75. this.list = res.data.list;
  76. uni.hideLoading();
  77. });
  78. },
  79. exchangerecord() {
  80. //进入兑换记录页面
  81. if (this.userServerInfo.type === 1) {
  82. uni.navigateTo({ url: '../exchangerecord/exchangerecord' });
  83. } else if (this.userServerInfo.type === 2) {
  84. uni.navigateTo({ url: '../mygift/mygift' });
  85. } else {
  86. uni.showModal({
  87. content: '无兑换记录',
  88. showCancel: false
  89. });
  90. }
  91. },
  92. priview(src) {
  93. // 预览
  94. uni.previewImage({ urls: [src] });
  95. },
  96. exchange(data) {
  97. // 兑换
  98. getApp().globalData.detail = data; //把兑换列表保存到 globalData 中
  99. uni.navigateTo({
  100. url: '../detail/detail' //去商品详情页面时
  101. });
  102. return false;
  103. if (!data.isCan) {
  104. uni.showModal({
  105. content: '兑换还未开始',
  106. showCancel: false
  107. });
  108. return false;
  109. }
  110. if (data.surplus) {
  111. //如果有货
  112. getApp().globalData.detail = data; //把兑换列表保存到 globalData 中
  113. uni.navigateTo({
  114. url: '../detail/detail' //去商品详情页面时
  115. });
  116. } else {
  117. uni.showModal({
  118. content: '来晚了!礼品已兑换完毕!再看看别的吧!',
  119. showCancel: false
  120. });
  121. }
  122. }
  123. }
  124. };
  125. </script>
  126. <style lang="scss">
  127. page {
  128. height: auto;
  129. display: flex;
  130. flex-direction: column;
  131. .giftContainer {
  132. flex: 1;
  133. overflow: hidden;
  134. padding: 30rpx;
  135. box-sizing: border-box;
  136. .message {
  137. width: 100%;
  138. display: flex;
  139. align-items: center;
  140. padding: 0 42rpx 0 14rpx;
  141. box-sizing: border-box;
  142. background-color: #fff4f3;
  143. height: 62rpx;
  144. border-radius: 62rpx;
  145. margin-bottom: 30rpx;
  146. .icon {
  147. width: 128rpx;
  148. height: 46rpx;
  149. background: linear-gradient(88deg, #ffc401 0%, #fe2400 41%, #fe0000 100%);
  150. border-radius: 45rpx;
  151. display: flex;
  152. align-items: center;
  153. justify-content: center;
  154. color: #ffffff;
  155. font-size: 28rpx;
  156. margin-right: 14rpx;
  157. &::before {
  158. content: '';
  159. display: block;
  160. width: 28rpx;
  161. height: 28rpx;
  162. background: url(../../static/gift/1.png) 100% center no-repeat;
  163. background-size: 100%;
  164. margin-right: 6rpx;
  165. }
  166. }
  167. .text {
  168. flex: 1;
  169. height: 40rpx;
  170. overflow: hidden;
  171. .scroll {
  172. height: 40rpx;
  173. line-height: 40rpx;
  174. white-space: nowrap;
  175. color: #ea4a41;
  176. font-weight: 28rpx;
  177. animation: scroll-left-right 12s linear infinite;
  178. }
  179. }
  180. }
  181. .banner {
  182. width: 100%;
  183. height: 240rpx;
  184. background: linear-gradient(270deg, #f97c55 0%, #f44545 100%);
  185. border-top-left-radius: 24rpx;
  186. border-top-right-radius: 24rpx;
  187. position: relative;
  188. padding: 60rpx 40rpx;
  189. box-sizing: border-box;
  190. display: flex;
  191. flex-direction: column;
  192. justify-content: space-between;
  193. margin-bottom: 30rpx;
  194. .num {
  195. color: #ffffff;
  196. font-size: 32rpx;
  197. line-height: 44rpx;
  198. .spec {
  199. font-size: 76rpx;
  200. margin-right: 10rpx;
  201. }
  202. }
  203. &::after {
  204. content: '';
  205. display: block;
  206. width: calc(100% + 30rpx);
  207. height: 28rpx;
  208. background: linear-gradient(180deg, rgba(234, 74, 65, 0) 0%, rgba(234, 74, 65, 0.35) 100%);
  209. border-radius: 28rpx;
  210. position: absolute;
  211. left: -15rpx;
  212. right: -15rpx;
  213. bottom: -14rpx;
  214. }
  215. &::before {
  216. content: '';
  217. display: block;
  218. width: 170rpx;
  219. height: 170rpx;
  220. background-image: url('https://api.jiuweiyun.cn/public/uploads/weapp/icon/2.png');
  221. background-position: center;
  222. background-size: 100%;
  223. background-repeat: no-repeat;
  224. position: absolute;
  225. top: 50%;
  226. right: 30rpx;
  227. transform: translateY(-50%);
  228. }
  229. }
  230. .fixedHeader {
  231. width: 100%;
  232. display: flex;
  233. align-items: center;
  234. justify-content: space-between;
  235. margin-bottom: 30rpx;
  236. .num {
  237. display: flex;
  238. align-items: center;
  239. color: #333333;
  240. font-size: 32rpx;
  241. line-height: 56rpx;
  242. .spec {
  243. color: #ea4a41;
  244. font-size: 40rpx;
  245. }
  246. &::before {
  247. content: '';
  248. display: block;
  249. width: 40rpx;
  250. height: 40rpx;
  251. background-image: url(../../static/gift/3.png);
  252. background-size: 100%;
  253. background-position: center;
  254. background-repeat: no-repeat;
  255. margin-right: 10rpx;
  256. }
  257. }
  258. .title {
  259. display: flex;
  260. align-items: center;
  261. color: #999999;
  262. font-size: 32rpx;
  263. &::before {
  264. content: '';
  265. display: block;
  266. width: 34rpx;
  267. height: 34rpx;
  268. background-image: url(../../static/gift/4.png);
  269. background-size: 100%;
  270. background-position: center;
  271. background-repeat: no-repeat;
  272. margin-right: 10rpx;
  273. }
  274. }
  275. }
  276. .list {
  277. width: 100%;
  278. .item {
  279. width: 100%;
  280. display: flex;
  281. align-items: stretch;
  282. justify-content: space-between;
  283. margin-bottom: 30rpx;
  284. .avatar {
  285. width: 260rpx;
  286. height: 260rpx;
  287. background-color: #f9f9fb;
  288. position: relative;
  289. border-radius: 16rpx;
  290. display: flex;
  291. align-items: center;
  292. justify-content: center;
  293. margin-right: 20rpx;
  294. background-position: center;
  295. background-repeat: no-repeat;
  296. background-size: 100%;
  297. overflow: hidden;
  298. .none {
  299. position: absolute;
  300. top: 0;
  301. bottom: 0;
  302. right: 0;
  303. left: 0;
  304. background: rgba(0, 0, 0, 0.5);
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. color: #ffffff;
  309. font-size: 32rpx;
  310. }
  311. }
  312. .info {
  313. flex: 1;
  314. overflow: hidden;
  315. display: flex;
  316. flex-direction: column;
  317. justify-content: space-between;
  318. .title {
  319. color: #333333;
  320. font-size: 32rpx;
  321. line-height: 44rpx;
  322. width: 100%;
  323. height: 44rpx;
  324. overflow: hidden;
  325. font-weight: bold;
  326. margin-bottom: 20rpx;
  327. }
  328. &-num {
  329. display: flex;
  330. align-items: center;
  331. justify-content: space-between;
  332. margin-bottom: 70rpx;
  333. .info-other {
  334. color: #ea4a41;
  335. font-size: 28rpx;
  336. height: 52rpx;
  337. line-height: 52rpx;
  338. padding: 0 10rpx;
  339. border-radius: 8rpx;
  340. background-color: #fff4f3;
  341. }
  342. .info-status {
  343. color: #ffffff;
  344. font-size: 28rpx;
  345. height: 44rpx;
  346. line-height: 44rpx;
  347. padding: 0 14rpx;
  348. background-color: #ffbb01;
  349. border-top-left-radius: 16rpx;
  350. border-bottom-right-radius: 16rpx;
  351. }
  352. }
  353. .bottom {
  354. display: flex;
  355. align-items: center;
  356. justify-content: space-between;
  357. .money {
  358. color: #ea4a41;
  359. font-size: 24rpx;
  360. .spec {
  361. font-size: 40rpx !important;
  362. }
  363. }
  364. .btn {
  365. height: 68rpx;
  366. border-radius: 68rpx;
  367. background: linear-gradient(141deg, #f97c55 0%, #f44545 100%);
  368. line-height: 68rpx;
  369. width: 192rpx;
  370. text-align: center;
  371. color: #ffffff;
  372. font-size: 28rpx;
  373. &.disabled {
  374. background: #f8f8f8 !important;
  375. color: #999999;
  376. }
  377. }
  378. }
  379. }
  380. }
  381. }
  382. }
  383. }
  384. .exchange {
  385. // @include page();
  386. .content {
  387. display: flex;
  388. flex-direction: column;
  389. .scroll {
  390. height: 50rpx;
  391. line-height: 50rpx;
  392. background: rgba(250, 99, 66, 0.2);
  393. display: flex;
  394. align-items: center;
  395. color: #fa6342;
  396. text {
  397. font-size: 40rpx;
  398. color: #fa6342;
  399. margin-left: 30rpx;
  400. }
  401. .scroll-wrapper {
  402. flex: 1;
  403. height: 100%;
  404. overflow: hidden;
  405. .scroller {
  406. height: 100%;
  407. white-space: nowrap;
  408. font-size: 26rpx;
  409. padding-left: 10rpx;
  410. animation: scroll-left-right 12s linear infinite;
  411. }
  412. }
  413. }
  414. .banner {
  415. width: 100%;
  416. height: 216rpx;
  417. }
  418. .nav {
  419. height: 76rpx;
  420. box-sizing: border-box;
  421. padding: 0 30rpx;
  422. border-bottom: 6rpx solid #eeeeee;
  423. display: flex;
  424. justify-content: space-between;
  425. align-items: center;
  426. font-size: 32rpx;
  427. view {
  428. height: 100%;
  429. display: flex;
  430. align-items: center;
  431. .cuIcon {
  432. font-size: 40rpx;
  433. margin-right: 12rpx;
  434. }
  435. }
  436. }
  437. .list {
  438. flex: 1;
  439. scroll-view {
  440. box-sizing: border-box;
  441. padding: 0 30rpx 0;
  442. }
  443. }
  444. }
  445. }
  446. @keyframes scroll-left-right {
  447. 0% {
  448. transform: translateX(100%);
  449. }
  450. 100% {
  451. transform: translateX(-100%);
  452. }
  453. }
  454. </style>