skill-cert-activity.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div class="activity-area">
  3. <div class="activity-container">
  4. <div class="activity-title">
  5. <span class="text">100%接单限时活动</span>
  6. <span v-if="isShowCountDown" class="count-time">(剩余{{ text }})</span>
  7. </div>
  8. <div class="activity-list">
  9. <div class="activity-item">
  10. <h6>活动1(默认参与):不接单全额退+赠送会员</h6>
  11. <p>
  12. * 完成认证后,2个月内未成功接单,退还全部认证费用,并保留认证权益<br />
  13. * 参与认证,赠送1个月<a
  14. href="/type/vip/developer"
  15. class="color-4D81BF"
  16. >开发者会员</a
  17. >
  18. </p>
  19. </div>
  20. <div class="activity-item">
  21. <h6>活动2(提交时勾选即可):先认证,接单后</h6>
  22. <p>
  23. * 先进行认证,成功接单后再扣除150%的认证费用
  24. </p>
  25. </div>
  26. </div>
  27. <div class="activity-tips">
  28. 备注:活动1和活动2只能参与1个<br />
  29. 活动时间:2022年4月10日0点—2022年5月10日0点
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. // 模拟结束时间,4月10号0点
  39. endTime: 0,
  40. pageNow: Date.now(),
  41. serverTime: Date.now(),
  42. text: "",
  43. timer: null,
  44. isShowCountDown:false
  45. };
  46. },
  47. mounted() {
  48. this.fetchActivityTime()
  49. },
  50. methods: {
  51. async fetchActivityTime(){
  52. let result = await this.$axios.$post("/uapi/cert/info");
  53. if(result.status == 1){
  54. let {
  55. endtime
  56. } = result.data
  57. this.pageNow = Date.now();
  58. // 测试倒计时
  59. // endtime = 10
  60. if(endtime >0){
  61. this.isShowCountDown = true
  62. }else{
  63. this.isShowCountDown = false
  64. return
  65. }
  66. this.endTime = endtime * 1000
  67. this.timer = setInterval(() => {
  68. let now = Date.now();
  69. let desc = now - this.pageNow;
  70. let countDown = this.endTime - desc;
  71. if(countDown <= 0){
  72. this.isShowCountDown = false
  73. this.clearTimer()
  74. }
  75. this.parseCountDownText(countDown);
  76. }, 1000);
  77. }
  78. },
  79. clearTimer() {
  80. clearInterval(this.timer);
  81. this.timer = null;
  82. },
  83. // 以毫秒作为单位
  84. parseCountDownText(countDown) {
  85. // 转换秒为单位
  86. let countDownTime = Math.ceil(countDown / 1000);
  87. let day = parseInt(countDownTime / (24 * 60 * 60), 10);
  88. let dayText = day;
  89. countDownTime = countDownTime - day * 24 * 60 * 60;
  90. let hour = parseInt(countDownTime / (60 * 60), 10);
  91. let hourText = hour > 9 ? hour : "0" + hour;
  92. countDownTime = countDownTime - hour * 60 * 60;
  93. let minute = parseInt(countDownTime / 60, 10);
  94. let minuteText = minute > 9 ? minute : "0" + minute;
  95. countDownTime = countDownTime - minute * 60;
  96. let second = countDownTime;
  97. let text = `${dayText}天${hourText}小时${minuteText}分钟${second}秒`;
  98. this.text = text;
  99. }
  100. }
  101. };
  102. </script>
  103. <style lang="scss" scoped>
  104. .activity-area {
  105. width: 100%;
  106. }
  107. .activity-container {
  108. min-width: 670px;
  109. // background: #fff6f4 url("~@/assets/img/skill_cert/bg22.png") no-repeat 50% top;
  110. // background-size: 1048px auto;
  111. padding-bottom: 20px;
  112. background: #fff7f4;
  113. padding-top: 70px;
  114. position: relative;
  115. }
  116. %bg {
  117. content: "";
  118. position: absolute;
  119. top: 0;
  120. bottom: 0;
  121. width: 85px;
  122. z-index: 2;
  123. }
  124. .activity-title {
  125. position: absolute;
  126. z-index: 3;
  127. top: -10px;
  128. left: 50%;
  129. transform: translateX(-50%);
  130. height: 50px;
  131. width: 430px;
  132. text-align: center;
  133. font-size: 22px;
  134. font-family: PingFangSC-Medium, PingFang SC;
  135. font-weight: 500;
  136. color: #ffffff;
  137. line-height: 50px;
  138. text-shadow: 0px 2px 4px #ff5530;
  139. text-align: center;
  140. background: url("~@/assets/img/skill_cert/bg_c.png") repeat left top;
  141. .count-time {
  142. font-size: 16px;
  143. font-weight: normal !important;
  144. font-family: PingFangSC-Regular, PingFang SC;
  145. }
  146. &::before {
  147. @extend %bg;
  148. left: 3px;
  149. transform: translateX(-100%);
  150. background: url("~@/assets/img/skill_cert/pc_l.png") no-repeat left top;
  151. background-size: cover;
  152. }
  153. &::after {
  154. @extend %bg;
  155. right: 3px;
  156. width: 88px;
  157. transform: translateX(100%);
  158. background: url("~@/assets/img/skill_cert/pc_r.png") no-repeat right top;
  159. background-size: cover;
  160. }
  161. }
  162. .activity-list {
  163. // margin-top: 40px;
  164. margin-left: 30px;
  165. margin-right: 30px;
  166. display: flex;
  167. justify-content: space-between;
  168. flex-wrap: wrap;
  169. }
  170. .activity-item {
  171. width: 48.7%;
  172. padding: 20px;
  173. border: 1px dashed #ff844f;
  174. background-color: #fff;
  175. border-radius: 16px;
  176. h6 {
  177. font-size: 15px;
  178. font-family: PingFangSC-Medium, PingFang SC;
  179. font-weight: 500;
  180. color: #ff4d27;
  181. line-height: 21px;
  182. }
  183. p {
  184. font-size: 15px;
  185. font-family: PingFangSC-Regular, PingFang SC;
  186. font-weight: 400;
  187. color: #0b121a;
  188. line-height: 24px;
  189. margin-top: 14px;
  190. }
  191. }
  192. .color-4D81BF {
  193. color: #4d81bf;
  194. }
  195. .activity-tips {
  196. margin-left: 30px;
  197. margin-top: 18px;
  198. font-size: 14px;
  199. font-family: PingFangSC-Regular, PingFang SC;
  200. font-weight: 400;
  201. color: #666666;
  202. line-height: 24px;
  203. }
  204. @media screen and (max-width: 670px) {
  205. .activity-container {
  206. min-width: inherit;
  207. }
  208. .activity-list {
  209. display: block;
  210. }
  211. .activity-item {
  212. width: auto;
  213. margin-bottom: 30px;
  214. }
  215. .activity-title {
  216. height: auto;
  217. width:auto;
  218. line-height: 1;
  219. padding:7px 10px;
  220. background: url("~@/assets/img/skill_cert/m_bg.png") repeat left top;
  221. &::before {
  222. background: url("~@/assets/img/skill_cert/m_l.png") no-repeat left top;
  223. background-size: cover;
  224. width:44px;
  225. left:0;
  226. }
  227. &::after{
  228. background: url("~@/assets/img/skill_cert/m_r.png") no-repeat left top;
  229. background-size: auto 100%;
  230. width:50px
  231. }
  232. span {
  233. display: block;
  234. }
  235. .text {
  236. font-size: 20px;
  237. font-family: PingFangSC-Medium, PingFang SC;
  238. font-weight: 500;
  239. color: #ffffff;
  240. line-height: 28px;
  241. text-shadow: 0px 2px 4px #ff5530;
  242. }
  243. .count-time {
  244. margin-top: 2px;
  245. font-size: 14px;
  246. font-family: PingFangSC-Regular, PingFang SC;
  247. font-weight: 400;
  248. color: rgba(255, 255, 255, 0.8);
  249. line-height: 20px;
  250. width:180px;
  251. text-align: center;
  252. }
  253. }
  254. }
  255. </style>