xuqiang 4 years ago
parent
commit
960dab1f0e
1 changed files with 25 additions and 43 deletions
  1. 25 43
      src/pages/store/productEdit.vue

+ 25 - 43
src/pages/store/productEdit.vue

@@ -9,7 +9,7 @@
 </config>
 <template>
     <div class="addorder">
-        <div v-if="flag">
+        <div v-show="flag">
             <van-cell-group :border="false" class="form">
                 <div v-if="time != 4">
                     <van-field
@@ -180,8 +180,8 @@
             </div>
 
             <div class="btn-list">
-                <div v-if="time != 4" @click="submit">确认上架1</div>
-                <div v-else @click="submits">确认上架2</div>
+                <div v-if="time != 4" @click="submit">确认上架</div>
+                <div v-else @click="submits">确认上架</div>
             </div>
             <van-action-sheet
                 :show="show"
@@ -205,8 +205,8 @@
                 />
             </van-popup>
         </div>
-        <div v-else class="addImg">
-            <div v-if="flags">
+        <div v-show="!flag" class="addImg">
+            <div v-show="flags">
                 <div class="top">
                     <div class="txt1">福袋总数量</div>
                     <div class="txt2">当前{{ cardList.length }}个福袋</div>
@@ -216,7 +216,7 @@
                     <div v-for="(item, index) in cardList" :key="index">
                         <div class="con">
                             <div class="con-l">
-                                <img :src="item.image" alt="" />
+                                <img :src="item.image[0].url" alt="" />
                                 <span>{{ item.name }}</span>
                             </div>
                             <p>x{{ item.amount }}</p>
@@ -232,7 +232,7 @@
                     <van-button type="primary" block @click="flag = true">完成</van-button>
                 </div>
             </div>
-            <div v-else>
+            <div v-show="!flags">
                 <van-cell-group :border="false" class="form">
                     <van-field
                         label="福袋名称"
@@ -287,7 +287,7 @@ export default {
                 limitOne: false,
                 groupDTOS: []
             },
-            forms: { name: '', amount: '', image: [], imagesList: [], imageUrls: [] },
+            forms: { name: '', amount: '', image: [] },
             name: '',
             soldStatus: '',
             show: false,
@@ -300,8 +300,6 @@ export default {
             count: 0,
             images: [],
             cardList: [],
-            imagesList: [],
-            imageUrls: [],
             nowChooseId: [],
             sotrId: [],
             list: [],
@@ -467,7 +465,7 @@ export default {
                 });
                 return;
             }
-            if (this.forms.imageUrls <= 0) {
+            if (this.forms.image <= 0) {
                 wx.showToast({
                     icon: 'none',
                     title: '请添加福袋图片'
@@ -475,8 +473,7 @@ export default {
                 return;
             }
             let data = { name: this.forms.name, amount: this.forms.amount };
-            let image = this.forms.imageUrls.join(',');
-            console.log(image);
+            let image = this.forms.image[0].url;
             data.image = image;
             this.$http
                 .post('/jackpot/save', data, {
@@ -485,18 +482,14 @@ export default {
                     }
                 })
                 .then(res => {
-                    console.log(res.id);
                     let cardLists = {
                         name: this.forms.name,
                         amount: this.forms.amount,
-                        image: this.forms.imageUrls,
+                        image: this.forms.image,
                         jackpotId: res.id
                     };
                     this.cardList.push(cardLists);
-
-                    console.log(this.cardList);
                     this.flags = true;
-                    this.saving = false;
                 })
                 .catch(e => {
                     console.log(e);
@@ -625,10 +618,11 @@ export default {
                         return;
                     }
                     this.hideLoading();
-                    this.imagesList.push({ ...file, url: res });
-                    this.images = [...this.imagesList];
-                    this.imageUrls.push(res);
-                    console.log(this.images);
+                    this.images = [
+                        {
+                            url: res
+                        }
+                    ];
                 })
                 .catch(e => {
                     this.hideLoading();
@@ -642,12 +636,8 @@ export default {
             let list = [...this.images];
             list.splice(e.detail.index, 1);
             this.images = list;
-            this.imageUrls = list.map(item => {
-                return item.url;
-            });
         },
         afterReads(file) {
-            console.log(file);
             this.showLoading();
             this.$http
                 .uploadFile(file.path)
@@ -658,10 +648,11 @@ export default {
                         return;
                     }
                     this.hideLoading();
-                    this.forms.imagesList.push({ ...file, url: res });
-                    this.forms.image = [...this.forms.imagesList];
-                    this.forms.imageUrls.push(res);
-                    console.log(this.forms.imageUrls);
+                    this.forms.image = [
+                        {
+                            url: res
+                        }
+                    ];
                 })
                 .catch(e => {
                     this.hideLoading();
@@ -676,9 +667,6 @@ export default {
             let list = [...this.forms.image];
             list.splice(e.detail.index, 1);
             this.forms.image = list;
-            this.forms.imageUrls = list.map(item => {
-                return item.url;
-            });
         },
         submit() {
             if (!this.form.boxPrice) {
@@ -768,16 +756,13 @@ export default {
                 let newJackpot = {};
                 newJackpot.name = item.name;
                 newJackpot.id = item.id;
-                newJackpot.image = item.image[0];
+                newJackpot.image = item.image[0].url;
                 newJackpot.amount = item.amount;
                 newJackpot.jackpotId = item.jackpotId;
                 var amount = new Number(item.amount);
                 count = count + amount;
                 this.caseJackpots.push(newJackpot);
             });
-            console.log('=====');
-            console.log(this.caseJackpots);
-            console.log('=====');
             if (!this.$mp.query.id) {
                 let box = {
                     group: 1,
@@ -790,10 +775,9 @@ export default {
                 let caseStatus = 'UNDO';
                 delete this.form.collectionId;
                 delete this.form.seriesId;
-                console.log(this.form.groupDTOS);
                 let cardCaseInputDTO = { ...this.form };
-                let images = this.imageUrls.join(',');
-                cardCaseInputDTO.images = images;
+                let images = this.images;
+                cardCaseInputDTO.images = images[0].url;
                 cardCaseInputDTO.caseStatus = caseStatus;
                 cardCaseInputDTO.caseJackpots = this.caseJackpots;
                 this.showLoading();
@@ -896,8 +880,6 @@ export default {
             margin-bottom: 10px;
         }
         .box {
-            // max-height: 70vh;
-            // min-height: 50vh;
             padding-right: 20px;
             .flex-col();
             padding-bottom: 6px;
@@ -1075,7 +1057,7 @@ export default {
                 width: 62px;
                 height: 90px;
                 border-radius: 6px;
-                padding-right: 10px;
+                margin-right: 10px;
             }
             .con-l {
                 .flex();