index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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" style="background: url(../static/activity/effectsone.png) no-repeat 100% 0%;background-size: 100%;">
  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 class="wrap-fixed" v-for="(item,index) in awardsList" :key="index">
  37. <view class="wrap-fixed-effectstwo" v-if="item.name == '一等奖'">
  38. <view class="effectsthree">
  39. <view class="effectsthree-width">
  40. <image src="../static/activity/effectsthree.png" mode=""></image>
  41. </view>
  42. <view class="effectsthree-position">{{item.quantity}}个名额 </view>
  43. <view class="effectsthree-positionTwo" >
  44. <image :src="awardsList[0].prizeList[0].picUrl" mode="" style=""></image>
  45. </view>
  46. </view>
  47. <view class="effectstwo" style="">
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view>
  53. <view v-for="(item,index) in awardsList" :key="index">
  54. <view v-if="item.name == '一等奖'">
  55. <view style="height: 90rpx;">
  56. <view style="float: left;">
  57. <text
  58. style="display: inline-block; background-color: #bbbbbb;width: 200rpx;height: 90rpx;line-height:90rpx;text-align: center;">{{item.name}}</text>
  59. </view>
  60. <view style="float: right;line-height: 90rpx;">{{item.quantity}}个名额</view>
  61. </view>
  62. <view v-for="(itemTwo,index) in item.prizeList" :key="index">
  63. <view style="text-align: center;">
  64. <image :src="itemTwo.picUrl" mode="" style="width: 400rpx;"></image>
  65. <view>{{itemTwo.title}}</view>
  66. <view>¥{{itemTwo.value / 100}}</view>
  67. </view>
  68. </view>
  69. <view v-if="item.prizeList.length > 1 " style="text-align: center;">以上奖品随机获得一件</view>
  70. </view>
  71. </view>
  72. <view v-for="(item,index) in awardsList" :key="index">
  73. <view v-if="item.name != '一等奖'">
  74. <view style="height: 60rpx;">
  75. <view style="float: left;">
  76. <text
  77. style="display: inline-block; background-color: #bbbbbb;width: 200rpx;height: 60rpx;line-height:60rpx;text-align: center;">{{item.name}}</text>
  78. </view>
  79. <view style="float: right;line-height: 60rpx;">{{item.quantity}}个名额</view>
  80. </view>
  81. <view v-for="(itemTwo,index) in item.prizeList" :key="index">
  82. <view style="overflow: hidden; width: 100%;padding: 10rpx 20rpx;">
  83. <view style="display: inline-block;">
  84. <image :src="itemTwo.picUrl" mode="" style="width: 100rpx;height: 100rpx;"></image>
  85. </view>
  86. <view style="display: inline-block;width: 60%;margin-left: 20rpx;">
  87. <view>{{itemTwo.title}}</view>
  88. <view>¥{{itemTwo.value / 100}}</view>
  89. </view>
  90. </view>
  91. </view>
  92. <view v-if="item.prizeList.length > 1 " style="text-align: center;">以上奖品随机获得一件</view>
  93. </view>
  94. </view>
  95. </view>
  96. <view>
  97. <view style="height: 90rpx;line-height: 90rpx;">
  98. <text
  99. style="display: inline-block; background-color: #bbbbbb;width: 200rpx;text-align: center;">图文介绍</text>
  100. </view>
  101. <view v-html="description">{{description}} </view>
  102. </view>
  103. <view v-if="false"> 关注公众号:获取抽奖码和开奖提醒 > </view>
  104. <view>
  105. <view>我的抽奖码</view>
  106. <view style="text-align: center;margin-top: 20rpx;margin-bottom: 50rpx;">
  107. <view v-if="info.codeList.length > 0">
  108. <view v-for="(item,index) in info.codeList">{{item}}</view>
  109. </view>
  110. <view v-else>还没有抽奖码</view>
  111. </view>
  112. <view style="text-align: center;line-height: 90rpx;border-top: 2rpx solid #555;">抽奖码越多,中奖概率越大</view>
  113. </view>
  114. <view style="height: 200rpx;"></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" @click="exChange">获取抽奖码</button>
  118. <u-count-down v-else :time="activityTimeTwo" format="DD:HH:mm:ss" autoStart millisecond @change="onChange">
  119. <button style="background-color: #555;" type="default">
  120. 开启倒计时:{{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}}
  121. </button>
  122. </u-count-down>
  123. </view>
  124. </view>
  125. <u-popup :show="popupShow" mode="bottom" @close="close" closeable>
  126. <view
  127. style="height: 98rpx;width: 100%; border-bottom: 2rpx solid #bbbbbb;text-align: center;line-height: 98rpx;">
  128. 获取抽奖码</view>
  129. <view style="padding: 30rpx 20rpx;">
  130. <view style="color: #101010; line-height: 50rpx;">邀请好友助力,获取抽奖码</view>
  131. <text style="color: #8c8c8c; font-size: 24rpx;">每邀请一位好友助力成功,即可获得1个抽奖码,没有上限</text>
  132. </view>
  133. <view style="padding: 0rpx 20rpx 50rpx ; ">
  134. <button type="default" style="background-color: #f7682b; color: #fff;"
  135. open-type="share">立即邀请好友助力</button>
  136. </view>
  137. </u-popup>
  138. </view>
  139. </template>
  140. <script>
  141. import env from '../../config/env.js'
  142. import $http from '@/utils/request.js'
  143. export default {
  144. data() {
  145. return {
  146. popupShow: false,
  147. id: '',
  148. description: '', //富文本
  149. info: {}, //列表
  150. timeData: {}, //时间
  151. awardsList: [], //奖品
  152. inviteCode: '', //邀请码
  153. activityTime: 0,
  154. activityTimeTwo: 0,
  155. }
  156. },
  157. onLoad(opthios) {
  158. this.id = opthios.id
  159. this.getDetail()
  160. },
  161. onShow() {
  162. },
  163. methods: {
  164. getDetail() {
  165. uni.showLoading({
  166. title: '加载中'
  167. });
  168. $http.post(`/api/v1/mp/user/marketing/detail/${this.id}`, {}).then(res => {
  169. uni.hideLoading();
  170. if (res.code == 0) {
  171. this.info = res.data
  172. let awardsList = res.data.awardsList
  173. awardsList.forEach(item => {
  174. item.prizeList.forEach(itemTwo => {
  175. itemTwo.picUrl = (env.filePublic + itemTwo.picUrl.split(',')[0] + '?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. },
  192. onChange(e) {
  193. this.timeData = e
  194. },
  195. exChange() {
  196. //弹出层打开
  197. this.popupShow = true
  198. $http.post('/api/v1/mp/user/marketing/inviteCode', {}).then(res => {
  199. if (res.code == 0) {
  200. this.inviteCode = res.data
  201. }
  202. })
  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. .wrap{
  253. &-fakeNum {
  254. margin-top: 46rpx;
  255. .fakeNum{
  256. line-height: 66rpx; text-align: center; width: 266rpx; height: 76rpx; background: url(../static/activity/rectangle.png) no-repeat center center; background-size: 266rpx 76rpx; margin: 0 auto; color: #A13D01; font-size: 30rpx;
  257. }
  258. }
  259. &-date {
  260. text-align: center;width: 100%;font-family: YouSheBiaoTiHei;color: #FFFFFF;
  261. &-on {
  262. display: inline-block;font-size: 76rpx;line-height: 68rpx;
  263. &-line {
  264. display: inline-block; width: 68rpx; height: 2rpx; overflow: hidden;background-color: #fff; position: relative; bottom: 25rpx;
  265. }
  266. }
  267. &-date {
  268. font-size: 52rpx;
  269. }
  270. }
  271. &-fixed {
  272. height: 630rpx;margin: 15rpx 30rpx;
  273. &-effectstwo {
  274. border-radius: 20rpx;width: 100%; height: 100%; background: url(../static/activity/effectstwo.png) no-repeat center center;
  275. .effectsthree {
  276. position: relative; height: 400rpx; width:100%; z-index: 10;
  277. &-width {
  278. position: absolute; width: 175rpx; height: 175rpx;margin: 0;
  279. image {
  280. width: 100%;height: 100%;
  281. }
  282. }
  283. &-position {
  284. position: absolute;width: 180rpx; height: 62rpx; background-image: linear-gradient( to right ,#FAE08A, #FFC45A);border-radius: 17rpx; line-height: 62rpx; text-align: center;color: #A13D01; font-size: 30rpx;top: 20rpx; right: 20rpx;
  285. }
  286. &-positionTwo {
  287. width: 100%;height: 100%;text-align: center;
  288. image {
  289. width: 330rpx;height: 330rpx; margin-top: 70rpx;
  290. }
  291. }
  292. }
  293. .effectstwo {
  294. position: relative; bottom: 110rpx; margin-left: 17.5%; width: 65%; height: 65%; background: url(../static/activity/effectssix.png) no-repeat 100% center;background-size: 100%;
  295. }
  296. }
  297. }
  298. }
  299. .data-btn {
  300. float: left;
  301. text {
  302. display: inline-block;
  303. width: 60rpx;
  304. }
  305. }
  306. .footer-fixed {
  307. position: fixed;
  308. bottom: var(--window-bottom);
  309. left: 0;
  310. right: 0;
  311. z-index: 11;
  312. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  313. background: #fff;
  314. // 设置ios刘海屏底部横线安全区域
  315. padding-bottom: constant(safe-area-inset-bottom);
  316. padding-bottom: env(safe-area-inset-bottom);
  317. .btn {
  318. padding: 20rpx 0;
  319. /deep/ button {
  320. width: 640rpx;
  321. height: 90rpx;
  322. line-height: 90rpx;
  323. font-size: 36rpx;
  324. color: #fff;
  325. background-color: $uni-bg-color;
  326. border: none;
  327. border-radius: 20rpx;
  328. }
  329. }
  330. // 设置ios刘海屏底部横线安全区域
  331. padding-bottom: constant(safe-area-inset-bottom);
  332. padding-bottom: env(safe-area-inset-bottom);
  333. }
  334. </style>