prize.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div class="prize" :class="{mobilePrize:isMobile}">
  3. <h1 v-if="isMobile">幸运大转盘</h1>
  4. <LuckyWheel
  5. class="lw"
  6. ref="LuckyWheel"
  7. width="340px"
  8. height="340px"
  9. :blocks="blocks"
  10. :prizes="prizes"
  11. :buttons="buttons"
  12. @start="startCallBack"
  13. @end="endCallBack"
  14. />
  15. <div class="bubble">
  16. <img class="btip" :src="require('@/assets/images/question/tipdialog.png')" alt="">
  17. <div class="b-title">
  18. 本轮奖品详情
  19. </div>
  20. <ul>
  21. <li v-for="(item,i) in 10" :key="i">一等奖:可爱的发哥抱枕</li>
  22. </ul>
  23. <div class="desc">
  24. <p>请保存当前二维码,可到现场领取精美礼品一份<br/>活动截止时间:2021年12月31日</p>
  25. </div>
  26. </div>
  27. <div class="lingjiang" v-show="lingjiang">
  28. <div class="ljcon">
  29. <img
  30. @click="lingjiang=false"
  31. class="qclose"
  32. :src="require('@/assets/images/question/close.png')"
  33. alt=""
  34. />
  35. <img class="lbg" :src="require('@/assets/images/question/lingjiang_bg.png')" alt="">
  36. <div class="lbody">
  37. <div class="ltitle">领取奖励</div>
  38. <img class="qrcode" :src="require('@/assets/images/question/qrcode.png')" alt="">
  39. <p>{{currentPrize.title}}</p>
  40. <div class="ldesc">请保存当前二维码,可到现场领取精美礼品一份<br/>活动截止时间:2021年12月31日</div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. import browser from '@/util/browser'
  48. // 设置奖品
  49. const prizes = []
  50. let data = [
  51. '感谢参与',
  52. '一等奖',
  53. '二等奖',
  54. '三等奖',
  55. '一等奖',
  56. '二等奖',
  57. '三等奖',
  58. '一等奖',
  59. '二等奖',
  60. '三等奖',
  61. '二等奖',
  62. '三等奖'
  63. ]
  64. data.forEach((item, index) => {
  65. prizes.push({
  66. title: item,
  67. fonts: [
  68. {
  69. fontColor: index % 2 ? '#ffffff' : '#311B04',
  70. text: item,
  71. lengthLimit: '20',
  72. fontSize: 12
  73. }
  74. ]
  75. })
  76. })
  77. export default {
  78. data () {
  79. return {
  80. blocks: [
  81. {
  82. padding: '40px',
  83. imgs: [
  84. {
  85. src: require('@/assets/images/question/prize_bigbg.png'),
  86. width: '100%',
  87. rotate: false
  88. }
  89. ]
  90. },
  91. {
  92. padding: '20px',
  93. imgs: [
  94. {
  95. src: require('@/assets/images/question/prize_bg.png'),
  96. width: '100%',
  97. rotate: true
  98. }
  99. ]
  100. }
  101. ],
  102. defaultStyle: {},
  103. prizes,
  104. defaultConfig: {
  105. stopRange: 0
  106. },
  107. currentPrize: {},
  108. lingjiang: false,
  109. buttons: [
  110. {
  111. fonts: [
  112. {
  113. fontSize: 18,
  114. fontWeight: 800,
  115. text: '开始',
  116. top: -12,
  117. fontColor: '#54320B'
  118. }
  119. ],
  120. radius: '50%',
  121. pointer: false,
  122. imgs: [
  123. {
  124. src: require('@/assets/images/question/pointer.png'),
  125. top: -48,
  126. width: 64
  127. }
  128. ]
  129. }
  130. ],
  131. isMobile: browser.mobile,
  132. }
  133. },
  134. methods: {
  135. startCallBack () {
  136. this.$refs.LuckyWheel.play()
  137. setTimeout(() => {
  138. let stop = (Math.random() * 12) >> 0
  139. console.log(data[stop])
  140. this.$refs.LuckyWheel.stop(stop)
  141. }, 1000)
  142. },
  143. endCallBack (prize) {
  144. this.currentPrize = prize
  145. this.lingjiang = true
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="less" scoped>
  151. .prize {
  152. margin: 0 auto;
  153. position: relative;
  154. z-index: 999;
  155. text-align: center;
  156. display: flex;
  157. justify-content: space-between;
  158. align-items: center;
  159. width: 100%;
  160. height: 100%;
  161. .lw {
  162. margin: 0 auto;
  163. }
  164. .bubble {
  165. width: 340px;
  166. height: 350px;
  167. position: relative;
  168. background-color: #fff;
  169. border-radius: 10px;
  170. margin-right: 40px;
  171. box-shadow: 0 0 15px rgba(0,0,0,0.5);
  172. @wh:30px;
  173. &:after {
  174. content: "";
  175. position: absolute;
  176. top: 100%;
  177. left: 40px;
  178. width: 0;
  179. height: 0;
  180. border-top: @wh solid #fff;
  181. border-right: @wh solid transparent;
  182. color: #fff;
  183. }
  184. .btip{
  185. position: absolute;
  186. bottom: -50px;
  187. right: -30px;
  188. pointer-events: none;
  189. }
  190. .b-title{
  191. background-color: #311B04;
  192. font-size: 18px;
  193. font-weight: bold;
  194. border-radius: 9px 9px 0 0;
  195. padding:14px 0;
  196. width: 100%;
  197. box-shadow: 0 0 15px rgba(0,0,0,0.5);
  198. }
  199. >ul{
  200. width: 100%;
  201. height: 240px;
  202. overflow-y: auto;
  203. >li{
  204. color: #FA3800;
  205. line-height: 1.5;
  206. margin: 8px 0;
  207. }
  208. }
  209. .desc{
  210. font-size: 12px;
  211. color: #311B04;
  212. line-height: 1.5;
  213. margin-top: 14px;
  214. width: 100%;
  215. }
  216. }
  217. .lingjiang{
  218. position: absolute;
  219. left: 0;
  220. top: 0;
  221. background-color: rgba(0,0,0,0.7);
  222. width: 100%;
  223. height: 100%;
  224. .ljcon{
  225. position: absolute;
  226. top: 50%;
  227. left: 50%;
  228. transform: translate(-50%,-50%);
  229. .qclose {
  230. position: absolute;
  231. right: 30px;
  232. top: 24px;
  233. cursor: pointer;
  234. z-index: 999;
  235. }
  236. .lbody{
  237. position: absolute;
  238. top: 42%;
  239. width: 80%;
  240. left: 50%;
  241. transform: translate(-50%,-50%);
  242. text-align: center;
  243. .ltitle{
  244. font-size: 24px;
  245. font-weight: bold;
  246. }
  247. .qrcode{
  248. margin-top: 10px;
  249. }
  250. >p{
  251. margin: 10px 0 20px;
  252. font-weight: bold;
  253. }
  254. .ldesc{
  255. font-size: 12px;
  256. color: #311B04;
  257. line-height: 1.5;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. .mobilePrize {
  264. }
  265. </style>