index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. <template>
  2. <view style="background-image: linear-gradient(#FF8000,#FFA524,#FF8000); width: 100%; height: 100%;">
  3. <u-navbar title="免费抽奖" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
  4. <view class="wrap">
  5. <view class="wrap-fakeNum">
  6. <view class="fakeNum">{{info.fakeNum}}人已参与</view>
  7. </view>
  8. <view v-if="info.status && JSON.parse(info.status).value == 3" class="wrap-date">
  9. <view class="wrap-date-on">
  10. <view class="wrap-date-on-line" style="right: 30rpx;"></view>距离开奖
  11. <view class="wrap-date-on-line" style="left: 30rpx;"></view>
  12. </view>
  13. <u-count-down :time="activityTime" format="DD:HH:mm:ss" autoStart millisecond @change="onChange">
  14. <view class="wrap-date-date">
  15. <text>{{timeData.days}}天</text>
  16. <text>{{ timeData.hours>=10?timeData.hours:'0'+timeData.hours }}:</text>
  17. <text>{{ timeData.minutes>=10?timeData.minutes:'0'+timeData.minutes }}:</text>
  18. <text>{{ timeData.seconds>=10?timeData.seconds:'0'+timeData.seconds }}</text>
  19. </view>
  20. </u-count-down>
  21. </view>
  22. <view v-if="info.status && JSON.parse(info.status).value == 2" class="wrap-date">
  23. <view class="wrap-date-on">
  24. <view class="wrap-date-on-line" style="right: 30rpx;"></view>距离开始
  25. <view class="wrap-date-on-line" style="left: 30rpx;"></view>
  26. </view>
  27. <u-count-down :time="activityTimeTwo" format="DD:HH:mm:ss" autoStart millisecond @change="onChange">
  28. <view class="wrap-date-date">
  29. <text>{{timeData.days}}天</text>
  30. <text>{{ timeData.hours>=10?timeData.hours:'0'+timeData.hours }}:</text>
  31. <text>{{ timeData.minutes>=10?timeData.minutes:'0'+timeData.minutes }}:</text>
  32. <text>{{ timeData.seconds>=10?timeData.seconds:'0'+timeData.seconds }}</text>
  33. </view>
  34. </u-count-down>
  35. </view>
  36. <view v-for="(item,index) in awardsList" :key="index">
  37. <view class="wrap-fixed" v-for="(itemTwo,index) in item.prizeList" :key="index"
  38. v-if="item.name == '一等奖'">
  39. <view class="wrap-fixed-effectstwo">
  40. <view class="effectsthree">
  41. <view class="effectsthree-width">
  42. <image src="../static/activity/effectsthree.png"></image>
  43. <view class="effectsthree-width-name">
  44. {{item.name}}
  45. </view>
  46. </view>
  47. <view class="effectsthree-position">{{item.quantity}}个名额 </view>
  48. <view class="effectsthree-positionTwo">
  49. <view>
  50. <image :src="itemTwo.picUrl" mode="aspectFit"></image>
  51. </view>
  52. <view class="textone" v-if="itemTwo.prizeType && JSON.parse(itemTwo.prizeType).value == 'coin'" > {{itemTwo.title}}x{{itemTwo.value}} </view>
  53. <view class="textone" v-else> {{itemTwo.title}} </view>
  54. <view class="texttwo" v-if="itemTwo.prizeType && JSON.parse(itemTwo.prizeType).value == 'goods'"> ¥{{$numberFormat(itemTwo.value)}} </view>
  55. </view>
  56. </view>
  57. <view class="effectstwo"></view>
  58. </view>
  59. </view>
  60. </view>
  61. <view>
  62. <view v-for="(item,index) in awardsList" :key="index">
  63. <view v-if="item.name != '一等奖'">
  64. <view class="wrap-award">
  65. <view class="effectsthree">
  66. <view class="effectsthree-width">
  67. <image src="../static/activity/effectsthree.png" mode=""></image>
  68. <view class="effectsthree-width-name">
  69. {{item.name}}
  70. </view>
  71. </view>
  72. <view class="effectsthree-position">{{item.quantity}}个名额 </view>
  73. <view class="effectsthree-positionTwo" v-for="(itemTwo,index) in item.prizeList"
  74. :key="index">
  75. <view>
  76. <image :src="itemTwo.picUrl" mode="aspectFit" class="imatwo"></image>
  77. </view>
  78. <image src="../static/activity/effectssix.png" mode="" class="imgone"></image>
  79. <view class="textone" v-if="itemTwo.prizeType && JSON.parse(itemTwo.prizeType).value == 'coin'" > {{itemTwo.title}}x{{itemTwo.value}} </view>
  80. <view class="textone" v-else> {{itemTwo.title}} </view>
  81. <view class="texttwo" v-if="itemTwo.prizeType && JSON.parse(itemTwo.prizeType).value != 'coin'"> ¥{{$numberFormat(itemTwo.value)}} </view>
  82. </view>
  83. </view>
  84. <view v-if="item.prizeList.length > 1 " class="wrap-award-explain">以上奖品随机获得一件</view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 我的抽奖码 -->
  90. <view class="wrap-description">
  91. <view class="wrap-description-code"> 我的抽奖码</view>
  92. <view v-if="info.codeList.length > 0" class="wrap-description-codetwo">
  93. <view class="codeList" v-for="(item,index) in info.codeList">
  94. <view class="codeList-bottom">{{item}}</view>
  95. </view>
  96. </view>
  97. <view v-else class="wrap-description-codethree">
  98. <view class="codethree">
  99. <image src="../static/activity/off.png" mode="" class="codeimg"></image>
  100. </view>
  101. <text class="codesix" style="">还没有抽奖码</text>
  102. </view>
  103. <view class="wrap-description-codesix">
  104. 抽奖码越多,中奖概率越大</view>
  105. </view>
  106. <!-- 关注公众号 -->
  107. <view class="wrap-account">
  108. <image src="../static/activity/gzh.png" mode=""></image>
  109. </view>
  110. <!-- 图文介绍 -->
  111. <view class="wrap-descriptiontwo">
  112. <view v-html="description">{{description}} </view>
  113. </view>
  114. </view>
  115. <view class="footer-fixed">
  116. <view class="flex btn">
  117. <button v-if="info.status && JSON.parse(info.status).value == 3" type="default"
  118. @click="exChange" open-type="share">获取抽奖码</button>
  119. <u-count-down v-else :time="activityTimeTwo" format="DD:HH:mm:ss" autoStart millisecond
  120. @change="onChange">
  121. <button class="buttoncol" type="default">
  122. 开始倒计时:{{timeData.days}}&nbsp;天{{ timeData.hours>=10?timeData.hours:'0'+timeData.hours}}&nbsp;:{{timeData.minutes>=10?timeData.minutes:'0'+timeData.minutes}}&nbsp;:{{timeData.seconds>=10?timeData.seconds:'0'+timeData.seconds}}
  123. </button>
  124. </u-count-down>
  125. </view>
  126. </view>
  127. <!-- <u-popup :show="popupShow" mode="bottom" @close="close" closeable>
  128. <view class="popupcode">获取抽奖码</view>
  129. <view class="popupcodetwo">
  130. <view class="popupcodetwo-view">邀请好友助力,获取抽奖码</view>
  131. <text class="popupcodetwo-text">每邀请一位好友助力成功,即可获得1个抽奖码,没有上限</text>
  132. </view>
  133. <view class="popupcodethree" style="">
  134. <button type="default" class="popupcodethree-default" open-type="share">立即邀请好友助力</button>
  135. </view>
  136. </u-popup> -->
  137. </view>
  138. </template>
  139. <script>
  140. import env from '../../config/env.js'
  141. import $http from '@/utils/request.js'
  142. export default {
  143. data() {
  144. return {
  145. popupShow: false,
  146. id: '',
  147. description: '', //富文本
  148. info: {}, //列表
  149. timeData: {}, //时间
  150. awardsList: [], //奖品
  151. inviteCode: '', //邀请码
  152. activityTime: 0,
  153. activityTimeTwo: 0,
  154. }
  155. },
  156. onLoad(opthios) {
  157. this.id = opthios.id
  158. this.getDetail()
  159. },
  160. onShow() {
  161. },
  162. methods: {
  163. getDetail() {
  164. uni.showLoading({
  165. title: '加载中'
  166. });
  167. $http.post(`/api/v1/mp/user/marketing/detail/${this.id}`, {}).then(res => {
  168. uni.hideLoading();
  169. if (res.code == 0) {
  170. this.info = res.data
  171. let awardsList = res.data.awardsList
  172. awardsList.forEach(item => {
  173. item.prizeList.forEach(itemTwo => {
  174. itemTwo.picUrl = (env.filePublic + itemTwo.picUrl.split(',')[0] +
  175. '?imageView2/2/w/750')
  176. })
  177. })
  178. this.awardsList = awardsList
  179. // 处理富文本
  180. const description = res.data.description.replaceAll(".jpg\"", ".jpg?imageView2/2/w/750\"")
  181. .replaceAll(".jpeg\"", ".jpeg?imageView2/2/w/750\"").replaceAll(".png\"",
  182. ".png?imageView2/2/w/750\"");
  183. this.description = this.formatRichText(description);
  184. let timestamp = parseInt(new Date().getTime())
  185. this.activityTime = this.info.endTime - timestamp
  186. this.activityTimeTwo = this.info.startTime - timestamp
  187. }
  188. }).catch(() => {
  189. uni.hideLoading();
  190. })
  191. $http.post('/api/v1/mp/user/marketing/inviteCode', {}).then(res => {
  192. if (res.code == 0) {
  193. this.inviteCode = res.data
  194. }
  195. })
  196. },
  197. onChange(e) {
  198. this.timeData = e
  199. },
  200. exChange() {
  201. //弹出层打开
  202. // this.popupShow = true
  203. uni.requestSubscribeMessage({
  204. tmplIds: ['3y_My-yRmqmGd3-f-vAwNaK4LQeehzXBSNDi_5wcnFI',
  205. 'FGcPOV1j9ApESr3VUlWjFr6E1vF4X_h0LLN82T2CLL0',
  206. '92xxL8XTRPLROyNUtmN04OT0kyq4iwSCH3sz-j6zbZs'
  207. ],
  208. success(res) {
  209. }
  210. })
  211. },
  212. close() {
  213. //弹出层收起
  214. this.popupShow = false
  215. },
  216. /**
  217. * 处理富文本里的图片宽度自适应
  218. * 1.去掉img标签里的style、width、height属性
  219. * 2.img标签添加style属性:max-width:100%;height:auto
  220. * 3.修改所有style里的width属性为max-width:100%
  221. * 4.去掉<br/>标签
  222. * @param html
  223. * @returns {void|string|*}
  224. */
  225. formatRichText(html) { //控制小程序中图片大小
  226. let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
  227. match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
  228. match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
  229. match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
  230. return match;
  231. });
  232. newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
  233. match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
  234. 'max-width:100%;');
  235. return match;
  236. });
  237. newContent = newContent.replace(/<br[^>]*\/>/gi, '');
  238. newContent = newContent.replace(/\<img/gi,
  239. '<img style="max-width:100%;height:auto;font-size: 0;margin-top: -5px;"');
  240. return newContent;
  241. },
  242. },
  243. onShareAppMessage(res) {
  244. return {
  245. title: '超值宝贝免费抽,参与活动仅需3秒',
  246. path: `/pages/index/index?marketingId=${ this.info.id }&inviteCode=${ this.inviteCode }`
  247. }
  248. },
  249. }
  250. </script>
  251. <style lang="scss" scoped>
  252. .popupcode {
  253. height: 98rpx;
  254. width: 100%;
  255. background-color: #F8832C;
  256. text-align: center;
  257. line-height: 98rpx;
  258. color: #fff;
  259. font-size: 32rpx;
  260. }
  261. .popupcodetwo {
  262. padding: 30rpx 20rpx;
  263. &-view {
  264. color: #101010;
  265. line-height: 50rpx;
  266. font-size: 30rpx;
  267. }
  268. &-text {
  269. color: #8c8c8c;
  270. font-size: 26rpx;
  271. }
  272. }
  273. .popupcodethree {
  274. padding: 0rpx 20rpx 50rpx;
  275. &-default {
  276. background-color: #FCE9DB;
  277. color: #fff;
  278. border: 2rpx solid #F8832C;
  279. color: #F9832C;
  280. border-radius: 22rpx;
  281. }
  282. }
  283. .wrap {
  284. // 设置ios刘海屏底部横线安全区域
  285. // padding-bottom: constant(safe-area-inset-bottom);
  286. // padding-bottom: env(safe-area-inset-bottom);
  287. padding-bottom: 200rpx;
  288. background: url(../static/activity/effectsone.png) no-repeat 100% 0%;
  289. background-size: 100%;
  290. &-fakeNum {
  291. margin-top: 46rpx;
  292. .fakeNum {
  293. line-height: 66rpx;
  294. text-align: center;
  295. width: 266rpx;
  296. height: 76rpx;
  297. background: url(../static/activity/rectangle.png) no-repeat center center;
  298. background-size: 266rpx 76rpx;
  299. margin: 0 auto;
  300. color: #A13D01;
  301. font-size: 30rpx;
  302. }
  303. }
  304. &-date {
  305. text-align: center;
  306. width: 100%;
  307. font-family: YouSheBiaoTiHei;
  308. color: #FFFFFF;
  309. &-on {
  310. display: inline-block;
  311. font-size: 76rpx;
  312. line-height: 68rpx;
  313. &-line {
  314. display: inline-block;
  315. width: 68rpx;
  316. height: 2rpx;
  317. overflow: hidden;
  318. background-color: #fff;
  319. position: relative;
  320. bottom: 25rpx;
  321. }
  322. }
  323. &-date {
  324. font-size: 52rpx;
  325. }
  326. }
  327. &-fixed {
  328. height: 630rpx;
  329. margin: 30rpx 30rpx;
  330. &-effectstwo {
  331. border-radius: 20rpx;
  332. width: 100%;
  333. height: 100%;
  334. background: url(../static/activity/effectstwo.png) no-repeat center center;
  335. .effectsthree {
  336. position: relative;
  337. height: 400rpx;
  338. width: 100%;
  339. z-index: 10;
  340. &-width {
  341. position: absolute;
  342. width: 175rpx;
  343. height: 175rpx;
  344. margin: 0;
  345. image {
  346. width: 100%;
  347. height: 100%;
  348. }
  349. &-name {
  350. position: relative;
  351. left: 10rpx;
  352. top: -160rpx;
  353. transform: rotateZ(-45deg);
  354. color: #fff;
  355. font-size: 26rpx;
  356. }
  357. }
  358. &-position {
  359. position: absolute;
  360. width: 180rpx;
  361. height: 62rpx;
  362. background-image: linear-gradient(to right, #FAE08A, #FFC45A);
  363. border-radius: 17rpx;
  364. line-height: 62rpx;
  365. text-align: center;
  366. color: #A13D01;
  367. font-size: 30rpx;
  368. top: 20rpx;
  369. right: 20rpx;
  370. }
  371. &-positionTwo {
  372. width: 100%;
  373. height: 100%;
  374. text-align: center;
  375. image {
  376. width: 350rpx;
  377. height: 350rpx;
  378. margin-top: 70rpx;
  379. }
  380. .textone {
  381. margin-top: 80rpx;
  382. color: #333333;
  383. font-size: 30rpx;
  384. line-height: 40rpx;
  385. }
  386. .texttwo {
  387. color: #FE2616;
  388. font-size: 28rpx;
  389. line-height: 34rpx;
  390. }
  391. }
  392. }
  393. .effectstwo {
  394. position: relative;
  395. bottom: 120rpx;
  396. margin-left: 17.5%;
  397. width: 65%;
  398. height: 65%;
  399. background: url(../static/activity/effectssix.png) no-repeat 100% center;
  400. background-size: 100%;
  401. }
  402. }
  403. }
  404. &-award {
  405. padding-bottom: 50rpx;
  406. // height: 2230rpx;
  407. border-radius: 18rpx;
  408. margin: 30rpx 30rpx;
  409. background-color: #fff;
  410. .effectsthree {
  411. position: relative;
  412. // height: 400rpx;
  413. // width: 100%;
  414. // z-index: 10;
  415. &-width {
  416. position: absolute;
  417. width: 175rpx;
  418. height: 175rpx;
  419. margin: 0;
  420. image {
  421. width: 100%;
  422. height: 100%;
  423. }
  424. &-name {
  425. position: relative;
  426. left: 10rpx;
  427. top: -160rpx;
  428. transform: rotateZ(-45deg);
  429. color: #fff;
  430. font-size: 26rpx;
  431. }
  432. }
  433. &-position {
  434. position: absolute;
  435. z-index: 11;
  436. width: 180rpx;
  437. height: 62rpx;
  438. background-image: linear-gradient(to right, #FAE08A, #FFC45A);
  439. border-radius: 17rpx;
  440. line-height: 62rpx;
  441. text-align: center;
  442. color: #A13D01;
  443. font-size: 30rpx;
  444. top: 20rpx;
  445. right: 20rpx;
  446. }
  447. &-positionTwo {
  448. width: 100%;
  449. height: 600rpx;
  450. text-align: center;
  451. .imatwo {
  452. position: relative;
  453. width: 350rpx;
  454. height: 350rpx;
  455. margin-top: 70rpx;
  456. z-index: 10;
  457. }
  458. .textone {
  459. position: relative;
  460. bottom: 200rpx;
  461. z-index: 10;
  462. color: #333333;
  463. font-size: 30rpx;
  464. line-height: 40rpx;
  465. }
  466. .texttwo {
  467. position: relative;
  468. bottom: 195rpx;
  469. z-index: 10;
  470. color: #FE2616;
  471. font-size: 28rpx;
  472. line-height: 34rpx;
  473. }
  474. .imgone {
  475. width: 449rpx;
  476. height: 280rpx;
  477. position: relative;
  478. bottom: 80rpx;
  479. margin-left: 0%;
  480. z-index: 0;
  481. // width: 45%;
  482. // height: 45%;
  483. }
  484. }
  485. }
  486. &-explain {
  487. margin-top: 30rpx;
  488. text-align: center;
  489. color: #999999;
  490. font-size: 30rpx;
  491. }
  492. }
  493. &-description {
  494. min-height: 200rpx;
  495. background-color: #fff;
  496. margin: 30rpx 30rpx;
  497. border-radius: 18rpx;
  498. &-code {
  499. font-size: 30rpx;
  500. color: #333;
  501. padding: 36rpx 24rpx;
  502. }
  503. &-codetwo {
  504. text-align: center;
  505. margin-top: 20rpx;
  506. margin-bottom: 50rpx;
  507. .codeList {
  508. text-align: center;
  509. margin-bottom: 40rpx;
  510. &-bottom {
  511. margin: 0 auto;
  512. width: 526rpx;
  513. height: 94rpx;
  514. background-color: #F8832C;
  515. color: #fff;
  516. border-radius: 12rpx;
  517. font-size: 38rpx;
  518. line-height: 94rpx;
  519. }
  520. }
  521. }
  522. &-codethree {
  523. text-align: center;
  524. .codethree {
  525. margin-left: 80rpx;
  526. .codeimg {
  527. width: 200rpx;
  528. height: 200rpx;
  529. }
  530. }
  531. .codesix {
  532. line-height: 1rpx;color: #9A9FB4; font-size: 30rpx;
  533. }
  534. }
  535. &-codesix {
  536. text-align: center;line-height: 200rpx;padding-bottom: 10rpx; font-size: 28rpx; color: #666;
  537. }
  538. }
  539. &-descriptiontwo {
  540. margin: 30rpx;
  541. border-radius: 18rpx;
  542. overflow: hidden;
  543. background-color: #fff;
  544. }
  545. &-account {
  546. margin: 15rpx 15rpx 0 15rpx;
  547. image {
  548. width: 100%;
  549. height: 152rpx;
  550. }
  551. }
  552. }
  553. .data-btn {
  554. float: left;
  555. text {
  556. display: inline-block;
  557. width: 60rpx;
  558. }
  559. }
  560. .footer-fixed {
  561. position: fixed;
  562. bottom: var(--window-bottom);
  563. left: 0;
  564. right: 0;
  565. z-index: 11;
  566. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  567. background: #fff;
  568. // 设置ios刘海屏底部横线安全区域
  569. padding-bottom: constant(safe-area-inset-bottom);
  570. padding-bottom: env(safe-area-inset-bottom);
  571. .btn {
  572. padding: 20rpx 0;
  573. /deep/ button {
  574. width: 640rpx;
  575. height: 90rpx;
  576. line-height: 90rpx;
  577. font-size: 34rpx;
  578. color: #fff;
  579. background-color: #FF6000;
  580. border: none;
  581. border-radius: 48rpx;
  582. }
  583. }
  584. .buttoncol {
  585. background-color: #555;
  586. }
  587. }
  588. </style>