commonVue.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. var app = new Vue({
  2. el: '#app',
  3. data: {
  4. backBanner: "",
  5. solution: [],
  6. solution_type: 1,
  7. id: null,
  8. array: [],
  9. solutionArray:[],
  10. solutionTypes: [],
  11. colin: ''
  12. },
  13. computed: {
  14. },
  15. created: function () {
  16. this.solution_type = this.getQueryVariable('solution_type')
  17. this.id = this.getQueryVariable('id')
  18. this.backBanner = '../assets/img/solution/solution-banner1.jpg'
  19. },
  20. mounted: function () {
  21. _this=this
  22. this.getColumnData()
  23. $.ajax({
  24. type: 'POST',
  25. dataType: 'json',
  26. url: window.FQDN + 'Solution/index',
  27. data: {
  28. id: '1'
  29. }
  30. }).done(function (arr) {
  31. _this.array = arr;
  32. console.log(_this.array)
  33. }).fail(function (err) {});
  34. },
  35. methods: {
  36. //获取内容
  37. getArticalData(param){
  38. $.ajax({
  39. type: 'GET',
  40. dataType: 'json',
  41. url: window.FQDN2 + 'siteArticle/siteArticleList',
  42. data: {
  43. categoryid: param
  44. }
  45. }).done(function (res) {
  46. console.log(res);
  47. var aa=res.data.records
  48. aa.sort(_this.compare("lmtitle"))
  49. _this.solutionArray=aa
  50. }).fail(function (err) {});
  51. },
  52. //获取栏目
  53. getColumnData() {
  54. $.ajax({
  55. type: 'get',
  56. dataType: 'json',
  57. url: window.FQDN2 + 'siteCategory/siteCategoryList',
  58. }).done(function (res) {
  59. for (let i = 0; i < res.data.length; i++) {
  60. console.log(res.data[i].sname)
  61. console.log(window.location.pathname)
  62. if (res.data[i].children.length > 0) {
  63. if (res.data[i].categoryName == '解决方案') {
  64. _this.solutionTypes=res.data[i].children
  65. _this.colin=_this.getQueryVariable('id')?_this.getQueryVariable('id'): _this.solutionTypes[0].id;
  66. _this.getArticalData( _this.id ? _this.id : _this.solutionTypes[0].id)
  67. }
  68. }
  69. }
  70. })
  71. },
  72. // 排序
  73. compare(property) {
  74. return function (a, b) {
  75. var value1 = a[property];
  76. var value2 = b[property];
  77. return value1 - value2;
  78. }
  79. },
  80. //解决方案类型点击
  81. facilityClick(e, item) {
  82. this.colin = item.id
  83. this.getArticalData(item.id)
  84. console.log(item.id)
  85. },
  86. getQueryVariable: function (variable) {
  87. var query = window.location.search.substring(1);
  88. var vars = query.split("&");
  89. for (var i = 0; i < vars.length; i++) {
  90. var pair = vars[i].split("=");
  91. if (pair[0] == variable) {
  92. return pair[1];
  93. }
  94. }
  95. return (false);
  96. }
  97. }
  98. });