1. <template>
    2. <view class="content">
    3. <view class="main">
    4. <image src="/static/turntable@2x.png" style="width: 100%;height: 100%;" class="turntable"
    5. :style=" 'transform: rotate(' +deg+ 'deg); transition-duration: ' +ss+'s ;' "
    6. ></image>
    7. <image src="/static/this@2x.png" mode="scaleToFill" style="width: 157upx;height: 229upx;" class="center-img" @click="start"></image>
    8. <image src="/static/img/tuoyuan@2x.png" style="width: 460upx;height: 75upx;" class="shadow"></image>
    9. </view>
    10. <view class="modal" :class="{show: modal}" @click="closeModal">
    11. <view class="modal-body" :class="{show: modal}" @click.stop>
    12. <view class="f-cc flex-column" style="margin-top: 300upx;">
    13. <view class="txt1" v-if="showTitle">恭喜您获得</view>
    14. <view class="txt2">{{modalTxt}}</view>
    15. </view>
    16. <image src="../../static/home_gb@2x.png" @click="closeModal" class="close" style="width: 48upx;height: 48upx;"></image>
    17. </view>
    18. </view>
    19. </view>
    20. </template>
    21. <script>
    22. let luck = false // 锁
    23. // 奖品池
    24. let arr = [
    25. {deg:0, showTitle: true, msg: '200金币',id: '1' },
    26. {deg:45, showTitle: false, msg: '谢谢参与',id: '2'},
    27. {deg:90, showTitle: true, msg: '500金币',id: '3'},
    28. {deg:135, showTitle: false, msg: '谢谢参与',id: '4'},
    29. {deg:180, showTitle: true, msg: '1000金币',id: '5'},
    30. {deg:225, showTitle: false, msg: '再来一次',id: '6'},
    31. {deg:270, showTitle: true, msg: '50金币',id: '7'},
    32. {deg:315, showTitle: false, msg: '再来一次',id: '8'}
    33. ]
    34. export default {
    35. data() {
    36. return {
    37. showTitle: true,
    38. modal: false, // 展示modal模块
    39. modalTxt: '', // 奖品
    40. ss: 5, // 旋转所用时间
    41. deg: 0 // 旋转角度
    42. };
    43. },
    44. onShow() {
    45. luck = false
    46. },
    47. methods:{
    48. play(num) {
    49. this.deg = 360 * 3 + arr[num].deg + 20
    50. setTimeout(()=> {
    51. this.showResult(arr[num])
    52. }, this.ss * 1000);
    53. },
    54. start() {
    55. if(luck) {
    56. return
    57. }
    58. luck = true // 关锁
    59. let num = Math.floor(Math.random() * arr.length)
    60. this.play(num)
    61. },
    62. // 展示结果
    63. showResult(data) {
    64. this.modal= true
    65. this.showTitle = data.showTitle
    66. this.modalTxt = data.msg
    67. },
    68. // 关闭
    69. closeModal() {
    70. luck = false
    71. let s = this.ss
    72. this.modal = false
    73. this.ss = 0
    74. this.deg = 0
    75. setTimeout(() => {
    76. this.ss = s
    77. }, 100)
    78. }
    79. }
    80. }
    81. </script>
    82. <style lang="scss" scoped>
    83. page {
    84. position: relative;
    85. width: 100%;
    86. min-height: 100%;
    87. }
    88. .content {
    89. box-sizing: border-box;
    90. width: 100%;
    91. height: 100vh;
    92. background-size: cover;
    93. overflow: hidden;
    94. padding-bottom: 90upx;
    95. background-color: pink;
    96. .main {
    97. position: relative;
    98. width: 624upx;
    99. height: 624upx;
    100. margin: 316upx auto 39upx;
    101. .turntable {
    102. position: absolute;
    103. top: 0;
    104. right: 0;
    105. left: 0;
    106. bottom: 0;
    107. margin: auto;
    108. // animation: rotateArc 5s cubic-bezier(0.61, 0.08, 0.35, 0.83);
    109. transform: rotate(0deg);
    110. z-index: 12;
    111. transition-timing-function: ease;
    112. transition-property: all;
    113. // transition: all 10s ease;
    114. }
    115. .center-img {
    116. position: absolute;
    117. top: 181upx;
    118. right: 0;
    119. left: 0;
    120. margin: auto;
    121. z-index: 99;
    122. }
    123. .shadow {
    124. position: absolute;
    125. bottom: -30upx;
    126. left: 0;
    127. right: 0;
    128. margin: auto;
    129. z-index: 1;
    130. }
    131. }
    132. .h1 {
    133. font-size: 32upx;
    134. text-align: center;
    135. color: #fff;
    136. }
    137. .h2 {
    138. width: 450upx;
    139. font-size: 22upx;
    140. color: #fff;
    141. margin-bottom: 22upx;
    142. margin: auto;
    143. }
    144. .modal.show {
    145. display: block;
    146. }
    147. .modal {
    148. position: fixed;
    149. top: 0;
    150. right: 0;
    151. bottom: 0;
    152. left: 0;
    153. background-color: rgba(0,0,0, .4);
    154. z-index: 100;
    155. display: none;
    156. .modal-body.show {
    157. animation: scaleFrames .4s cubic-bezier(.5,.49,.57,1.41) forwards;
    158. }
    159. .modal-body {
    160. position: absolute;
    161. top: 0;
    162. right: 0;
    163. bottom: 0;
    164. left: 0;
    165. margin: auto;
    166. width: 544upx;
    167. height: 570upx;
    168. background-size: 100% 100%;
    169. background-image: url('../../static/zhuanpan_tanchaung@2x.png');
    170. padding: 1upx;
    171. transform: scale(0);
    172. .txt1 {
    173. font-size:60upx;
    174. font-family:Source Han Sans CN;
    175. font-weight:500;
    176. color:rgba(255,255,255,1);
    177. line-height:104upx;
    178. text-shadow:0upx -5upx 10upx rgba(253,49,58,0.5);
    179. text-align: center;
    180. }
    181. .txt2 {
    182. font-size:60upx;
    183. font-family:Source Han Sans CN;
    184. font-weight:500;
    185. color:rgba(255,234,58,1);
    186. line-height:121upx;
    187. text-align: center;
    188. }
    189. .close {
    190. position: absolute;
    191. left: 0;
    192. right: 0;
    193. bottom: -68upx;
    194. margin: auto;
    195. }
    196. }
    197. }
    198. }
    199. @keyframes scaleFrames{
    200. from{
    201. transform: scale(0);
    202. }
    203. to{
    204. transform: scale(1);
    205. }
    206. }
    207. @keyframes rotateArc{
    208. from{
    209. transform: rotate(0deg);
    210. }
    211. to{
    212. transform: rotate(3600deg);
    213. }
    214. }
    215. </style>