Просмотр исходного кода

Merge branch 'master' of http://git.huaml.com/zhh/front-end

shish 10 месяцев назад
Родитель
Сommit
3f1951b8e9

+ 20 - 6
ghsApp/src/admin/item/add.vue

@@ -470,9 +470,18 @@ export default {
           this.form[i] = res.data[i];
         });
 
-        this.currentImgData.push(res.data.cover)
-        this.form.images = [res.data.shortCover]
-        this.form.cover = res.data.shortCover
+        // this.currentImgData.push(res.data.cover)
+        // this.form.images = [res.data.shortCover]
+        // this.form.cover = res.data.shortCover
+        const imageUrls = (res.data.images || '').split(',').filter(i => i);
+        this.form.images = imageUrls;
+        this.currentImgData = imageUrls.map(url => {
+          return this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'
+        });
+        this.form.cover = res.data.shortCover || '';
+        if (!this.form.cover && this.form.images.length > 0) {
+          this.form.cover = this.form.images[0];
+        }
 
         this.form.stock = ''
         this.form.itemId = ptItemId
@@ -496,9 +505,14 @@ export default {
           this.form[i] = res.data[i];
         });
 
-        this.currentImgData.push(res.data.cover)
-        this.form.images = [res.data.shortCover]
-        this.form.cover = res.data.shortCover
+        // this.currentImgData.push(res.data.cover)
+        // this.form.images = [res.data.shortCover]
+        // this.form.cover = res.data.shortCover
+        const imageUrls = (res.data.images || '').split(',').filter(i => i);
+        this.form.images = imageUrls;
+        this.currentImgData = imageUrls.map(url => {
+          return this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'
+        });
 
         this.form.price = res.data.prePrice
 

+ 61 - 11
ghsApp/src/admin/item/copy.vue

@@ -128,10 +128,22 @@
           <span class="app-color-3"></span>
         </view>
         <view class="module-det">
-          <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
+          <htz-image-upload :max="5" :compress="true" v-model="currentImgData" :headers="headers"
            @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
           </htz-image-upload>
         </view>
+        <tui-list-cell class="line-cell category-wrap" :hover="false">
+          <view class="tui-title">封面</view>
+          <view class="tui-input">
+            <block v-if="coverImgData.length > 0">
+              <button class="admin-button-com" :class="[(form.cover == item) ? '' : 'default']" 
+              v-for="(item, index) in coverImgData" :key="index"
+              @click="selCoverFn(index)" >第{{ index + 1 }}张</button>
+            </block>
+            <view v-else class="no-img-tip">请先上传图片</view>
+            <view v-if="coverImgData.length > 0" class="use-img">选择上面的图片作为封面</view>
+          </view>
+        </tui-list-cell>
       </view>
 
       <view class="module-com input-line-wrap">
