Commit 1365dfe1 by 前端

配置物料加限制

1 parent 090b771a
......@@ -219,12 +219,9 @@
</div>
</template>
<template v-else-if="itm.materialType == ATT_TYPE.LINK">
<el-tag
type="info"
:closable="!linkStatus"
@close="close(index)"
>{{ itm.materialContent }}</el-tag
>
<el-tag type="info" closable @close="close(index)">{{
itm.materialContent
}}</el-tag>
</template>
<!-- <i class="el-icon-circle-close" @click="close(index)"></i> -->
</div>
......@@ -396,9 +393,7 @@ export default {
}
},
mounted() {
console.log(this.linkStatus, 999)
if (this.previewList.length) {
console.log(this.previewList, 999)
this.previewList.map((item) => {
if (item.materialType == ATT_TYPE.TEXT) {
this.textValue = this.changeText(item.materialContent)
......@@ -442,7 +437,6 @@ export default {
watch: {
previewList: {
handler(val) {
console.log(val, 'previewList')
this.$emit('shareMatrial', val)
this.$emit('getEditor')
},
......@@ -454,10 +448,8 @@ export default {
this.uploadInfo.clickEvent(e.srcElement.files)
},
resetItem() {
console.log(this.previewList, 'previewList')
this.previewList = []
this.textValue = ''
console.log(this.previewList, this.linkStatus, 'previewList2')
setTimeout(() => {
if (this.linkStatus) this.handleFun({ type: 'link' })
})
......@@ -527,29 +519,23 @@ export default {
},
// 上传图片
handleImgChange(e) {
// 判断是否有链接
var materialFlag = 0
this.previewList.some((item) => {
if (item.materialType == ATT_TYPE.LINK) {
materialFlag = materialFlag + 1
}
})
if (materialFlag) {
this.$message.error(
'为规范小程序显示样式,专属链接不能与图片或视频同时配置'
)
return
}
this.$notify({
title: '提示',
message: '图片上传中,请稍后',
})
// let imgFlag = false
// this.previewList.map((item) => {
// if (
// item.materialType != ATT_TYPE.IMAGE &&
// item.materialType != ATT_TYPE.TEXT
// ) {
// imgFlag = true
// }
// return imgFlag
// })
// let newList = []
// if (imgFlag) {
// this.previewList.map((item, index) => {
// if (item.materialType == this.ATT_TYPE.TEXT) {
// newList.push(item)
// }
// })
// this.previewList = newList
// }
var reader = new FileReader()
var file = e.srcElement.files[0]
// 默认1MB
......@@ -619,6 +605,20 @@ export default {
},
// 上传视频
async handleVideoChange(e) {
// 判断是否有链接
var materialFlag = 0
this.previewList.some((item) => {
if (item.materialType == ATT_TYPE.LINK) {
materialFlag = materialFlag + 1
}
})
if (materialFlag) {
this.$message.error(
'为规范小程序显示样式,专属链接不能与图片或视频同时配置'
)
document.querySelector('.upload-video').value = ''
return
}
await this.uploadFileVideo(e)
const that = this
this.uploadInfo = new upload({
......@@ -718,6 +718,22 @@ export default {
})
},
handleFun(type) {
// 判断是否有图片或者视频
var materialFlag = 0
this.previewList.some((item) => {
if (
item.materialType == ATT_TYPE.IMAGE ||
item.materialType == ATT_TYPE.VEDIO
) {
materialFlag = materialFlag + 1
}
})
if (materialFlag) {
this.$message.error(
'为规范小程序显示样式,专属链接不能与图片或视频同时配置'
)
return
}
const name = type.type
if (name == 'nickname') {
this.$refs.textContent.addTag('@昵称')
......@@ -733,13 +749,10 @@ export default {
if (this.previewList.length) {
let linkFlag = 0
this.previewList.map((item) => {
console.log(item)
if (item.materialType == this.ATT_TYPE.LINK) {
console.log(111)
linkFlag = linkFlag + 1
}
})
console.log(linkFlag, 'linkFlag')
if (linkFlag > 0) {
this.$message.warning('最多上传一条活动专属链接!')
return
......@@ -750,7 +763,6 @@ export default {
materialType: this.ATT_TYPE.LINK,
materialContent: '#活动专属链接#',
})
console.log(this.previewList)
}
},
close(index) {
......
......@@ -14,7 +14,7 @@
import MD5 from 'md5'
var that = ''
var w = {}
var upload = function(options) {
var upload = function (options) {
//upload("options") 或者 new upload("options")都可以使用upload方法
if (!(this instanceof upload)) {
return new upload(options)
......@@ -28,7 +28,7 @@ var upload = function(options) {
tips: '',
size: 2,
url: '',
success: ''
success: '',
},
options
)
......@@ -41,7 +41,7 @@ var upload = function(options) {
v: '1.0.0',
format: 'json',
url: 'http://didicb.glsx.com.cn/router',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b',
}
/*this.token = '';
......@@ -60,7 +60,7 @@ upload.prototype = {
/**
* 初始化方法
*/
init: function(id) {
init: function (id) {
if (!id) {
return false
}
......@@ -69,8 +69,6 @@ upload.prototype = {
that.config.id = id
console.log(that.config)
//创建最外层div
var _div = document.createElement('div')
_div.className = 'test'
......@@ -85,7 +83,8 @@ upload.prototype = {
var _input = document.createElement('input')
_input.type = 'file'
_input.className = 'file_input'
_input.style = 'opacity:0;position:absolute;top:0px;right:0px;bottom:0px;left:0px;font-size:14px;'
_input.style =
'opacity:0;position:absolute;top:0px;right:0px;bottom:0px;left:0px;font-size:14px;'
_input.onchange = this.clickEvent
_iptdiv.appendChild(_input)
......@@ -93,7 +92,8 @@ upload.prototype = {
var _button = document.createElement('button')
_button.className = 'testbu'
_button.innerText = '选择文件'
_button.style = 'border:1px solid #409eff;background:#409eff;color:#fff;border-radius:4px;padding:6px 14px;outline:none;font-size:14px;'
_button.style =
'border:1px solid #409eff;background:#409eff;color:#fff;border-radius:4px;padding:6px 14px;outline:none;font-size:14px;'
_iptdiv.appendChild(_button)
_div.appendChild(_iptdiv)
......@@ -124,12 +124,14 @@ upload.prototype = {
var _pDiv = document.createElement('div')
_pDiv.className = 'progress_box'
_pDiv.id = 'upload_progress_box'
_pDiv.style = 'background:#ebeef5;border-radius:100px;position:relative;height:2px;min-width:200px;display:none;'
_pDiv.style =
'background:#ebeef5;border-radius:100px;position:relative;height:2px;min-width:200px;display:none;'
//创建进度条内部
var _iDiv = document.createElement('div')
_iDiv.className = 'progress_box_inner'
_iDiv.style = 'background:#409eff;border-radius:2px;position:absolute;left:0px;top:0px;bottom:0px;border-radius:100px;'
_iDiv.style =
'background:#409eff;border-radius:2px;position:absolute;left:0px;top:0px;bottom:0px;border-radius:100px;'
_pDiv.appendChild(_iDiv)
_fileDiv.appendChild(_pDiv)
}
......@@ -139,7 +141,7 @@ upload.prototype = {
},
// 参数合并方法体
extend: function(obj, obj2) {
extend: function (obj, obj2) {
for (var key in obj2) {
obj[key] = obj2[key]
// 确保参数唯一
......@@ -158,7 +160,7 @@ upload.prototype = {
// }
// that.checkFile(files[0])
// },
clickEvent: function(e) {
clickEvent: function (e) {
var files = e
if (!files || files.length <= 0) {
return false
......@@ -168,7 +170,7 @@ upload.prototype = {
/**
* 处理选中的文件
*/
treatEvent: async function(file) {
treatEvent: async function (file) {
//var random = Math.random();
// var _workerJs = await that.calculateHashWorker()
// var _workerJs = that.createWorker()
......@@ -184,7 +186,7 @@ upload.prototype = {
oParams.config = that.config
//oParams.options = that.options;
webWorker.postMessage(oParams)
webWorker.onmessage = function(e) {
webWorker.onmessage = function (e) {
console.log(e)
var _obj = e.data
w = _obj
......@@ -199,10 +201,10 @@ upload.prototype = {
var _arr = fileSlice(_obj)
w.list = _arr
w.fileMD5 = _obj.fileMD5
Promise.all([r1]).then(res => {
Promise.all([r1]).then((res) => {
var _token = res[0]
that.config.token = _token
checkFileIsUpload(_obj.fileMD5).then(res => {
checkFileIsUpload(_obj.fileMD5).then((res) => {
var _data = res.data
if (res.code == 0) {
//如果存在fileUrl,则证明服务器存在该文件
......@@ -221,7 +223,7 @@ upload.prototype = {
/**
* 文件校验
*/
checkFile: function(file) {
checkFile: function (file) {
var o = that.options
var max = o.max ? Number(o.max) * 1024 * 1024 : ''
if (max && file.size > max) {
......@@ -242,17 +244,17 @@ upload.prototype = {
that.treatEvent(file)
},
async calculateHashWorker() {
return new Promise(resolve => {
return new Promise((resolve) => {
this.worker = new Worker('/hash.js')
this.worker.postMessage({ chunks: this.chunks })
this.worker.onmessage = e => {
this.worker.onmessage = (e) => {
const { hash } = e.data
if (hash) {
resolve(hash)
}
}
})
}
},
// //创建worker分线程
// createWorker: function() {
// var myWorker = function() {
......@@ -317,7 +319,7 @@ upload.prototype = {
* 封装请求方法
*/
function request(options) {
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
var _url = options.url
var _data = options.data
var xhr = new XMLHttpRequest()
......@@ -329,16 +331,16 @@ function request(options) {
xhr.responseType = options.responseType || 'json'
//请求成功
xhr.onload = function(res) {
xhr.onload = function (res) {
resolve(res.target.response)
}
//请求失败
xhr.onerror = function(res) {
xhr.onerror = function (res) {
reject(res.target.response)
}
//请求超时
xhr.ontimeout = function(res) {
xhr.ontimeout = function (res) {
reject(res.target.response)
}
......@@ -427,13 +429,15 @@ function send(arr) {
o.method = 'POST'
o.data = oParams
o.url = (that.options.url || that.config.url) + '?method=glsx.accounts.biz.common.uploadFileWithFileInfo'
o.url =
(that.options.url || that.config.url) +
'?method=glsx.accounts.biz.common.uploadFileWithFileInfo'
//fileFragmentUpload(o);
//如果存在url,则直接跳出循环
if (hasFile) {
return false
}
request(o).then(res => {
request(o).then((res) => {
if (res.code == 0) {
_num++
var _obj = res.data
......@@ -475,7 +479,7 @@ function _allCallback(url) {
*/
function fileFragmentUpload(oParams) {
request()
.then(res => {
.then((res) => {
if (res.code == 0) {
this._num++
var _obj = res.data
......@@ -493,7 +497,7 @@ function fileFragmentUpload(oParams) {
}; */
}
})
.catch(res => {
.catch((res) => {
fileFragmentUpload(oParams)
})
}
......@@ -518,7 +522,7 @@ function createSign(params) {
}
params[key] = obj
}
keys.forEach(e => {
keys.forEach((e) => {
!noSignAttr.includes(e) && str.push(e + params[e])
})
params.sign = MD5(secret + str.join('') + secret)
......@@ -577,7 +581,7 @@ function getParams(index, oInfo) {
* 获取token
*/
function getToken(file) {
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
var _obj = that.config
var o = {}
var oParams = {}
......@@ -608,14 +612,14 @@ function getToken(file) {
o.data = createSign(oParams)
o.method = 'GET'
request(o)
.then(res => {
.then((res) => {
if (res.code == 0) {
var _data = res.data || {}
w.token = _data.token
resolve(_data.token)
}
})
.catch(res => {
.catch((res) => {
reject(res)
})
})
......@@ -658,12 +662,12 @@ function checkFileIsUpload(md5) {
o.data = createSign(oParams)
o.method = 'GET'
request(o)
.then(res => {
.then((res) => {
if (res.code == 0) {
resolve(res)
}
})
.catch(res => {
.catch((res) => {
reject(res)
})
})
......
......@@ -118,12 +118,10 @@ export default {
return day
},
handleSelectItem(item) {
console.log(item)
this.selectItem = item
},
// 确认活动
confirmActivity() {
console.log(11)
if (!this.selectItem.id) {
this.$message({
message: '请选择活动',
......
......@@ -193,14 +193,18 @@
</el-form-item>
<el-form-item
label="分享模式:"
:prop="'missionList.' + index1 + '.shareModel'"
:rules="taskFormRules.shareModel"
v-if="itm.missonType && itm.missonType != 1"
:prop="'missionList.' + index1 + '.sharingMethod'"
:rules="taskFormRules.sharingMethod"
v-if="
itm.missonType &&
itm.missonType != 1 &&
itm.sharingMethod
"
>
<el-checkbox-group v-model="itm.shareModel">
<el-checkbox label="微信群发"></el-checkbox>
<el-checkbox label="分享好友"></el-checkbox>
<el-checkbox label="分享朋友圈"></el-checkbox>
<el-checkbox-group v-model="itm.sharingMethod">
<el-checkbox label="1">微信群发</el-checkbox>
<el-checkbox label="2">分享好友</el-checkbox>
<el-checkbox label="3">分享朋友圈</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item
......@@ -478,7 +482,7 @@ export default {
rewardCount: '',
triggerValue: '',
minTriggerValue: '',
shareModel: [],
sharingMethod: [],
},
// 浏览指标任务类型
browseObj: {
......@@ -488,7 +492,7 @@ export default {
repeatCount: '',
triggerValue: '',
minTriggerValue: '',
shareModel: [],
sharingMethod: [],
},
// 访客指标任务类型
visitorObj: {
......@@ -496,7 +500,7 @@ export default {
rewardType: '',
triggerValue: '',
minTriggerValue: '',
shareModel: [],
sharingMethod: [],
},
// 成单指标任务类型
orderObj: {
......@@ -504,7 +508,7 @@ export default {
rewardType: '',
triggerValue: '',
minTriggerValue: '',
shareModel: [],
sharingMethod: [],
},
// 编辑任务计划数据
taskEditList: {},
......@@ -558,7 +562,7 @@ export default {
rewardScore: [
{ required: true, trigger: 'blur', validator: validateAwardIntegral },
],
shareModel: [
sharingMethod: [
{ required: true, trigger: 'change', message: '请选择分享模式' },
],
attachmentList: [{ required: true, message: '请输入分享素材' }],
......@@ -755,7 +759,6 @@ export default {
...this.basicObj,
})
this.taskList[index].missionList[0].taskid = this.getUuid()
console.log(this.taskList[index].missionList[0])
},
// 任务选择类型切换
selectTaskType(dateTask, dateTaskIndex, task, taskIndex) {
......@@ -771,13 +774,6 @@ export default {
typeIndex = typeIndex + 1
}
})
} else {
// var box = document.getElementById('missionList' + task.id + 'welcome')
// if (box) {
// var editName = 'missionList' + task.id + 'welcome'
// // console.log(this.$refs[editName])
// // this.$refs[editName][0].resetItem()
// }
}
if (typeIndex > 1) {
this.$alert('每个时间标签下最多只能有1个该类型任务', '警告', {
......@@ -792,19 +788,19 @@ export default {
let taskItem
switch (task.missonType) {
case 1:
taskItem = { ...this.basicObj }
taskItem = Object.assign({}, this.basicObj)
break
case 2:
taskItem = { ...this.basicObj, ...this.shareObj }
taskItem = Object.assign({}, this.basicObj, this.shareObj)
break
case 3:
taskItem = { ...this.basicObj, ...this.browseObj }
taskItem = Object.assign({}, this.basicObj, this.browseObj)
break
case 4:
taskItem = { ...this.basicObj, ...this.visitorObj }
taskItem = Object.assign({}, this.basicObj, this.visitorObj)
break
case 5:
taskItem = { ...this.basicObj, ...this.orderObj }
taskItem = Object.assign({}, this.basicObj, this.orderObj)
break
default:
taskItem = { ...this.basicObj }
......@@ -828,7 +824,6 @@ export default {
this.$refs[editName][0].resetItem()
}
})
console.log(this.taskList[dateTaskIndex].missionList)
},
// 获取分享素材内容
getEditor(dateTask, dateTaskIndex, task, taskIndex) {
......@@ -921,10 +916,17 @@ export default {
if (!itm.missionMaterialList) {
delete itm.missionMaterialList
}
// 处理重复次数
if (itm.repeatCount && itm.repeatCount == -1) {
this.$set(itm, 'repeatFlag', true)
itm.repeatCount = ''
}
// 处理分享模式
if (itm.sharingMethod) {
itm.sharingMethod = itm.sharingMethod.split(',')
} else {
itm.sharingMethod = []
}
})
})
this.setHouseRatesColumn(startTime, endTime)
......@@ -943,7 +945,6 @@ export default {
},
// 奖励模式切换
rewardTypeChange(itm) {
console.log(itm)
if (itm.rewardType == 2) {
this.$nextTick(() => {
this.$set(itm, 'triggerValue', '')
......@@ -984,9 +985,7 @@ export default {
taskFormValidate() {
this.taskList.map((item, index) => {
this.$refs['taskForm'][index].validate((valid) => {
console.log(valid)
if (!valid) {
console.log(111)
this.validFlag = false
this.dayIndex = index
return
......@@ -1023,9 +1022,12 @@ export default {
itm.rewardCount == 2 &&
!itm.minTriggerValue
) {
console.log(22323233)
itm.minTriggerValue = 1
}
// 分享模式处理
if (itm.sharingMethod) {
itm.sharingMethod = itm.sharingMethod.toString()
}
// 自定义uuid删除
delete itm.taskid
})
......@@ -1076,7 +1078,6 @@ export default {
}
},
(err) => {
console.log(err)
this.$message({
message: err,
type: 'error',
......@@ -1088,7 +1089,6 @@ export default {
// 编辑
taskApi.updateMission(params).then(
(res) => {
console.log(res, 'res')
if (res && res.code == 0) {
this.$root.to([
'任务中心',
......@@ -1101,7 +1101,6 @@ export default {
}
},
(err) => {
console.log(err)
this.$message({
message: err,
type: 'error',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!