commonVue.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. bbb:'',
  23. //首页
  24. homeList: [],
  25. status: false,
  26. //解决方案
  27. array: [], //解决方案旧
  28. solutionArray: [], //解决方案详情数据
  29. solutionTypes: [], //解决方案类型
  30. // 新聞
  31. news: [],
  32. goPage: 1,
  33. one_page_size: 3,
  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.getQueryVariable('id')
  59. this.title = this.getQueryVariable('title')?this.getQueryVariable('title'):''
  60. alert(this.title)
  61. },
  62. mounted: function () {
  63. _this = this
  64. this.getColumnData()
  65. },
  66. methods: {
  67. //获取栏目
  68. getColumnData() {
  69. $.ajax({
  70. type: 'get',
  71. dataType: 'json',
  72. url: window.FQDN2 + 'siteCategory/siteCategoryList',
  73. }).done(function (res) {
  74. _this.columnList=res.data;
  75. _this.bbb=window.location.pathname
  76. for (let i = 0; i < res.data.length; i++) {
  77. // console.log(res.data[i].sname)
  78. // console.log(window.location.pathname)
  79. if (res.data[i].categoryName == '首页'&& window.location.pathname=='/index.html') {
  80. //首页旧
  81. jQuery.ajax({
  82. type: 'POST',
  83. dataType: 'json',
  84. url: window.FQDN + 'Index/index',
  85. }).done(function (res) {
  86. _this.homeList = res
  87. _this.status = true
  88. }).fail(function (err) {});
  89. }
  90. if (res.data[i].categoryName == '新闻动态'&& window.location.pathname=='/news/read.html') {
  91. console.log(res.data[i].categoryName)
  92. //新闻详情旧
  93. jQuery.ajax({
  94. type: 'POST',
  95. dataType: 'json',
  96. url: window.FQDN + 'agw/journalism_details',
  97. data: {
  98. id: 154
  99. }
  100. }).done(function(res) {
  101. if (!res.msg) {
  102. return;
  103. }
  104. _this.loading = false;
  105. _this.articleInfo = res;
  106. _this.relativeArr = res.related;
  107. console.log(_this.relativeArr)
  108. if (res.previous != null) {
  109. _this.previousInfo = res.previous;
  110. }
  111. if (res.next != null) {
  112. _this.nextInfo = res.next;
  113. }
  114. }).fail(function(err) {});
  115. }
  116. if (res.data[i].children.length > 0) {
  117. if (res.data[i].categoryName == '解决方案'&& window.location.pathname.indexOf('solution')>-1) {
  118. _this.solutionTypes = res.data[i].children
  119. _this.id = _this.getQueryVariable('id') ? _this.getQueryVariable('id') : _this.solutionTypes[0].id;
  120. _this.getArticalData(_this.id ? _this.id : _this.solutionTypes[0].id)
  121. //解决方案旧
  122. $.ajax({
  123. type: 'POST',
  124. dataType: 'json',
  125. url: window.FQDN + 'Solution/index',
  126. data: {
  127. id: '1'
  128. }
  129. }).done(function (arr) {
  130. _this.array = arr;
  131. console.log(_this.array)
  132. }).fail(function (err) {});
  133. }
  134. if (res.data[i].categoryName == '新闻动态'&& window.location.pathname.indexOf('news')>-1) {
  135. _this.solutionTypes = res.data[i].children
  136. _this.id = _this.getQueryVariable('id') ? _this.getQueryVariable('id') : _this.solutionTypes[0].id;
  137. _this.getArticalData(_this.id ? _this.id : _this.solutionTypes[0].id)
  138. }
  139. }
  140. }
  141. })
  142. },
  143. //获取内容
  144. getArticalData(param) {
  145. $.ajax({
  146. type: 'GET',
  147. dataType: 'json',
  148. url: window.FQDN2 + 'siteArticle/siteArticleList',
  149. data: {
  150. categoryid: param,
  151. pageNum:_this.currentPageNum,
  152. pageSize:_this.one_page_size,
  153. title:_this.title
  154. }
  155. }).done(function (res) {
  156. var aa = res.data.records
  157. aa.sort(_this.compare("lmtitle"))
  158. _this.loading = false;
  159. _this.solutionArray = aa;
  160. _this.totalPageSzie = res.data.total
  161. _this.totalPageNum = Math.ceil(res.data.total / res.data.size);
  162. console.log(aa)
  163. }).fail(function (err) {});
  164. },
  165. //类型点击
  166. facilityClick(e, item) {
  167. this.id = item.id
  168. this.getArticalData(item.id)
  169. this.currentPageNum=1
  170. // console.log(item.id)
  171. },
  172. // 分页
  173. oneInnerBox: function(param) {
  174. alert(param.title)
  175. window.location = "./read.html?id=" + param.id+'&title='+param.title;
  176. // window.location = "./read.html?id=154"
  177. },
  178. enterPage: function(res) {
  179. if (this.goPage >= 1 && this.goPage <= this.totalPageNum) {
  180. this.currentPageNum = this.goPage
  181. this.getArticalData(this.id ? this.id : this.solutionTypes[0].id)
  182. } else {
  183. this.goPage = 1
  184. alert('输入页数有误!')
  185. }
  186. },
  187. currentChange: function(res) {
  188. this.currentPageNum = res
  189. this.getArticalData(this.id ? this.id : this.solutionTypes[0].id)
  190. },
  191. // 排序
  192. compare(property) {
  193. return function (a, b) {
  194. var value1 = a[property];
  195. var value2 = b[property];
  196. return value1 - value2;
  197. }
  198. },
  199. //获取路由参数
  200. getQueryVariable: function (variable) {
  201. var query = window.location.search.substring(1);
  202. var vars = query.split("&");
  203. for (var i = 0; i < vars.length; i++) {
  204. var pair = vars[i].split("=");
  205. if (pair[0] == variable) {
  206. return pair[1];
  207. }
  208. }
  209. return (false);
  210. }
  211. }
  212. });