shizhongqi 10 месяцев назад
Родитель
Сommit
ba9267ad6a

+ 54 - 8
ghsApp/src/admin/item/add.vue

@@ -128,10 +128,24 @@
           <span class="app-color-3"></span>
           <span class="app-color-3"></span>
         </div>
         </div>
         <view class="module-det">
         <view class="module-det">
-          <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
-           @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
+          <htz-image-upload :max="5" :compress="true" v-model="currentImgData" :headers="headers"
+            @uploadSuccess="imgUploadSuccess"
+            @imgDelete="imgDeleteFn"
+            :action="getLoginInfo.imgUploadApi">
           </htz-image-upload>
           </htz-image-upload>
         </view>
         </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>
       </div>
 
 
       <view class="module-com input-line-wrap">
       <view class="module-com input-line-wrap">
@@ -236,7 +250,8 @@ export default {
         skDiscountPrice:0,
         skDiscountPrice:0,
         cost:0,
         cost:0,
         weight:1.5,
         weight:1.5,
-        cover:[],
+        cover: "", // 将cover字段的类型从数组改成字符串
+        images: [], // 新增images字段来保存图片列表
         stockWarning:5,
         stockWarning:5,
         status:2,
         status:2,
         itemId:0,
         itemId:0,
@@ -265,7 +280,14 @@ export default {
     };
     };
   },
   },
 	computed:{
 	computed:{
-		...mapGetters(["getLoginInfo","getDictionariesInfo"])
+		...mapGetters(["getLoginInfo","getDictionariesInfo"]),
+    // 根据上传的图片数量动态生成封面选项
+    coverImgData() {
+      if (this.form.images.length === 0) {
+        return [];
+      }
+      return this.form.images;
+    }
 	},
 	},
   onShow(){
   onShow(){
     let that = this
     let that = this
@@ -293,6 +315,9 @@ export default {
     this.headers.token = token
     this.headers.token = token
   },
   },
   methods: {
   methods: {
+    selCoverFn(index) {
+      this.form.cover = this.form.images[index];
+    },
     showWeightPopup(){
     showWeightPopup(){
       this.$refs.weightRef.open('center')
       this.$refs.weightRef.open('center')
     },
     },
@@ -446,7 +471,8 @@ export default {
         });
         });
 
 
         this.currentImgData.push(res.data.cover)
         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.stock = ''
         this.form.itemId = ptItemId
         this.form.itemId = ptItemId
@@ -471,7 +497,8 @@ export default {
         });
         });
 
 
         this.currentImgData.push(res.data.cover)
         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.price = res.data.prePrice
         this.form.price = res.data.prePrice
 
 
