diff --git a/pages/product/addGood/addGood.vue b/pages/product/addGood/addGood.vue
index f9e4eec..c79955a 100644
--- a/pages/product/addGood/addGood.vue
+++ b/pages/product/addGood/addGood.vue
@@ -15,15 +15,24 @@
上传时应注重真实性、清晰度
-
+
+
+
+ 上传图片/视频
+
+
+
+
@@ -98,7 +107,8 @@
-
+
@@ -131,6 +141,9 @@
},
data() {
return {
+ columns: [
+ ['图片', '视频', ]
+ ],
isWholeSale: false, //批发商
show: false, //选择图片还是视屏
showCustom: false, //计量单位自定义
@@ -152,24 +165,6 @@
],
selfAttr: "",
formData: {
- // // store_name: "",
- // imageList: [],
- // cate_name: "",
- // cate_id: "",
- // attrValue: [{
- // "price": "",
- // "unit_name": "",
- // "wholesale_unit_name": "",
- // "wholesale_price": '',
- // "stock": "",
- // open: true,
- // spec_type: '单规格'
- // }],
- // image: '',
- // slider_image: [],
- // delivery_way: [],
- // attr: [],
- // // product_attribute: [],
"store_name": "",
"imageList": [
@@ -189,7 +184,7 @@
"extension_one": "",
"extension_two": "",
open: true,
- spec_type: ""
+ spec_type: " "
}],
"cate_name": "",
"unit_name": "",
@@ -240,24 +235,100 @@
message: '请选择',
trigger: ['blur', 'change']
}
- // 'userInfo.name': {
- // type: 'string',
- // required: true,
- // message: '请填写姓名',
- // trigger: ['blur', 'change']
- // },
- // 'userInfo.sex': {
- // type: 'string',
- // max: 1,
- // required: true,
- // message: '请选择男或女',
- // trigger: ['blur', 'change']
- // },
+
},
};
},
methods: {
+ choseMedia(e) {
+ console.log(e.value)
+ this.show = false
+ if (e.value[0] == '图片') {
+ this.handleChooseImage()
+ // uni.chooseImage({
+ // count: 6, //默认9
+ // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
+ // sourceType: ['album', 'camera'], //从相册选择
+ // success: function(res) {
+ // console.log(JSON.stringify(res.tempFilePaths));
+ // }
+ // });
+ } else {
+ this.uploadVideo()
+ // uni.chooseVideo({
+ // sourceType: ['camera', 'album'],
+ // success: function(res) {
+ // self.src = res.tempFilePath;
+ // }
+ // });
+ }
+
+ },
+ // 选择图片
+ handleChooseImage() {
+ let that = this;
+ that.$util.uploadImageOne('upload/image', function(res) {
+ // that.setFormData.imageList.push(res.data.path);
+ });
+ },
+ // 上传视频
+ uploadVideo() {
+ uni.chooseVideo({
+ sourceType: ['camera', 'album'],
+ success: res => {
+ console.log(res)
+
+ if (Math.ceil(res.size / 1024) < this.upload_max * 1024) {
+ uni.uploadFile({
+ url: this.uploadUrl, //仅为示例,非真实的接口地址
+ filePath: res.tempFilePath,
+ name: 'file',
+ //请求参数
+ // formData: {
+ // user: 'test'
+ // },
+ header: {
+ // #ifdef MP
+ 'Content-Type': 'multipart/form-data',
+ // #endif
+ [TOKENNAME]: 'Bearer ' + store.state.app.token
+ },
+ success: uploadFileRes => {
+ // let data = JSON.parse(uploadFileRes.data);
+ // this.addGoodsSecoundData.video_link = (data.data.src);
+ },
+ complete: a => {
+ // console.log(a);
+ }
+ });
+ } else {
+ uni.showModal({
+ title: '提示',
+ content: `视频超出限制${this.upload_max}MB,已过滤`
+ });
+ }
+ },
+ fail: err => {
+ // 取消上传也会出现弹框
+ // uni.showModal({
+ // content: JSON.stringify(err)
+ // });
+ console.log(err)
+ }
+ });
+ },
+
+ test() {
+ uni.chooseFile({
+ count: 6, //默认100
+ extension: ['.zip', '.doc'],
+ success: function(res) {
+ console.log(JSON.stringify(res.tempFilePaths));
+ }
+ });
+
+ },
// 删除图片
deletePic(event) {
this.formData[`imageList`].splice(event.index, 1)
diff --git a/pages/product/addGoodDetail/addGoodDetail.vue b/pages/product/addGoodDetail/addGoodDetail.vue
index 2d99b41..bbc3a57 100644
--- a/pages/product/addGoodDetail/addGoodDetail.vue
+++ b/pages/product/addGoodDetail/addGoodDetail.vue
@@ -56,8 +56,7 @@
- {{Object.values(formData.product_attribute).address ?"已设置":"未设置"}}
-
+ {{isSet(formData.product_attribute)?'已设置':'未设置' }}
@@ -285,7 +284,15 @@
};
},
methods: {
+ isSet(obj) {
+ for (let key in obj) {
+ if (typeof obj[key] == 'object') this.isSet(obj[key])
+ else {
+ if (Boolean(obj[key])) return true;
+ }
+ }
+ },
// 删除图片
deletePic1(event) {
this.formData[`imageList`].splice(event.index, 1)
@@ -326,8 +333,6 @@
});
})
},
-
-
// 删除图片
deletePic(event) {
this.formData.content.image.splice(event.index, 1)