index.vue 18 KB

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