@@ -541,10 +568,14 @@ export default {
     },
     },
     // 确认
     // 确认
     confirmFn() {
     confirmFn() {
-      if (this.$util.isEmpty(this.form.cover)) {
+      if (this.$util.isEmpty(this.form.images)) {
         this.$msg("请上传图片")
         this.$msg("请上传图片")
         return false
         return false
       }
       }
+      // 如果没有选择封面,默认使用第一张图片
+      if (!this.form.cover && this.form.images.length > 0) {
+        this.form.cover = this.form.images[0];
+      }
       let requestHost = addProduct
       let requestHost = addProduct
       if(this.form.id && this.form.id != 0){
       if(this.form.id && this.form.id != 0){
         requestHost = updateProduct;
         requestHost = updateProduct;
@@ -588,7 +619,11 @@ export default {
       }
       }
       let form = JSON.parse(JSON.stringify(this.form))
       let form = JSON.parse(JSON.stringify(this.form))
       uni.showLoading({mask:true})
       uni.showLoading({mask:true})
-      requestHost({...form,cover:this.form.cover[0],appVersion:1}).then(res => {
+      requestHost({
+        ...form,
+        images:this.form.images,
+        appVersion:1
+      }).then(res => {
         uni.hideLoading()
         uni.hideLoading()
         if(res.code == 1){
         if(res.code == 1){
           this.$msg("操作成功!");
           this.$msg("操作成功!");
@@ -735,6 +770,17 @@ export default {
     }
     }
   }
   }
 }
 }
+.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;
+}
 .summary-wrap {
 .summary-wrap {
   .goods-summary {
   .goods-summary {
     height: 400upx;
     height: 400upx;

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

@@ -195,10 +195,22 @@
           <span class="app-color-3"></span>
           <span class="app-color-3"></span>
         </view>
         </view>
         <view class="module-det">
         <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">
            @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
           </htz-image-upload>
           </htz-image-upload>
         </view>
         </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>
 
 
       <view class="module-com input-line-wrap">
       <view class="module-com input-line-wrap">
@@ -414,7 +426,7 @@ import TuiListCell from "@/components/plugin/list-cell";
 const form = require("@/utils/formValidation.js");
 const form = require("@/utils/formValidation.js");
 import { getAllItemClass } from "@/api/item-class";
 import { getAllItemClass } from "@/api/item-class";
 import { applyAuth,modifyCgStaff,setLosing,modifyUnit,modifyRatio,modifyWeight,clearLimitBuy } from '@/api/item';
 import { applyAuth,modifyCgStaff,setLosing,modifyUnit,modifyRatio,modifyWeight,clearLimitBuy } from '@/api/item';
-import { delCpItem,addCpItem } from '@/api/cp'
+//import { delCpItem,addCpItem } from '@/api/cp'
 import { getAllUnit } from "@/api/unit";
 import { getAllUnit } from "@/api/unit";
 import { addProduct,updateProduct,getProductDetail,py,print,modifyOnStockFn,delStatusUpdate,changeBelongCost } from "@/api/product";
 import { addProduct,updateProduct,getProductDetail,py,print,modifyOnStockFn,delStatusUpdate,changeBelongCost } from "@/api/product";
 import { getPtItemDetail } from "@/api/pt-item";
 import { getPtItemDetail } from "@/api/pt-item";
@@ -466,7 +478,8 @@ export default {
         cost:0,
         cost:0,
         skMore:3,
         skMore:3,
         weight:'',
         weight:'',
-        cover:[],
+        cover: "",
+        images: [],
         limitBuy:0,
         limitBuy:0,
         stockWarning:5,
         stockWarning:5,
         status:2,
         status:2,
@@ -511,7 +524,10 @@ export default {
     };
     };
   },
   },
 	computed:{
 	computed:{
-		...mapGetters(["getLoginInfo","getDictionariesInfo"])
+		...mapGetters(["getLoginInfo","getDictionariesInfo"]),
+    coverImgData() {
+      return this.form.images || [];
+    }
 	},
 	},
   onLoad(option) {
   onLoad(option) {
     if(option.id){
     if(option.id){
@@ -559,6 +575,9 @@ export default {
     }
     }
   },
   },
   methods: {
   methods: {
+    selCoverFn(index) {
+      this.form.cover = this.form.images[index];
+    },
     showWeightPopup(){
     showWeightPopup(){
       this.$refs.weightRef.open('center')
       this.$refs.weightRef.open('center')
     },
     },
@@ -1064,17 +1083,25 @@ export default {
             this.form[i] = res.data[i]
             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
         this.form.price = res.data.prePrice
 
 
         let currentClass = this.itemClassData.filter(
         let currentClass = this.itemClassData.filter(
           e => this.form.classId == e.id
           e => this.form.classId == e.id
         )[0];
         )[0];
-        this.form.className = currentClass.name ? currentClass.name : ''
+        if(currentClass){
+          this.form.className = currentClass.name ? currentClass.name : ''
+        }
 
 
         this.smallUnitSelectedData = this.unitData.filter(
         this.smallUnitSelectedData = this.unitData.filter(
           e => this.form.smallUnitId == e.id
           e => this.form.smallUnitId == e.id
@@ -1085,18 +1112,26 @@ export default {
         this.productData = res.data
         this.productData = res.data
         this.cost = res.data.cost ? res.data.cost : 0
         this.cost = res.data.cost ? res.data.cost : 0
         this.belongCost = res.data.belongCost ? res.data.belongCost : 0
         this.belongCost = res.data.belongCost ? res.data.belongCost : 0
-      })
+      });
     },
     },
     imgUploadSuccess(res) {
     imgUploadSuccess(res) {
       var _res = JSON.parse(res.data)
       var _res = JSON.parse(res.data)
       if(_res.code == 1){
       if(_res.code == 1){
         this.currentImgData.push(_res.data.bigUrl)
         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){
     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() {
     init() {
       //从平台选择花材
       //从平台选择花材
@@ -1141,10 +1176,13 @@ export default {
     },
     },
     // 确认
     // 确认
     confirmFn() {
     confirmFn() {
-      if (this.$util.isEmpty(this.form.cover)) {
+      if (this.$util.isEmpty(this.form.images)) {
         this.$msg("请上传图片")
         this.$msg("请上传图片")
         return false
         return false
       }
       }
+      if (!this.form.cover && this.form.images.length > 0) {
+        this.form.cover = this.form.images[0];
+      }
       let requestHost = addProduct
       let requestHost = addProduct
       if(this.form.id && this.form.id != 0){
       if(this.form.id && this.form.id != 0){
         requestHost = updateProduct;
         requestHost = updateProduct;
@@ -1179,8 +1217,9 @@ export default {
 				}
 				}
       }
       }
       let form = JSON.parse(JSON.stringify(this.form))
       let form = JSON.parse(JSON.stringify(this.form))
+      form.images = form.images.join(',')
       uni.showLoading({mask:true,title:'提交中'})
       uni.showLoading({mask:true,title:'提交中'})
-      requestHost({...form,cover:this.form.cover[0],appVersion:1}).then(res => {
+      requestHost({...form,appVersion:1}).then(res => {
         uni.hideLoading()
         uni.hideLoading()
         if(res.code == 1){
         if(res.code == 1){
           this.$msg("操作成功");
           this.$msg("操作成功");
@@ -1333,6 +1372,17 @@ export default {
     }
     }
   }
   }
 }
 }
+.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;
+}
 .summary-wrap {
 .summary-wrap {
   .goods-summary {
   .goods-summary {
     height: 400upx;
     height: 400upx;

+ 7 - 4
hdApp/src/admin/ghsProduct/detail.vue

@@ -167,9 +167,12 @@ export default {
           this.productInfo = res.data
           this.productInfo = res.data
           let content = res.data.picTextGoods ? res.data.picTextGoods.content || "[]" : "[]";
           let content = res.data.picTextGoods ? res.data.picTextGoods.content || "[]" : "[]";
           this.previewContent = typeof content === "string" ? JSON.parse(content) : content || [];
           this.previewContent = typeof content === "string" ? JSON.parse(content) : content || [];
-          let newArr = [];
-          newArr.push({img: res.data.largeCover});
-          this.imgList = newArr;
+          // let newArr = [];
+          // newArr.push({img: res.data.largeCover});
+          const imageUrls = (res.data.images || '').split(',').filter(i => i);
+          this.imgList = imageUrls.map(url => {
+            return {img: this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'}
+          });
 
 
           let title = res.data.name+' ¥'+res.data.price
           let title = res.data.name+' ¥'+res.data.price
           if(res.data.discountPrice && Number(res.data.discountPrice) > 0){
           if(res.data.discountPrice && Number(res.data.discountPrice) > 0){
@@ -245,7 +248,7 @@ export default {
     .module-det {
     .module-det {
       color: $fontColor2;
       color: $fontColor2;
       .module-det-text {
       .module-det-text {
-        padding: 24upx;
+        padding: 14upx 0;
       }
       }
     }
     }
   }
   }

+ 1 - 1
mallApp/src/pages/goods/detail.vue

@@ -450,7 +450,7 @@ export default {
     .module-det {
     .module-det {
       color: $fontColor2;
       color: $fontColor2;
       .module-det-text {
       .module-det-text {
-        padding: 0upx;
+        padding: 12upx 0;
       }
       }
     }
     }
 
 

+ 7 - 6
mallApp/src/pages/item/detail.vue

@@ -54,7 +54,6 @@ import AppTrademark from "@/components/module/app-trademark";
 import RichMediaViewer from "@/components/RichMediaViewer/index.vue";
 import RichMediaViewer from "@/components/RichMediaViewer/index.vue";
 import BuyFoot from "./components/buy-foot.vue";
 import BuyFoot from "./components/buy-foot.vue";
 import SelPopup from "./components/sel-popup.vue";
 import SelPopup from "./components/sel-popup.vue";
-import GoLogin from "@/pages/home/components/go-login.vue";
 import { mapGetters } from "vuex";
 import { mapGetters } from "vuex";
 import { getMallItemInfo } from "@/api/item";
 import { getMallItemInfo } from "@/api/item";
 import { getHdInfo } from "@/api/hd";
 import { getHdInfo } from "@/api/hd";
@@ -70,7 +69,6 @@ export default {
     BuyFoot,
     BuyFoot,
     SelPopup,
     SelPopup,
     AppImg,
     AppImg,
-    GoLogin,
     RichMediaViewer
     RichMediaViewer
   },
   },
   data() {
   data() {
@@ -164,9 +162,12 @@ export default {
           this.data = res.data.info ? res.data.info : {}
           this.data = res.data.info ? res.data.info : {}
           let content = this.data.picTextGoods ? this.data.picTextGoods.content || "[]" : "[]";
           let content = this.data.picTextGoods ? this.data.picTextGoods.content || "[]" : "[]";
           this.previewContent = typeof content === "string" ? JSON.parse(content) : content || [];
           this.previewContent = typeof content === "string" ? JSON.parse(content) : content || [];
-          let newArr = [];
-          newArr.push({img: this.data.bigCover});
-          this.imgList = newArr;
+          // let newArr = [];
+          // newArr.push({img: this.data.bigCover});
+          const imageUrls = (this.data.images || '').split(',').filter(i => i);
+          this.imgList = imageUrls.map(url => {
+            return {img: this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'}
+          });
 
 
           let skPrice = this.data.skPrice ? parseFloat(this.data.skPrice) : 0
           let skPrice = this.data.skPrice ? parseFloat(this.data.skPrice) : 0
           let title = this.data.name+' ¥'+skPrice
           let title = this.data.name+' ¥'+skPrice
@@ -231,7 +232,7 @@ export default {
     .module-det {
     .module-det {
       color: $fontColor2;
       color: $fontColor2;
       .module-det-text {
       .module-det-text {
-        padding: 24upx;
+        padding: 14upx 0;
       }
       }
     }
     }
   }
   }