doubleElevenLottery.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <view>
  3. <u-modal title="恭喜" confirm-text="前往查看" cancel-color="#333333" :show-cancel-button="true"
  4. @confirm="modalConfirm" cancel-text="关闭" :title-style="{color: '#101010',fontSize:'48rpx'}"
  5. confirm-color="#00B962" v-model="show">
  6. <view class="slot-content">
  7. <p>恭喜您!获得本次抽奖的幸运大奖</p>
  8. <p>奖品:<span style="color:#F08736 ;font-weight: bold;">{{resultObj.name}}</span></p>
  9. <p></p>
  10. </view>
  11. </u-modal>
  12. <ujp-navbar title="双11抽奖转盘" :zIndex="999999" :isBack="false"></ujp-navbar>
  13. <view class="top">
  14. <img class="cover" src="@/assets/img/topCover.png" alt="" />
  15. <img class="img1" src="@/assets/img/doubleEleven3x.png" alt="" />
  16. <img class="img2" src="@/assets/img/doubleElevenLogo.png" alt="" />
  17. </view>
  18. <view class="lotteryBox">
  19. <img class="cover2" src="@/assets/img/cover2.png" alt="" />
  20. <view class="chance">
  21. 您有 {{useNum}} 次抽奖机会
  22. </view>
  23. <Lottery class="lottery" :width="550" :height="550" :data="dataLottery" @end="showlottery=false"
  24. ref="refLottery" @clickBtn="clickBtn" @playRewardEnd="playRewardEnd" :setWinnerFn="getWinnerFn">
  25. </Lottery>
  26. </view>
  27. <view class="listBox">
  28. <view class="head">
  29. <view class="head2">
  30. <view class="contentHead">
  31. </view>
  32. </view>
  33. </view>
  34. <view class="content">
  35. <view class="list">
  36. <view class="title">
  37. 中奖名单
  38. <view class="img">
  39. <img src="@/assets/img/goldMedal.png" alt="" />
  40. </view>
  41. </view>
  42. <view class="listContent">
  43. <view class="name">
  44. <view class="title">
  45. 用户名
  46. </view>
  47. <view class="title">
  48. 手机号
  49. </view>
  50. <view class="title">
  51. 奖品
  52. </view>
  53. <!-- <view class="title">
  54. 时间
  55. </view> -->
  56. </view>
  57. <view class="account container">
  58. <scroll-view class="scroll-list" scroll-y :style="{ height: scrollHeight + 'px' }"
  59. :scroll-top="scrollTop" scroll-with-animation @scroll="onScroll">
  60. <view class="value" v-for="(item,i) in winList" :key="i">
  61. <view class="item">
  62. {{item.name}}
  63. </view>
  64. <view class="item">
  65. {{item.phone}}
  66. </view>
  67. <!-- <view class="item">
  68. {{item.prize}}
  69. </view> -->
  70. <view class="item item2" :class="{
  71. 'itemA':item.prize=='充电免单券',
  72. 'itemB':item.prize=='充电服务费6折月卡',
  73. 'itemC':item.prize=='服务费免单劵',
  74. }" >
  75. {{(item.prize)}}
  76. </view>
  77. </view>
  78. <view class="value" style="color: #fff" v-for="(item) in 4" :key="item+'_a'">
  79. <view class="item">
  80. 123
  81. </view>
  82. <view class="item">
  83. </view>
  84. <view class="item item2">
  85. </view>
  86. </view>
  87. </scroll-view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="hint">
  94. 活动最终解释权归湖北鹏育优电新能源科技有限公司所有
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. import * as API from '@/apis/temporary.js'
  100. import Lottery from '@/components/lottery/index11.vue'
  101. export default {
  102. components: {
  103. Lottery
  104. },
  105. data() {
  106. return {
  107. ckKey: false,
  108. resultObj: {
  109. id: 2,
  110. name: '服务费免单卷',
  111. nameText: ['服务费免单卷'],
  112. url: "/pages/user/coupon/myCoupon",
  113. img: '1',
  114. color: "#f7e2c3",
  115. },
  116. show: false,
  117. useNum: 0,
  118. scrollHeight: 310, // 滚动区域高度
  119. scrollTop: 0, // 初始滚动位置
  120. scrollSpeed: 1, // 滚动速度,值越大滚动越快
  121. intervalId: null, // 定时器ID
  122. lotteryIndex: -1,
  123. winList: [],
  124. dataLottery: [{
  125. id: 1,
  126. name: '充电免单卷(含电费)',
  127. nameText: ['充电免单卷', '(含电费)'],
  128. url: "/pages/user/coupon/myCoupon",
  129. img: '1',
  130. color: "#fbf0df"
  131. },
  132. {
  133. id: 2,
  134. name: '服务费免单卷',
  135. nameText: ['服务费免单卷'],
  136. url: "/pages/user/coupon/myCoupon",
  137. img: '1',
  138. color: "#f7e2c3",
  139. },
  140. {
  141. id: 3,
  142. name: '充电服务费6折月卡',
  143. nameText: ['充电服务费6折', '月卡'],
  144. url: "/pages/cardBag/cardBag",
  145. img: '1',
  146. color: "#fbf0df"
  147. },
  148. {
  149. id: 100,
  150. name: '谢谢参与',
  151. nameText: ['谢谢参与'],
  152. img: '2',
  153. color: "#f7e2c3",
  154. },
  155. ],
  156. }
  157. },
  158. onLoad() {
  159. this.getInfo()
  160. // 页面加载时计算滚动区域高度,并启动自动滚动
  161. // this.scrollHeight = uni.getSystemInfoSync().windowHeight - 100; // 根据实际屏幕高度调整
  162. },
  163. methods: {
  164. onScroll(event) {
  165. // 可以监听滚动事件做一些其他处理
  166. //console.log("当前滚动位置:", event.detail.scrollTop);
  167. },
  168. startAutoScroll() {
  169. // 设置定时器,让列表自动滚动
  170. this.intervalId = setInterval(() => {
  171. // 更新 scrollTop,实现自动滚动
  172. this.scrollTop += this.scrollSpeed;
  173. // 如果滚动到底部,重置 scrollTop 重新开始
  174. if (this.scrollTop >= this.scrollHeight) {
  175. this.scrollTop = 0;
  176. }
  177. }, 50); // 每20毫秒更新一次,调整这个时间来控制滚动速度
  178. },
  179. stopAutoScroll() {
  180. // 清除定时器,停止滚动
  181. if (this.intervalId) {
  182. clearInterval(this.intervalId);
  183. }
  184. },
  185. modalConfirm() {
  186. uni.navigateTo({
  187. url: this.resultObj.url
  188. })
  189. },
  190. playRewardEnd() {
  191. if (this.resultObj.id != 100) {
  192. this.show = true;
  193. }
  194. },
  195. clickBtn() {
  196. if ((this.$refs.refLottery.isLottery || this.show) || !this.ckKey) {
  197. uni.showToast({
  198. title: "摇奖中...",
  199. icon: "none"
  200. })
  201. return
  202. }
  203. this.ckKey = false
  204. uni.showLoading({
  205. title: "加载中",
  206. mask: true,
  207. })
  208. API.getActivityResults({
  209. }).then((res) => {
  210. uni.hideLoading();
  211. var lotteryIndex = this.dataLottery.findIndex(item => {
  212. item.weight = 0
  213. //console.log(res.data.serviceDiscountRatio,item.num,res.data.serviceDiscountRatio==item.num)
  214. return res.data == item.id
  215. })
  216. if (lotteryIndex != -1) {
  217. this.resultObj = this.dataLottery[lotteryIndex]
  218. this.dataLottery[lotteryIndex].weight = 100
  219. this.$refs.refLottery.playReward()
  220. }
  221. this.getInfo()
  222. }).catch(error => {
  223. //this.showNt = false;
  224. this.ckKey = true
  225. uni.showToast({
  226. title: error,
  227. icon: "none"
  228. })
  229. })
  230. },
  231. getInfo() {
  232. uni.showLoading({
  233. title: "加载中",
  234. mask: true,
  235. })
  236. API.activityDetails({
  237. }).then((res) => {
  238. this.ckKey = true
  239. uni.hideLoading();
  240. this.useNum = res.data.useNum
  241. this.winList = res.data.winList
  242. if (this.winList.length > 10 && this.intervalId == null) {
  243. this.startAutoScroll();
  244. }
  245. }).catch(error => {
  246. //this.showNt = false;
  247. uni.showToast({
  248. title: error,
  249. icon: "none"
  250. })
  251. })
  252. },
  253. getWinnerFn() {
  254. // 自定义抽奖结果 ,返回值为 options 奖品列表下标,若返回 -1,则会进行随机抽奖
  255. return this.lotteryIndex
  256. },
  257. }
  258. }
  259. </script>
  260. <style lang="scss" scoped>
  261. page {
  262. background-color: #DD3032;
  263. padding-bottom: 44rpx;
  264. }
  265. .top {
  266. .cover {
  267. width: 100%;
  268. height: 100%;
  269. position: relative;
  270. }
  271. .img1 {
  272. width: 100%;
  273. height: 456rpx;
  274. position: absolute;
  275. top: 98rpx;
  276. left: 50%;
  277. transform: translateX(-50%);
  278. }
  279. .img2 {
  280. width: 594rpx;
  281. height: 248rpx;
  282. position: absolute;
  283. top: 108rpx;
  284. left: 50%;
  285. transform: translateX(-50%);
  286. }
  287. }
  288. .lotteryBox {
  289. margin-top: -248rpx;
  290. position: relative;
  291. background: linear-gradient(180deg, rgba(221, 48, 50, 0) 0%, rgba(221, 48, 50, 1) 76%);
  292. .chance {
  293. width: 402rpx;
  294. height: 72rpx;
  295. line-height: 72rpx;
  296. border-radius: 50px;
  297. background: linear-gradient(90deg, rgba(211, 51, 0, 1) 0%, rgba(255, 79, 63, 1) 53%, rgba(226, 19, 0, 1) 100%);
  298. text-align: center;
  299. margin: 0 auto;
  300. color: rgba(255, 255, 215, 1);
  301. font-size: 18px;
  302. position: absolute;
  303. top: -80rpx;
  304. left: 50%;
  305. transform: translateX(-50%);
  306. }
  307. .cover2 {
  308. width: 100%;
  309. height: 100%;
  310. }
  311. .lottery {
  312. margin-top: -500rpx;
  313. }
  314. }
  315. .slot-content {
  316. font-size: 36rpx;
  317. padding: 30rpx;
  318. margin-top: 40rpx;
  319. p {
  320. margin-bottom: 16rpx;
  321. line-height: 40rpx;
  322. text {
  323. color: #00B962;
  324. }
  325. }
  326. }
  327. .listBox {
  328. position: relative;
  329. margin-top: -60rpx;
  330. .head {
  331. width: 100%;
  332. height: 144rpx;
  333. border-radius: 16px 16px 0px 0px;
  334. background: linear-gradient(180deg, rgba(239, 121, 66, 1) 0%, rgba(221, 48, 50, 1) 100%);
  335. // border: 1px solid rgba(252, 163, 131, 1);
  336. display: flex;
  337. align-items: center;
  338. justify-content: center;
  339. }
  340. .head2 {
  341. position: relative;
  342. width: 702rpx;
  343. height: 56rpx;
  344. border-radius: 8px;
  345. background-color: rgba(145, 17, 18, 1);
  346. text-align: center;
  347. border: 6px solid rgba(206, 38, 37, 1);
  348. }
  349. .contentHead {
  350. width: 678rpx;
  351. height: 36rpx;
  352. background: linear-gradient(180deg, rgba(187, 58, 60, 1) 0%, rgba(255, 255, 255, 1) 100%);
  353. }
  354. .content {
  355. width: 678rpx;
  356. border-radius: 0px 0px 12px 12px;
  357. background-color: rgba(255, 255, 255, 1);
  358. padding: 24rpx 0;
  359. margin: -54rpx auto 0;
  360. z-index: 999;
  361. position: relative;
  362. .list {
  363. border-radius: 8px 50px 8px 8px;
  364. background: linear-gradient(88.8deg, rgba(226, 54, 53, 1) 1.5%, rgba(247, 143, 30, 1) 99.88%);
  365. margin: 24rpx;
  366. padding: 8rpx;
  367. .title {
  368. color: rgba(255, 255, 255, 1);
  369. font-size: 36rpx;
  370. text-align: center;
  371. font-weight: bold;
  372. position: relative;
  373. padding-top: 18rpx;
  374. .img {
  375. width: 144rpx;
  376. height: 144rpx;
  377. position: absolute;
  378. top: -16rpx;
  379. left: 0;
  380. img {
  381. width: 100%;
  382. height: 100%;
  383. }
  384. }
  385. }
  386. .listContent {
  387. margin-top: 26rpx;
  388. padding: 16rpx 0;
  389. border-radius: 8rpx;
  390. background-color: #fff;
  391. .name,
  392. .value {
  393. display: flex;
  394. align-items: center;
  395. justify-content: space-around;
  396. text-align: center;
  397. }
  398. .name,
  399. .account {
  400. .title {
  401. color: rgba(119, 119, 119, 1);
  402. font-size: 24rpx;
  403. margin-top: 24rpx;
  404. }
  405. .value {
  406. color: rgba(51, 51, 51, 1);
  407. .item {
  408. width: 240rpx;
  409. overflow: hidden;
  410. line-height: 64rpx;
  411. }
  412. .item2 {
  413. width: 340rpx;
  414. white-space: pre;
  415. }
  416. .itemA {
  417. color: #ff9900;
  418. }
  419. .itemB {
  420. color: #00b962;
  421. }
  422. .itemC {
  423. }
  424. }
  425. }
  426. }
  427. }
  428. }
  429. }
  430. .hint {
  431. color: rgba(96, 2, 3, 1);
  432. font-size: 24rpx;
  433. text-align: center;
  434. margin-top: 20px;
  435. }
  436. .container {
  437. display: flex;
  438. justify-content: center;
  439. align-items: center;
  440. //padding: 20px;
  441. }
  442. .scroll-list {
  443. // width: 80%;
  444. // border: 1px solid #ccc;
  445. border-radius: 8px;
  446. padding: 10px;
  447. overflow: hidden;
  448. }
  449. .list-item {
  450. padding: 10px;
  451. text-align: center;
  452. font-size: 16px;
  453. border-bottom: 1px solid #f0f0f0;
  454. }
  455. .list-item:last-child {
  456. border-bottom: none;
  457. }
  458. </style>