Explorar el Código

校验我要投稿

ljh hace 2 años
padre
commit
056c25236e
Se han modificado 1 ficheros con 74 adiciones y 58 borrados
  1. 74 58
      nngkxxdp/src/main/resources/static/impression/js/inperssion.js

+ 74 - 58
nngkxxdp/src/main/resources/static/impression/js/inperssion.js

@@ -15,10 +15,10 @@ new Vue({
             tel: '',
             file: '',
             content: '',
-            title:'',
-            author:'',
+            title: '',
+            author: '',
         },
-        parent:{
+        parent: {
             page: 1,
             limit: 10,
             pictureType: 0,
@@ -27,7 +27,7 @@ new Vue({
     },
     methods: {
         beforeLiberation() {
-            this.parent.pictureType=0
+            this.parent.pictureType = 0
             this.getajax()
             $('.afterLiberation').hide(2000);
             $('.eightyYears').hide(2000);
@@ -36,36 +36,36 @@ new Vue({
             })
         },
         afterLiberation() {
-            this.parent.pictureType=1
+            this.parent.pictureType = 1
             this.getajax()
             $('.beforeLiberation').hide(2000);
             $('.eightyYears').hide(2000);
             $('.newCentury').hide(2000);
             $('.afterLiberation').show(2000, function () {
             });
-            
+
         },
         eightyYears() {
-            this.parent.pictureType=2
+            this.parent.pictureType = 2
             this.getajax()
             $('.beforeLiberation').hide(2000);
             $('.afterLiberation').hide(2000);
             $('.newCentury').hide(2000);
             $('.eightyYears').show(2000, function () {
-               
+
             });
-            
+
         },
         newCentury() {
-            this.parent.pictureType=3
+            this.parent.pictureType = 3
             this.getajax()
             $('.beforeLiberation').hide(2000);
             $('.afterLiberation').hide(2000);
             $('.eightyYears').hide(2000);
             $('.newCentury').show(2000, function () {
-               
+
             });
-            
+
         },
         contribute() {
             $('.contribute').show()
@@ -75,44 +75,60 @@ new Vue({
         },
         notarizeUp() {
             var _this = this
-            if (Number.isInteger(_this.form.tel)) {
-                var reg = /1[3-9]\d{9}/
-                if (reg.test(_this.form.tel)) {
-                    let FormDatas = new FormData()
-                    FormDatas.append('file', _this.form.file);
-                    FormDatas.append('uploaderPhone', _this.form.tel)
-                    FormDatas.append('pictureDescription', _this.form.content)
-                    FormDatas.append('pictureTitle', _this.form.title)
-                    FormDatas.append('pictureAuthor', _this.form.author)
-                    $.ajax({
-                        type: 'post',
-                        url: PATH+ '/yxnn/uploadDocumet',
-                        data: FormDatas,
-                        contentType: false,
-                        processData: false,
-                        success: function (json) {
-                            console.log(json)
-                            if(json.result){
-                                _this.getajax()
-                                _this.isshow=false
-                                _this.isshows=true
-                                _this.$message({
-                                    message: '发布成功',
-                                    type: 'success'
-                                });
-                                _this.form.tel='';
-                                _this.form.content='';
-                            }else{
-                                _this.$message(json.data);
-                            }
-                        },
-                        error: function (err) {
-                        }
-                    });
-                }
-
+            var reg = /1[3-9]\d{9}/
+            if (!reg.test(_this.form.tel)) {
+                _this.$message('请输入正确格式的电话');
+                return;
             }
-
+            if (!_this.form.title || _this.form.title.length > 20) {
+                _this.$message('请输入正确的作品名称');
+                return;
+            }
+            if (!_this.form.author || _this.form.author.length > 10) {
+                _this.$message('请输入作者');
+                return;
+            }
+            if (!_this.form.file) {
+                _this.$message('请添加文件');
+                return;
+            }
+            if (!_this.form.content) {
+                _this.$message('请添加内容');
+                return;
+            }
+            let FormDatas = new FormData()
+            FormDatas.append('file', _this.form.file);
+            FormDatas.append('uploaderPhone', _this.form.tel)
+            FormDatas.append('pictureDescription', _this.form.content)
+            FormDatas.append('pictureTitle', _this.form.title)
+            FormDatas.append('pictureAuthor', _this.form.author)
+            $.ajax({
+                type: 'post',
+                url: PATH + '/yxnn/uploadDocumet',
+                data: FormDatas,
+                contentType: false,
+                processData: false,
+                success: function (json) {
+                    console.log(json)
+                    if (json.result) {
+                        _this.getajax()
+                        _this.isshow = false
+                        _this.isshows = true
+                        _this.$message({
+                            message: '发布成功',
+                            type: 'success'
+                        });
+                        _this.form.tel = '';
+                        _this.form.content = '';
+                        _this.form.title = '';
+                        _this.form.author = '';
+                    } else {
+                        _this.$message(json.data);
+                    }
+                },
+                error: function (err) {
+                }
+            });
 
 
         },
@@ -128,14 +144,14 @@ new Vue({
             $.ajax({
                 type: 'get',
                 url: PATH + '/yxnn/getDocumentPage',
-                async:false,
+                async: false,
                 data: _this.parent,
                 success: function (json) {
                     var content = json.data.data;
 
-                    if(content.length>0){
+                    if (content.length > 0) {
                         var arr = [];
-                        var obj=[]
+                        var obj = []
                         obj.unshift([]);
                         for (var i = 0; i < content.length; i++) {
                             var year = content[i].updateTime.split('-');
@@ -143,17 +159,17 @@ new Vue({
                             obj.push({
                                 content: arr[i][0],
                                 time: arr[i][1] + '/' + arr[i][2].slice(0, 2),
-                                author: '《'+content[i].pictureTitle+'》作者:'+content[i].pictureAuthor,
+                                author: '《' + content[i].pictureTitle + '》作者:' + content[i].pictureAuthor,
                                 img: PATH + '/' + content[i].urlAddress,
-                                synopsis:content[i].pictureDescription
+                                synopsis: content[i].pictureDescription
                             })
                         }
-                        _this.activities=obj
+                        _this.activities = obj
                         obj.push([]);
-                    }else{
-                        _this.activities=[]
+                    } else {
+                        _this.activities = []
                     }
-                    
+
                 },
                 error: function (err) {
                 }