index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <template>
  2. <view class="container">
  3. <!-- 头部banner -->
  4. <view class="topBox">
  5. <image class="topImgBg" src="../../static/img/ganme01/gamebg.png" mode="widthFix"></image>
  6. <view class="leftGz">
  7. 规则
  8. </view>
  9. <view class="moneyIcon flex">
  10. <image class="icon" src="../../static/img/ganme01/icontb.png" mode="scaleToFill"></image>
  11. <text>55555</text>
  12. </view>
  13. <view class="jlBox flex">
  14. <image class="icon" src="../../static/img/ganme01/iconjlu.png" mode="scaleToFill"></image>
  15. <text>
  16. 记录>
  17. </text>
  18. </view>
  19. </view>
  20. <!-- 头部bannerEnd -->
  21. <view class="content" :style="{height:contentHeight+'px'}">
  22. <view class="listItem" v-for="(item,index) in list">
  23. <view class="line" v-if="index>0"></view>
  24. <view class="itemBox">
  25. <!-- 名次排行 -->
  26. <!-- 右侧头像 -->
  27. <view class="rightImgAv flex">
  28. <image class="imgAv" :src="`../../static/img/ganme01/xdw0${index+1}.png`" mode="widthFix">
  29. </image>
  30. </view>
  31. <!-- 右侧头像END -->
  32. <!-- 左侧详情 -->
  33. <view class="levelBox flex" :class="{noWin:index!=winIndex,win:index==winIndex}" :style="{marginRight:item.onEnd?0:''}">
  34. <view class="levelLeft flex">
  35. <view class="imgAvBox flex" :class="{noWin:index!=winIndex,win:index==winIndex}">
  36. <image class="imgAv" :src="`../../static/img/ganme01/xdw0${index+1}.png`"
  37. mode="widthFix">
  38. </image>
  39. </view>
  40. <view class="levelContent">
  41. <view class="levelItemName" :class="{noWin:index!=winIndex,win:index==winIndex}">
  42. {{item.name}}
  43. </view>
  44. <view class="levelItemEnName">
  45. {{item.enName}}
  46. </view>
  47. </view>
  48. <view class="rightTIp">
  49. </view>
  50. </view>
  51. <view class="levelRight">
  52. {{index}}
  53. </view>
  54. </view>
  55. <!-- 左侧详情END -->
  56. <!-- 名次排行END -->
  57. </view>
  58. </view>
  59. <image class="saidao" v-if="gameStart" src="../../static/img/ganme01/saidao.png" mode="widthFix"></image>
  60. </view>
  61. <view class="bottomBox">
  62. <!-- 底部标题 -->
  63. <view class="bottomTitle flex">
  64. <view class="titleLeft flex">
  65. <image class="titleRtip" src="../../static/img/ganme01/icongj.png" mode="widthFix"></image>
  66. <view class="title">
  67. 猜冠军
  68. </view>
  69. <view class="tip">
  70. 猜对得5倍积分
  71. </view>
  72. </view>
  73. <view class="titleRight flex">
  74. <image class="rightIcon" src="../../static/img/ganme01/iconrw.png" mode="widthFix"></image>
  75. <view class="rightNum">
  76. 12
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 底部标题END -->
  81. <!-- 动物列表 -->
  82. <view class="bottoItemList flex">
  83. <view v-for="(item,index) in list" class="item flex" @click="checkedItem(item.key)"
  84. :class="{itemchecked:checked==item.key}">
  85. <image class="itemIcon" :src="`../../static/img/ganme01/xdw0${index+1}.png`" mode="widthFix">
  86. </image>
  87. <view class="nameBox">
  88. <view class="name">
  89. {{item.name}}
  90. </view>
  91. <view class="nameTip">
  92. {{item.enName}}
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <!-- 动物列表END -->
  98. <view class="buttomBox flex">
  99. <!-- <image class="leftIcon" src="../../static/img/ganme01/iconDj.png" mode="widthFix"></image> -->
  100. <view class="buttom flex">
  101. <view class="buttomLeft flex">
  102. <view>
  103. <view class="name">
  104. 积分
  105. </view>
  106. <view class="num">
  107. 10
  108. </view>
  109. </view>
  110. </view>
  111. <view class="buttomRight flex">
  112. <view class="left">
  113. <view class="tip">
  114. 消耗10积分
  115. </view>
  116. <view class="tip">
  117. 才对可得50积分
  118. </view>
  119. </view>
  120. <view class="right flex" @click="onStart">
  121. <view class="cont">
  122. </view>
  123. <view>
  124. 竞猜
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. </view>
  132. </template>
  133. <script>
  134. import {
  135. mapState
  136. } from 'vuex';
  137. export default {
  138. computed: {
  139. contentHeight() {
  140. return this.heightMath.pageHeight - this.heightMath.bottomHeight - this.heightMath.bannerHeight + this
  141. .heightMath.cMathNum / this.pageWidth * 750
  142. }
  143. },
  144. data() {
  145. return {
  146. gameStart: false, //判断游戏是否结束
  147. winIndex: 0, //当前游戏排名第一的人
  148. checked: 1, //当前选中的要投票的人物
  149. heightMath: {
  150. pageHeight: 0,
  151. bannerHeight: 0,
  152. bottomHeight: 0,
  153. cMathNum: 30,
  154. },
  155. pageWidth: 0,
  156. list: [{
  157. key: 1,
  158. name: '小老虎',
  159. enName: 'Tiger',
  160. onEnd:false,
  161. },
  162. {
  163. key: 2,
  164. name: '大熊猫',
  165. enName: 'Panda',
  166. onEnd:false,
  167. },
  168. {
  169. key: 3,
  170. name: '小柴犬',
  171. enName: 'Shiba Inu',
  172. onEnd:false,
  173. },
  174. {
  175. key: 4,
  176. name: '小兔子',
  177. enName: 'Rabbit',
  178. onEnd:false,
  179. },
  180. {
  181. key: 5,
  182. name: '小鸭子',
  183. enName: 'Duck',
  184. onEnd:false,
  185. },
  186. {
  187. key: 6,
  188. name: '大棕熊',
  189. enName: 'Bear',
  190. onEnd:false,
  191. },
  192. ]
  193. };
  194. },
  195. onReady: function(option) {
  196. console.log('渲染完毕');
  197. let that = this;
  198. setTimeout((e) => {
  199. uni.createSelectorQuery().select(".topBox").fields({
  200. size: true,
  201. }, (e) => {
  202. that.heightMath.bannerHeight = e.height;
  203. console.log(e, '返回结果')
  204. }).exec();
  205. uni.createSelectorQuery().select(".bottomBox").fields({
  206. size: true,
  207. }, (e) => {
  208. that.heightMath.bottomHeight = e.height;
  209. console.log(e, '返回结果2')
  210. }).exec();
  211. uni.createSelectorQuery().select(".container").fields({
  212. size: true,
  213. }, (e) => {
  214. that.heightMath.pageHeight = e.height;
  215. that.pageWidth = e.width;
  216. console.log(e, '返回结果3')
  217. }).exec();
  218. }, 50)
  219. },
  220. onShow: function() {
  221. },
  222. methods: {
  223. // 选中的要投票的小动物
  224. checkedItem(ind) {
  225. this.checked = ind
  226. },
  227. // 开始竞猜
  228. onStart(){
  229. this.gameStart = true;
  230. const num = Math.floor(Math.random()*6);
  231. this.list[num].onEnd = true;
  232. }
  233. }
  234. };
  235. </script>
  236. <style lang="scss">
  237. page {
  238. height: 0;
  239. min-height: 100%;
  240. }
  241. .flex {
  242. display: flex;
  243. justify-content: space-between;
  244. align-items: center;
  245. }
  246. .buttomBox {
  247. padding-top: 10rpx;
  248. .leftIcon {
  249. width: 120rpx;
  250. margin-right: 20rpx;
  251. }
  252. .buttom {
  253. flex-grow: 1;
  254. border-radius: 20rpx;
  255. height: 110rpx;
  256. font-weight: bold;
  257. overflow: hidden;
  258. .buttomLeft {
  259. background: linear-gradient(0deg, #F5B231, #F5CA31);
  260. height: 100%;
  261. justify-content: center;
  262. min-width: 150rpx;
  263. .name {
  264. font-size: 24rpx;
  265. }
  266. .num {
  267. font-size: 48rpx;
  268. }
  269. }
  270. .buttomRight {
  271. flex-grow: 1;
  272. color: #FFFFFF;
  273. height: 100%;
  274. padding: 0 20rpx;
  275. background: linear-gradient(0deg, #E9254E, #F4869D);
  276. .left {
  277. font-size: 24rpx;
  278. line-height: 1.5;
  279. }
  280. .cont {
  281. height: 40rpx;
  282. width: 2px;
  283. background-color: #FFFFFF;
  284. margin-right: 40rpx;
  285. }
  286. .right {
  287. font-size: 60rpx;
  288. margin-right: 20rpx;
  289. }
  290. }
  291. }
  292. }
  293. .content {
  294. background: linear-gradient(0deg, #F2977C, #FFCBBC);
  295. padding-top: 10rpx;
  296. position: relative;
  297. .saidao {
  298. position: absolute;
  299. right: 170rpx;
  300. top: 0;
  301. width: 30rpx;
  302. }
  303. .listItem {
  304. .line {
  305. background: #FFFFFF;
  306. opacity: 0.6;
  307. width: 100%;
  308. height: 10rpx;
  309. }
  310. .itemBox {
  311. height: 100rpx;
  312. overflow: hidden;
  313. .levelBox {
  314. padding: 5rpx 50rpx;
  315. width: 400rpx;
  316. height: 100rpx;
  317. float: right;
  318. margin-right: 100%;
  319. transition:all 1s ease-out;
  320. &.win {
  321. background: linear-gradient(90deg, rgba(255, 113, 143, 0), #F5B231, rgba($color: #F5CA31, $alpha: 0.72), rgba(255, 113, 143, 0));
  322. }
  323. &.noWin {
  324. background: linear-gradient(90deg, rgba(255, 113, 143, 0), #FF718F, rgba(255, 113, 143, 0.72), rgba(255, 113, 143, 0));
  325. }
  326. .levelLeft {
  327. align-items: stretch;
  328. height: 90rpx;
  329. .imgAvBox {
  330. border: 2px solid #FFFFFF;
  331. border-radius: 999rpx;
  332. padding: 10rpx;
  333. z-index: 1;
  334. &.win {
  335. background-color: rgba($color: #F5CA31, $alpha: 1);
  336. }
  337. &.noWin {
  338. background-color: rgba(255, 113, 143, 1);
  339. }
  340. .imgAv {
  341. width: 70rpx;
  342. }
  343. }
  344. .rightTIp {
  345. height: 100%;
  346. border-bottom: 90rpx solid #FFFFFF;
  347. border-right: 45rpx solid rgba($color: #FFFFFF, $alpha: 0);
  348. }
  349. .levelContent {
  350. width: 150rpx;
  351. margin-left: -45rpx;
  352. align-self: stretch;
  353. height: 100%;
  354. background-color: #FFFFFF;
  355. color: #7B3C0E;
  356. font-weight: bold;
  357. .levelItemName {
  358. padding-left: 45rpx;
  359. font-size: 28rpx;
  360. line-height: 50rpx;
  361. &.win {
  362. background: linear-gradient(90deg, rgba($color: #F5CA31, $alpha: 0.72), rgba(255, 113, 143, 0));
  363. }
  364. &.noWin {
  365. background: linear-gradient(90deg, rgba(255, 113, 143, 0.72), rgba(255, 113, 143, 0));
  366. }
  367. }
  368. .levelItemEnName {
  369. padding-left: 45rpx;
  370. font-size: 20rpx;
  371. line-height: 1.5;
  372. }
  373. }
  374. }
  375. .levelRight {
  376. font-size: 60rpx;
  377. font-weight: bold;
  378. color: #FFFFFF;
  379. text-shadow: 0px 3rpx 7rpx rgba(0, 0, 0, 0.52);
  380. }
  381. }
  382. .rightImgAv {
  383. margin-right: 50rpx;
  384. margin-left: 60rpx;
  385. float: right;
  386. height: 100%;
  387. .imgAv {
  388. width: 90rpx;
  389. }
  390. }
  391. }
  392. }
  393. }
  394. .bottomBox {
  395. position: fixed;
  396. bottom: 0;
  397. left: 0;
  398. right: 0;
  399. border-top-left-radius: 50rpx;
  400. border-top-right-radius: 50rpx;
  401. background-image: url(../../static/img/ganme01/bottomBg.png);
  402. background-repeat: no-repeat;
  403. background-size: 100% auto;
  404. background-color: #F2977C;
  405. color: #7B3C0E;
  406. font-weight: bold;
  407. line-height: 1;
  408. padding: 0 20rpx;
  409. padding-bottom: 30rpx;
  410. .bottomTitle {
  411. padding: 30rpx 5rpx;
  412. .titleLeft {
  413. .titleRtip {
  414. width: 60rpx;
  415. margin-right: 10rpx;
  416. }
  417. .title {
  418. font-size: 38rpx;
  419. margin-right: 10rpx;
  420. }
  421. .tip {
  422. font-size: 28rpx;
  423. }
  424. }
  425. .titleRight {
  426. .rightIcon {
  427. width: 30rpx;
  428. margin-right: 5rpx;
  429. }
  430. .rightNum {
  431. font-size: 35rpx;
  432. }
  433. }
  434. }
  435. .bottoItemList {
  436. flex-wrap: wrap;
  437. .item {
  438. width: 225rpx;
  439. height: 110rpx;
  440. border: 3px solid #FFFFFF;
  441. border-radius: 15rpx;
  442. padding: 0 10rpx;
  443. margin-bottom: 20rpx;
  444. &.itemchecked {
  445. border-color: #FF2553;
  446. }
  447. .itemIcon {
  448. width: 90rpx;
  449. }
  450. .nameBox {
  451. .name {
  452. font-size: 28rpx;
  453. }
  454. .nameTip {
  455. font-size: 20rpx;
  456. }
  457. }
  458. }
  459. }
  460. }
  461. .container {
  462. line-height: 1;
  463. height: 100%;
  464. background-color: #F2977C;
  465. .topBox {
  466. position: relative;
  467. line-height: 0;
  468. .topImgBg {
  469. width: 750rpx;
  470. }
  471. .leftGz {
  472. width: 1.8rem;
  473. line-height: 1.3;
  474. background: #FFFFFF;
  475. opacity: 0.8;
  476. border-radius: 0rpx 10rpx 10rpx 0rpx;
  477. position: absolute;
  478. left: 0;
  479. bottom: 10rpx;
  480. color: $font-color;
  481. padding: 20rpx 10rpx;
  482. }
  483. .moneyIcon,
  484. .jlBox {
  485. line-height: 1;
  486. min-width: 180rpx;
  487. border-radius: 50rpx 0px 0px 50rpx;
  488. padding: 10rpx 20rpx;
  489. position: absolute;
  490. background-color: #7B3C0E;
  491. right: 0;
  492. .icon {
  493. width: 30rpx;
  494. height: 30rpx;
  495. }
  496. }
  497. .moneyIcon {
  498. color: $font-color;
  499. background: #FAF9F4;
  500. opacity: 0.8;
  501. bottom: 80rpx;
  502. }
  503. .jlBox {
  504. color: #FFFFFF;
  505. bottom: 10rpx;
  506. }
  507. }
  508. }
  509. </style>