123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421 |
- // 定义一个名为 button-counter 的新组件
- Vue.component('button-counter', {
- props: ['title'],
- data() {
- return {
- count: 0
- }
- },
- methods: {
- addCount() {
- this.count++
- }
- },
- template: '<button @click="addCount">{{ title }} : You clicked me {{ count }} times.</button>'
- })
- var app = new Vue({
- el: '#app',
- data: {
- //公共
- id: null,
- columnList: [
- {categoryName:'首页',sname:'/index.html',id:1},
- {categoryName:'解决方案',sname:'/solution.html',id:2},
- {categoryName:'产品服务',sname:'/product.html',id:3},
- {categoryName:'新闻动态',sname:'/news.html',id:4},
- {categoryName:'关于永天',sname:'/about.html',id:5},
- ],
- currentPath: '',
- articalArray: [], //详情数组
- articalArrayRelated: [], //相关新闻
- columnTypes: [], //栏目类型
-
- // 公共弹框
- centerDialogVisible: false,
- dialogDataArray:[],
- ruleForm: {
- platName: '智慧安防',
- consultName: '',
- consultPhone: '',
- mail: '',
- company: '',
- consultContent: "",
- },
- rules: {
- platName: [{
- required: true,
- message: '请选择类型',
- trigger: 'change'
- },
- ],
- consultName: [{
- required: true,
- message: '请输入姓名',
- trigger: 'blur'
- }, ],
- consultPhone: [{
- required: true,
- message: '请输入正确的电话号码',
- pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
- trigger: 'change'
- }],
- mail: [{
- required: false,
- type: "email",
- message: "请输入正确的邮箱地址",
- trigger: 'blur'
- }],
- },
- //首页
- homeList: [],
- status: false,
- // 新闻
- news: [],
- goPage: 1,
- totalPageNum: 1,
- totalPageSzie: 1,
- loading: true,
- categoryid:0,
- requestParams:{
- categoryid: this.id,
- pageNum: 1,
- pageSize: 9,
- title: ''
- },
- //解决方案旧
- array: [],
- //新闻详情旧
- articleInfo: {},
- previousInfo: {},
- nextInfo: {},
- relativeArr: [],
- // ariticle_id: 0,
- },
- computed: {
- // 新闻详情旧
- isNews: function () {
- return (this.articleInfo.type == 1);
- },
- hasPrevious: function () {
- return Object.keys(this.previousInfo).length > 0;
- },
- hasNext: function () {
- return Object.keys(this.nextInfo).length > 0;
- }
- },
- created: function () {
- this.requestParams.categoryid = this.getQuery('id') ? this.getQuery('id') : ''
- // this.ariticle_id = this.getQuery('id')
- this.requestParams.title = this.getQuery('title') ? this.getQuery('title') : ''
- },
- mounted: function () {
- _this = this
- this.getColumnData()
- },
- methods: {
- //获取栏目
- getColumnData() {
- this.columnTypes = []
- $.ajax({
- type: 'get',
- dataType: 'json',
- url: window.FQDN2 + 'siteCategory/siteCategoryList',
- }).done(function (res) {
- _this.columnList = res.data;
- _this.currentPath = window.location.pathname
- for (let i = 0; i < res.data.length; i++) {
- // console.log(res.data[i].sname)
- // console.log(window.location.pathname)
-
- if (res.data[i].categoryName == '首页' && window.location.pathname == '/index.html') {
- //首页旧
- jQuery.ajax({
- type: 'POST',
- dataType: 'json',
- url: window.FQDN + 'Index/index',
- }).done(function (res) {
- _this.homeList = res
- _this.status = true
- }).fail(function (err) {});
- }
- if (res.data[i].categoryName == '产品服务' && window.location.pathname == '/product/read.html') {
- _this.currentPath = '/product/index.html' //产品详情时栏目高亮
- setTimeout(()=>{
- _this.requestParams.title=''
- _this.getArticalData( _this.requestParams,1)
- },1)
-
- }
- if (res.data[i].categoryName == '解决方案' && window.location.pathname == '/solution/read.html') {
- _this.currentPath = '/solution/index.html' //产品详情时栏目高亮
- //获取相关新闻数据
- setTimeout(()=>{
- _this.requestParams.title=''
- _this.getArticalData( _this.requestParams,1)
- },1)
-
- }
- if (res.data[i].categoryName == '解决方案') {
- _this.dialogDataArray=(res.data[i].children)
- _this.ruleForm.platName= _this.dialogDataArray[0].categoryName
- }
- if (res.data[i].categoryName == '新闻动态' && window.location.pathname == '/news/read.html') {
- _this.currentPath = '/news/index.html' //新闻详情时栏目高亮
- //获取相关新闻数据
- setTimeout(()=>{
- _this.requestParams.title=''
- _this.getArticalData( _this.requestParams,1)
- },1)
- //新闻详情旧
- jQuery.ajax({
- type: 'POST',
- dataType: 'json',
- url: window.FQDN + 'agw/journalism_details',
- data: {
- id: 154
- }
- }).done(function (res) {
- if (!res.msg) {
- return;
- }
- _this.loading = false;
- _this.articleInfo = res;
- _this.relativeArr = res.related;
- console.log(_this.relativeArr)
- if (res.previous != null) {
- _this.previousInfo = res.previous;
- }
- if (res.next != null) {
- _this.nextInfo = res.next;
- }
- }).fail(function (err) {});
- }
- if (res.data[i].categoryName == '关于永天' && window.location.pathname.indexOf('about') > -1) {
- _this.columnTypes = res.data[i].children
- _this.requestParams.categoryid=_this.getQuery('id')
- console.log(_this.requestParams)
- _this.getArticalData(_this.requestParams)
- //关于永天旧
- $.ajax({
- type: 'POST',
- dataType: 'json',
- url: window.FQDN + 'Aboutus/index',
- }).done(function (arr) {
- // console.log(arr)
- _this.array = arr;
- }).fail(function (err) {});
- }
- if (res.data[i].children.length > 0) {
- if (res.data[i].categoryName == '解决方案' && window.location.pathname.indexOf('solution') > -1) {
- _this.columnTypes = res.data[i].children
- _this.requestParams.categoryid = (_this.getQuery('isUrlId') == 1) ? _this.getQuery('id') : _this.columnTypes[0].id;
- _this.getArticalData(_this.requestParams)
- //解决方案旧
- $.ajax({
- type: 'POST',
- dataType: 'json',
- url: window.FQDN + 'Solution/index',
- data: {
- id: '1'
- }
- }).done(function (arr) {
- _this.array = arr;
- console.log(_this.array)
- }).fail(function (err) {});
- }
- if (res.data[i].categoryName == '新闻动态' && window.location.pathname.indexOf('news') > -1) {
- _this.columnTypes = res.data[i].children
- _this.requestParams.categoryid = (_this.getQuery('isUrlId') == 1) ? _this.getQuery('id') : _this.columnTypes[0].id;
- _this.getArticalData(_this.requestParams)
- }
- if (res.data[i].categoryName == '产品服务' && window.location.pathname.indexOf('product') > -1) {
- _this.columnTypes = res.data[i].children
- _this.requestParams.categoryid = (_this.getQuery('isUrlId') == 1) ? _this.getQuery('id') : _this.columnTypes[0].id;
- _this.getArticalData(_this.requestParams)
- }
- }
- }
- })
- },
- //获取内容
- getArticalData(requestParams,type) {
- $.ajax({
- type: 'GET',
- dataType: 'json',
- url: window.FQDN2 + 'siteArticle/siteArticleList',
- data: requestParams
- }).done(function (res) {
-
-
- var aa
- var bb
- if(type==1){
- bb=res.data.records
- }else{
- aa= res.data.records;
- // aa.sort(_this.compare("lmtitle"))
- _this.articalArray = aa;
- }
- if(bb){
- _this.articalArrayRelated =bb.filter(obj => obj.id != _this.articalArray[0].id);
- console.log(_this.articalArrayRelated)
- }
- _this.loading = false;
- _this.totalPageSzie = res.data.total
- _this.totalPageNum = Math.ceil(res.data.total / res.data.size);
-
- }).fail(function (err) {});
- },
- //类型点击
- facilityClick(e, item) {
- this.requestParams.categoryid = item.id
- this.requestParams.pageNum = 1
- this.getArticalData(this.requestParams)
-
- },
- // 分页
- oneInnerBox: function (param) {
- window.location = "./read.html?id=" + param.categoryid + "&title=" + param.title+ "&isUrlId=1";
- // window.location = "./read.html?id=154"
- },
- enterPage: function (res) {
- if (this.goPage >= 1 && this.goPage <= this.totalPageNum) {
- this.requestParams.pageNum = this.goPage
- this.getArticalData(this.requestParams)
- } else {
- this.goPage = 1
- alert('输入页数有误!')
- }
- },
- currentChange: function (res) {
- this.requestParams.pageNum = res
- this.getArticalData(this.requestParams)
- },
- //首页
- scrollToTop() {
- window.scrollTo({
- top: 0,
- behavior: "smooth"
- });
- },
- //公共弹框
- submitForm(formName) {
- _this = this
- this.$refs[formName].validate((valid) => {
- if (valid) {
- console.log(_this.ruleForm)
- let param = JSON.stringify(_this.ruleForm)
- jQuery.ajax({
- type: 'POST',
- // dataType: 'json',
- contentType: 'application/json;charset=UTF-8',
- url: window.FQDN2 + 'siteReview',
- data: param
- }).done(function (res) {
- if (res.status === "SUCCESS") {
- _this.$message({
- message: '提交成功',
- type: 'success'
- });
- _this.centerDialogVisible = false
- _this.$refs[formName].resetFields(); //重置from校验
- }
- }).fail(function (err) {});
- } else {
- console.log('error submit!!');
- return false;
- }
- });
- },
- resetForm(formName) {
- this.$refs[formName].resetFields();
- this.centerDialogVisible = false
- },
- // 排序
- compare(property) {
- return function (a, b) {
- var value1 = a[property];
- var value2 = b[property];
- return value1 - value2;
- }
- },
- // 获取路由参数
- getQuery(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) return decodeURI(r[2]);
- return null;
- },
- //获得年月日时分秒 //传入日期//例:2020-10-27T14:36:23
- timeFormatSeconds(time) {
- var d = time ? new Date(time) : new Date();
- var year = d.getFullYear();
- var month = d.getMonth() + 1;
- var day = d.getDate();
- var hours = d.getHours();
- var min = d.getMinutes();
- var seconds = d.getSeconds();
- if (month < 10) month = '0' + month;
- if (day < 10) day = '0' + day;
- if (hours < 0) hours = '0' + hours;
- if (min < 10) min = '0' + min;
- if (seconds < 10) seconds = '0' + seconds;
- return (year + '-' + month + '-' + day + ' ' + hours + ':' + min + ':' + seconds);
- }
- }
- });
|