diff --git a/pages/product/addGood/addGood.vue b/pages/product/addGood/addGood.vue index 796a2af..0ab7d5d 100644 --- a/pages/product/addGood/addGood.vue +++ b/pages/product/addGood/addGood.vue @@ -38,16 +38,16 @@ - + - + - + @@ -264,8 +264,7 @@ }) }, async submit() { - this.formData.imageList = this.formData.imageList.map(item => item.url) - console.log(this.formData) + // this.formData.imageList = this.formData.imageList.map(item => item.url) // await this.$refs.formData.validate() productCreate(this.mer_id, this.formData) .then(res => { @@ -282,7 +281,7 @@ }) }) .catch(rej => { - Toast(rej); + // Toast(rej); }); console.log(this.formData) } diff --git a/pages/product/addGood/addGoodOld.vue b/pages/product/addGood/addGoodOld.vue index 33e97b4..fc9575f 100644 --- a/pages/product/addGood/addGoodOld.vue +++ b/pages/product/addGood/addGoodOld.vue @@ -495,15 +495,15 @@ // selHeight: '350upx', // inner: true // }); - this.$util.uploadImageOne({ - url: 'upload/image', - crop: { - width: 2000, - height: 2000, - } - },(res)=> { - this.setFormData.imageList.push(res.data.path); - }); + this.$util.uploadImageOne({ + url: 'upload/image', + crop: { + width: 2000, + height: 2000, + } + }, (res) => { + this.setFormData.imageList.push(res.data.path); + }); }, doUpload(rsp) { let that = this diff --git a/pages/product/addGoodDetail/addGoodDetail.vue b/pages/product/addGoodDetail/addGoodDetail.vue index 6e2a3f8..633d2f5 100644 --- a/pages/product/addGoodDetail/addGoodDetail.vue +++ b/pages/product/addGoodDetail/addGoodDetail.vue @@ -16,8 +16,8 @@ 上传时应注重真实性、清晰度 - + @@ -30,8 +30,8 @@ 上传时应注重真实性、清晰度 - + @@ -48,7 +48,7 @@ - 请选择 + {{ formData.cate_name|| '请选择'}} @@ -96,7 +96,7 @@ - + @@ -143,6 +143,10 @@ import { HTTP_REQUEST_URL } from '@/config/app.js'; + import { + formatDate + } from '../../../libs/uniApi'; + import uploadImgVideo from "../addGood/components/uploadImgVideo.vue" export default { components: { @@ -153,8 +157,7 @@ formData: { "store_name": "测试商品", "imageList": [ - "https://crmeb-test.shop.lihaink.cn/uploads/def/20240419/a09b7188e9ef408a3f96d82b2b178082.jpeg", - "https://crmeb-test.shop.lihaink.cn/uploads/def/20240419/7a6d14dc327f6b0936e479891c0d253a.jpg" + ], "attrValue": [{ "price": "100", @@ -191,7 +194,7 @@ "once_min_count": "", "image": "https://crmeb-test.shop.lihaink.cn/uploads/def/20240419/a09b7188e9ef408a3f96d82b2b178082.jpeg", "slider_image": [ - "https://crmeb-test.shop.lihaink.cn/uploads/def/20240419/7a6d14dc327f6b0936e479891c0d253a.jpg" + ], "is_good": 0, "is_gift_bag": 0, @@ -200,9 +203,7 @@ "video_link": "", "content": { "title": "", - "image": [ - "https://crmeb-test.shop.lihaink.cn/uploads/def/20240419/6f96b50e17bbf9a1289f82f620747b73.jpeg" - ] + "image": [] }, "stock": "20" }, @@ -252,17 +253,59 @@ }, methods: { + // 删除图片 + deletePic1(event) { + this.formData[`imageList`].splice(event.index, 1) + }, + // 新增图片 + async afterRead1(event) { + // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式 + let lists = [].concat(event.file) + let fileListLen = this.formData[`imageList`].length + lists.map((item) => { + this.formData[`imageList`].push({ + ...item, + status: 'uploading', + message: '上传中' + }) + }) + for (let i = 0; i < lists.length; i++) { + const result = await this.uploadFilePromise1(lists[i].url) + let item = this.formData[`imageList`][fileListLen] + this.formData[`imageList`].splice(fileListLen, 1, Object.assign(item, { + status: 'success', + message: '', + url: result + })) + fileListLen++ + } + }, + uploadFilePromise1(url) { + return new Promise((resolve, reject) => { + let a = uni.uploadFile({ + url: HTTP_REQUEST_URL + '/api/upload/image/field', + filePath: url, + name: 'field', + success: (res) => { + console.log(res.data) + resolve(JSON.parse(res.data).data.path) + } + }); + }) + }, + + // 删除图片 deletePic(event) { - this[`fileList${event.name}`].splice(event.index, 1) + this.formData.content.image.splice(event.index, 1) }, // 新增图片 async afterRead(event) { // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式 let lists = [].concat(event.file) - let fileListLen = this[`fileList${event.name}`].length + let fileListLen = this.formData.content.image.length lists.map((item) => { - this[`fileList${event.name}`].push({ + this.formData.content.image.push({ ...item, status: 'uploading', message: '上传中' @@ -270,8 +313,8 @@ }) for (let i = 0; i < lists.length; i++) { const result = await this.uploadFilePromise(lists[i].url) - let item = this[`fileList${event.name}`][fileListLen] - this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, { + let item = this.formData.content.image[fileListLen] + this.formData.content.image.splice(fileListLen, 1, Object.assign(item, { status: 'success', message: '', url: result @@ -310,13 +353,21 @@ }, showlayFn() { uni.navigateBack() + }, + submit() { + console.log(this.formData) } }, onLoad(option) { this.mer_id = option.mer_id if (option.typeData) { - console.log(option, 'option') + this.formData.cate_name = JSON.parse(option.typeData).label + this.formData.cate_id = JSON.parse(option.typeData).value + console.log(this.formData, 'option') + } + if (option.formData) { + Object.assign(this.formData, JSON.parse(option.formData), {}) } }, diff --git a/pages/product/addGoodDetail/goodsAttr.vue b/pages/product/addGoodDetail/goodsAttr.vue index 5ad4eb6..cc42eae 100644 --- a/pages/product/addGoodDetail/goodsAttr.vue +++ b/pages/product/addGoodDetail/goodsAttr.vue @@ -18,33 +18,34 @@ - 请选择 + {{formData.leval||'请选择'}} - 请选择 + {{formData.pack||'请选择'}} 产品属性 - + 自定义 + style="display: flex;padding: 20rpx 20rpx 20rpx 2rpx;justify-content: space-between;margin-bottom: 30rpx;" + v-for="(item,index) in attr"> - + - + - + 删除 @@ -57,46 +58,52 @@ - 取消 - 商品产地 - 确定 + 取消 + + {{popType=='place'?'商品产地': popType=='leval'?'商品等级':'商品包装' }} + + 确定 - 四川得分手段解决客户 + {{address.province}}{{address.city}}{{address.district}} - + 刷新定位 - - 四川省 + {{address.province||'请选择' }} - - 泸州市 + {{address.city ||'请选择'}} - - 牛马谭 + {{address.district ||'请选择'}} - 请选择省份 + 请选择 - + - 四川省 + {{item}} + @@ -106,24 +113,20 @@ - - - - 一等平 + + + + {{item}} - - 二等平 - - - 自定义 + + 自定义 - - - - + + + @@ -131,22 +134,21 @@ - + - - 纸箱子 + + {{item}} - - 木箱子 - - + + 自定义 - - - + + + @@ -159,15 +161,114 @@ + \ No newline at end of file