index.vue 16 KB

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