commonVue.js 2.6 KB

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