exchange.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <template>
  2. <view>
  3. <view class="giftContainer">
  4. <view class="banner">
  5. <view class="num">
  6. <text class="spec" v-if="userServerInfo">{{ integral }}</text>
  7. </view>
  8. <view class="flex">
  9. <view class="mingxi" @click="goAddress">
  10. 收货地址
  11. </view>
  12. </view>
  13. </view>
  14. <view class="fixedHeader">
  15. <view />
  16. <view v-if="userServerInfo">
  17. <view class="title" @tap="exchangerecord">
  18. <text>兑换记录</text>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="list" v-if="list.length > 0">
  23. <view v-for="item in list" :key="item.id" class="item" @click="exchange(item)">
  24. <view class="avatar" :style="{ backgroundImage: `url(${item.img})` }" @click.stop="priview(item.img)">
  25. <view v-if="!Number(item.surplus)" class="none"><text>已兑完</text></view>
  26. </view>
  27. <view class="info">
  28. <view class="title">{{ item.name }}</view>
  29. <view class="info-num">
  30. <view class="info-other">限量{{ item.total }}份</view>
  31. <view class="info-status" v-if="item.exchanged">已兑换</view>
  32. </view>
  33. <view class="bottom">
  34. <view class="money">
  35. <text class="spec">{{ item.price }}</text>
  36. </view>
  37. <view class="btn" :class="Number(item.surplus) ? '' : 'disabled'">立即兑换</view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. api_getExchangeList,
  48. GetInte
  49. } from '../../apis/zbs.js';
  50. export default {
  51. data() {
  52. return {
  53. list: [],
  54. integral: ''
  55. };
  56. },
  57. computed: {
  58. userServerInfo() {
  59. //用户服务器信息
  60. return this.$store.state.userinfo
  61. }
  62. },
  63. onShow() {
  64. // const data = uni.getStorageSync('userServerInfo')
  65. // this.$store.commit('GETUSERSERVERINFO', data)
  66. this.getGiftList()
  67. this.getBound()
  68. },
  69. onPullDownRefresh() {
  70. this.getGiftList()
  71. this.getBound()
  72. setTimeout(function() {
  73. uni.stopPullDownRefresh()
  74. }, 1500);
  75. },
  76. methods: {
  77. goAddress() {
  78. uni.navigateTo({
  79. url: "../zbs-addAddress/addAddress"
  80. })
  81. },
  82. getGiftList() {
  83. // uni.showLoading();
  84. api_getExchangeList().then(res => {
  85. if (res.code == 200) {
  86. //获取兑换礼品列表
  87. this.list = res.data.list;
  88. console.log(res.data.list)
  89. // uni.hideLoading();
  90. } else {
  91. uni.showToast({
  92. title: res.message || '获取失败',
  93. duration: 2000,
  94. icon: 'none'
  95. })
  96. }
  97. });
  98. },
  99. getBound() {
  100. GetInte({ user_id: this.userServerInfo.id }).then(res => {
  101. //获取jiang xue jin
  102. this.integral = res.data.integral
  103. console.log(res.data.integral)
  104. });
  105. },
  106. exchangerecord() {
  107. //进入兑换记录页面
  108. uni.navigateTo({
  109. url: '../zbs-exchangerecord/exchangerecord'
  110. })
  111. },
  112. priview(src) {
  113. // 预览
  114. uni.previewImage({
  115. urls: [src]
  116. });
  117. },
  118. exchange(data) {
  119. if (data.surplus) {
  120. //如果有货
  121. // getApp().globalData.detail = data; //把兑换列表保存到 globalData 中
  122. uni.navigateTo({
  123. url: '../zbs-detail/detail?item=' + encodeURIComponent(JSON.stringify(data))
  124. });
  125. } else {
  126. uni.showModal({
  127. content: '来晚了!礼品已兑换完毕!再看看别的吧!',
  128. showCancel: false
  129. });
  130. }
  131. }
  132. }
  133. };
  134. </script>
  135. <style lang="scss" scoped>
  136. .flexCC {
  137. display: flex;
  138. flex-direction: column;
  139. justify-content: center;
  140. align-items: center;
  141. }
  142. .share_show {
  143. width: 100%;
  144. height: 100vh;
  145. position: fixed;
  146. top: 0;
  147. left: 0;
  148. background-color: rgba(0, 0, 0, 0.7);
  149. z-index: 9999;
  150. .share_con {
  151. width: 80%;
  152. margin: 0 auto;
  153. height: 100%;
  154. z-index: 999999;
  155. .canvas {
  156. width: 540rpx;
  157. height: 960rpx;
  158. position: relative;
  159. #canvas {
  160. width: 540rpx;
  161. height: 960rpx;
  162. position: absolute;
  163. top: 0;
  164. left: 0;
  165. }
  166. .poster_img {
  167. -webkit-touch-callout: default;
  168. width: 540rpx;
  169. height: 960rpx;
  170. display: block;
  171. }
  172. img[src=''],
  173. img:not([src]) {
  174. opacity: 0;
  175. }
  176. }
  177. .save_img {
  178. color: #fff;
  179. width: 100%;
  180. text-align: center;
  181. font-size: 40rpx;
  182. margin-top: 20rpx;
  183. }
  184. .iconfont {
  185. position: absolute;
  186. top: 4vh;
  187. right: 25rpx;
  188. color: #dedede;
  189. font-size: 60rpx;
  190. z-index: 999;
  191. }
  192. }
  193. .sub_btn {
  194. margin-top: 76rpx;
  195. }
  196. }
  197. page {
  198. height: auto;
  199. display: flex;
  200. flex-direction: column;
  201. // .status_bar {
  202. // width: 100vw;
  203. // position: relative;
  204. // z-index: 10;
  205. // margin: 0;
  206. // .nav_box {
  207. // width: 100%;
  208. // padding: 0 20px;
  209. // font-size: 40rpx;
  210. // .back {
  211. // margin-right: 8rpx;
  212. // }
  213. // }
  214. // position: fixed;
  215. // top: 0;
  216. // padding-top: 40rpx;
  217. // left: 25rpx;
  218. // height: 128rpx;
  219. // z-index: 1000;
  220. // line-height: 88rpx;
  221. // background-color: #fff;
  222. // width: 100%;
  223. // display: flex;
  224. // justify-content: space-between;
  225. // align-items: center;
  226. // }
  227. .giftContainer {
  228. flex: 1;
  229. overflow: hidden;
  230. padding: 30rpx;
  231. box-sizing: border-box;
  232. // margin-top: 110rpx;
  233. .message {
  234. width: 100%;
  235. display: flex;
  236. align-items: center;
  237. padding: 0 42rpx 0 14rpx;
  238. box-sizing: border-box;
  239. background-color: #fff4f3;
  240. height: 62rpx;
  241. border-radius: 62rpx;
  242. margin-bottom: 30rpx;
  243. .icon {
  244. width: 128rpx;
  245. height: 46rpx;
  246. background: linear-gradient(88deg, #ffc401 0%, #fe2400 41%, #fe0000 100%);
  247. border-radius: 45rpx;
  248. display: flex;
  249. align-items: center;
  250. justify-content: center;
  251. color: #ffffff;
  252. font-size: 28rpx;
  253. margin-right: 14rpx;
  254. &::before {
  255. content: '';
  256. display: block;
  257. width: 28rpx;
  258. height: 28rpx;
  259. background: url(../../static/gift/1.png) 100% center no-repeat;
  260. background-size: 100%;
  261. margin-right: 6rpx;
  262. }
  263. }
  264. .text {
  265. flex: 1;
  266. height: 40rpx;
  267. overflow: hidden;
  268. .scroll {
  269. height: 40rpx;
  270. line-height: 40rpx;
  271. white-space: nowrap;
  272. color: #ea4a41;
  273. font-weight: 28rpx;
  274. animation: scroll-left-right 12s linear infinite;
  275. }
  276. }
  277. }
  278. .banner {
  279. width: 100%;
  280. height: 240rpx;
  281. background: linear-gradient(270deg, #f97c55 0%, #f44545 100%);
  282. border-top-left-radius: 24rpx;
  283. border-top-right-radius: 24rpx;
  284. position: relative;
  285. padding: 60rpx 40rpx;
  286. box-sizing: border-box;
  287. display: flex;
  288. flex-direction: column;
  289. justify-content: space-between;
  290. margin-bottom: 30rpx;
  291. .num {
  292. color: #ffffff;
  293. font-size: 32rpx;
  294. line-height: 44rpx;
  295. .spec {
  296. font-size: 76rpx;
  297. margin-right: 10rpx;
  298. }
  299. margin-bottom: 10rpx;
  300. }
  301. .mingxi {
  302. width: 184rpx;
  303. height: 64rpx;
  304. background: linear-gradient(180deg, #FCEAC0 0%, #FFD57D 100%);
  305. border-radius: 32rpx;
  306. color: #FB231F;
  307. font-size: 28rpx;
  308. text-align: center;
  309. line-height: 64rpx;
  310. }
  311. &::after {
  312. content: '';
  313. display: block;
  314. width: calc(100% + 30rpx);
  315. height: 28rpx;
  316. background: linear-gradient(180deg, rgba(234, 74, 65, 0) 0%, rgba(234, 74, 65, 0.35) 100%);
  317. border-radius: 28rpx;
  318. position: absolute;
  319. left: -15rpx;
  320. right: -15rpx;
  321. bottom: -14rpx;
  322. }
  323. &::before {
  324. content: '';
  325. display: block;
  326. width: 170rpx;
  327. height: 170rpx;
  328. background-image: url('https://api.jiuweiyun.cn/public/uploads/weapp/icon/2.png');
  329. background-position: center;
  330. background-size: 100%;
  331. background-repeat: no-repeat;
  332. position: absolute;
  333. top: 50%;
  334. right: 30rpx;
  335. transform: translateY(-50%);
  336. }
  337. }
  338. .fixedHeader {
  339. width: 100%;
  340. display: flex;
  341. align-items: center;
  342. justify-content: space-between;
  343. margin-bottom: 30rpx;
  344. .num {
  345. display: flex;
  346. align-items: center;
  347. color: #333333;
  348. font-size: 32rpx;
  349. line-height: 56rpx;
  350. .spec {
  351. color: #ea4a41;
  352. font-size: 40rpx;
  353. }
  354. &::before {
  355. content: '';
  356. display: block;
  357. width: 40rpx;
  358. height: 40rpx;
  359. background-image: url(../../static/gift/3.png);
  360. background-size: 100%;
  361. background-position: center;
  362. background-repeat: no-repeat;
  363. margin-right: 10rpx;
  364. }
  365. }
  366. .title {
  367. display: flex;
  368. align-items: center;
  369. color: #999999;
  370. font-size: 32rpx;
  371. &::before {
  372. content: '';
  373. display: block;
  374. width: 34rpx;
  375. height: 34rpx;
  376. background-image: url(../../static/gift/4.png);
  377. background-size: 100%;
  378. background-position: center;
  379. background-repeat: no-repeat;
  380. margin-right: 10rpx;
  381. }
  382. }
  383. }
  384. .list {
  385. width: 100%;
  386. .item {
  387. width: 100%;
  388. display: flex;
  389. align-items: stretch;
  390. justify-content: space-between;
  391. margin-bottom: 30rpx;
  392. .avatar {
  393. width: 260rpx;
  394. height: 260rpx;
  395. background-color: #f9f9fb;
  396. position: relative;
  397. border-radius: 16rpx;
  398. display: flex;
  399. align-items: center;
  400. justify-content: center;
  401. margin-right: 20rpx;
  402. background-position: center;
  403. background-repeat: no-repeat;
  404. background-size: 100%;
  405. overflow: hidden;
  406. .none {
  407. position: absolute;
  408. top: 0;
  409. bottom: 0;
  410. right: 0;
  411. left: 0;
  412. background: rgba(0, 0, 0, 0.5);
  413. display: flex;
  414. align-items: center;
  415. justify-content: center;
  416. color: #ffffff;
  417. font-size: 32rpx;
  418. }
  419. }
  420. .info {
  421. flex: 1;
  422. overflow: hidden;
  423. display: flex;
  424. flex-direction: column;
  425. justify-content: space-between;
  426. .title {
  427. color: #333333;
  428. font-size: 32rpx;
  429. line-height: 44rpx;
  430. width: 100%;
  431. height: 44rpx;
  432. overflow: hidden;
  433. font-weight: bold;
  434. margin-bottom: 20rpx;
  435. }
  436. &-num {
  437. display: flex;
  438. align-items: center;
  439. justify-content: space-between;
  440. margin-bottom: 70rpx;
  441. .info-other {
  442. color: #ea4a41;
  443. font-size: 28rpx;
  444. height: 52rpx;
  445. line-height: 52rpx;
  446. padding: 0 10rpx;
  447. border-radius: 8rpx;
  448. background-color: #fff4f3;
  449. }
  450. .info-status {
  451. color: #ffffff;
  452. font-size: 28rpx;
  453. height: 44rpx;
  454. line-height: 44rpx;
  455. padding: 0 14rpx;
  456. background-color: #ffbb01;
  457. border-top-left-radius: 16rpx;
  458. border-bottom-right-radius: 16rpx;
  459. }
  460. }
  461. .bottom {
  462. display: flex;
  463. align-items: center;
  464. justify-content: space-between;
  465. .money {
  466. color: #ea4a41;
  467. font-size: 24rpx;
  468. .spec {
  469. font-size: 40rpx !important;
  470. }
  471. }
  472. .btn {
  473. height: 68rpx;
  474. border-radius: 68rpx;
  475. background: linear-gradient(141deg, #f97c55 0%, #f44545 100%);
  476. line-height: 68rpx;
  477. width: 192rpx;
  478. text-align: center;
  479. color: #ffffff;
  480. font-size: 28rpx;
  481. &.disabled {
  482. background: #f8f8f8 !important;
  483. color: #999999;
  484. }
  485. }
  486. }
  487. }
  488. }
  489. }
  490. }
  491. }
  492. .exchange {
  493. // @include page();
  494. .content {
  495. display: flex;
  496. flex-direction: column;
  497. .scroll {
  498. height: 50rpx;
  499. line-height: 50rpx;
  500. background: rgba(250, 99, 66, 0.2);
  501. display: flex;
  502. align-items: center;
  503. color: #fa6342;
  504. text {
  505. font-size: 40rpx;
  506. color: #fa6342;
  507. margin-left: 30rpx;
  508. }
  509. .scroll-wrapper {
  510. flex: 1;
  511. height: 100%;
  512. overflow: hidden;
  513. .scroller {
  514. height: 100%;
  515. white-space: nowrap;
  516. font-size: 26rpx;
  517. padding-left: 10rpx;
  518. animation: scroll-left-right 12s linear infinite;
  519. }
  520. }
  521. }
  522. .banner {
  523. width: 100%;
  524. height: 216rpx;
  525. }
  526. .nav {
  527. height: 76rpx;
  528. box-sizing: border-box;
  529. padding: 0 30rpx;
  530. border-bottom: 6rpx solid #eeeeee;
  531. display: flex;
  532. justify-content: space-between;
  533. align-items: center;
  534. font-size: 32rpx;
  535. view {
  536. height: 100%;
  537. display: flex;
  538. align-items: center;
  539. .cuIcon {
  540. font-size: 40rpx;
  541. margin-right: 12rpx;
  542. }
  543. }
  544. }
  545. .list {
  546. flex: 1;
  547. scroll-view {
  548. box-sizing: border-box;
  549. padding: 0 30rpx 0;
  550. }
  551. }
  552. }
  553. }
  554. @keyframes scroll-left-right {
  555. 0% {
  556. transform: translateX(100%);
  557. }
  558. 100% {
  559. transform: translateX(-100%);
  560. }
  561. }
  562. </style>