historypush.js 9.4 KB

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