red-packet.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <div class="content">
  3. <!-- open -->
  4. <div v-if="data.status == 'opened'" class="opened">
  5. <div class="header">
  6. <div class="title">Awesome! You Will Get</div>
  7. <div class="money">
  8. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  9. <span class="big">1.23</span>
  10. <span class="small">USD</span>
  11. </div>
  12. </div>
  13. <div class="list">
  14. <div class="item" v-for="item, i in data.list" v-bind:key="i">
  15. <img :src="item.url" alt />
  16. <div class="item-content">
  17. <div class="item-title">{{ item.title }}</div>
  18. <span>@shasid \!@asd</span>
  19. </div>
  20. <div class="btn">{{ item.title }}</div>
  21. </div>
  22. </div>
  23. <div class="people">
  24. <div class="txt">Total $100 USD,173/1000 People Got</div>
  25. <div class="right" @click="clickRoad">
  26. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  27. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  28. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  29. <img :src="require('../assets/svg/icon-right.svg')" alt class="road" />
  30. </div>
  31. </div>
  32. <div class="footer">
  33. <div class="first">
  34. <div class="validity">Validity</div>
  35. <div class="time">23:57:32</div>
  36. </div>
  37. <div class="btn" @click="clickGetGiveways">Get Giveaways</div>
  38. </div>
  39. </div>
  40. <!-- success -->
  41. <div v-if="data.status == 'success'" class="success">
  42. <div class="header">
  43. <div class="money">
  44. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  45. <span class="big">1.23</span>
  46. <span class="small">USD</span>
  47. </div>
  48. </div>
  49. <div class="luck-list-title">
  50. <div>173/1000 People Got</div>
  51. <div>Total $100 USD</div>
  52. </div>
  53. <div class="luck-list">
  54. <div class="luck-item" v-for="item,index in data.luck_list" v-bind:key="index">
  55. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  56. <div class="luck-content">
  57. <div class="luck-title">{{item.title}}</div>
  58. <div class="luck-time">刚刚</div>
  59. </div>
  60. <div class="luck-money">
  61. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  62. <div class="luck-money-txt">123</div>
  63. </div>
  64. <div class="luck-king">
  65. <img :src="require('../assets/svg/icon-king-hat.svg')" alt />
  66. <span>Luckiest Draw</span>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. <!-- no-open -->
  72. <div v-if="data.status == 'not-open'" class="not-open">
  73. <img :src="require('../assets/img/up.png')" alt class="up" />
  74. <img :src="require('../assets/img/down.png')" alt class="down" />
  75. <div class="open" @click="clickOpenRedPacket">OPEN</div>
  76. </div>
  77. <!-- 领取列表 -->
  78. <div v-if="data.status == 'luck-peopel-list'" class="luck-peopel-list">
  79. <div class="head">
  80. <img :src="require('../assets/svg/icon-back.svg')" alt @click="clickBack" />
  81. </div>
  82. <div class="luck-list-title">
  83. <div>173/1000 People Got</div>
  84. <div>Total $100 USD</div>
  85. </div>
  86. <div class="luck-list">
  87. <div class="luck-item" v-for="item,i in data.luck_list" v-bind:key="i">
  88. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  89. <div class="luck-content">
  90. <div class="luck-title">{{item}}</div>
  91. <div class="luck-time">刚刚</div>
  92. </div>
  93. <div class="luck-money">
  94. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  95. <div class="luck-money-txt">123</div>
  96. </div>
  97. <div class="luck-king">
  98. <img :src="require('../assets/svg/icon-king-hat.svg')" alt />
  99. <span>Luckiest Draw</span>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </template>
  106. <script>
  107. export default {
  108. name: 'redPacket',
  109. }
  110. </script>
  111. <script setup>
  112. import { onMounted, reactive } from "vue";
  113. import { getPostDetail,getRedPacket} from '../server/redPacket.js'
  114. let data = reactive({
  115. status: '',
  116. list: [
  117. {
  118. title: 'Follow',
  119. url: require('../assets/svg/icon-follow.svg')
  120. },
  121. {
  122. title: 'Like',
  123. url: require('../assets/svg/icon-like.svg')
  124. }, {
  125. title: 'Retweet',
  126. url: require('../assets/svg/icon-retweet.svg')
  127. }
  128. ],
  129. luck_list: [
  130. {
  131. title: 'Retweet',
  132. url: require('../assets/svg/icon-retweet.svg')
  133. },
  134. {
  135. title: 'Retweet',
  136. url: require('../assets/svg/icon-retweet.svg')
  137. }
  138. ]
  139. })
  140. onMounted(()=>{
  141. getPostDetail().then((res)=>{
  142. if(res.data.myReceived){
  143. // 领取了红包
  144. data.status = 'opened'
  145. }else{
  146. data.status = 'not-open'
  147. }
  148. console.log(JSON.parse(res.data.postBizData))
  149. })
  150. })
  151. function clickOpenRedPacket() {
  152. data.status = 'opened'
  153. getRedPacket().then((res)=>{
  154. })
  155. }
  156. function clickGetGiveways() {
  157. data.status = 'success'
  158. }
  159. function clickBack() {
  160. data.status = 'opened'
  161. }
  162. function clickRoad(){
  163. data.status = 'luck-peopel-list'
  164. }
  165. </script>
  166. <style lang="scss">
  167. html,
  168. body {
  169. margin: 0;
  170. padding: 0;
  171. }
  172. .content {
  173. width: 375px;
  174. height: 500px;
  175. background: #fafafa;
  176. border-radius: 11px;
  177. font-family: "SF Pro Display";
  178. font-style: normal;
  179. .success,
  180. .luck-peopel-list {
  181. filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
  182. width: 100%;
  183. height: 100%;
  184. border-radius: 11px;
  185. background: #fff;
  186. .head {
  187. padding: 14px 16px;
  188. img {
  189. cursor: pointer;
  190. width: 24px;
  191. height: 24px;
  192. }
  193. }
  194. .header {
  195. text-align: center;
  196. height: 120px;
  197. width: 100%;
  198. background: #ef4545;
  199. padding-top: 30px;
  200. .title {
  201. color: #fff7e4;
  202. opacity: 0.6;
  203. font-weight: 700;
  204. font-size: 18px;
  205. line-height: 21px;
  206. letter-spacing: -0.3px;
  207. }
  208. .money {
  209. img {
  210. width: 40px;
  211. height: 40px;
  212. }
  213. .big {
  214. font-weight: 700;
  215. font-size: 46px;
  216. line-height: 55px;
  217. /* identical to box height */
  218. letter-spacing: 0.3px;
  219. color: #fff8e6;
  220. }
  221. .small {
  222. font-weight: 700;
  223. font-size: 13px;
  224. line-height: 16px;
  225. /* identical to box height */
  226. letter-spacing: 0.5px;
  227. color: #fff8e6;
  228. }
  229. }
  230. }
  231. .luck-list-title {
  232. padding: 0 16px;
  233. background: #fff;
  234. color: #9b9b9b;
  235. display: flex;
  236. justify-content: space-between;
  237. }
  238. .luck-list {
  239. background: #fff;
  240. .luck-item {
  241. display: flex;
  242. padding: 12px 16px;
  243. border-top: 1px solid #d1d1d1;
  244. justify-content: space-between;
  245. position: relative;
  246. .luck-king {
  247. position: absolute;
  248. top: 36px;
  249. right: 16px;
  250. display: flex;
  251. align-items: center;
  252. img {
  253. width: 22px;
  254. height: 19px;
  255. margin: 0;
  256. }
  257. span {
  258. font-weight: 500;
  259. font-size: 12px;
  260. line-height: 14px;
  261. letter-spacing: 0.3px;
  262. color: #f5b945;
  263. }
  264. }
  265. img {
  266. width: 42px;
  267. height: 42px;
  268. margin-right: 12px;
  269. }
  270. .luck-content {
  271. flex: auto;
  272. .luck-title {
  273. font-weight: 500;
  274. font-size: 16px;
  275. letter-spacing: 0.3px;
  276. color: #444444;
  277. }
  278. .luck-time {
  279. font-weight: 400;
  280. font-size: 12px;
  281. line-height: 14px;
  282. color: #9b9b9b;
  283. }
  284. }
  285. .luck-money {
  286. display: flex;
  287. height: 17px;
  288. align-items: center;
  289. img {
  290. width: 14px;
  291. height: 14px;
  292. margin-right: 6px;
  293. }
  294. .luck-money-txt {
  295. font-weight: 500;
  296. font-size: 14px;
  297. /* identical to box height */
  298. text-align: right;
  299. letter-spacing: 0.3px;
  300. color: #444444;
  301. }
  302. }
  303. }
  304. }
  305. }
  306. .opened {
  307. filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
  308. width: 100%;
  309. height: 100%;
  310. .header {
  311. text-align: center;
  312. height: 120px;
  313. width: 100%;
  314. background: #ef4545;
  315. padding-top: 30px;
  316. .title {
  317. color: #fff7e4;
  318. opacity: 0.6;
  319. font-weight: 700;
  320. font-size: 18px;
  321. line-height: 21px;
  322. letter-spacing: -0.3px;
  323. }
  324. .money {
  325. img {
  326. width: 40px;
  327. height: 40px;
  328. }
  329. .big {
  330. font-weight: 700;
  331. font-size: 46px;
  332. line-height: 55px;
  333. /* identical to box height */
  334. letter-spacing: 0.3px;
  335. color: #fff8e6;
  336. }
  337. .small {
  338. font-weight: 700;
  339. font-size: 13px;
  340. line-height: 16px;
  341. /* identical to box height */
  342. letter-spacing: 0.5px;
  343. color: #fff8e6;
  344. }
  345. }
  346. }
  347. .list {
  348. padding: 0 16px 0 16px;
  349. background: #ffffff;
  350. .item {
  351. display: flex;
  352. align-items: center;
  353. min-height: 50px;
  354. border-bottom: 1px solid #f0f0f0;
  355. img {
  356. width: 24px;
  357. height: 24px;
  358. }
  359. .item-content {
  360. flex: 1;
  361. .item-title {
  362. font-weight: 500;
  363. font-size: 16px;
  364. letter-spacing: 0.3px;
  365. color: #000000;
  366. }
  367. span {
  368. font-weight: 400;
  369. font-size: 11px;
  370. line-height: 13px;
  371. letter-spacing: 0.3px;
  372. color: #000000;
  373. opacity: 0.4;
  374. }
  375. }
  376. .btn {
  377. width: 72px;
  378. height: 29px;
  379. line-height: 29px;
  380. background: #389aff;
  381. border-radius: 500px;
  382. text-align: center;
  383. letter-spacing: 0.3px;
  384. color: #ffffff;
  385. cursor: pointer;
  386. }
  387. }
  388. .item:last-child {
  389. border: 0;
  390. }
  391. }
  392. .people {
  393. padding-left: 16px;
  394. height: 44px;
  395. line-height: 44px;
  396. background: #faf9f8;
  397. box-shadow: 0px 1px 0px #f2f2f2;
  398. display: flex;
  399. align-items: center;
  400. justify-content: space-between;
  401. .txt {
  402. font-weight: 400;
  403. font-size: 12px;
  404. line-height: 14px;
  405. letter-spacing: 0.3px;
  406. color: #000000;
  407. opacity: 0.4;
  408. }
  409. .right {
  410. cursor: pointer;
  411. margin-right: 22px;
  412. display: flex;
  413. align-items: center;
  414. img {
  415. width: 22px;
  416. height: 22px;
  417. }
  418. }
  419. }
  420. .footer {
  421. background: #ffffff;
  422. display: flex;
  423. padding: 20px 22px 20px 17px;
  424. .first {
  425. flex: 1;
  426. .validity {
  427. font-weight: 400;
  428. font-size: 12px;
  429. line-height: 14px;
  430. letter-spacing: 0.3px;
  431. color: #000000;
  432. opacity: 0.4;
  433. margin: 2px 0 8px 0;
  434. }
  435. .time {
  436. font-weight: 500;
  437. font-size: 13px;
  438. line-height: 16px;
  439. /* identical to box height */
  440. color: #000000;
  441. }
  442. }
  443. .btn {
  444. background: #ef4545;
  445. border-radius: 100px;
  446. color: #fff;
  447. width: 258px;
  448. height: 52px;
  449. font-weight: 600;
  450. font-size: 18px;
  451. line-height: 52px;
  452. text-align: center;
  453. cursor: pointer;
  454. }
  455. }
  456. }
  457. .not-open {
  458. filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
  459. position: relative;
  460. img {
  461. width: 100%;
  462. }
  463. .up {
  464. position: absolute;
  465. top: 0;
  466. box-shadow: 0px 4px 44px rgba(0, 0, 0, 0.1);
  467. z-index: 1;
  468. }
  469. .down {
  470. position: absolute;
  471. top: 253px;
  472. }
  473. .open {
  474. width: 110px;
  475. height: 110px;
  476. text-align: center;
  477. font-size: 26px;
  478. font-weight: 600;
  479. background: #ffe9b5;
  480. color: #ef4545;
  481. cursor: pointer;
  482. border-radius: 50%;
  483. line-height: 110px;
  484. position: absolute;
  485. top: 235px;
  486. left: 50%;
  487. margin-left: -55px;
  488. z-index: 2;
  489. }
  490. }
  491. }
  492. </style>