@@ -237,7 +249,8 @@ export default {
         hjDiscountPrice:0,
         cost:0,
         weight:'',
-        cover:[],
+        cover:'',
+        images:[],
         stockWarning:5,
         status:2,
         itemId:0,
@@ -264,7 +277,10 @@ export default {
     };
   },
 	computed:{
-		...mapGetters(["getLoginInfo","getDictionariesInfo"])
+		...mapGetters(["getLoginInfo","getDictionariesInfo"]),
+    coverImgData() {
+      return this.form.images || [];
+    }
 	},
   onLoad(option) {
     if(option.id){
@@ -292,6 +308,9 @@ export default {
     }
   },
   methods: {
+    selCoverFn(index) {
+      this.form.cover = this.form.images[index];
+    },
     showWeightPopup(){
       this.$refs.weightRef.open('center')
     },
@@ -465,8 +484,16 @@ export default {
           this.form[i] = res.data[i];
         });
 
-        this.currentImgData.push(res.data.cover)
-        this.form.cover = [res.data.shortCover]
+        const imageUrls = (res.data.images || '').split(',').filter(i => i);
+        this.form.images = imageUrls;
+        this.currentImgData = imageUrls.map(url => {
+          return this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'
+        });
+
+        this.form.cover = res.data.shortCover || '';
+        if (!this.form.cover && this.form.images.length > 0) {
+          this.form.cover = this.form.images[0];
+        }
         this.form.price = res.data.prePrice
         this.form.stock = 0
 
@@ -488,13 +515,21 @@ export default {
     imgUploadSuccess(res) {
       var _res = JSON.parse(res.data)
       if(_res.code == 1){
-        this.currentImgData.push(_res.data.smallUrl)
-        this.form.cover.push(_res.data.shortUrl)
+        this.currentImgData.push(_res.data.bigUrl)
+        this.form.images.push(_res.data.shortUrl)
+        if (!this.form.cover) {
+          this.form.cover = _res.data.shortUrl;
+        }
       }
     },
     imgDeleteFn(res){
-      const index = res.index
-      this.form.cover.splice(index,1)
+      const index = res.index;
+      const deletedUrl = this.form.images[index];
+      this.form.images.splice(index, 1);
+
+      if (this.form.cover === deletedUrl) {
+        this.form.cover = this.form.images[0] || '';
+      }
     },
     init() {
       //从平台选择花材
@@ -539,10 +574,13 @@ export default {
     },
     // 确认
     confirmFn() {
-      if (this.$util.isEmpty(this.form.cover)) {
+      if (this.$util.isEmpty(this.form.images)) {
         this.$msg("请上传图片")
         return false
       }
+      if (!this.form.cover && this.form.images.length > 0) {
+        this.form.cover = this.form.images[0];
+      }
       let requestHost = addProduct
       if(this.form.id && this.form.id != 0){
         requestHost = cloneProduct;
@@ -585,8 +623,9 @@ export default {
 				}
       }
       let form = JSON.parse(JSON.stringify(this.form))
+      form.images = form.images.join(',')
       uni.showLoading({mask:true})
-      requestHost({...form,cover:this.form.cover[0],appVersion:1}).then(res => {
+      requestHost({...form,appVersion:1}).then(res => {
         uni.hideLoading()
         if(res.code == 1){
           this.$msg("操作成功");
@@ -719,6 +758,17 @@ export default {
     padding: 0 30upx;
   }
 }
+.use-img{
+  font-size: 22rpx;
+  color: #999999;
+  padding-left: 4rpx 8rpx;
+  line-height: 1.5;
+}
+.no-img-tip {
+  font-size: 26rpx;
+  color: #cccccc;
+  padding: 12rpx 0;
+}
 .category-wrap {
   align-items: flex-start;
   padding-bottom: 0 !important;

+ 66 - 12
hdApp/src/admin/item/add.vue

@@ -128,10 +128,22 @@
           <span class="app-color-3"></span>
         </div>
         <view class="module-det">
-          <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
+          <htz-image-upload :max="5" :compress="true" v-model="currentImgData" :headers="headers"
            @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
           </htz-image-upload>
         </view>
+        <tui-list-cell class="line-cell category-wrap" :hover="false">
+          <view class="tui-title">封面</view>
+          <view class="tui-input">
+            <block v-if="coverImgData.length > 0">
+              <button class="admin-button-com" :class="[(form.cover == item) ? '' : 'default']" 
+              v-for="(item, index) in coverImgData" :key="index"
+              @click="selCoverFn(index)" >第{{ index + 1 }}张</button>
+            </block>
+            <view v-else class="no-img-tip">请先上传图片</view>
+            <view v-if="coverImgData.length > 0" class="use-img">选择上面的图片作为封面</view>
+          </view>
+        </tui-list-cell>
       </div>
 
       <view class="module-com input-line-wrap">
@@ -243,7 +255,8 @@ export default {
         skDiscountPrice:0,
         cost:0,
         weight:1.5,
-        cover:[],
+        cover: "",
+        images: [],
         stockWarning:5,
         status:2,
         itemId:0,
@@ -272,7 +285,10 @@ export default {
     };
   },
 	computed:{
-		...mapGetters(["getLoginInfo","getDictionariesInfo"])
+		...mapGetters(["getLoginInfo","getDictionariesInfo"]),
+    coverImgData() {
+      return this.form.images || [];
+    }
 	},
   onShow(){
     let that = this
@@ -300,6 +316,9 @@ export default {
     this.headers.token = token
   },
   methods: {
+    selCoverFn(index) {
+      this.form.cover = this.form.images[index];
+    },
     showWeightPopup(){
       this.$refs.weightRef.open('center')
     },
@@ -453,7 +472,8 @@ export default {
         });
 
         this.currentImgData.push(res.data.cover)
-        this.form.cover = [res.data.shortCover]
+        this.form.images = [res.data.shortCover]
+        this.form.cover = res.data.shortCover
 
         this.form.stock = ''
         this.form.itemId = ptItemId
@@ -477,8 +497,14 @@ export default {
           this.form[i] = res.data[i];
         });
 
-        this.currentImgData.push(res.data.cover)
-        this.form.cover = [res.data.shortCover]
+        // this.currentImgData.push(res.data.cover)
+        // this.form.images = [res.data.shortCover]
+        // this.form.cover = res.data.shortCover
+        const imageUrls = (res.data.images || '').split(',').filter(i => i);
+        this.form.images = imageUrls;
+        this.currentImgData = imageUrls.map(url => {
+          return this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'
+        });
 
         this.form.price = res.data.prePrice
 
@@ -497,13 +523,21 @@ export default {
     imgUploadSuccess(res) {
       var _res = JSON.parse(res.data)
       if(_res.code == 1){
-        this.currentImgData.push(_res.data.smallUrl)
-        this.form.cover.push(_res.data.shortUrl)
+        this.currentImgData.push(_res.data.bigUrl)
+        this.form.images.push(_res.data.shortUrl)
+        if (!this.form.cover) {
+          this.form.cover = _res.data.shortUrl;
+        }
       }
     },
     imgDeleteFn(res){
-      const index = res.index
-      this.form.cover.splice(index,1)
+      const index = res.index;
+      const deletedUrl = this.form.images[index];
+      this.form.images.splice(index, 1);
+
+      if (this.form.cover === deletedUrl) {
+        this.form.cover = this.form.images[0] || '';
+      }
     },
     init() {
       //从平台选择花材
@@ -548,10 +582,13 @@ export default {
     },
     // 确认
     confirmFn() {
-      if (this.$util.isEmpty(this.form.cover)) {
+      if (this.$util.isEmpty(this.form.images)) {
         this.$msg("请上传图片")
         return false
       }
+      if (!this.form.cover && this.form.images.length > 0) {
+        this.form.cover = this.form.images[0];
+      }
       let requestHost = addProduct
       if(this.form.id && this.form.id != 0){
         requestHost = updateProduct;
@@ -594,8 +631,9 @@ export default {
 				}
       }
       let form = JSON.parse(JSON.stringify(this.form))
+      form.images = form.images.join(',')
       uni.showLoading({mask:true})
-      requestHost({...form,cover:this.form.cover[0],appVersion:1}).then(res => {
+      requestHost({...form,appVersion:1}).then(res => {
         uni.hideLoading()
         if(res.code == 1){
           this.$msg("操作成功!");
@@ -828,4 +866,20 @@ export default {
     }
   }
 }
+.use-img{
+  font-size: 22rpx;
+  color: #999999;
+  padding: 4rpx 8rpx;
+  line-height: 1.5;
+}
+.no-img-tip {
+  font-size: 26rpx;
+  color: #cccccc;
+  padding: 12rpx 0;
+}
+.summary-wrap {
+  .goods-summary {
+    height: 400upx;
+  }
+}
 </style>

+ 64 - 12
hdApp/src/admin/item/copy.vue

@@ -128,10 +128,22 @@
           <span class="app-color-3"></span>
         </view>
         <view class="module-det">
-          <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
+          <htz-image-upload :max="5" :compress="true" v-model="currentImgData" :headers="headers"
            @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
           </htz-image-upload>
         </view>
+        <tui-list-cell class="line-cell category-wrap" :hover="false">
+          <view class="tui-title">封面</view>
+          <view class="tui-input">
+            <block v-if="coverImgData.length > 0">
+              <button class="admin-button-com" :class="[(form.cover == item) ? '' : 'default']" 
+              v-for="(item, index) in coverImgData" :key="index"
+              @click="selCoverFn(index)" >第{{ index + 1 }}张</button>
+            </block>
+            <view v-else class="no-img-tip">请先上传图片</view>
+            <view v-if="coverImgData.length > 0" class="use-img">选择上面的图片作为封面</view>
+          </view>
+        </tui-list-cell>
       </view>
 
       <view class="module-com input-line-wrap">
@@ -244,7 +256,8 @@ export default {
         hjDiscountPrice:0,
         cost:0,
         weight:'',
-        cover:[],
+        cover: "",
+        images: [],
         stockWarning:5,
         status:2,
         itemId:0,
@@ -271,7 +284,10 @@ export default {
     };
   },
 	computed:{
-		...mapGetters(["getLoginInfo","getDictionariesInfo"])
+		...mapGetters(["getLoginInfo","getDictionariesInfo"]),
+    coverImgData() {
+      return this.form.images || [];
+    }
 	},
   onLoad(option) {
     if(option.id){
@@ -299,6 +315,9 @@ export default {
     }
   },
   methods: {
+    selCoverFn(index) {
+      this.form.cover = this.form.images[index];
+    },
     delOneCp(info,index){
       let that = this
       that.$util.confirmModal({content:'确认删除'+info.cpName+'?'},() => {
@@ -445,7 +464,8 @@ export default {
         });
 
         this.currentImgData.push(res.data.cover)
-        this.form.cover = [res.data.shortCover]
+        this.form.images = [res.data.shortCover]
+        this.form.cover = res.data.shortCover
 
         this.form.stock = ''
         this.form.itemId = ptItemId
@@ -472,8 +492,17 @@ export default {
           this.form[i] = res.data[i];
         });
 
-        this.currentImgData.push(res.data.cover)
-        this.form.cover = [res.data.shortCover]
+        const imageUrls = (res.data.images || '').split(',').filter(i => i);
+        this.form.images = imageUrls;
+        this.currentImgData = imageUrls.map(url => {
+          return this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'
+        });
+
+        this.form.cover = res.data.shortCover || '';
+        if (!this.form.cover && this.form.images.length > 0) {
+          this.form.cover = this.form.images[0];
+        }
+        
         this.form.price = res.data.prePrice
         this.form.stock = 0
 
@@ -495,13 +524,21 @@ export default {
     imgUploadSuccess(res) {
       var _res = JSON.parse(res.data)
       if(_res.code == 1){
-        this.currentImgData.push(_res.data.smallUrl)
-        this.form.cover.push(_res.data.shortUrl)
+        this.currentImgData.push(_res.data.bigUrl)
+        this.form.images.push(_res.data.shortUrl)
+        if (!this.form.cover) {
+          this.form.cover = _res.data.shortUrl;
+        }
       }
     },
     imgDeleteFn(res){
-      const index = res.index
-      this.form.cover.splice(index,1)
+      const index = res.index;
+      const deletedUrl = this.form.images[index];
+      this.form.images.splice(index, 1);
+
+      if (this.form.cover === deletedUrl) {
+        this.form.cover = this.form.images[0] || '';
+      }
     },
     init() {
       //从平台选择花材
@@ -546,10 +583,13 @@ export default {
     },
     // 确认
     confirmFn() {
-      if (this.$util.isEmpty(this.form.cover)) {
+      if (this.$util.isEmpty(this.form.images)) {
         this.$msg("请上传图片")
         return false
       }
+      if (!this.form.cover && this.form.images.length > 0) {
+        this.form.cover = this.form.images[0];
+      }
       let requestHost = addProduct
       if(this.form.id && this.form.id != 0){
         requestHost = cloneProduct;
@@ -592,8 +632,9 @@ export default {
 				}
       }
       let form = JSON.parse(JSON.stringify(this.form))
+      form.images = form.images.join(',')
       uni.showLoading({mask:true})
-      requestHost({...form,cover:this.form.cover[0],appVersion:1}).then(res => {
+      requestHost({...form,appVersion:1}).then(res => {
         uni.hideLoading()
         if(res.code == 1){
           this.$msg("操作成功");
@@ -826,4 +867,15 @@ export default {
     }
   }
 }
+.use-img{
+  font-size: 22rpx;
+  color: #999999;
+  padding: 4rpx 8rpx;
+  line-height: 1.5;
+}
+.no-img-tip {
+  font-size: 26rpx;
+  color: #cccccc;
+  padding: 12rpx 0;
+}
 </style>

+ 65 - 15
hdApp/src/admin/item/detail.vue

@@ -196,10 +196,22 @@
           <span class="app-color-3"></span>
         </view>
         <view class="module-det">
-          <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
+          <htz-image-upload :max="5" :compress="true" v-model="currentImgData" :headers="headers"
            @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
           </htz-image-upload>
         </view>
+        <tui-list-cell class="line-cell category-wrap" :hover="false">
+          <view class="tui-title">封面</view>
+          <view class="tui-input">
+            <block v-if="coverImgData.length > 0">
+              <button class="admin-button-com" :class="[(form.cover == item) ? '' : 'default']" 
+              v-for="(item, index) in coverImgData" :key="index"
+              @click="selCoverFn(index)" >第{{ index + 1 }}张</button>
+            </block>
+            <view v-else class="no-img-tip">请先上传图片</view>
+            <view v-if="coverImgData.length > 0" class="use-img">选择上面的图片作为封面</view>
+          </view>
+        </tui-list-cell>
       </view>
 
       <view class="module-com input-line-wrap">
@@ -478,7 +490,8 @@ export default {
         cost:0,
         skMore:3,
         weight:'',
-        cover:[],
+        cover: "",
+        images: [],
         limitBuy:0,
         stockWarning:5,
         status:2,
@@ -523,7 +536,10 @@ export default {
     };
   },
 	computed:{
-		...mapGetters(["getLoginInfo","getDictionariesInfo"])
+		...mapGetters(["getLoginInfo","getDictionariesInfo"]),
+    coverImgData() {
+      return this.form.images || [];
+    }
 	},
   onLoad(option) {
     if(option.id){
@@ -571,6 +587,9 @@ export default {
     }
   },
   methods: {
+    selCoverFn(index) {
+      this.form.cover = this.form.images[index];
+    },
     showWeightPopup(){
       this.$refs.weightRef.open('center')
     },
@@ -1052,7 +1071,7 @@ export default {
         });
 
         this.currentImgData.push(res.data.bigCover)
-        this.form.cover = [res.data.shortCover]
+        this.form.images = [res.data.shortCover]
 
         this.form.stock = 0
         this.form.itemId = ptItemId
@@ -1083,17 +1102,25 @@ export default {
             this.form[i] = res.data[i]
         });
 
-        this.currentImgData = []
-        this.form.cover = []
-        this.currentImgData.push(res.data.bigCover)
-        this.form.cover = [res.data.shortCover]
+        const imageUrls = (res.data.images || '').split(',').filter(i => i);
+        this.form.images = imageUrls;
+        this.currentImgData = imageUrls.map(url => {
+          return this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'
+        });
+
+        this.form.cover = res.data.shortCover || '';
+        if (!this.form.cover && this.form.images.length > 0) {
+          this.form.cover = this.form.images[0];
+        }
 
         this.form.price = res.data.prePrice
 
         let currentClass = this.itemClassData.filter(
           e => this.form.classId == e.id
         )[0];
-        this.form.className = currentClass.name ? currentClass.name : ''
+        if(currentClass){
+          this.form.className = currentClass.name ? currentClass.name : ''
+        }
 
         this.smallUnitSelectedData = this.unitData.filter(
           e => this.form.smallUnitId == e.id
@@ -1104,18 +1131,26 @@ export default {
         this.productData = res.data
         this.cost = res.data.cost ? res.data.cost : 0
         this.belongCost = res.data.belongCost ? res.data.belongCost : 0
-      })
+      });
     },
     imgUploadSuccess(res) {
       var _res = JSON.parse(res.data)
       if(_res.code == 1){
         this.currentImgData.push(_res.data.bigUrl)
-        this.form.cover.push(_res.data.shortUrl)
+        this.form.images.push(_res.data.shortUrl)
+        if (!this.form.cover) {
+          this.form.cover = _res.data.shortUrl;
+        }
       }
     },
     imgDeleteFn(res){
-      const index = res.index
-      this.form.cover.splice(index,1)
+      const index = res.index;
+      const deletedUrl = this.form.images[index];
+      this.form.images.splice(index, 1);
+
+      if (this.form.cover === deletedUrl) {
+        this.form.cover = this.form.images[0] || '';
+      }
     },
     init() {
       //从平台选择花材
@@ -1160,10 +1195,13 @@ export default {
     },
     // 确认
     confirmFn() {
-      if (this.$util.isEmpty(this.form.cover)) {
+      if (this.$util.isEmpty(this.form.images)) {
         this.$msg("请上传图片")
         return false
       }
+      if (!this.form.cover && this.form.images.length > 0) {
+        this.form.cover = this.form.images[0];
+      }
       let requestHost = addProduct
       if(this.form.id && this.form.id != 0){
         requestHost = updateProduct;
@@ -1198,8 +1236,9 @@ export default {
 				}
       }
       let form = JSON.parse(JSON.stringify(this.form))
+      form.images = form.images.join(',')
       uni.showLoading({mask:true,title:'提交中'})
-      requestHost({...form,cover:this.form.cover[0],appVersion:1}).then(res => {
+      requestHost({...form,appVersion:1}).then(res => {
         uni.hideLoading()
         if(res.code == 1){
           this.$msg("操作成功");
@@ -1436,4 +1475,15 @@ export default {
     }
   }
 }
+.use-img{
+  font-size: 22rpx;
+  color: #999999;
+  padding: 4rpx 8rpx;
+  line-height: 1.5;
+}
+.no-img-tip {
+  font-size: 26rpx;
+  color: #cccccc;
+  padding: 12rpx 0;
+}
 </style>