123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div class="index-box">
  3. <popup :show="showPopup" @cancel="cancelFrom" :current-month="currentMonth" />
  4. <MyWinning :show="showMyWinning" :current-month="currentMonth" />
  5. <!-- <div>
  6. <div> -->
  7. <img class="topImage" src="../assets/indexImg/indexBgctop.jpg" alt />
  8. <!-- </div>
  9. </div> -->
  10. <div class="outer6-wrapper">
  11. <div class="outer6 flex-col">
  12. <div v-for="month in list" :key="month.id" class="section-item">
  13. <div @click="handleMonthClick(month)">
  14. <ImgBox :prize="month"></ImgBox>
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import { useModel } from '@/store'
  23. import { drawLottery, getPrizeList } from '@/services/person'
  24. import { rand, shuffle } from '@/utils/math'
  25. import { hideLoading } from '@/utils'
  26. // 月份信息
  27. //posterImg关闭的图片
  28. //popImg 打开的图片
  29. //shareImg分享图片
  30. //screenImg屏保
  31. //calendarImg日历图片
  32. const monthList = [
  33. {
  34. id: 1,
  35. posterImg: require('../assets/indexImg/imgex_MEW/1.jpg'),
  36. popImg: require('../assets/luckyImg/1.jpg'),
  37. shareImg: require('../assets/sharePagesImg/1.jpg'),
  38. screenImg: require('../assets/screenImg/1.jpg'),
  39. calendarImg: require('../assets/monthImg/January1.jpg'),
  40. mode: 1
  41. },
  42. {
  43. id: 2,
  44. posterImg: require('../assets/indexImg/imgex_MEW/2.jpg'),
  45. popImg: require('../assets/luckyImg/2.jpg'),
  46. shareImg: require('../assets/sharePagesImg/2.jpg'),
  47. screenImg: require('../assets/screenImg/2.jpg'),
  48. calendarImg: require('../assets/monthImg/February2.jpg'),
  49. mode: 1
  50. },
  51. {
  52. id: 3,
  53. posterImg: require('../assets/indexImg/imgex_MEW/3.jpg'),
  54. popImg: require('../assets/luckyImg/3.jpg'),
  55. shareImg: require('../assets/sharePagesImg/3.jpg'),
  56. screenImg: require('../assets/screenImg/3.jpg'),
  57. calendarImg: require('../assets/monthImg/March3.jpg'),
  58. mode: 1
  59. },
  60. {
  61. id: 4,
  62. posterImg: require('../assets/indexImg/imgex_MEW/4.jpg'),
  63. popImg: require('../assets/luckyImg/4.jpg'),
  64. shareImg: require('../assets/sharePagesImg/4.jpg'),
  65. screenImg: require('../assets/screenImg/4.jpg'),
  66. calendarImg: require('../assets/monthImg/April4.jpg'),
  67. mode: 1
  68. },
  69. {
  70. id: 5,
  71. posterImg: require('../assets/indexImg/imgex_MEW/5.jpg'),
  72. popImg: require('../assets/luckyImg/5.jpg'),
  73. shareImg: require('../assets/sharePagesImg/5.jpg'),
  74. screenImg: require('../assets/screenImg/5.jpg'),
  75. calendarImg: require('../assets/monthImg/May5.jpg'),
  76. mode: 1
  77. },
  78. {
  79. id: 6,
  80. posterImg: require('../assets/indexImg/imgex_MEW/6.jpg'),
  81. popImg: require('../assets/luckyImg/6.jpg'),
  82. shareImg: require('../assets/sharePagesImg/6.jpg'),
  83. screenImg: require('../assets/screenImg/6.jpg'),
  84. calendarImg: require('../assets/monthImg/June6.jpg'),
  85. mode: 1
  86. },
  87. {
  88. id: 7,
  89. posterImg: require('../assets/indexImg/imgex_MEW/7.jpg'),
  90. popImg: require('../assets/luckyImg/7.jpg'),
  91. shareImg: require('../assets/sharePagesImg/7.jpg'),
  92. screenImg: require('../assets/screenImg/7.jpg'),
  93. calendarImg: require('../assets/monthImg/July7.jpg'),
  94. mode: 1
  95. },
  96. {
  97. id: 8,
  98. posterImg: require('../assets/indexImg/imgex_MEW/8.jpg'),
  99. popImg: require('../assets/luckyImg/8.jpg'),
  100. shareImg: require('../assets/sharePagesImg/8.jpg'),
  101. screenImg: require('../assets/screenImg/8.jpg'),
  102. calendarImg: require('../assets/monthImg/August8.jpg'),
  103. mode: 1
  104. },
  105. {
  106. id: 9,
  107. posterImg: require('../assets/indexImg/imgex_MEW/9.jpg'),
  108. popImg: require('../assets/luckyImg/9.jpg'),
  109. shareImg: require('../assets/sharePagesImg/9.jpg'),
  110. screenImg: require('../assets/screenImg/9.jpg'),
  111. calendarImg: require('../assets/monthImg/September9.jpg'),
  112. mode: 1
  113. },
  114. {
  115. id: 10,
  116. posterImg: require('../assets/indexImg/imgex_MEW/10.jpg'),
  117. popImg: require('../assets/luckyImg/10.jpg'),
  118. shareImg: require('../assets/sharePagesImg/10.jpg'),
  119. screenImg: require('../assets/screenImg/10.jpg'),
  120. calendarImg: require('../assets/monthImg/October10.jpg'),
  121. mode: 1
  122. },
  123. {
  124. id: 11,
  125. posterImg: require('../assets/indexImg/imgex_MEW/11.jpg'),
  126. popImg: require('../assets/luckyImg/11.jpg'),
  127. shareImg: require('../assets/sharePagesImg/11.jpg'),
  128. screenImg: require('../assets/screenImg/11.jpg'),
  129. calendarImg: require('../assets/monthImg/November11.jpg'),
  130. mode: 1
  131. },
  132. {
  133. id: 12,
  134. posterImg: require('../assets/indexImg/imgex_MEW/12.jpg'),
  135. popImg: require('../assets/luckyImg/12.jpg'),
  136. shareImg: require('../assets/sharePagesImg/12.jpg'),
  137. screenImg: require('../assets/screenImg/12.jpg'),
  138. calendarImg: require('../assets/monthImg/December12.jpg'),
  139. mode: 1
  140. }
  141. ]
  142. export default {
  143. name: 'Honghe',
  144. components: {
  145. Popup: () => import('@/components/Popup.vue'),
  146. MyWinning: () => import('@/components/MyWinning.vue'),
  147. ImgBox: () => import('@/components/imgbox.vue')
  148. },
  149. data() {
  150. return {
  151. list: shuffle(monthList),
  152. currentMonth: null,
  153. showPopup: false,
  154. showMyWinning: false,
  155. prizeList: [],
  156. clickNum: 0,
  157. bingoClickNum: rand(0, 12)
  158. }
  159. },
  160. computed: {
  161. person: {
  162. get() {
  163. return useModel('person')[0]
  164. },
  165. set(val) {
  166. useModel('person')[1](val)
  167. }
  168. }
  169. },
  170. created() {
  171. this.getPrizes()
  172. },
  173. methods: {
  174. //关闭
  175. cancelFrom() {
  176. this.showPopup = false
  177. this.list.map((item) => {
  178. if (item.id == this.currentMonth.id) {
  179. item.mode = 3
  180. }
  181. })
  182. },
  183. handleMonthClick(month) {
  184. this.list.map((item) => {
  185. if (item.id == month.id) {
  186. item.mode = 2
  187. }
  188. })
  189. this.currentMonth = month
  190. // 如果点击可以抽奖
  191. if (this.clickNum === this.bingoClickNum) {
  192. if (!this.person.personId) {
  193. // 报错, 提示刷新页面
  194. } else {
  195. // 如果还没有参与
  196. if (!this.person.isJoined) {
  197. this.drawLots()
  198. } else {
  199. this.showPopup = true
  200. }
  201. }
  202. } else {
  203. this.showPopup = true
  204. }
  205. if (this.clickNum < this.bingoClickNum) {
  206. this.clickNum += 1
  207. }
  208. },
  209. // 抽奖
  210. drawLots() {
  211. drawLottery(this.person).then((res) => {
  212. // 更新人员信息
  213. this.person = res
  214. // 其他动作
  215. })
  216. },
  217. // 获取奖品列表
  218. getPrizes() {
  219. getPrizeList().then((list) => {
  220. this.prizeList = list
  221. const t = setTimeout(() => {
  222. hideLoading()
  223. clearTimeout(t)
  224. }, 1000)
  225. })
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="less" scoped>
  231. .flex-col {
  232. display: flex;
  233. flex-direction: column;
  234. }
  235. .index-box {
  236. background-color: #b12b32;
  237. width: 100vw;
  238. height: 100vh;
  239. position: relative;
  240. top: 0;
  241. left: 0;
  242. right: 0;
  243. bottom: 0;
  244. overflow: auto;
  245. .dialog {
  246. z-index: 2;
  247. }
  248. .topImage {
  249. width: 100vw;
  250. }
  251. .outer6-wrapper {
  252. width: 92vw;
  253. border: 1px solid #d0b69a;
  254. margin: 0 auto;
  255. margin-bottom: 2em;
  256. .outer6 {
  257. flex-flow: row wrap;
  258. align-content: flex-start;
  259. z-index: 2;
  260. background-color: #9c0014;
  261. align-self: center;
  262. width: 90vw;
  263. margin: 3px auto;
  264. border-right: 1px solid #d0b69a;
  265. border-bottom: 1px solid #d0b69a;
  266. overflow: hidden;
  267. .section-item {
  268. width: 22vw;
  269. border-left: 1px solid #d0b69a;
  270. border-top: 1px solid #d0b69a;
  271. display: inline-flex;
  272. overflow: hidden;
  273. &-image {
  274. width: 22vw;
  275. background-size: 100% 100%;
  276. }
  277. .backImag {
  278. // position: relative;
  279. width: 22vw;
  280. animation: change 0.8s linear forwards;
  281. }
  282. @keyframes change {
  283. from {
  284. width: 44vw;
  285. transform: rotateY(180deg);
  286. }
  287. to {
  288. width: 22vw;
  289. }
  290. }
  291. }
  292. }
  293. }
  294. }
  295. </style>