show-result.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <uni-popup class="cartoon-main" ref="prize" mode="top" :mask="false">
  3. <view class="cartoon">
  4. <view :class="['payMoney', explode && 'xianshi']">
  5. <view class="payMoneyBox">
  6. <view class="close-btn" @click="payclose()"><image src="https://www.chaomangdao.com/image/home/guanbi@2x.png" mode=""></image></view>
  7. >
  8. <!-- 1开 -->
  9. <view :class="['money-buniss', 'center', 'buy1', 'tag-' + tag, scale && 'money-buniss-balance']" v-if="mode == 0">
  10. <view class="xuanzhuan"></view>
  11. <view class="applybc">
  12. <image class="xuanzhuanBg" :src="tagImg" mode="aspectFit"></image>
  13. <text class="xuanzhuanFont">{{ tagText }}</text>
  14. </view>
  15. <image class="onlyone" v-if="prizedata && prizedata.prizeInfo" :src="prizedata.prizeInfo[0].image" mode="widthFix"></image>
  16. <text class="box-font" v-if="prizedata && prizedata.prizeInfo">{{ prizedata.prizeInfo[0].goods_name }}</text>
  17. <text class="box-font" v-if="prizedata && prizedata.prizeInfo">¥{{ prizedata.prizeInfo[0].coin_price }}</text>
  18. </view>
  19. <!-- 5开or10开 -->
  20. <view class="money-list" :class="'money-list-' + mode" v-else>
  21. <view :class="['money-list-item', 'buy2', 'flex', 'tag-' + tagFun(item)]" v-for="(item, index) in prizedata.prizeInfo" :key="index">
  22. <view class="applybc">
  23. <image class="xuanzhuanBg" :src="tagImgFun(item)" mode="aspectFit"></image>
  24. <text class="xuanzhuanFont">{{ tagTextFun(item) }}</text>
  25. </view>
  26. <image class="hengduo" :src="item.image" mode="widthFix"></image>
  27. <view class="name">{{ item.goods_name }}</view>
  28. <view class="money">¥{{ item.coin_price }}</view>
  29. </view>
  30. </view>
  31. <view class="money-btnBox" :class="'money-btnBox-' + mode" v-if="type == 0">
  32. <!-- 立即收下 -->
  33. <view class="money-btn goumai" @click="shouxia()">立即收下</view>
  34. <!-- 一键回收 -->
  35. <view class="money-btn huishou" @click="huishou()">一键回收</view>
  36. </view>
  37. <view class="tryplay center" v-else>试玩结果仅供展示哦~</view>
  38. </view>
  39. </view>
  40. <view v-show="!hide" class="donghua" @click="showAnimation">
  41. <view :class="['donghua-box', explode && 'explode']">
  42. <view :animation="boxAnimation"><image :src="boxImg" mode="heightFix" class="box"></image></view>
  43. <image src="https://www.chaomangdao.com/image/result/halo.png" mode="heightFix" class="halo"></image>
  44. </view>
  45. <view class="shouzhi" v-if="!isopen"><image src="https://www.chaomangdao.com/image/ss.gif" mode=""></image></view>
  46. </view>
  47. </view>
  48. </uni-popup>
  49. </template>
  50. <script>
  51. export default {
  52. name: 'show-result',
  53. props: {
  54. //数量
  55. num: Number,
  56. /**
  57. * 类型 0:正式开盒 1:试玩
  58. */
  59. type: {
  60. type: Number,
  61. default: 0
  62. }
  63. },
  64. data() {
  65. return {
  66. //奖品列表
  67. prizedata: [],
  68. //特效
  69. scale: false,
  70. //开盒动画
  71. openLoading: true,
  72. boxImg: 'https://www.chaomangdao.com/image/result/box.png',
  73. //动画
  74. boxAnimation: {},
  75. animationTime: 100,
  76. explode: false,
  77. hide: false,
  78. isopen: false
  79. };
  80. },
  81. computed: {
  82. //开盒模式 0:1抽 1:5抽 2:9抽
  83. mode() {
  84. switch (this.num) {
  85. case 5:
  86. return 1;
  87. case 9:
  88. return 2;
  89. }
  90. return 0;
  91. },
  92. //当前单抽商品
  93. currPrizedata() {
  94. if (!this.prizedata) {
  95. return null;
  96. }
  97. if (!this.prizedata.prizeInfo || this.prizedata.length < 1) {
  98. return null;
  99. }
  100. return this.prizedata.prizeInfo[0];
  101. },
  102. //单抽商品品质
  103. tag() {
  104. return this.tagFun(this.currPrizedata);
  105. },
  106. //单抽品质文本
  107. tagText() {
  108. return this.tagTextFun(this.currPrizedata);
  109. },
  110. //单抽品质角标
  111. tagImg() {
  112. return this.tagImgFun(this.currPrizedata);
  113. }
  114. },
  115. methods: {
  116. //盒子抖动
  117. shake: function(animation) {
  118. let time = 0;
  119. const duration = 90;
  120. for (var i = 0; i < 20; i++) {
  121. let rotate = -10;
  122. let scaleY = 1.1;
  123. if (i % 2 != 0) {
  124. rotate = 0;
  125. scaleY = 1;
  126. }
  127. animation
  128. .rotate(rotate)
  129. .scaleY(scaleY)
  130. .step({
  131. duration
  132. });
  133. time += duration;
  134. }
  135. return time;
  136. },
  137. //盒子压缩
  138. compress: function(animation) {
  139. const duration = 100;
  140. animation
  141. .translateY('5vh')
  142. .scaleY(0.9)
  143. .scaleX(1.2)
  144. .step({
  145. duration
  146. });
  147. return duration;
  148. },
  149. //盒子跳跃
  150. jump: function(animation) {
  151. const duration = 150;
  152. animation
  153. .translateY('-50vh')
  154. .scaleY(1.1)
  155. .scaleX(0.9)
  156. .step({
  157. duration
  158. });
  159. return duration;
  160. },
  161. open(prizedata) {
  162. prizedata.boxImg && (this.boxImg = prizedata.boxImg);
  163. //打开结果
  164. this.$refs.prize.open();
  165. //加载动画
  166. this.prizedata = prizedata;
  167. // this.$nextTick(() => {
  168. // this.showAnimation();
  169. // });
  170. },
  171. showAnimation() {
  172. this.isopen = true;
  173. let animation = uni.createAnimation();
  174. this.animationTime += this.shake(animation);
  175. this.animationTime += this.compress(animation);
  176. this.animationTime += this.jump(animation);
  177. this.animation = animation;
  178. this.boxAnimation = animation.export();
  179. console.log(this.animationTime, '动画时长');
  180. setTimeout(() => {
  181. this.explode = true;
  182. this.hide = true;
  183. // this.hideAnimation();
  184. if (this.tag != 'normal') {
  185. //开启震动
  186. try {
  187. uni.vibrateShort({
  188. success: function() {
  189. console.log('震动');
  190. }
  191. });
  192. } catch (e) {
  193. console.log(e);
  194. }
  195. //开启效果
  196. // this.scale = true
  197. // setTimeout(() => {
  198. // this.scale = false
  199. // }, 1000)
  200. }
  201. }, this.animationTime);
  202. },
  203. hideAnimation() {
  204. setTimeout(() => {
  205. this.hide = true;
  206. }, 1300);
  207. },
  208. //关闭
  209. payclose() {
  210. this.animationTime = 0;
  211. this.explode = false;
  212. this.hide = false;
  213. this.isopen = false;
  214. this.$emit('close');
  215. this.$refs.prize.close();
  216. },
  217. //商品品质
  218. tagFun(prizeInfo) {
  219. if (!prizeInfo) return null;
  220. return prizeInfo.tag;
  221. },
  222. //品质文本
  223. tagTextFun(prizeInfo) {
  224. if (!prizeInfo) return null;
  225. if (prizeInfo.tag == 'normal') {
  226. return '普通';
  227. }
  228. if (prizeInfo.tag == 'rare') {
  229. return '稀有';
  230. }
  231. if (prizeInfo.tag == 'supreme') {
  232. return '史诗';
  233. }
  234. if (prizeInfo.tag == 'legend') {
  235. return '传说';
  236. }
  237. },
  238. //品质角标
  239. tagImgFun(prizeInfo) {
  240. if (!prizeInfo) return null;
  241. if (prizeInfo.tag == 'normal') {
  242. return 'https://www.chaomangdao.com/image/tag-1.png';
  243. }
  244. if (prizeInfo.tag == 'rare') {
  245. return 'https://www.chaomangdao.com/image/tag-2.png';
  246. }
  247. if (prizeInfo.tag == 'supreme') {
  248. return 'https://www.chaomangdao.com/image/tag-3.png';
  249. }
  250. if (prizeInfo.tag == 'legend') {
  251. return 'https://www.chaomangdao.com/image/tag-4.png';
  252. }
  253. },
  254. shouxia() {
  255. this.$refs.prize.close();
  256. this.$emit('accept');
  257. },
  258. huishou() {
  259. this.$refs.prize.close();
  260. uni.showModal({
  261. cancelText: '取消',
  262. confirmText: '确认',
  263. title: '一键回收',
  264. content: '是否确认一键回收?',
  265. success: res => {
  266. if (res.confirm) {
  267. this.$emit('recycle', this.prizedata);
  268. }
  269. }
  270. });
  271. }
  272. }
  273. };
  274. </script>
  275. <style lang="scss">
  276. .buy1 {
  277. height: 372rpx;
  278. width: 352rpx;
  279. border-radius: 26rpx;
  280. background-color: #fff;
  281. }
  282. .buy2 {
  283. width: 176rpx;
  284. border-radius: 13rpx;
  285. background-color: #fff;
  286. }
  287. .cartoon-main {
  288. z-index: 9999;
  289. .cartoon {
  290. background-image: url('https://www.chaomangdao.com/image/kjbg.jpg');
  291. position: fixed;
  292. bottom: 0;
  293. left: 0;
  294. background-repeat: no-repeat;
  295. background-size: 100% 100%;
  296. }
  297. }
  298. .payMoney {
  299. transform: scale(0);
  300. opacity: 0;
  301. transition: 0.2s;
  302. width: 750rpx;
  303. height: 100vh;
  304. display: flex;
  305. justify-content: center;
  306. &.xianshi {
  307. transform: scale(1);
  308. opacity: 1;
  309. }
  310. .payMoneyBox {
  311. width: 100%;
  312. height: 1120rpx;
  313. position: relative;
  314. flex-direction: column;
  315. // background: url(static/image/result/guang@2x.png) no-repeat;
  316. background-size: 100% auto;
  317. background-position: top;
  318. background-repeat: no-repeat;
  319. .close-btn {
  320. width: 64rpx;
  321. height: 64rpx;
  322. top: 280rpx;
  323. right: 30rpx;
  324. position: absolute;
  325. z-index: 999999;
  326. }
  327. .prize-top {
  328. width: 528rpx;
  329. height: 270rpx;
  330. position: absolute;
  331. top: 120rpx;
  332. left: 118rpx;
  333. &-2 {
  334. top: 40rpx;
  335. }
  336. }
  337. .money-btnBox {
  338. width: 100%;
  339. &-2 {
  340. bottom: -200rpx;
  341. }
  342. .money-btn {
  343. height: 84rpx;
  344. border-radius: 16rpx;
  345. position: absolute;
  346. }
  347. .goumai {
  348. bottom: 0rpx;
  349. background-image: -webkit-linear-gradient(0deg, #89f7fe 0%, #66a6ff 100%);
  350. font-size: 38rpx;
  351. text-align: center;
  352. line-height: 86rpx;
  353. width: 159px;
  354. border-radius: 8px;
  355. position: absolute;
  356. left: 40rpx;
  357. color: #ffffff;
  358. font-weight: bold;
  359. }
  360. .huishou {
  361. bottom: 0rpx;
  362. background-image: -webkit-linear-gradient(60deg, #ffc8de 0%, #ff67a4 100%);
  363. font-size: 38rpx;
  364. text-align: center;
  365. line-height: 86rpx;
  366. right: 40rpx;
  367. width: 159px;
  368. color: #ffffff;
  369. font-weight: bold;
  370. }
  371. }
  372. }
  373. .tryplay {
  374. background: url(https://www.chaomangdao.com/image/open/tanchuangbeijing@2x.png) no-repeat;
  375. background-size: cover;
  376. }
  377. .money-list {
  378. width: 566rpx;
  379. // padding: 0 92rpx;
  380. display: flex;
  381. flex-wrap: wrap;
  382. justify-content: space-between;
  383. position: absolute;
  384. top: 336rpx;
  385. left: 92rpx;
  386. &-2 {
  387. top: 360rpx;
  388. }
  389. &::after {
  390. content: '';
  391. width: 176rpx;
  392. }
  393. }
  394. // .scroll-view {
  395. // width: 522rpx;
  396. // white-space:nowrap;
  397. .money-list-item {
  398. margin-bottom: 16rpx;
  399. position: relative;
  400. width: 176rpx;
  401. display: flex;
  402. flex-direction: column;
  403. align-items: center;
  404. justify-content: center;
  405. display: flex;
  406. padding: 8rpx;
  407. // margin-right: 20rpx;
  408. box-sizing: border-box;
  409. .hengduo {
  410. width: 176rpx;
  411. height: 176rpx;
  412. }
  413. .name {
  414. font-size: 24rpx;
  415. // font-family: PingFangSC-Medium, PingFang SC;
  416. font-weight: 500;
  417. color: #171a20;
  418. width: 146rpx;
  419. overflow: hidden;
  420. white-space: nowrap;
  421. text-overflow: ellipsis;
  422. }
  423. .money {
  424. margin-top: 6rpx;
  425. font-size: 24rpx;
  426. font-weight: 500;
  427. color: #171a20;
  428. }
  429. .applybc {
  430. position: absolute;
  431. top: 0;
  432. left: 0;
  433. z-index: 9999999;
  434. width: 3rem;
  435. height: 3rem;
  436. .xuanzhuanBg {
  437. width: 100%;
  438. height: 100%;
  439. }
  440. .xuanzhuanFont {
  441. font-size: 0.6rem !important;
  442. position: absolute;
  443. position: absolute;
  444. top: 30%;
  445. left: 30%;
  446. color: #fff !important;
  447. width: auto !important;
  448. transform: translateX(-50%) translateY(-50%) rotate(-45deg);
  449. }
  450. }
  451. }
  452. // }
  453. .money-buniss {
  454. transition: 1s;
  455. position: absolute;
  456. top: 336rpx;
  457. left: 198rpx;
  458. display: flex;
  459. flex-direction: column;
  460. .xuanzhuan {
  461. z-index: -1;
  462. height: 150vh;
  463. width: 150vh;
  464. background-image: url(https://www.chaomangdao.com/image/result/spining.png);
  465. background-repeat: no-repeat;
  466. background-size: 100% 100%;
  467. position: absolute;
  468. }
  469. image {
  470. width: 174rpx;
  471. height: 235rpx;
  472. margin-bottom: 20rpx;
  473. }
  474. text {
  475. width: 70%;
  476. font-size: 16rpx;
  477. font-family: PingFangSC-Medium, PingFang SC;
  478. font-weight: 500;
  479. color: #171a20;
  480. overflow: hidden;
  481. white-space: nowrap;
  482. text-overflow: ellipsis;
  483. text-align: center;
  484. }
  485. .box-font {
  486. font-size: 32rpx !important;
  487. font-family: PingFangSC-Medium, PingFang SC;
  488. font-weight: 500;
  489. color: #171a20;
  490. }
  491. .applybc {
  492. position: absolute;
  493. top: -2rpx;
  494. left: -2rpx;
  495. z-index: 9999999;
  496. width: 5rem;
  497. height: 5rem;
  498. .xuanzhuanBg {
  499. width: 100%;
  500. height: 100%;
  501. }
  502. .xuanzhuanFont {
  503. font-size: 1rem;
  504. position: absolute;
  505. top: 30%;
  506. left: 30%;
  507. color: #fff !important;
  508. width: auto !important;
  509. transform: translateX(-50%) translateY(-50%) rotate(-45deg);
  510. }
  511. }
  512. }
  513. .tag-normal {
  514. box-shadow: 0 0 40rpx 18rpx #9d85ff;
  515. }
  516. .tag-rare {
  517. box-shadow: 0 0 40rpx 18rpx #47a8ff;
  518. }
  519. .tag-supreme {
  520. box-shadow: 0 0 40rpx 32rpx #feb337;
  521. }
  522. .tag-legend {
  523. box-shadow: 0 0 40rpx 32rpx #fe615e;
  524. }
  525. .tryplay {
  526. width: 399rpx;
  527. height: 48rpx;
  528. color: #ffffff;
  529. font-size: 30rpx;
  530. margin-top: 40rpx;
  531. background: #000000;
  532. border-radius: 27rpx 27rpx 27rpx 27rpx;
  533. }
  534. }
  535. .money-buniss-balance {
  536. transform: scale(1.3);
  537. }
  538. .donghua {
  539. z-index: 999;
  540. position: fixed;
  541. top: -180rpx;
  542. left: 0;
  543. height: 100vh;
  544. width: 100vw;
  545. display: flex;
  546. align-items: flex-end;
  547. justify-content: center;
  548. .shouzhi {
  549. position: absolute;
  550. bottom: 100rpx;
  551. width: 400rpx;
  552. height: 400rpx;
  553. }
  554. .donghua-box {
  555. margin-bottom: 10vh;
  556. image {
  557. height: 360rpx;
  558. }
  559. .halo {
  560. opacity: 1;
  561. transform: scale(0);
  562. position: absolute;
  563. top: 0;
  564. }
  565. &.explode {
  566. .box {
  567. transition: 0.3s;
  568. opacity: 0;
  569. transform: scale(0);
  570. }
  571. .halo {
  572. transition: 1.2s;
  573. opacity: 0;
  574. transform: scale(5);
  575. }
  576. }
  577. }
  578. }
  579. @keyframes rotate {
  580. from {
  581. transform: rotate(0deg);
  582. }
  583. to {
  584. transform: rotate(360deg);
  585. }
  586. }
  587. .xuanzhuan {
  588. transition: 0.3s;
  589. animation: rotate 10s linear infinite;
  590. /*开始动画后无限循环,用来控制rotate*/
  591. }
  592. </style>