commonVue.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. // 定义一个名为 button-counter 的新组件
  2. Vue.component('button-counter', {
  3. props: ['title'],
  4. data () {
  5. return {
  6. count: 0
  7. }
  8. },
  9. methods: {
  10. addCount() {
  11. this.count++
  12. }
  13. },
  14. template: '<button @click="addCount">{{ title }} : You clicked me {{ count }} times.</button>'
  15. })
  16. var app = new Vue({
  17. el: '#app',
  18. data: {
  19. //公共
  20. id: null,
  21. columnList:[],
  22. currentPath:'',
  23. articalArray: [], //详情数组
  24. columnTypes: [], //栏目类型
  25. //首页
  26. homeList: [],
  27. status: false,
  28. //解决方案旧
  29. array: [],
  30. // 新闻
  31. news: [],
  32. goPage: 1,
  33. one_page_size: 9,
  34. currentPageNum: 1,
  35. totalPageNum: 1,
  36. totalPageSzie: 4,
  37. loading: true,
  38. //新闻详情旧
  39. articleInfo: {},
  40. previousInfo: {},
  41. nextInfo: {},
  42. relativeArr: [],
  43. ariticle_id: 0,
  44. },
  45. computed: {
  46. // 新闻详情旧
  47. isNews: function() {
  48. return (this.articleInfo.type == 1);
  49. },
  50. hasPrevious: function() {
  51. return Object.keys(this.previousInfo).length > 0;
  52. },
  53. hasNext: function() {
  54. return Object.keys(this.nextInfo).length > 0;
  55. }
  56. },
  57. created: function () {
  58. this.ariticle_id = this.getQuery('id')
  59. // this.title = this.getQuery('title')?this.getQuery('title'):''
  60. this.title = this.getQuery('title')?this.getQuery('title'):''
  61. },
  62. mounted: function () {
  63. _this = this
  64. this.getColumnData()
  65. },
  66. methods: {
  67. //获取栏目
  68. getColumnData() {
  69. this.columnTypes= []
  70. $.ajax({
  71. type: 'get',
  72. dataType: 'json',
  73. url: window.FQDN2 + 'siteCategory/siteCategoryList',
  74. }).done(function (res) {
  75. _this.columnList=res.data;
  76. _this.currentPath=window.location.pathname
  77. for (let i = 0; i < res.data.length; i++) {
  78. // console.log(res.data[i].sname)
  79. // console.log(window.location.pathname)
  80. if (res.data[i].categoryName == '首页'&& window.location.pathname=='/index.html') {
  81. //首页旧
  82. jQuery.ajax({
  83. type: 'POST',
  84. dataType: 'json',
  85. url: window.FQDN + 'Index/index',
  86. }).done(function (res) {
  87. _this.homeList = res
  88. _this.status = true
  89. }).fail(function (err) {});
  90. }
  91. if (res.data[i].categoryName == '产品服务'&& window.location.pathname=='/product/read.html') {
  92. _this.currentPath='/product/index.html' //新闻详情时栏目高亮
  93. }
  94. if (res.data[i].categoryName == '新闻动态'&& window.location.pathname=='/news/read.html') {
  95. _this.currentPath='/news/index.html' //新闻详情时栏目高亮
  96. console.log(res.data[i].categoryName)
  97. //新闻详情旧
  98. jQuery.ajax({
  99. type: 'POST',
  100. dataType: 'json',
  101. url: window.FQDN + 'agw/journalism_details',
  102. data: {
  103. id: 154
  104. }
  105. }).done(function(res) {
  106. if (!res.msg) {
  107. return;
  108. }
  109. _this.loading = false;
  110. _this.articleInfo = res;
  111. _this.relativeArr = res.related;
  112. console.log(_this.relativeArr)
  113. if (res.previous != null) {
  114. _this.previousInfo = res.previous;
  115. }
  116. if (res.next != null) {
  117. _this.nextInfo = res.next;
  118. }
  119. }).fail(function(err) {});
  120. }
  121. if (res.data[i].categoryName == '关于永天'&& window.location.pathname.indexOf('about')>-1) {
  122. _this.columnTypes = res.data[i].children
  123. // _this.id = _this.columnTypes[0].id;
  124. _this.getArticalData( _this.getQuery('id'))
  125. //关于永天旧
  126. $.ajax({
  127. type: 'POST',
  128. dataType: 'json',
  129. url: window.FQDN + 'Aboutus/index',
  130. }).done(function(arr) {
  131. // console.log(arr)
  132. _this.array = arr;
  133. }).fail(function(err) {});
  134. }
  135. if (res.data[i].children.length > 0) {
  136. if (res.data[i].categoryName == '解决方案'&& window.location.pathname.indexOf('solution')>-1) {
  137. _this.columnTypes = res.data[i].children
  138. _this.id = _this.columnTypes[0].id;
  139. _this.getArticalData(_this.id)
  140. //解决方案旧
  141. $.ajax({
  142. type: 'POST',
  143. dataType: 'json',
  144. url: window.FQDN + 'Solution/index',
  145. data: {
  146. id: '1'
  147. }
  148. }).done(function (arr) {
  149. _this.array = arr;
  150. console.log(_this.array)
  151. }).fail(function (err) {});
  152. }
  153. if (res.data[i].categoryName == '新闻动态'&& window.location.pathname.indexOf('news')>-1) {
  154. _this.columnTypes = res.data[i].children
  155. _this.id = _this.columnTypes[0].id;
  156. _this.getArticalData(_this.id)
  157. }
  158. if (res.data[i].categoryName == '产品服务'&& window.location.pathname.indexOf('product')>-1) {
  159. _this.columnTypes = res.data[i].children
  160. _this.id = _this.columnTypes[0].id;
  161. _this.getArticalData(_this.id)
  162. }
  163. }
  164. }
  165. })
  166. },
  167. //获取内容
  168. getArticalData(param) {
  169. $.ajax({
  170. type: 'GET',
  171. dataType: 'json',
  172. url: window.FQDN2 + 'siteArticle/siteArticleList',
  173. data: {
  174. categoryid: param,
  175. pageNum:_this.currentPageNum,
  176. pageSize:_this.one_page_size,
  177. title:_this.title
  178. }
  179. }).done(function (res) {
  180. var aa = res.data.records;
  181. aa.sort(_this.compare("lmtitle"))
  182. _this.loading = false;
  183. _this.articalArray = aa;
  184. _this.totalPageSzie = res.data.total
  185. _this.totalPageNum = Math.ceil(res.data.total / res.data.size);
  186. console.log(aa)
  187. }).fail(function (err) {});
  188. },
  189. //类型点击
  190. facilityClick(e, item) {
  191. this.id = item.id
  192. this.getArticalData(item.id)
  193. this.currentPageNum=1
  194. // console.log(item.id)
  195. },
  196. // 分页
  197. oneInnerBox: function(param) {
  198. window.location = "./read.html?id=" + param.categoryid+'&title='+param.title;
  199. // window.location = "./read.html?id=154"
  200. },
  201. enterPage: function(res) {
  202. if (this.goPage >= 1 && this.goPage <= this.totalPageNum) {
  203. this.currentPageNum = this.goPage
  204. this.getArticalData(this.id )
  205. } else {
  206. this.goPage = 1
  207. alert('输入页数有误!')
  208. }
  209. },
  210. currentChange: function(res) {
  211. this.currentPageNum = res
  212. this.getArticalData(this.id)
  213. },
  214. // 排序
  215. compare(property) {
  216. return function (a, b) {
  217. var value1 = a[property];
  218. var value2 = b[property];
  219. return value1 - value2;
  220. }
  221. },
  222. // 获取路由参数
  223. getQuery(name) {
  224. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  225. var r = window.location.search.substr(1).match(reg);
  226. if (r != null) return decodeURI(r[2]); return null;
  227. },
  228. //获得年月日时分秒
  229. //传入日期//例:2020-10-27T14:36:23
  230. timeFormatSeconds(time) {
  231. var d = time ? new Date(time) : new Date();
  232. var year = d.getFullYear();
  233. var month = d.getMonth() + 1;
  234. var day = d.getDate();
  235. var hours = d.getHours();
  236. var min = d.getMinutes();
  237. var seconds = d.getSeconds();
  238. if (month < 10) month = '0' + month;
  239. if (day < 10) day = '0' + day;
  240. if (hours < 0) hours = '0' + hours;
  241. if (min < 10) min = '0' + min;
  242. if (seconds < 10) seconds = '0' + seconds;
  243. return (year + '-' + month + '-' + day + ' ' + hours + ':' + min + ':' + seconds);
  244. }
  245. }
  246. });