historypush.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. var IframeOnClick = {
  2. resolution: 200,
  3. iframes: [],
  4. interval: null,
  5. Iframe: function() {
  6. this.element = arguments[0];
  7. this.cb = arguments[1];
  8. this.hasTracked = false;
  9. },
  10. track: function(element, cb) {
  11. this.iframes.push(new this.Iframe(element, cb));
  12. var _this = this;
  13. this.interval = setInterval(function() { _this.checkClick(); }, this.resolution);
  14. },
  15. checkClick: function() {
  16. if (document.activeElement) {
  17. var activeElement = document.activeElement;
  18. for (var i in this.iframes) {
  19. if (activeElement === this.iframes[i].element) { // user is in this Iframe
  20. if (this.iframes[i].hasTracked == false) {
  21. this.iframes[i].cb.apply(window, []);
  22. this.iframes[i].hasTracked = true;
  23. $.ajax({
  24. type: 'POST',
  25. url: '/publicapply/adLeague/click',
  26. data: {
  27. client: 'WX',
  28. id: 'ad6',
  29. position: '订阅推送列表页'
  30. },
  31. success: function(res) {
  32. console.log(res)
  33. }
  34. })
  35. }
  36. } else {
  37. this.iframes[i].hasTracked = false;
  38. }
  39. }
  40. }
  41. }
  42. };
  43. var vm = new Vue({
  44. el: '#select-meau',
  45. components: {
  46. dateComponent: dateComponent,
  47. areaCityMobile: areaCityMobileComponent,
  48. industryComponent: industryComponent,
  49. cateComponent: cateComponent,
  50. keywordComponent: keywordComponent,
  51. noticeComponent: noticeComponent,
  52. rootComponent: rootComponent
  53. },
  54. data () {
  55. return {
  56. sessStorageKey: '$data-historypush',
  57. // 时间参数
  58. time:'',
  59. // 选择的时间数据
  60. selectDate: {
  61. startDate: '',
  62. endDate: '',
  63. exact: ''
  64. },
  65. // 地区参数
  66. area: '',
  67. // 城市
  68. city: '',
  69. // 行业参数
  70. subscopeclass: '',
  71. // 采购单位
  72. buyerclass: '',
  73. // 关键词
  74. key: '',
  75. // 公告类型
  76. subtype: '',
  77. screenShow: false,
  78. tagText: {
  79. timeText: '时间',
  80. areaText: '地区',
  81. industryText: '行业',
  82. cateText: '采购单位',
  83. keywordText: '关键词',
  84. noticeText: '公告类型'
  85. },
  86. selectCateList: [], // 选择的采购单位类型列表
  87. selectAreaList: {}, // 选择的地区列表
  88. selectIndustryList: [], // 选择的行业列表
  89. selectKeyWordList: [], // 选择的关键词列表
  90. selectNoticeList: [], // 选择的公告类型列表
  91. setTimer: {
  92. datetimer: '',
  93. areatimer: '',
  94. catetimer: '',
  95. industrytimer: '',
  96. keytimer: '',
  97. noticetimer: ''
  98. },
  99. moreFiltersText: {
  100. cateItem: '',
  101. keywordItem: '',
  102. noticeItem: ''
  103. },
  104. moreFiltersTextCache: {
  105. cateItem: '',
  106. keywordItem: '',
  107. noticeItem: ''
  108. },
  109. moreFiltersShow: {
  110. cateItem: false, // 采购单位类型
  111. keywordItem: false, // 关键词
  112. noticeItem: false, // 公告类型
  113. },
  114. iosMeauStyle: false,
  115. goUpText: ''
  116. }
  117. },
  118. computed: {
  119. selectedMoreCancelDisabled: function () {
  120. return !(this.buyerclass || this.key || this.subtype)
  121. }
  122. },
  123. created () {
  124. this.getHasWeekMonthData()
  125. this.getUserRoot()
  126. if (firstTime) {
  127. firstTime = `${firstTime}_${firstTime}`
  128. this.time = firstTime
  129. this.setPushTime(firstTime)
  130. } else {
  131. firstTime = this.time
  132. }
  133. },
  134. mounted () {
  135. var recover = this.recover()
  136. if (!recover) {
  137. setTimeout(() => {
  138. // 如果订阅消息进来时间不为空
  139. if(this.time !== '') {
  140. this.setPushTime(this.time)
  141. this.revorceOtherData()
  142. }else{
  143. // 清空筛选数据
  144. this.revorceData()
  145. }
  146. })
  147. }
  148. // utils.iosBackRefresh()
  149. },
  150. methods: {
  151. showDialog: function (conf) {
  152. var defaultConf = {
  153. title: '提示',
  154. message: 'message',
  155. className: 'j-confirm-dialog',
  156. overlayClass: 'j-overlay',
  157. showConfirmButton: true,
  158. showCancelButton: true,
  159. confirmButtonText: '确定',
  160. confirmButtonColor: '#2abed1'
  161. }
  162. if (conf) {
  163. Object.assign(defaultConf, conf)
  164. }
  165. return this.$dialog.confirm(defaultConf)
  166. },
  167. // 显示去开通超级订阅弹框
  168. showSuperVipDialog: function () {
  169. this.showDialog({
  170. title: '开通超级订阅',
  171. message: '立享更多搜索权限\n寻找商机更精准',
  172. confirmButtonText: '去开通',
  173. className: 'j-confirm-dialog text-center super-vip-dialog',
  174. }).then(function () {
  175. topay()
  176. }).catch(function() {})
  177. },
  178. recover: function () {
  179. var excludeKey = ['sessStorageKey', 'moreFiltersShow']
  180. var $data = sessionStorage.getItem(this.sessStorageKey)
  181. if ($data) {
  182. $data = JSON.parse($data)
  183. for (var key in $data) {
  184. if (excludeKey.indexOf(key) !== -1) {
  185. continue
  186. }
  187. this.$data[key] = $data[key]
  188. }
  189. const res = $data
  190. // 时间
  191. console.log(res)
  192. if(res.time != '') {
  193. this.selectDate.startDate = res.time.split('_')[0] * 1000
  194. this.selectDate.endDate= res.time.split('_')[1] * 1000
  195. }
  196. // 地区
  197. if(res.area || res.city) {
  198. setTimeout(() => {
  199. this.$refs.areaCitySelector.setState(this.selectAreaList)
  200. $('.areaText').html(res.tagText.areaText)
  201. }, 0)
  202. }
  203. // 采购单位类型
  204. if(res.buyerclass != '') {
  205. this.selectCateList = res.buyerclass.split(',')
  206. this.moreFiltersText.cateItem = this.selectCateList.length
  207. }
  208. // 行业
  209. if(res.subscopeclass != '') {
  210. setTimeout(() => {
  211. $('.industryText').html(res.tagText.industryText)
  212. })
  213. this.selectIndustryList = res.subscopeclass.split(',')
  214. }
  215. // 关键词
  216. if(res.key != '') {
  217. this.selectKeyWordList = res.key.split(',')
  218. this.moreFiltersText.keywordItem = this.selectKeyWordList.length
  219. }
  220. // 公告类型
  221. if(res.subtype != '') {
  222. this.selectNoticeList = res.subtype.split(',')
  223. this.moreFiltersText.noticeItem = this.selectNoticeList.length
  224. }
  225. sessionStorage.removeItem(this.sessStorageKey)
  226. }
  227. return !!$data
  228. },
  229. // 清空筛选数据
  230. revorceData: function() {
  231. this.time = ''
  232. this.area = ''
  233. this.city = ''
  234. this.subtype = ''
  235. this.subscopeclass = ''
  236. this.key = ''
  237. this.buyerclass = ''
  238. },
  239. revorceOtherData: function() {
  240. this.area = ''
  241. this.city = ''
  242. this.subtype = ''
  243. this.subscopeclass = ''
  244. this.key = ''
  245. this.buyerclass = ''
  246. },
  247. open: function(name) {
  248. this.goUpText = name
  249. },
  250. close: function() {
  251. this.iosMeauStyle = false
  252. },
  253. calcSelected: function (which) {
  254. return this.moreFiltersText[which] || '全部'
  255. },
  256. moreFiltersItemShow: function (which, text) {
  257. this.goUpText = text
  258. if (this.screenShow) {
  259. this.moreFiltersShow[which] = true
  260. } else {
  261. this.showSuperVipDialog()
  262. }
  263. },
  264. // 订阅推送消息展示数据
  265. setPushTime: function(time) {
  266. let pushtime = {
  267. start: parseInt(time.split('_')[0] * 1000),
  268. end: parseInt(time.split('_')[0] * 1000),
  269. }
  270. this.tagText.timeText = new Date(pushtime.end).pattern('yyyy.MM.dd')
  271. this.selectDate.startDate = pushtime.start
  272. this.selectDate.endDate= pushtime.end
  273. this.selectDate.exact = 'exact'
  274. },
  275. // 判断是否显示免费用户体验报告入口
  276. checkShowFreeLink () {
  277. if (window.isFreeUserStatus && window.isUserWeekMonthStatus) {
  278. $(".vip_report").show();
  279. }
  280. },
  281. // 判断是否有周报月报数据
  282. getHasWeekMonthData: function () {
  283. var _this = this
  284. $.ajax({
  285. url: '/subscribepay/report/starttime?type=free',
  286. type: 'POST',
  287. success: function(res) {
  288. // 如果是商机管理、大会员、超级订阅会员有筛选权限
  289. if (res != 0) {
  290. window.isUserWeekMonthStatus = true
  291. _this.checkShowFreeLink()
  292. }
  293. }
  294. })
  295. },
  296. // 判断是否是有筛选条件
  297. getUserRoot: function() {
  298. var _this = this
  299. $.ajax({
  300. url: '/publicapply/bidcoll/power',
  301. type: 'POST',
  302. success: function(res) {
  303. // res.data.entniche = false
  304. // res.data.member = false
  305. // res.data.vip = 0
  306. // 如果是商机管理、大会员、超级订阅会员有筛选权限
  307. if (!res.data.member && res.data.vip <= 0) {
  308. window.isFreeUserStatus = true
  309. _this.checkShowFreeLink()
  310. }
  311. if(res.data.entniche || res.data.member || res.data.vip > 0) {
  312. _this.screenShow = true
  313. } else {
  314. _this.screenShow = false;
  315. (window.slotbydup = window.slotbydup || []).push({
  316. id: "u6603902",
  317. container: "_36y1d8lbx9n",
  318. async: true
  319. });
  320. (window.slotbydup = window.slotbydup || []).push({
  321. id: "u6603902",
  322. container: "_061vbh43quq3",
  323. async: true
  324. });
  325. _this.getAjaxAdv()
  326. setTimeout(() => {
  327. var frames = document.getElementById("iframeu6603902_0");
  328. console.log(frames, 'frames')
  329. IframeOnClick.track(frames, function() {
  330. jQuery(document).click();
  331. });
  332. }, 1000)
  333. }
  334. }
  335. })
  336. },
  337. getAjaxAdv () {
  338. $.ajax({
  339. type: 'POST',
  340. url: '/publicapply/adLeague/exposure',
  341. data: {
  342. client: 'WX',
  343. id: 'ad6',
  344. position: '订阅推送列表页'
  345. },
  346. success: function(res) {
  347. console.log(res)
  348. }
  349. })
  350. },
  351. selectedMoreConfirmed: function () {
  352. this.$refs.moreDropdownItems.toggle(false)
  353. if (this.screenShow) {
  354. this.buyerclass = this.moreFiltersTextCache.cateItem
  355. this.key = this.moreFiltersTextCache.keywordItem
  356. this.subtype = this.moreFiltersTextCache.noticeItem
  357. this.doSearch()
  358. }
  359. },
  360. selectedMoreCancel: function () {
  361. this.cancel({ name: 'cateItem' })
  362. this.cancel({ name: 'keywordItem' })
  363. this.cancel({ name: 'noticeItem' })
  364. this.$refs.moreDropdownItems.toggle(false)
  365. if (this.screenShow) {
  366. this.buyerclass = ''
  367. this.key = ''
  368. this.subtype = ''
  369. this.doSearch()
  370. }
  371. },
  372. confirm: function(data){
  373. if(data.name === 'dateItem'){
  374. const timeRange = {
  375. start: (data.data.start / 1000).toFixed(0),
  376. end: (data.data.end / 1000).toFixed(0)
  377. }
  378. if (timeRange.start == 0 && timeRange.end == 0) {
  379. this.time = ''
  380. this.tagText.timeText = '时间'
  381. } else if(timeRange.start == 0 && timeRange.end != 0) {
  382. this.time = '_' + timeRange.end
  383. } else if(timeRange.start != 0 && timeRange.end == 0) {
  384. this.time = timeRange.start + '_'
  385. } else {
  386. this.time = timeRange.start + '_' + timeRange.end
  387. }
  388. this.selectDate.exact = data.data.exact
  389. switch (data.data.exact) {
  390. case 'all': {
  391. this.tagText.timeText = '时间'
  392. break
  393. }
  394. case 'lately7': {
  395. this.tagText.timeText = '最近7天'
  396. break
  397. }
  398. case 'lately30': {
  399. this.tagText.timeText = '最近30天'
  400. break
  401. }
  402. case 'lastYear': {
  403. this.tagText.timeText = '去年'
  404. break
  405. }
  406. case 'exact': {
  407. this.tagText.timeText = new Date(timeRange.end*1000).pattern('yyyy.MM.dd')
  408. break
  409. }
  410. }
  411. this.setToggle()
  412. this.doSearch()
  413. } else if(data.name === 'areaCityItem'){
  414. var areaCityRes = data.data
  415. var count = data.count
  416. this.selectAreaList = areaCityRes
  417. if (!areaCityRes || Object.keys(areaCityRes).length === 0) {
  418. this.area = ''
  419. this.city = ''
  420. $('.areaText').html('地区')
  421. } else {
  422. var obj = {
  423. p: [], // 省份全选
  424. c: [] // 所有的市
  425. }
  426. for (var key in areaCityRes) {
  427. if (areaCityRes[key].length === 0) {
  428. obj.p.push(key)
  429. } else {
  430. obj.c = obj.c.concat(areaCityRes[key])
  431. }
  432. }
  433. $('.areaText').text('地区 ' + count)
  434. this.tagText.areaText = '地区 ' + count
  435. this.area = obj.p.join(',')
  436. this.city = obj.c.join(',')
  437. }
  438. this.setToggle()
  439. this.doSearch()
  440. } else if(data.name === 'industryItem'){
  441. $('.industryText').html(data.t)
  442. this.tagText.industryText = data.t
  443. this.subscopeclass = data.data.join(',')
  444. this.setToggle()
  445. this.doSearch()
  446. } else if(data.name === 'cateItem'){
  447. this.moreFiltersText.cateItem = data.t
  448. this.moreFiltersTextCache.cateItem = data.data.join(',')
  449. this.moreFiltersShow.cateItem = false
  450. } else if(data.name === 'keywordItem'){
  451. this.moreFiltersText.keywordItem = data.t.replace('关键词', '')
  452. this.moreFiltersTextCache.keywordItem = data.data.join(',')
  453. this.moreFiltersShow.keywordItem = false
  454. } else if(data.name === 'noticeItem'){
  455. this.moreFiltersText.noticeItem = data.t.replace('公告类型', '')
  456. this.moreFiltersTextCache.noticeItem = data.data.join(',')
  457. this.moreFiltersShow.noticeItem = false
  458. } else if(data.name === 'rootItem'){
  459. try {
  460. _hmt.push(['_trackEvent','超级订阅-wx', 'click', '推送列表页' + this.goUpText + '-去开通']);
  461. } catch (e) {
  462. console.log('未初始化百度统计')
  463. }
  464. topay()
  465. } else {
  466. return console.log('暂无数据')
  467. }
  468. },
  469. cancel: function(data){
  470. if(data.name === 'dateItem'){
  471. this.time = ''
  472. this.tagText.timeText = '时间'
  473. this.selectDate.start = ''
  474. this.selectDate.end = ''
  475. this.selectDate.exact = 'all'
  476. this.setTimer.datetimer = new Date().getTime()
  477. this.setToggle()
  478. this.doSearch()
  479. } else if(data.name === 'areaCityItem'){
  480. this.area = ''
  481. this.city = ''
  482. $('.areaText').html('地区')
  483. this.setTimer.areatimer = new Date().getTime()
  484. this.setToggle()
  485. this.doSearch()
  486. } else if(data.name === 'industryItem'){
  487. this.subscopeclass = ''
  488. $('.industryText').html('行业')
  489. this.setTimer.industrytimer = new Date().getTime()
  490. this.setToggle()
  491. this.doSearch()
  492. } else if(data.name === 'cateItem'){
  493. this.selectCateList = []
  494. this.moreFiltersTextCache.cateItem = ''
  495. this.moreFiltersText.cateItem = ''
  496. this.setTimer.catetimer = new Date().getTime()
  497. this.moreFiltersShow.cateItem = false
  498. } else if(data.name === 'keywordItem'){
  499. this.selectKeyWordList = []
  500. this.moreFiltersTextCache.keywordItem = ''
  501. this.moreFiltersText.keywordItem = ''
  502. this.setTimer.keytimer = new Date().getTime()
  503. this.moreFiltersShow.keywordItem = false
  504. } else if(data.name === 'noticeItem'){
  505. this.selectNoticeList = []
  506. this.moreFiltersTextCache.noticeItem = ''
  507. this.moreFiltersText.noticeItem = ''
  508. this.setTimer.noticetimer = new Date().getTime()
  509. this.moreFiltersShow.noticeItem = false
  510. } else if(data.name === 'rootItem') {
  511. this.setToggle()
  512. }
  513. },
  514. doSearch: function (delay) {
  515. delay = delay || 500
  516. setTimeout(this.getAjaXParams, delay)
  517. },
  518. getAjaXParams: function() {
  519. ajaxFun(this.time, this.area, this.city, this.subscopeclass, this.buyerclass, this.key, this.subtype)
  520. },
  521. setToggle: function() {
  522. this.$refs.dateItem.toggle(false)
  523. this.$refs.areaCityItem.toggle(false)
  524. this.$refs.industryItem.toggle(false)
  525. this.$refs.moreDropdownItems.toggle(false)
  526. }
  527. }
  528. })