lottery_new.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. <template>
  2. <view class="lottery_new">
  3. <view class="welcome" v-if="pageIndex == 0">
  4. <!-- logo与跑马灯 -->
  5. <view class="header">
  6. <img :src="lotteryInfo.logo" class="logo" mode="widthFix" />
  7. <view class="barrage-box">
  8. <view class="text">{{ recordList.length == 0 ? '还没有人中奖,快来参与吧!' : '' }}</view>
  9. </view>
  10. </view>
  11. <!-- 立即参与页面 -->
  12. <view class="page-1" style="padding: 0 16rpx">
  13. <view class="activity-info">
  14. <!-- <text class="title">{{ acticve_detail?.name }}</text> -->
  15. <view class="active-rule">
  16. <rich-text :nodes="lotteryInfo.rule" class="rich_text" style="font-size: 36rpx; font-weight: 300"></rich-text>
  17. </view>
  18. </view>
  19. <view class="activity-btn" @click="_handleChangePage(1)"></view>
  20. </view>
  21. </view>
  22. <view class="lottery" v-if="pageIndex == 1">
  23. <view class="lottery_box">
  24. <view class="lottery_rule_btn" @click="showRule">活动规则</view>
  25. <l-dialer
  26. :customStyle="'width: 500rpx;height: 500rpx;margin: 0rpx auto;'"
  27. @click="onClick"
  28. dial-style="color: rgba(60,48,158,0.7); padding: 32rpx;background-image: url(https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/lottery_bg.png)"
  29. :prizeList="prizeList"
  30. :turns="5"
  31. :duration="5"
  32. @done="onDone"
  33. ref="dialer"
  34. pointerStyle="display: none"
  35. />
  36. <view class="lottery_bottom">
  37. <view class="lottery_btn" @click="onClick"></view>
  38. <view class="lottery_number">可用次数:{{ lotteryInfo.number }}</view>
  39. </view>
  40. <!-- <view class="lottery_need_score"> </view> -->
  41. <view class="lottery_record_title"></view>
  42. <view class="lottery_record">
  43. <view class="lottery_record_none" v-if="!recordList.length">这里还是空的哦~</view>
  44. <scroll-view class="lottery_record_list" scroll-y="true">
  45. <view class="lottery_record_item" v-for="(item, index) in recordList" :key="index">
  46. <view class="reward_name">获得{{ item.reward_name }}</view>
  47. <view class="reward_time">{{ item.insert_time }}</view>
  48. </view>
  49. </scroll-view>
  50. </view>
  51. </view>
  52. <uni-popup ref="lotteryRule" type="center">
  53. <view class="lottery_rule_box">
  54. <view class="active-rule">
  55. <rich-text :nodes="lotteryInfo.rule" class="rich_text" style="font-size: 36rpx; font-weight: 300"></rich-text>
  56. </view>
  57. <view class="close-btn" @click="closeRule"></view>
  58. </view>
  59. </uni-popup>
  60. <uni-popup ref="lotteryReward" type="center">
  61. <view class="lottery_reward_box">
  62. <view class="reward_box">
  63. <view :class="['reward_title', reward_info.id == 0 ? 'noGet' : 'get']">{{ reward_info.id == 0 ? '很遗憾' : '恭喜您' }}</view>
  64. <view>
  65. <view :class="['reward_image', reward_info.id == 0 ? 'noget' : reward_info.reward_type == 1 ? 'score' : 'redpacket']"></view>
  66. <view class="reward_name"> {{ reward_info.id == 0 ? '谢谢参与' : reward_info.name }}</view>
  67. </view>
  68. <view class="reward_btn" @click="closeReward">{{ reward_info.id == 0 ? '我知道了' : '开心收下' }}</view>
  69. </view>
  70. <view class="close-btn" @click="closeReward"></view>
  71. </view>
  72. </uni-popup>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. export default {
  78. data() {
  79. return {
  80. pageIndex: 0,
  81. height: '',
  82. // 奖项列表,
  83. prizeList: [],
  84. // 中奖记录
  85. recordList: [],
  86. // 地址列表
  87. addrList: [],
  88. // 抽奖信息
  89. lotteryInfo: {
  90. id: 0,
  91. name: '',
  92. logo: '',
  93. number: '0',
  94. start_date: '',
  95. end_date: '',
  96. start_time: '',
  97. end_time: '',
  98. rule: '',
  99. },
  100. recordId: 0,
  101. // 请求参数
  102. requestParam: {
  103. id: 0,
  104. activity_id: 0,
  105. },
  106. reward_info: {
  107. id: 0,
  108. },
  109. };
  110. },
  111. onLoad(param) {
  112. //未登陆提醒用户登陆
  113. try {
  114. // 接收参数
  115. console.log(param, 'onload param');
  116. this.requestParam.id = param.id;
  117. this.requestParam.activity_id = param.activity_id;
  118. // 如果有scene参数的话,获取其中的ID
  119. if (param.scene) {
  120. // 转键值对参数
  121. let scene = this.$http.strToParam(param.scene);
  122. // 如果没有传入ID,但是传入了场景ID,获取场景ID
  123. if (!param.id && scene.id) this.requestParam.id = scene.id;
  124. }
  125. // 窗口信息
  126. var sysinfo = uni.getWindowInfo();
  127. // 获取屏幕可用高度
  128. this.height = 'height:' + sysinfo.windowHeight + 'px;';
  129. // 监听地址变动
  130. uni.$on('addr_list_change', (data) => {
  131. // 地址列表
  132. this.addrList = data.list;
  133. });
  134. // #ifdef MP-WEIXIN
  135. //分享按钮
  136. uni.showShareMenu({
  137. withShareTicket: true,
  138. menus: ['shareAppMessage', 'shareTimeline'],
  139. });
  140. // #endif
  141. } catch (e) {
  142. console.log(e);
  143. }
  144. },
  145. onShareAppMessage(obj) {
  146. // if (obj) {
  147. // this.shareRequest();
  148. // }
  149. return {
  150. title: '999智控终端平台\n新人抽奖',
  151. path: `/pages/recruitment/lottery_new?id=${this.requestParam.id}&activity_id=${this.requestParam.activity_id}`,
  152. imageUrl: 'https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/20250210-143021.jpg',
  153. promise: new Promise((resolve, reject) => {
  154. this.$http.request('api/share_message/get_item', { item_id: this.requestParam.activity_id, pages: '/pages/recruitment/lottery_new' }).then((callback) => {
  155. console.log(callback, 'api/share_message/get_item');
  156. let obj = {
  157. title: callback.data?.title == '' ? this.lotteryInfo.name : callback.data.title,
  158. path: '/pages/recruitment/lottery_new?id=' + this.requestParam.id,
  159. imageUrl: callback.data?.image_url == '' ? this.lotteryInfo.logo : callback.data.image_url,
  160. };
  161. resolve(obj);
  162. });
  163. }),
  164. };
  165. },
  166. onShow() {
  167. console.log(this.requestParam, 'onshow requestParam');
  168. if (!this.$checkAccess.checkLogin()) {
  169. uni.showModal({
  170. title: '温馨提示',
  171. content: '请先登录',
  172. confirmText: '去登录',
  173. cancelText: '取消',
  174. success: (res) => {
  175. if (res.confirm) {
  176. uni.redirectTo({
  177. url: `/pages/login/index?redirect=/pages/recruitment/lottery_new&id=${this.requestParam.id}`,
  178. });
  179. }
  180. },
  181. });
  182. return;
  183. }
  184. // 没有数据的话,或者请求中,不允许刷新
  185. if (this.isReqing) return;
  186. // 登录提示
  187. // if (!this.$checkAccess.alterLogin()) return;
  188. // 如果存在产品ID的话
  189. if (this.requestParam.id > 0) {
  190. // 设置请求中
  191. this.isReqing = true;
  192. // 请求
  193. this.$http.request('api/lottery_recruitment/get_detail', this.requestParam).then((re) => {
  194. // 设置非请求中
  195. this.isReqing = false;
  196. // 成功结果
  197. if (re.code == 'success') {
  198. this.lotteryInfo = re.data;
  199. this.prizeList = re.data.reward_list;
  200. } else {
  201. if (re.code != 'no_login') {
  202. uni.showModal({
  203. content: re.msg,
  204. showCancel: false,
  205. });
  206. }
  207. }
  208. });
  209. this.showRecord();
  210. } else {
  211. uni.showModal({
  212. content: '未知的活动ID',
  213. showCancel: false,
  214. });
  215. }
  216. },
  217. methods: {
  218. _handleChangePage(index) {
  219. this.pageIndex = index;
  220. },
  221. onDone(index) {
  222. this.reward_info = this.prizeList[index];
  223. this.$refs.lotteryReward.open('center');
  224. this.showRecord();
  225. },
  226. onClick() {
  227. // 活动是否开始
  228. if (!this.lotteryInfo.id) {
  229. uni.showToast({
  230. title: '暂无可参与活动',
  231. icon: 'none',
  232. });
  233. return;
  234. }
  235. // 活动是否开始
  236. if (this.lotteryInfo.start_time * 1000 > new Date().getTime()) {
  237. uni.showToast({
  238. title: '活动还没开始哦',
  239. icon: 'none',
  240. });
  241. return;
  242. }
  243. // 活动是否结束
  244. if (this.lotteryInfo.end_time * 1000 <= new Date().getTime()) {
  245. uni.showToast({
  246. title: '活动已结束了哦',
  247. icon: 'none',
  248. });
  249. return;
  250. }
  251. // 次数已用完了
  252. if (this.lotteryInfo.number <= 0) {
  253. uni.showToast({
  254. title: '次数已用完了',
  255. icon: 'none',
  256. });
  257. return;
  258. }
  259. if (!this.$checkAccess.getHasFollow()) {
  260. this.$refs.addFollow.open('center');
  261. return;
  262. }
  263. // 次数操作
  264. this.lotteryInfo.number = this.lotteryInfo.number - 1;
  265. // 请求列表
  266. this.$http.request('/api/lottery_recruitment/get_reward', { lottery_id: this.lotteryInfo.id }).then((re) => {
  267. // 设置非请求中
  268. this.isReqing = false;
  269. // 成功结果
  270. if (re.code == 'success') {
  271. // 奖品列表更新
  272. this.prizeList = re.data.reward_list;
  273. // 奖品的索引
  274. return this.$refs.dialer.run(re.data.reward_index);
  275. } else {
  276. uni.showToast({
  277. title: re.msg,
  278. icon: 'none',
  279. });
  280. return;
  281. }
  282. });
  283. },
  284. closePopup() {
  285. this.$refs.addFollow.close();
  286. },
  287. closeReward() {
  288. this.$refs.lotteryReward.close();
  289. },
  290. showRule() {
  291. this.$refs.lotteryRule.open('center');
  292. },
  293. closeRule() {
  294. this.$refs.lotteryRule.close();
  295. },
  296. showRecord() {
  297. // 活动是否开始
  298. // 请求列表
  299. this.$http.request('/api/lottery_recruitment_record/get_list', { lottery_id: this.requestParam.id }).then((re) => {
  300. // 设置非请求中
  301. this.isReqing = false;
  302. // 成功结果
  303. if (re.code == 'success') {
  304. this.recordList = re.data;
  305. } else {
  306. this.recordList = [];
  307. }
  308. });
  309. },
  310. openAddr(index) {
  311. // 选择的下标
  312. this.recordIndex = index;
  313. // 地址列表
  314. this.getAddrList(true);
  315. },
  316. // 选择地址
  317. checkedAddrItem(item) {
  318. // 判断数据
  319. this.$http.request('api/lottery_recruitment_record/set_addr', { id: this.recordList[this.recordIndex].id, addr_id: item.id }, 'post').then((callback) => {
  320. // 获取成功
  321. if (callback.code == 'success') {
  322. this.recordList[this.recordIndex].status = 1;
  323. this.recordList[this.recordIndex].state = '进行中';
  324. }
  325. this.$refs.addrPopup.close();
  326. });
  327. },
  328. getAddrList(showPopup = false) {
  329. // 判断数据
  330. this.$http.request('api/custom_addr/get_list').then((callback) => {
  331. // 获取成功
  332. if (callback.code == 'success') {
  333. this.addrList = callback.data;
  334. // 如果有的话
  335. if (this.addrList.length) {
  336. // 获取默认的
  337. for (let i in this.addrList) {
  338. // 如果是默认的
  339. if (this.addrList[i].is_default) this.checkedAddr = this.addrList[i];
  340. }
  341. // 如果没有默认的话
  342. if (!this.checkedAddr.id) {
  343. this.checkedAddr = this.addrList[this.addrList.length - 1];
  344. }
  345. }
  346. // 弹出地址层
  347. if (showPopup) this.$refs.addrPopup.open('bottom');
  348. }
  349. });
  350. },
  351. },
  352. };
  353. </script>
  354. <style lang="less" scoped>
  355. .lottery_new {
  356. box-sizing: border-box;
  357. position: relative;
  358. height: 100vh;
  359. .welcome {
  360. width: 100vw;
  361. height: 100%;
  362. display: flex;
  363. flex-direction: column;
  364. box-sizing: border-box;
  365. background: linear-gradient(to bottom, #fedc9f, #ff9861);
  366. .header {
  367. .logo {
  368. width: 100%;
  369. }
  370. .barrage-box {
  371. padding: 10rpx;
  372. width: 100%;
  373. transform-origin: 65vw 75vw;
  374. transform: rotate(0deg);
  375. white-space: nowrap;
  376. display: flex;
  377. justify-content: center;
  378. align-items: center;
  379. z-index: 3;
  380. box-sizing: border-box;
  381. background-color: #ff8b37;
  382. opacity: 0.8;
  383. overflow-x: hidden;
  384. }
  385. .text {
  386. width: 200vw; //调整文字显示
  387. font-size: 16px;
  388. color: #333;
  389. animation: aniMove 8s linear infinite;
  390. animation-fill-mode: forwards;
  391. }
  392. /* 文字滚动 */
  393. @keyframes aniMove {
  394. 0% {
  395. transform: translateX(100%);
  396. }
  397. 100% {
  398. transform: translateX(-100%);
  399. }
  400. }
  401. }
  402. .page-1 {
  403. width: 100%;
  404. display: flex;
  405. align-items: center;
  406. flex-direction: column;
  407. box-sizing: border-box;
  408. height: 100%;
  409. .activity-info {
  410. padding-top: 60rpx;
  411. display: flex;
  412. flex-direction: column;
  413. align-items: center;
  414. justify-content: center;
  415. width: 100%;
  416. .title {
  417. font-size: 46rpx;
  418. font-weight: bold;
  419. color: #fff;
  420. text-align: center;
  421. margin-bottom: 40rpx;
  422. }
  423. .active-rule {
  424. display: block;
  425. font-size: 30rpx;
  426. line-height: 40rpx;
  427. box-sizing: border-box;
  428. margin-bottom: 32rpx;
  429. width: 670rpx;
  430. height: 609rpx;
  431. overflow-y: auto;
  432. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/rule.png');
  433. background-repeat: no-repeat;
  434. background-size: 100% 100%;
  435. padding: 93rpx 48rpx;
  436. .rich_text {
  437. white-space: break-spaces;
  438. }
  439. }
  440. }
  441. .activity-btn {
  442. width: 368rpx;
  443. height: 108rpx;
  444. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/join.png');
  445. background-size: 100% 100%;
  446. background-repeat: no-repeat;
  447. // background: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/join.png') no-repeat center 100% 100%;
  448. }
  449. }
  450. }
  451. .lottery {
  452. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/lottery_background.png');
  453. background-size: 100% 100%;
  454. background-repeat: no-repeat;
  455. width: 100vw;
  456. min-height: 100vh;
  457. padding-top: 405rpx;
  458. .lottery_box {
  459. display: block;
  460. width: 750rpx;
  461. margin: 0 auto;
  462. position: relative;
  463. .lottery_bottom {
  464. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/lottery_bottom.png');
  465. background-size: 100% 100%;
  466. background-repeat: no-repeat;
  467. width: 512rpx;
  468. height: 220rpx;
  469. margin: 0 auto;
  470. display: flex;
  471. flex-direction: column;
  472. align-items: center;
  473. padding-top: 80rpx;
  474. box-sizing: border-box;
  475. .lottery_number {
  476. color: #fff;
  477. font-size: 22rpx;
  478. margin-top: 10rpx;
  479. }
  480. .lottery_btn {
  481. width: 285rpx;
  482. height: 78rpx;
  483. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/lottery_btn.png');
  484. background-repeat: no-repeat;
  485. background-size: 100% 100%;
  486. }
  487. }
  488. .lottery_rule_btn {
  489. width: 140rpx;
  490. height: 42rpx;
  491. background: #fef7db;
  492. color: #ff7f00;
  493. border-radius: 500rpx 0rpx 0rpx 500rpx;
  494. position: absolute;
  495. right: 0;
  496. top: 0;
  497. z-index: inherit;
  498. font-size: 24rpx;
  499. text-align: center;
  500. line-height: 42rpx;
  501. }
  502. // .lottery_need_score {
  503. // width: 453rpx;
  504. // height: 35rpx;
  505. // background: #d4430e;
  506. // border-radius: 0rpx 0rpx 0rpx 0rpx;
  507. // font-size: 24rpx;
  508. // color: #fff;
  509. // border-radius: 20rpx;
  510. // text-align: center;
  511. // margin: 20rpx auto 0;
  512. // opacity: 0.5;
  513. // }
  514. .lottery_record_title {
  515. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/lottery_record_title.png');
  516. background-size: 100% 100%;
  517. background-repeat: no-repeat;
  518. width: 516rpx;
  519. height: 61rpx;
  520. margin: 60rpx auto 24rpx;
  521. }
  522. .lottery_record {
  523. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/lettery_record.png');
  524. background-size: 100% 100%;
  525. background-repeat: no-repeat;
  526. width: 682rpx;
  527. height: 456rpx;
  528. margin: 0 auto;
  529. overflow-y: auto;
  530. padding: 56rpx 48rpx;
  531. box-sizing: border-box;
  532. .lottery_record_none {
  533. width: 100%;
  534. height: 100%;
  535. display: flex;
  536. align-items: center;
  537. justify-content: center;
  538. color: #deb887;
  539. }
  540. .lottery_record_item {
  541. width: 586rpx;
  542. height: 93rpx;
  543. border-radius: 0rpx 0rpx 0rpx 0rpx;
  544. border-bottom: 1rpx solid #e3e3e3;
  545. display: flex;
  546. justify-content: space-between;
  547. align-items: center;
  548. .reward_name {
  549. color: #333;
  550. }
  551. .reward_time {
  552. font-size: 24rpx;
  553. color: #999999;
  554. }
  555. }
  556. }
  557. }
  558. }
  559. .lottery_rule_box {
  560. display: flex;
  561. flex-direction: column;
  562. justify-content: center;
  563. align-items: center;
  564. .active-rule {
  565. display: block;
  566. font-size: 30rpx;
  567. line-height: 40rpx;
  568. box-sizing: border-box;
  569. margin-bottom: 32rpx;
  570. width: 670rpx;
  571. height: 609rpx;
  572. overflow-y: auto;
  573. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/rule.png');
  574. background-repeat: no-repeat;
  575. background-size: 100% 100%;
  576. padding: 93rpx 48rpx;
  577. .rich_text {
  578. white-space: break-spaces;
  579. }
  580. }
  581. }
  582. .lottery_reward_box {
  583. display: flex;
  584. flex-direction: column;
  585. justify-content: center;
  586. align-items: center;
  587. .reward_box {
  588. width: 548rpx;
  589. height: 658rpx;
  590. border-radius: 20rpx;
  591. background: linear-gradient(to bottom, #fedc9f, #ff9861);
  592. padding: 40rpx 0;
  593. box-sizing: border-box;
  594. display: flex;
  595. flex-direction: column;
  596. align-items: center;
  597. justify-content: space-between;
  598. .reward_title {
  599. font-size: 68rpx;
  600. font-weight: 400;
  601. &.get {
  602. color: #ff0000;
  603. }
  604. &.noGet {
  605. color: #fe7b2b;
  606. }
  607. }
  608. .reward_btn {
  609. width: 272rpx;
  610. height: 77rpx;
  611. color: #fff;
  612. text-align: center;
  613. line-height: 77rpx;
  614. background: linear-gradient(180deg, #ff211a 0%, #ffb883 100%);
  615. box-shadow: inset 0rpx -2rpx 1rpx 0rpx #fff6b6, inset 0rpx 4rpx 6rpx 0rpx rgba(255, 255, 255, 0.6);
  616. border-radius: 50rpx 50rpx 50rpx 50rpx;
  617. }
  618. .reward_image {
  619. width: 208rpx;
  620. height: 208rpx;
  621. background-size: 100% 100%;
  622. background-repeat: no-repeat;
  623. &.noget {
  624. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/noget.png');
  625. }
  626. &.score {
  627. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/score.png');
  628. }
  629. &.redpacket {
  630. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/redpacket.png');
  631. }
  632. }
  633. .reward_name {
  634. color: #333;
  635. text-align: center;
  636. }
  637. }
  638. }
  639. .close-btn {
  640. background-image: url('https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/lottery/close_btn.png');
  641. background-repeat: no-repeat;
  642. background-size: 100% 100%;
  643. width: 62rpx;
  644. height: 62rpx;
  645. margin-top: 32rpx;
  646. }
  647. }
  648. </style>