Commit 6aad7b33 by cwq0219

直播间

1 parent abfee68e
......@@ -10,4 +10,15 @@ const getWarehousListApi = params => {
})
}
export { getWarehousListApi }
const uploadImg = params => {
params.method = 'scrm.api.live.wechat.upload.image'
return http({
url: '',
method: 'POST',
data: params,
sign: true,
noSignAttr: ['file']
})
}
export { getWarehousListApi, uploadImg }
......@@ -45,7 +45,7 @@
</el-radio-group>
<el-date-picker v-else-if="item.type === 'datePicker'" v-model="formObj[item.name]" :type="item.dateType || 'daterange'" :clearable="item.isClear || false" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOption[item.pickerOptions]"></el-date-picker>
<!-- 图片上传 -->
<el-upload v-else-if="item.type === 'upload'" action="#" list-type="picture-card" :auto-upload="false" :limit="item.limitNum || 1" :fileList="formObj[item.name]" accept="image/jpeg,image/png,image/jpg" :on-change="(file, fileList) => handleChangeUpload(file, fileList, item)">
<el-upload v-else-if="item.type === 'upload'" :auto-upload="false" action="#" list-type="picture-card" :limit="item.limitNum || 1" :fileList="formObj[item.name]" accept="image/jpeg,image/png,image/jpg" :on-change="(file, fileList) => handleChangeUpload(file, fileList, item)">
<i slot="default" class="el-icon-plus"></i>
<div slot="file" slot-scope="{ file }">
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
......@@ -137,7 +137,12 @@ export default {
const limitSize = targetItem.limitSize || 10
const isType = ['image/jpeg', 'image/png', 'image/jpg'].includes(file.raw.type)
const isLt10M = file.size / 1024 / 1024 < limitSize
const limitNum = targetItem.limitNum || 1
if (limitNum == this.formObj[targetItem.name].length) {
this.$message.error('只能上传' + limitNum + '张图片')
return true
}
if (!isType) {
this.$message.error('上传图片不是jpg、jpeg或png的格式!')
this.formObj[targetItem.name] = this.formObj[targetItem.name].filter(item => item.uid != file.uid)
......
......@@ -14,9 +14,9 @@
</tr>
<tr>
<td><img :src="editForm.selectedProInfo.goodsImage" /></td>
<td>{{editForm.selectedProInfo.goodsName}}</td>
<td>{{editForm.selectedProInfo.goodsCode}}</td>
<td>{{editForm.selectedProInfo.goodsCode}}</td>
<td>{{ editForm.selectedProInfo.goodsName }}</td>
<td>{{ editForm.selectedProInfo.goodsCode }}</td>
<td>{{ editForm.selectedProInfo.goodsCode }}</td>
</tr>
</table>
</div>
......@@ -34,6 +34,7 @@ import _ from 'lodash'
import '@/assets/css/public.scss'
import glsxCombiForm from '@/components/glsx-combi-form'
import selectSingleProDialog from './selectSingleProDialog'
import { uploadImg } from '@/api/modules/cmmodityLibrary'
export default {
name: 'editProduct',
data() {
......@@ -43,7 +44,7 @@ export default {
editChildRef: 'editChildRef',
editForm: {
selectedProInfo: {},
thumbUrl: []
coverImgUrl: []
},
editRule: {
title: [{ required: true, message: '请输入商品名称', trigger: 'change' }],
......@@ -55,13 +56,23 @@ export default {
editFormData: [
{
label: '商品缩略图',
name: 'thumbUrl',
name: 'coverImgUrl',
type: 'upload',
limitSize: 1,
tips: '建议尺寸:300像素 * 300像素,图片大小不得超过1M',
handleUpload: (file, fileList, targetItem) => {
this.editForm[targetItem.name] = fileList
// this.editForm[targetItem.name] = fileList
// this.editForm[targetItem.name].pop()
var reader = new FileReader()
var fileInfo = file.raw
reader.readAsDataURL(fileInfo)
reader.onload = e => {
const imgFile = e.target.result
const base64 = fileInfo.name.split('.')[1] + '@' + imgFile.split(',')[1]
uploadImg({ file: base64, fileType: 'image' }).then(res => {
this.editForm[targetItem.name] = [{ url: res, uid: file.uid }]
})
}
}
},
{
......@@ -110,6 +121,7 @@ export default {
this.handleSinglePro()
},
handleConfirm() {
console.log(this.editForm)
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
console.log('-----------')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!