Commit a9d4f9a2 by test

朋友圈发表动态添加校验

1 parent 7d11f964
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<div style="margin:10px 0;display:flex;"> <div style="margin:10px 0;display:flex;">
<el-button type="primary" size="mini" @click="gotoRoute">发表动态</el-button> <el-button type="primary" size="mini" @click="gotoRoute">发表动态</el-button>
<el-button type="primary" size="mini" @click="syncFn">同步朋友圈</el-button> <el-button type="primary" size="mini" @click="syncFn">同步朋友圈</el-button>
<div class="time" v-if="lastSyncTime">{{lastSyncTime}}</div> <div class="time" v-if="lastSyncTime">最近同步:{{lastSyncTime}}</div>
<div class="time" v-else>暂无记录,请手动点击同步</div> <div class="time" v-else>暂无记录,请手动点击同步</div>
</div> </div>
</div> </div>
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<img style="margin-right: 3px; height: 12px; width: 12px" :src="require('@/assets/drainageCode/delete.png')" alt="" />删除 <img style="margin-right: 3px; height: 12px; width: 12px" :src="require('@/assets/drainageCode/delete.png')" alt="" />删除
</div> </div>
</div> </div>
<el-form-item label="图片上传" required> <el-form-item label="图片上传" required :error="item.contentError">
<upload class="image-uploader" :fileUrl.sync="item.annexUrl" type="0"></upload> <upload class="image-uploader" :fileUrl.sync="item.annexUrl" type="0"></upload>
</el-form-item> </el-form-item>
</div> </div>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<img style="margin-right: 3px; height: 12px; width: 12px" :src="require('@/assets/drainageCode/delete.png')" alt="" />删除 <img style="margin-right: 3px; height: 12px; width: 12px" :src="require('@/assets/drainageCode/delete.png')" alt="" />删除
</div> </div>
</div> </div>
<el-form-item label="图文链接" style="width: 50%" required> <el-form-item label="图文链接" style="width: 50%" required :error="item.contentError">
<el-input v-model="item.annexUrl" placeholder="请输入图文链接"></el-input> <el-input v-model="item.annexUrl" placeholder="请输入图文链接"></el-input>
<div class="sub-des"> <div class="sub-des">
仅支持公众号图文链接,且必须以 http://或 https://开头 仅支持公众号图文链接,且必须以 http://或 https://开头
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<img style="margin-right: 3px; height: 12px; width: 12px" :src="require('@/assets/drainageCode/delete.png')" alt="" />删除 <img style="margin-right: 3px; height: 12px; width: 12px" :src="require('@/assets/drainageCode/delete.png')" alt="" />删除
</div> </div>
</div> </div>
<el-form-item label="视频上传" required> <el-form-item label="视频上传" required :error="item.contentError">
<upload class="image-uploader" :fileUrl.sync="item.annexUrl" type="2"></upload> <upload class="image-uploader" :fileUrl.sync="item.annexUrl" type="2"></upload>
</el-form-item> </el-form-item>
</div> </div>
...@@ -108,10 +108,6 @@ import { gotoPublish } from '@/api/circle' ...@@ -108,10 +108,6 @@ import { gotoPublish } from '@/api/circle'
import SelectTag from '@/components/SelectTag' import SelectTag from '@/components/SelectTag'
import SelectUser from '@/components/SelectUser' import SelectUser from '@/components/SelectUser'
import upload from '@/components/Upload' import upload from '@/components/Upload'
const materialField = {
annexType: "",
annexUrl: ""
}
export default { export default {
name: 'publish-detail', name: 'publish-detail',
components: { components: {
...@@ -158,7 +154,8 @@ import { gotoPublish } from '@/api/circle' ...@@ -158,7 +154,8 @@ import { gotoPublish } from '@/api/circle'
this.form.contentType = e this.form.contentType = e
this.form.otherContent.push({ this.form.otherContent.push({
annexType: e, annexType: e,
annexUrl: '' annexUrl: '',
contentError:''
}) })
}, },
onRemoveMaterial (index) { onRemoveMaterial (index) {
...@@ -171,7 +168,18 @@ import { gotoPublish } from '@/api/circle' ...@@ -171,7 +168,18 @@ import { gotoPublish } from '@/api/circle'
onBackStep () { onBackStep () {
this.$router.go(-1) this.$router.go(-1)
}, },
validateMaterial () {
let goto = true
this.form.otherContent.forEach(dd => {
if (!dd.annexUrl) {
dd.contentError = '内容不能为空'
goto = false
} else {
dd.contentError =''
}
})
return goto
},
submit () { submit () {
if (!this.form.content) { if (!this.form.content) {
this.welcomeMsgError = '请输入动态内容' this.welcomeMsgError = '请输入动态内容'
...@@ -187,24 +195,28 @@ import { gotoPublish } from '@/api/circle' ...@@ -187,24 +195,28 @@ import { gotoPublish } from '@/api/circle'
return dd.userId return dd.userId
}).join(',') }).join(',')
} }
let goto = true const checkMaterialResult = this.validateMaterial()
this.form.otherContent.forEach((dd) => { if (checkMaterialResult) {
if (dd.annexType === 'link') { let goto = true
let reUrl = /(http|https):\/\/([\w.]+\/?)\S*/ this.form.otherContent.forEach((dd) => {
if (!reUrl.test(dd.content)) { delete dd.contentError
goto = false if (dd.annexType === 'link') {
dd.contentError = '必须以 http://或 https://开头' let reUrl = /(http|https):\/\/([\w.]+\/?)\S*/
} if (!reUrl.test(dd.content)) {
} goto = false
}) dd.contentError = '必须以 http://或 https://开头'
this.$forceUpdate() }
if (goto) {
gotoPublish(this.form).then(res => {
if (res.code === 200) {
this.msgSuccess('操作成功')
this.$router.go(-1)
} }
}) })
this.$forceUpdate()
if (goto) {
gotoPublish(this.form).then(res => {
if (res.code === 200) {
this.msgSuccess('操作成功')
this.$router.go(-1)
}
})
}
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!