index.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. function initSwiper() {
  2. var interleaveOffset = 0.5; //视差比值
  3. function playAnOfIndex(index, type = true, delay = 0) {
  4. setTimeout(function () {
  5. var tempNode = $('.swiper-container .slide-inner').eq(index).find('*[animate-name]')
  6. $(tempNode).each(function () {
  7. var anName = $(this).attr('animate-name')
  8. var anDelay = $(this).attr('animate-delay') || '200'
  9. if (type) {
  10. $(this).addClass(anName)
  11. $(this).css('animation-delay', anDelay + 'ms')
  12. } else {
  13. tempNode.removeClass(anName)
  14. }
  15. })
  16. }, delay)
  17. }
  18. var swiperOptions = {
  19. loop: false,
  20. speed: 1000,
  21. grabCursor: true,
  22. watchSlidesProgress: true,
  23. mousewheelControl: false,
  24. direction: 'vertical',
  25. mousewheel: true,
  26. //设置宽度为全屏
  27. width: window.innerWidth,
  28. height: window.innerHeight,
  29. allowSlideNext: false,
  30. lazy: {
  31. loadPrevNext: true,
  32. },
  33. on: {
  34. init: function () {
  35. playAnOfIndex(0, true, 1000)
  36. },
  37. slideChangeTransitionStart: function () {
  38. var index = this.activeIndex
  39. playAnOfIndex(index, false)
  40. },
  41. slideChangeTransitionEnd: function () {
  42. var index = this.activeIndex
  43. playAnOfIndex(index)
  44. },
  45. slideChange: function () {
  46. var index = this.activeIndex
  47. playAnOfIndex(index)
  48. },
  49. progress: function () {
  50. for (var i = 0; i < this.slides.length; i++) {
  51. var slideProgress = this.slides[i].progress;
  52. var innerOffset = this.width * interleaveOffset;
  53. var innerTranslate = slideProgress * innerOffset;
  54. this.slides[i].querySelector(".slide-inner").style.transform =
  55. "translate3d(0," + innerTranslate + "px, 0)";
  56. }
  57. },
  58. touchStart: function () {
  59. for (var i = 0; i < this.slides.length; i++) {
  60. this.slides[i].style.transition = "";
  61. }
  62. },
  63. setTransition: function (speed) {
  64. for (var i = 0; i < this.slides.length; i++) {
  65. this.slides[i].style.transition = speed + "ms";
  66. this.slides[i].querySelector(".slide-inner").style.transition =
  67. speed + "ms";
  68. }
  69. }
  70. }
  71. };
  72. var swiper = new Swiper(this.$refs.mySwiper, swiperOptions);
  73. this.$swiper = swiper
  74. }
  75. function initPlayMusic() {
  76. var isAutoPlayMusic = false
  77. var bgvid = document.getElementById("audio");
  78. var b_music = document.getElementById('music-control-box')
  79. var fullbox = document.querySelector('body');
  80. fullbox.addEventListener('touchstart', function () {
  81. if (isAutoPlayMusic) {
  82. isAutoPlayMusic = false
  83. bgvid.play()
  84. b_music.classList.add('run-music')
  85. }
  86. }, false);
  87. bgvid.addEventListener("playing", function () {
  88. b_music.style.display = 'block'
  89. b_music.classList.add('run-music')
  90. });
  91. bgvid.addEventListener("pause", function () {
  92. b_music.classList.remove('run-music')
  93. });
  94. b_music.addEventListener('click', function (e) {
  95. if (b_music.classList.contains('run-music')) {
  96. bgvid.pause()
  97. b_music.classList.remove('run-music')
  98. } else {
  99. bgvid.play()
  100. b_music.classList.add('run-music')
  101. }
  102. })
  103. }
  104. function dateTime(date, fmt) {
  105. if (fmt === void 0) {
  106. fmt = 'yyyy年MM月dd日 hh:mm';
  107. }
  108. // 时间戳转换
  109. if (!date) return '';
  110. var d = new Date(date);
  111. var o = {
  112. "M+": d.getMonth() + 1,
  113. //月份
  114. "d+": d.getDate(),
  115. //日
  116. "h+": d.getHours(),
  117. //小时
  118. "m+": d.getMinutes(),
  119. //分
  120. "s+": d.getSeconds() //秒
  121. }; // 根据y的长度来截取年
  122. if (/(y+)/.test(fmt)) {
  123. fmt = fmt.replace(RegExp.$1, (d.getFullYear() + "").substr(4 - RegExp.$1.length));
  124. }
  125. for (var k in o) {
  126. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
  127. }
  128. return fmt;
  129. }
  130. const pageInfo = {
  131. // 用户信息
  132. user_name: '醉纸鸢',
  133. user_head: 'https://www.jianyu360.cn/images/auto.png',
  134. share_link: 'https://www.jianyu360.cn/images/auto.png',
  135. // 是否新用户
  136. is_new: false,
  137. // 注册时间 秒
  138. registration_time: 1644249599,
  139. // 距离今天的天数
  140. total_days: 100,
  141. // 近一年登录天数
  142. login_days: 50,
  143. // 深夜登录天数
  144. active_days: -1,
  145. // 最关注的项目名称
  146. focus_project: '最关注的项目名称',
  147. // 浏览信息次数
  148. view_total: 1000,
  149. // 搜索次数
  150. search_total: 999,
  151. // 企业/项目关注数量
  152. follow_total: -1,
  153. // 繁忙月份
  154. active_month: 7,
  155. // 行业发布数据条数
  156. industry_total: 99,
  157. // 体验新功能列表
  158. exp_list: ['大会员', '超级订阅', '数据导出', '行业解决方案'],
  159. // 结果页type
  160. result: 1
  161. }
  162. var vPage = new Vue({
  163. el: '.jy-report',
  164. delimiters: ['${', '}'],
  165. data: function () {
  166. return {
  167. pageInfo: pageInfo,
  168. showToastText: false,
  169. readPact: false
  170. }
  171. },
  172. created: function () {
  173. this.getPageInfo()
  174. },
  175. filters: {
  176. dateFormat: function (value) {
  177. return dateTime(value * 1000, 'yyyy年MM月dd日')
  178. }
  179. },
  180. mounted: function () {
  181. initPlayMusic()
  182. initSwiper.bind(this)()
  183. },
  184. methods: {
  185. goResult: function () {
  186. location.href = './yearEndReportResult'
  187. },
  188. getPageInfo: function () {
  189. var _this = this
  190. $.ajax({
  191. url: '/publicapply/active/yearEndReport',
  192. type: 'GET',
  193. success: function (res) {
  194. console.log(res)
  195. },
  196. error: function () {
  197. var res = {
  198. "error_code": 0,
  199. "error_msg": "",
  200. "data": {
  201. "user_name": "微信",
  202. "user_head": "/upload/2021/03/26/2021032609182610879.jpg",
  203. "registration_time": 1462779190,
  204. "login_days": 108,
  205. "active_days": 11,
  206. "view_total": 175,
  207. "search_total": 67,
  208. "follow_total": 17,
  209. "active_month": 11,
  210. "industry_total": 680708,
  211. "exp_list": [
  212. "大会员",
  213. "超级订阅"
  214. ],
  215. "focus_project": [
  216. "计算机",
  217. "信息技术"
  218. ],
  219. "total_days": 2076,
  220. "is_new": false,
  221. "result": 7,
  222. "share_link": "https://web-wky.jydev.jianyu360.com/active/yearEndReport?from=share"
  223. }
  224. }
  225. if (res && res.error_msg === '' && res.data) {
  226. _this.pageInfo = res.data
  227. }
  228. }
  229. })
  230. },
  231. changeReadPact: function () {
  232. if (this.$swiper.activeIndex === 0 && this.readPact) {
  233. return
  234. }
  235. this.$swiper.allowSlideNext = this.readPact
  236. },
  237. goStart: function () {
  238. if (!this.readPact) {
  239. return this.showToast('请先阅读并同意授权协议')
  240. }
  241. this.$swiper.allowSlideNext = this.readPact
  242. this.$swiper.slideNext()
  243. },
  244. showToast: function (str, delay = 1500) {
  245. this.showToastText = str
  246. setTimeout(() => {
  247. this.showToastText = false
  248. }, delay)
  249. }
  250. }
  251. })