historypush.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. var vm = new Vue({
  2. el: '#select-meau',
  3. components: {
  4. dateComponent: dateComponent,
  5. areaCityMobile: areaCityMobileComponent,
  6. industryComponent: industryComponent,
  7. cateComponent: cateComponent,
  8. keywordComponent: keywordComponent,
  9. noticeComponent: noticeComponent,
  10. rootComponent: rootComponent
  11. },
  12. data () {
  13. return {
  14. sessStorageKey: '$data-historypush',
  15. // 时间参数
  16. time:'',
  17. // 选择的时间数据
  18. selectDate: {
  19. startDate: '',
  20. endDate: '',
  21. exact: ''
  22. },
  23. // 地区参数
  24. area: '',
  25. // 城市
  26. city: '',
  27. // 行业参数
  28. subscopeclass: '',
  29. // 采购单位
  30. buyerclass: '',
  31. // 关键词
  32. key: '',
  33. // 公告类型
  34. subtype: '',
  35. screenShow: false,
  36. tagText: {
  37. timeText: '时间',
  38. areaText: '地区',
  39. industryText: '行业',
  40. cateText: '采购单位',
  41. keywordText: '关键词',
  42. noticeText: '公告类型'
  43. },
  44. selectCateList: [], // 选择的采购单位类型列表
  45. selectAreaList: {}, // 选择的地区列表
  46. selectIndustryList: [], // 选择的行业列表
  47. selectKeyWordList: [], // 选择的关键词列表
  48. selectNoticeList: [], // 选择的公告类型列表
  49. setTimer: {
  50. datetimer: '',
  51. areatimer: '',
  52. catetimer: '',
  53. industrytimer: '',
  54. keytimer: '',
  55. noticetimer: ''
  56. },
  57. iosMeauStyle: false,
  58. goUpText: ''
  59. }
  60. },
  61. created () {
  62. this.getUserRoot()
  63. if (firstTime) {
  64. firstTime = `${firstTime}_${firstTime}`
  65. this.time = firstTime
  66. this.setPushTime(firstTime)
  67. } else {
  68. firstTime = this.time
  69. }
  70. },
  71. mounted () {
  72. var recover = this.recover()
  73. if (!recover) {
  74. setTimeout(() => {
  75. // 如果订阅消息进来时间不为空
  76. if(this.time !== '') {
  77. this.setPushTime(this.time)
  78. this.revorceOtherData()
  79. }else{
  80. // 清空筛选数据
  81. this.revorceData()
  82. }
  83. })
  84. }
  85. // utils.iosBackRefresh()
  86. },
  87. methods: {
  88. recover: function () {
  89. var excludeKey = ['sessStorageKey']
  90. var $data = sessionStorage.getItem(this.sessStorageKey)
  91. if ($data) {
  92. $data = JSON.parse($data)
  93. for (var key in $data) {
  94. if (excludeKey.indexOf(key) !== -1) {
  95. continue
  96. }
  97. this.$data[key] = $data[key]
  98. }
  99. const res = $data
  100. // 时间
  101. console.log(res)
  102. if(res.time != '') {
  103. this.selectDate.startDate = res.time.split('_')[0] * 1000
  104. this.selectDate.endDate= res.time.split('_')[1] * 1000
  105. }
  106. // 地区
  107. if(res.area || res.city) {
  108. setTimeout(() => {
  109. this.$refs.areaCitySelector.setState(this.selectAreaList)
  110. $('.areaText').html(res.tagText.areaText)
  111. }, 0)
  112. }
  113. // 采购单位类型
  114. if(res.buyerclass != '') {
  115. setTimeout(() => {
  116. $('.cateText').html(res.tagText.cateText)
  117. })
  118. this.selectCateList = res.buyerclass.split(',')
  119. }
  120. // 行业
  121. if(res.subscopeclass != '') {
  122. setTimeout(() => {
  123. $('.industryText').html(res.tagText.industryText)
  124. })
  125. this.selectIndustryList = res.subscopeclass.split(',')
  126. }
  127. // 关键词
  128. if(res.key != '') {
  129. setTimeout(() => {
  130. $('.keywordText').html(res.tagText.keywordText)
  131. })
  132. this.selectKeyWordList = res.key.split(',')
  133. }
  134. // 公告类型
  135. if(res.subtype != '') {
  136. setTimeout(() => {
  137. $('.noticeText').html(res.tagText.noticeText)
  138. })
  139. this.selectNoticeList = res.subtype.split(',')
  140. }
  141. sessionStorage.removeItem(this.sessStorageKey)
  142. }
  143. return !!$data
  144. },
  145. // 清空筛选数据
  146. revorceData: function() {
  147. this.time = ''
  148. this.area = ''
  149. this.city = ''
  150. this.subtype = ''
  151. this.subscopeclass = ''
  152. this.key = ''
  153. this.buyerclass = ''
  154. },
  155. revorceOtherData: function() {
  156. this.area = ''
  157. this.city = ''
  158. this.subtype = ''
  159. this.subscopeclass = ''
  160. this.key = ''
  161. this.buyerclass = ''
  162. },
  163. open: function(name) {
  164. this.goUpText = name
  165. },
  166. close: function() {
  167. this.iosMeauStyle = false
  168. },
  169. // 订阅推送消息展示数据
  170. setPushTime: function(time) {
  171. let pushtime = {
  172. start: parseInt(time.split('_')[0] * 1000),
  173. end: parseInt(time.split('_')[0] * 1000),
  174. }
  175. this.tagText.timeText = new Date(pushtime.end).pattern('yyyy.MM.dd')
  176. this.selectDate.startDate = pushtime.start
  177. this.selectDate.endDate= pushtime.end
  178. this.selectDate.exact = 'exact'
  179. },
  180. // 判断是否是有筛选条件
  181. getUserRoot: function() {
  182. let _this = this
  183. $.ajax({
  184. url: '/publicapply/bidcoll/power',
  185. type: 'POST',
  186. success: function(res) {
  187. // 如果是商机管理、大会员、超级订阅会员有筛选权限
  188. if(res.data.entniche || res.data.member || res.data.vip > 0) {
  189. _this.screenShow = true
  190. } else {
  191. _this.screenShow = false
  192. }
  193. }
  194. })
  195. },
  196. confirm: function(data){
  197. console.log(data)
  198. if(data.name === 'dateItem'){
  199. const timeRange = {
  200. start: (data.data.start / 1000).toFixed(0),
  201. end: (data.data.end / 1000).toFixed(0)
  202. }
  203. if (timeRange.start == 0 && timeRange.end == 0) {
  204. this.time = ''
  205. this.tagText.timeText = '时间'
  206. } else if(timeRange.start == 0 && timeRange.end != 0) {
  207. this.time = '_' + timeRange.end
  208. } else if(timeRange.start != 0 && timeRange.end == 0) {
  209. this.time = timeRange.start + '_'
  210. } else {
  211. this.time = timeRange.start + '_' + timeRange.end
  212. }
  213. this.selectDate.exact = data.data.exact
  214. switch (data.data.exact) {
  215. case 'all': {
  216. this.tagText.timeText = '时间'
  217. break
  218. }
  219. case 'lately7': {
  220. this.tagText.timeText = '最近7天'
  221. break
  222. }
  223. case 'lately30': {
  224. this.tagText.timeText = '最近30天'
  225. break
  226. }
  227. case 'lastYear': {
  228. this.tagText.timeText = '去年'
  229. break
  230. }
  231. case 'exact': {
  232. this.tagText.timeText = new Date(timeRange.end*1000).pattern('yyyy.MM.dd')
  233. break
  234. }
  235. }
  236. } else if(data.name === 'areaCityItem'){
  237. var areaCityRes = data.data
  238. var count = data.count
  239. this.selectAreaList = areaCityRes
  240. if (!areaCityRes || Object.keys(areaCityRes).length === 0) {
  241. } else {
  242. var obj = {
  243. p: [], // 省份全选
  244. c: [] // 所有的市
  245. }
  246. for (var key in areaCityRes) {
  247. if (areaCityRes[key].length === 0) {
  248. obj.p.push(key)
  249. } else {
  250. obj.c = obj.c.concat(areaCityRes[key])
  251. }
  252. }
  253. $('.areaText').text('地区 ' + count)
  254. this.tagText.areaText = '地区 ' + count
  255. this.area = obj.p.join(',')
  256. this.city = obj.c.join(',')
  257. }
  258. } else if(data.name === 'industryItem'){
  259. $('.industryText').html(data.t)
  260. this.tagText.industryText = data.t
  261. this.subscopeclass = data.data.join(',')
  262. } else if(data.name === 'cateItem'){
  263. $('.cateText').html('采购单位' + data.t)
  264. this.tagText.cateText = '采购单位' + data.t
  265. this.buyerclass = data.data.join(',')
  266. } else if(data.name === 'keywordItem'){
  267. $('.keywordText').html(data.t)
  268. this.tagText.keywordText = data.t
  269. this.key = data.data.join(',')
  270. } else if(data.name === 'noticeItem'){
  271. $('.noticeText').html(data.t)
  272. this.tagText.noticeText = data.t
  273. this.subtype = data.data.join(',')
  274. } else if(data.name === 'rootItem'){
  275. try {
  276. _hmt.push(['_trackEvent','超级订阅-wx', 'click', '推送列表页' + this.goUpText + '-去开通']);
  277. } catch (e) {
  278. console.log('未初始化百度统计')
  279. }
  280. topay()
  281. } else {
  282. return console.log('暂无数据')
  283. }
  284. this.setToggle()
  285. setTimeout(()=>{
  286. this.getAjaXParams()
  287. }, 500)
  288. },
  289. cancel: function(data){
  290. console.log(data)
  291. if(data.name === 'dateItem'){
  292. this.time = ''
  293. this.tagText.timeText = '时间'
  294. this.selectDate.start = ''
  295. this.selectDate.end = ''
  296. this.selectDate.exact = 'all'
  297. this.setTimer.datetimer = new Date().getTime()
  298. } else if(data.name === 'areaCityItem'){
  299. this.area = ''
  300. this.city = ''
  301. $('.areaText').html('地区')
  302. this.setTimer.areatimer = new Date().getTime()
  303. } else if(data.name === 'industryItem'){
  304. this.subscopeclass = ''
  305. $('.industryText').html('行业')
  306. this.setTimer.industrytimer = new Date().getTime()
  307. } else if(data.name === 'cateItem'){
  308. this.buyerclass = ''
  309. $('.cateText').html('采购单位')
  310. this.setTimer.catetimer = new Date().getTime()
  311. } else if(data.name === 'keywordItem'){
  312. this.key = ''
  313. $('.keywordText').html('关键词')
  314. this.setTimer.keytimer = new Date().getTime()
  315. } else if(data.name === 'noticeItem'){
  316. this.subtype = ''
  317. $('.noticeText').html('公告类型')
  318. this.setTimer.noticetimer = new Date().getTime()
  319. }
  320. this.setToggle()
  321. setTimeout(()=>{
  322. this.getAjaXParams()
  323. }, 500)
  324. },
  325. getAjaXParams: function() {
  326. ajaxFun(this.time, this.area, this.city, this.subscopeclass, this.buyerclass, this.key, this.subtype)
  327. },
  328. setToggle: function() {
  329. this.$refs.dateItem.toggle(false)
  330. this.$refs.areaCityItem.toggle(false)
  331. this.$refs.industryItem.toggle(false)
  332. this.$refs.cateItem.toggle(false)
  333. this.$refs.keywordItem.toggle(false)
  334. this.$refs.noticeItem.toggle(false)
  335. }
  336. }
  337. })