From cd8513ec021b0843c95be0fa37c6ac21c0a48114 Mon Sep 17 00:00:00 2001
From: weipengfei <2187978347@qq.com>
Date: Mon, 15 Apr 2024 17:48:03 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8B=8D=E7=85=A7=E4=B8=8A?=
=?UTF-8?q?=E4=BC=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/product/addGood/addGood.vue | 21 ++++++---
.../addGood/components/inputGoodsDetils.vue | 43 +++++++++++++------
utils/util.js | 8 +++-
3 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/pages/product/addGood/addGood.vue b/pages/product/addGood/addGood.vue
index 406339d..f2a978d 100644
--- a/pages/product/addGood/addGood.vue
+++ b/pages/product/addGood/addGood.vue
@@ -489,12 +489,21 @@
});
},
clk() {
- let avatar = this.$refs.avatar;
- avatar.fChooseImg(1, {
- selWidth: '350upx',
- selHeight: '350upx',
- inner: true
- });
+ // let avatar = this.$refs.avatar;
+ // avatar.fChooseImg(1, {
+ // selWidth: '350upx',
+ // selHeight: '350upx',
+ // inner: true
+ // });
+ 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/addGood/components/inputGoodsDetils.vue b/pages/product/addGood/components/inputGoodsDetils.vue
index c115029..e29b56a 100644
--- a/pages/product/addGood/components/inputGoodsDetils.vue
+++ b/pages/product/addGood/components/inputGoodsDetils.vue
@@ -32,8 +32,9 @@
-
+
+
@@ -41,7 +42,8 @@
-
+
@@ -81,7 +83,7 @@
data() {
return {
uploadImg: this.prodectContent.imageList,
- upstore : '',
+ upstore: '',
isUpload: true,
imgName: ""
};
@@ -90,12 +92,12 @@
watch: {
prodectContent: {
handler(val) {
- // console.log(val.store_name);
- this.upstore=val.store_name
+ // console.log(val.store_name);
+ this.upstore = val.store_name
this.$emit('getProductContent', val);
-
+
},
- immediate: true,
+ immediate: true,
deep: true
},
uploadImg: {
@@ -106,7 +108,7 @@
this.isUpload = val.length < 1 ? true : false
}
},
- immediate: true,
+ immediate: true,
deep: true
}
},
@@ -122,8 +124,22 @@
});
},
clk() {
- let avatar = this.$refs.avatar;
- avatar.fChooseImg(1, { selWidth: '350upx', selHeight: '350upx', inner: true });
+ // let avatar = this.$refs.avatar;
+ // avatar.fChooseImg(1, {
+ // selWidth: '350upx',
+ // selHeight: '350upx',
+ // inner: true
+ // });
+ this.$util.uploadImageOne({
+ url: 'upload/image',
+ crop: {
+ width: 2000,
+ height: 2000,
+ }
+ }, (res)=> {
+ this.uploadImg.push(res.data.path);
+ this.$set(this.prodectContent, 'imageList', this.uploadImg);
+ });
},
doUpload(rsp) {
// console.log(rsp);
@@ -146,8 +162,9 @@
// console.log(JSON.parse(uploadFileRes.data));
let imgData = JSON.parse(uploadFileRes.data)
// that.prodectContent.imageList.push(imgData.data.path)
- if(!that.prodectContent.imageList)that.prodectContent.imageList=[];
- that.prodectContent = { imageList: [...that.prodectContent.imageList, imgData.data.path] ,store_name:this.upstore};
+ if (!that.prodectContent.imageList) that.prodectContent.imageList = [];
+ that.prodectContent = { imageList: [...that.prodectContent.imageList, imgData.data.path],
+ store_name: this.upstore };
},
complete(res) {
// console.log(res)
diff --git a/utils/util.js b/utils/util.js
index c4bc796..15c59f1 100644
--- a/utils/util.js
+++ b/utils/util.js
@@ -590,22 +590,28 @@ export default {
*/
uploadImageOne: function(opt, successCallback, errorCallback) {
let that = this;
+ let obj = {};
if (typeof opt === 'string') {
let url = opt;
opt = {};
opt.url = url;
- }
+ }else {
+ opt.crop ? obj.crop = opt.crop : null;
+ }
let count = opt.count || 1,
sizeType = opt.sizeType || ['compressed'],
sourceType = opt.sourceType || ['album', 'camera'],
is_load = opt.is_load || true,
uploadUrl = opt.url || '',
inputName = opt.name || 'field';
+
uni.chooseImage({
count: count, //最多可以选择的图片总数
sizeType: sizeType, // 可以指定是原图还是压缩图,默认二者都有
sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有
+ ...obj,
success: function(res) {
+ console.log(res);
//启动上传等待中...
uni.showLoading({
title: '图片上传中',