|
|
@@ -18,6 +18,7 @@
|
|
|
:hideImage="false"
|
|
|
:content="content"
|
|
|
@change="handleChange"
|
|
|
+ @changeText="handleChangeText"
|
|
|
placeholder="请输入话题描述"></editor>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -122,11 +123,12 @@ export default {
|
|
|
title: '', // 标题
|
|
|
selectedConsultCate: [], // 选中的技能分类
|
|
|
consultCate: [], // 技能分类数据源
|
|
|
- content: '', // 话题描述
|
|
|
+ content: '', // 话题描述富文本
|
|
|
+ contentText: '', // 话题描述文字
|
|
|
defaultContent: '', // 默认的话题描述
|
|
|
price: '', // 价格
|
|
|
week: [], // 接受咨询的星期几
|
|
|
- time: [], // 接受咨询的时间范围
|
|
|
+ time: null, // 接受咨询的时间范围
|
|
|
imageList: [], // 用户上传的图片
|
|
|
publishIsLoading: false,
|
|
|
pcreateIsLoading: false
|
|
|
@@ -168,22 +170,144 @@ export default {
|
|
|
_getConsultDetail () {
|
|
|
const self = this
|
|
|
|
|
|
- // this.$axios.$post('/api/sale/saleInfo', { sale_id: this.sale_id }).then(res => {
|
|
|
- // if (res.status === 1) {
|
|
|
- // console.log('获取技能详情成功', res.data)
|
|
|
- // self.title = res.data.title || ""
|
|
|
- // self.price = res.data.price || ""
|
|
|
- // self.content = res.data.content || self.defaultContent
|
|
|
- // if (res.data.cate_id_one && res.data.cate_id_two) {
|
|
|
- // self.selectedSkillCate = [res.data.cate_id_one, res.data.cate_id_two]
|
|
|
- // }
|
|
|
- // self._setSkillImages(res.data)
|
|
|
- // }
|
|
|
- // })
|
|
|
+ this.$axios.$post('/api/sale/saleInfo', { sale_id: this.sale_id }).then(res => {
|
|
|
+ if (res.status === 1) {
|
|
|
+ console.log('获取技能详情成功', res.data)
|
|
|
+ self.title = res.data.title || ""
|
|
|
+ self.price = res.data.price || ""
|
|
|
+ self.content = res.data.content || self.defaultContent
|
|
|
+ if (res.data.cate_id_one && res.data.cate_id_two) {
|
|
|
+ self.selectedConsultCate = [res.data.cate_id_one, res.data.cate_id_two]
|
|
|
+ }
|
|
|
+ self._setSkillImages(res.data)
|
|
|
+ let week = []
|
|
|
+ let time = []
|
|
|
+ let timeJson = JSON.parse(res.data.time_json || '')
|
|
|
+ for (let key in timeJson) {
|
|
|
+ let times = timeJson[key][0]
|
|
|
+ // 找到 stime !== etime 的项,即为用户选中的咨询时间(周几)
|
|
|
+ if (times.stime && times.etime && times.stime !== times.etime) {
|
|
|
+ week.push(key)
|
|
|
+ if (time.length === 0) {
|
|
|
+ // 未初始化开放时间,每天开放时间相同,初始化一次即可
|
|
|
+ // const now = new Date()
|
|
|
+ // const year = now.getFullYear()
|
|
|
+ // const month = now.getMonth()
|
|
|
+ // const date = now.getDate()
|
|
|
+ // const sHour = times.stime.split(':')[0]
|
|
|
+ // const sMin = times.stime.split(':')[1]
|
|
|
+ // const eHour = times.etime.split(':')[0]
|
|
|
+ // const eMin = times.etime.split(':')[1]
|
|
|
+ // const sDate = new Date(year, month, date, sHour, sMin)
|
|
|
+ // const eDate = new Date(year, month, date, eHour, eMin)
|
|
|
+
|
|
|
+ // time = [sDate, eDate]
|
|
|
+ time = [times.stime, times.etime]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.week = week
|
|
|
+ this.time = time
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 编辑时初始化图片列表 */
|
|
|
+ _setSkillImages (data) {
|
|
|
+ let images = data.image.split(',')
|
|
|
+ if (images && images.length > 0) {
|
|
|
+ images.forEach((image, index) => {
|
|
|
+ let imageName = this._getImageName(image);
|
|
|
+ console.log("imageName", imageName);
|
|
|
+ this.imageList.push({ name: imageName + index, url: image });
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /** 通过 image url 获取名字 */
|
|
|
+ _getImageName (url) {
|
|
|
+ if (url) {
|
|
|
+ try {
|
|
|
+ const lastquotaIndex = url.lastIndexOf("/");
|
|
|
+ const lastDotIndex = url.lastIndexOf('.');
|
|
|
+ return url.substring(lastquotaIndex + 1, lastDotIndex);
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ""
|
|
|
},
|
|
|
/** 创建、编辑咨询服务 */
|
|
|
- _publishConsultData (actionType) {
|
|
|
+ _publishConsultData (actType) {
|
|
|
+ const self = this
|
|
|
+ let timeJson = {
|
|
|
+ monday: [{ stime: '00:00', etime: '00:00' }],
|
|
|
+ tuesday: [{ stime: '00:00', etime: '00:00' }],
|
|
|
+ wednesday: [{ stime: '00:00', etime: '00:00' }],
|
|
|
+ thursday: [{ stime: '00:00', etime: '00:00' }],
|
|
|
+ friday: [{ stime: '00:00', etime: '00:00' }],
|
|
|
+ saturday: [{ stime: '00:00', etime: '00:00' }],
|
|
|
+ sunday: [{ stime: '00:00', etime: '00:00' }]
|
|
|
+ }
|
|
|
+ if (this.week.indexOf('monday') > -1) {
|
|
|
+ timeJson.monday = [{ stime: this.time[0], etime: this.time[1] }]
|
|
|
+ }
|
|
|
+ if (this.week.indexOf('tuesday') > -1) {
|
|
|
+ timeJson.tuesday = [{ stime: this.time[0], etime: this.time[1] }]
|
|
|
+ }
|
|
|
+ if (this.week.indexOf('wednesday') > -1) {
|
|
|
+ timeJson.wednesday = [{ stime: this.time[0], etime: this.time[1] }]
|
|
|
+ }
|
|
|
+ if (this.week.indexOf('thursday') > -1) {
|
|
|
+ timeJson.thursday = [{ stime: this.time[0], etime: this.time[1] }]
|
|
|
+ }
|
|
|
+ if (this.week.indexOf('friday') > -1) {
|
|
|
+ timeJson.friday = [{ stime: this.time[0], etime: this.time[1] }]
|
|
|
+ }
|
|
|
+ if (this.week.indexOf('saturday') > -1) {
|
|
|
+ timeJson.saturday = [{ stime: this.time[0], etime: this.time[1] }]
|
|
|
+ }
|
|
|
+ if (this.week.indexOf('sunday') > -1) {
|
|
|
+ timeJson.sunday = [{ stime: this.time[0], etime: this.time[1] }]
|
|
|
+ }
|
|
|
+
|
|
|
+ const data = {
|
|
|
+ title: this.title,
|
|
|
+ price: this.price,
|
|
|
+ content: this.content,
|
|
|
+ img: this.imageList.map((it) => it.url).join(","),
|
|
|
+ type: 2,
|
|
|
+ cate_id_one: this.selectedConsultCate[0],
|
|
|
+ cate_id_two: this.selectedConsultCate[1],
|
|
|
+ act: actType,
|
|
|
+ sale_id: this.sale_id || '',
|
|
|
+ time_json: JSON.stringify(timeJson)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (actType === 'pcreate') {
|
|
|
+ this.pcreateIsLoading = true
|
|
|
+ } else {
|
|
|
+ this.publishIsLoading = true
|
|
|
+ }
|
|
|
|
|
|
+ this.$axios.$post('/api/sale/create', data).then(res => {
|
|
|
+ if (res.status === 1) {
|
|
|
+ // self.$message.success(`${self.sale_id ? '编辑' : '创建'}技能成功!`)
|
|
|
+ if (actType === 'pcreate') {
|
|
|
+ self.$message.success('保存草稿成功')
|
|
|
+ } else {
|
|
|
+ self.$message.success('您已成功提交咨询服务审核,平台将在1-3个工作日内完成审核,并通过短信、邮件通知您')
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ window.location.href = '/consult/index'
|
|
|
+ }, 1200)
|
|
|
+ } else {
|
|
|
+ self.$message.error('保存失败')
|
|
|
+ }
|
|
|
+ }).then(() => {
|
|
|
+ setTimeout(() => {
|
|
|
+ self.pcreateIsLoading = false
|
|
|
+ self.publishIsLoading = false
|
|
|
+ }, 800)
|
|
|
+ })
|
|
|
},
|
|
|
/** 验证提交的数据 */
|
|
|
_validateConsultData () {
|
|
|
@@ -199,11 +323,11 @@ export default {
|
|
|
this.$message.error('话题标题不可超过50字符,请删减')
|
|
|
return false
|
|
|
}
|
|
|
- if (this.content.length < 50) {
|
|
|
+ if (this.contentText.length < 50) {
|
|
|
this.$message.error('话题描述不可少于50字符')
|
|
|
return false
|
|
|
}
|
|
|
- if (this.content.length > 5000) {
|
|
|
+ if (this.contentText.length > 5000) {
|
|
|
this.$message.error('话题描述不可超过5000字符,请删减')
|
|
|
return false
|
|
|
}
|
|
|
@@ -226,7 +350,7 @@ export default {
|
|
|
this.$message.error('请选择咨询时间')
|
|
|
return false
|
|
|
}
|
|
|
- if (this.time.length === 0) {
|
|
|
+ if (!this.time || this.time.length !== 2) {
|
|
|
this.$message.error('请选择开放时间')
|
|
|
return false
|
|
|
}
|
|
|
@@ -237,6 +361,10 @@ export default {
|
|
|
handleChange (val) {
|
|
|
this.content = val
|
|
|
},
|
|
|
+ /** 技能描述内容改变时,获取输入的 text */
|
|
|
+ handleChangeText (val) {
|
|
|
+ this.contentText = val
|
|
|
+ },
|
|
|
/** 点击提交审核时 */
|
|
|
handleCreate () {
|
|
|
if (this._validateConsultData()) {
|