xuqiang 4 лет назад
Родитель
Сommit
a29e8c3e3e
3 измененных файлов с 125 добавлено и 174 удалено
  1. 1 1
      .env.production
  2. 36 74
      src/pages/store/administration.vue
  3. 88 99
      src/pages/store/productEdit.vue

+ 1 - 1
.env.production

@@ -1 +1 @@
-VUE_APP_BASE_URL=https://zhuoka.izouma.com
+VUE_APP_BASE_URL=http://192.168.50.120:8080

+ 36 - 74
src/pages/store/administration.vue

@@ -9,7 +9,7 @@
         <van-cell-group :border="false">
             <van-field
                 label="卡牌名称"
-                :value="form.name"
+                :value="name"
                 placeholder="请输入卡牌名称"
                 is-link
                 readonly
@@ -18,23 +18,23 @@
             </van-field>
             <van-field
                 label="卡牌售价"
-                :value="form.price"
-                @input="form.price = $event.detail"
+                :value="form.boxPrice"
+                @input="form.boxPrice = $event.detail"
                 placeholder="请输入金额"
             >
             </van-field>
             <van-field
                 label="拼箱结束"
                 is-link
-                :value="form.dates"
+                :value="form.startTime"
                 placeholder="请输入结束日期"
                 @click="newShow = true"
             >
             </van-field>
             <van-field
                 label="拼箱人数"
-                :value="form.num"
-                @input="form.num = $event.detail"
+                :value="form.boxesCount"
+                @input="form.boxesCount = $event.detail"
                 placeholder="请输入参加人数"
             >
             </van-field>
@@ -48,6 +48,7 @@
         </van-cell-group>
         <div class="box-con">
             <div class="label">卡牌细节图</div>
+            <img v-if="imgBox.lenght == 0" :src="imgBox.image" alt="" />
             <van-uploader :file-list="fileList" :after-read="afterRead" />
             <div></div>
             <div class="box">
@@ -67,14 +68,14 @@
                         <div class="card-title">第{{ index + 1 }}组</div>
                         <div class="card-list">
                             <div
-                                v-for="(item, itemIndex) in card"
-                                :key="item.id"
+                                v-for="(item, itemIndex) in card.dynamicTags"
+                                :key="itemIndex"
                                 class="card-item"
                                 :class="{
                                     used: canChoose(item.caseStatus),
-                                    active: nowChooseId.includes(item.id)
+                                    active: nowChooseId.includes(item.cardBoxId)
                                 }"
-                                @click="choose(item.id, canChoose(item.caseStatus))"
+                                @click="choose(item.cardBoxId, canChoose(item.caseStatus))"
                             >
                                 {{ itemIndex }}
                             </div>
@@ -84,8 +85,8 @@
             </div>
             <div class="label">卡牌详情描述</div>
             <van-field
-                :value="form.message"
-                @input="message = $event.detail"
+                :value="form.description"
+                @input="description = $event.detail"
                 :border="false"
                 rows="1"
                 autosize
@@ -125,63 +126,29 @@ export default {
     data() {
         return {
             form: {
-                name: '',
-                num: '',
-                postage: 10,
-                price: '',
-                dates: '',
-                message: ''
+                boxesCount: '',
+                postage: '',
+                boxPrice: '',
+                startTime: '',
+                description: ''
             },
             show: false,
             newShow: false,
             nowChoose: [],
+            name: '',
             closeFlag: false,
             detailsList: [],
             nowChooseId: [],
             list: [],
-            cardList: [
-                // [
-                //     { id: '106', title: '数组', caseStatus: 'WAIT' },
-                //     { id: '11', title: '数组' },
-                //     { id: '201', title: '数组' },
-                //     { id: '31', title: '数组', caseStatus: 'WAIT' },
-                //     { id: '41', title: '数组' },
-                //     { id: '51', title: '数组' }
-                // ],
-                // [
-                //     { id: '100', title: '数组' },
-                //     { id: '212', title: '数组' },
-                //     { id: '22', title: '数组' },
-                //     { id: '32', title: '数组' },
-                //     { id: '47', title: '数组' },
-                //     { id: '58', title: '数组', caseStatus: 'WAIT' }
-                // ],
-                // [
-                //     { id: '90', title: '数组' },
-                //     { id: '19', title: '数组' },
-                //     { id: '29', title: '数组', caseStatus: 'WAIT' },
-                //     { id: '39', title: '数组' },
-                //     { id: '49', title: '数组' },
-                //     { id: '59', title: '数组' }
-                // ]
-            ],
+            imgBox: [],
+            cardList: [],
             actions: [],
             minDate: new Date(new Date().getFullYear() - 1, 10, 1).getTime(),
             maxDate: new Date(new Date().getFullYear() + 2, 10, 1).getTime(),
             currentDate: new Date().getTime()
         };
     },
-    computed: {
-        cardLists() {
-            let boxMap = { ...this.cardList };
-            return Object.keys(boxMap).map(item => {
-                return boxMap[item];
-            });
-        },
-        allCards() {
-            return [...this.cardLists].flat();
-        }
-    },
+    computed: {},
     watch: {
         show: {
             handler: function(newVal) {
@@ -241,7 +208,7 @@ export default {
         onConfirm(event) {
             this.currentDate = event.detail;
             var timeValue = this.timeFormat(new Date(event.detail), 'yyyy-MM-dd hh:mm');
-            this.form.dates = timeValue;
+            this.form.startTime = timeValue + ':00';
             this.newShow = false;
         },
         // 时间取消按钮
@@ -270,10 +237,11 @@ export default {
                 this.list.push(id);
             }
             this.nowChooseId = [...this.list].join(',');
+            console.log(this.nowChooseId);
         },
         select(e) {
             if (this.closeFlag) {
-                this.form.name = e.detail.name;
+                this.name = e.detail.name;
                 this.show = false;
                 return;
             }
@@ -305,41 +273,35 @@ export default {
                 });
         },
         cartBox() {
-            // this.$http.post('/cardCase/genNew').then(res => {
-            //     console.log(res);
-            // });
-            this.$http.get('cardCase/getCardCase', { id: 2767 }).then(res => {
+            this.$http.get('/cardCase/getCardCase', { id: 2767 }).then(res => {
                 console.log(res);
-                // console.log(res.groupDTOS);
-                // this.cardList = res.groupDTOS;
-                // console.log(this.cardLists);
-                // console.log(this.allCards);
-                // this.cardList = this.cardLists[0].dynamicTags;
-                // console.log(this.cardList);
+                this.cardList = res.groupDTOS;
+                this.imgBox = res;
                 this.form = {
-                    price: res.boxPrice,
-                    dates: res.startTime,
-                    message: res.description,
-                    num: res.boxesCount
+                    boxPrice: res.boxPrice,
+                    startTime: res.startTime,
+                    description: res.description,
+                    boxesCount: res.boxesCount || 0,
+                    postage: res.postage || 10
                 };
             });
         },
         submit() {
-            if (!this.form.name) {
+            if (!this.name) {
                 wx.showToast({
                     icon: 'none',
                     title: '卡牌名称不能为空'
                 });
                 return;
             }
-            if (!this.form.price) {
+            if (!this.form.boxPrice) {
                 wx.showToast({
                     icon: 'none',
                     title: '价格不能为空'
                 });
                 return;
             }
-            if (!this.form.dates) {
+            if (!this.form.startTime) {
                 wx.showToast({
                     icon: 'none',
                     title: '结束时间不能为空'

+ 88 - 99
src/pages/store/productEdit.vue

@@ -9,7 +9,7 @@
         <van-cell-group :border="false">
             <van-field
                 label="卡牌名称"
-                :value="form.name"
+                :value="name"
                 placeholder="请输入卡牌名称"
                 is-link
                 readonly
@@ -18,23 +18,23 @@
             </van-field>
             <van-field
                 label="卡牌售价"
-                :value="form.price"
-                @input="form.price = $event.detail"
+                :value="form.boxPrice"
+                @input="form.boxPrice = $event.detail"
                 placeholder="请输入金额"
             >
             </van-field>
             <van-field
                 label="拼箱结束"
                 is-link
-                :value="form.dates"
+                :value="form.startTime"
                 placeholder="请输入结束日期"
                 @click="newShow = true"
             >
             </van-field>
             <van-field
                 label="拼箱人数"
-                :value="form.num"
-                @input="form.num = $event.detail"
+                :value="form.boxesCount"
+                @input="form.boxesCount = $event.detail"
                 placeholder="请输入参加人数"
             >
             </van-field>
@@ -48,18 +48,19 @@
         </van-cell-group>
         <div class="box-con">
             <div class="label">卡牌细节图</div>
-            <van-uploader :file-list="fileList" :after-read="afterRead" @delete="deleteImg" />
-            <van-sticky :offset-top="0">
-                <div class="time-box">
-                    <van-dropdown-menu>
-                        <van-dropdown-item @change="change" :value="time" :options="option1" />
-                    </van-dropdown-menu>
-                </div>
-            </van-sticky>
-
-            <div class="box">
+            <van-uploader :file-list="form.images" :after-read="afterRead" @delete="deleteImg" />
+            <div class="box-top">
+                <div class="top"><span>选择卡包</span></div>
+                <van-sticky :offset-top="0">
+                    <div class="time-box">
+                        <van-dropdown-menu>
+                            <van-dropdown-item @change="change" :value="time" :options="option1" />
+                        </van-dropdown-menu>
+                    </div>
+                </van-sticky>
+            </div>
+            <div class="box" v-if="switchs">
                 <div class="top">
-                    <span>选择卡包</span>
                     <div class="right">
                         <div class="tool-item">
                             出售中
@@ -70,11 +71,11 @@
                     </div>
                 </div>
                 <div class="content">
-                    <div class="card" v-for="(card, index) in cardLists" :key="index">
-                        <div class="card-title">第{{ index }}组</div>
+                    <div class="card" v-for="(card, index) in form.groupDTOS" :key="index">
+                        <div class="card-title">第{{ index + 1 }}组</div>
                         <div class="card-list">
-                            <div v-for="(item, itemIndex) in card" :key="item" class="card-item">
-                                {{ itemIndex }}
+                            <div v-for="(item, itemIndex) in card.dynamicTags" :key="itemIndex" class="card-item">
+                                {{ itemIndex + 1 }}
                             </div>
                         </div>
                     </div>
@@ -82,8 +83,8 @@
             </div>
             <div class="label">卡牌详情描述</div>
             <van-field
-                :value="form.message"
-                @input="message = $event.detail"
+                :value="form.description"
+                @input="form.description = $event.detail"
                 :border="false"
                 rows="1"
                 autosize
@@ -123,45 +124,25 @@ export default {
     data() {
         return {
             form: {
-                name: '',
-                num: '',
+                boxesCount: '',
                 postage: 10,
-                price: '',
-                dates: '',
-                message: ''
+                boxPrice: '',
+                startTime: '',
+                description: '',
+                collectionId: 0,
+                seriesId: 0,
+                caseStatus: 'progress',
+                images: [],
+                groupDTOS: []
             },
             show: false,
+            name: '',
             newShow: false,
-            fileList: [],
             nowChooseId: [],
+            sotrId: [],
             list: [],
+            switchs: false,
             closeFlag: false,
-            cardList: [
-                // [
-                //     { id: '106', title: '数组' },
-                //     { id: '11', title: '数组' },
-                //     { id: '201', title: '数组' },
-                //     { id: '31', title: '数组' },
-                //     { id: '41', title: '数组' },
-                //     { id: '51', title: '数组' }
-                // ],
-                // [
-                //     { id: '100', title: '数组' },
-                //     { id: '212', title: '数组' },
-                //     { id: '22', title: '数组' },
-                //     { id: '32', title: '数组' },
-                //     { id: '47', title: '数组' },
-                //     { id: '58', title: '数组' }
-                // ],
-                // [
-                //     { id: '90', title: '数组' },
-                //     { id: '19', title: '数组' },
-                //     { id: '29', title: '数组' },
-                //     { id: '39', title: '数组' },
-                //     { id: '49', title: '数组' },
-                //     { id: '59', title: '数组' }
-                // ]
-            ],
             time: 0,
             typeOptions: [
                 { id: 0, name: '组队模板(24组6包)', group: 24, groupCount: 6, special: false },
@@ -184,15 +165,6 @@ export default {
                     value: item.id
                 };
             });
-        },
-        cardLists() {
-            let boxMap = { ...this.cardList };
-            return Object.keys(boxMap).map(item => {
-                return boxMap[item];
-            });
-        },
-        allCards() {
-            return [...this.cardLists].flat();
         }
     },
     watch: {
@@ -221,6 +193,10 @@ export default {
                 .then(res => {
                     this.hideLoading();
                     this.actions = res.content;
+                    this.sotrId = this.actions.find(item => {
+                        return item.id;
+                    });
+                    this.form.collectionId = this.sotrId.id;
                 })
                 .catch(e => {
                     this.hideLoading();
@@ -251,7 +227,7 @@ export default {
         onConfirm(event) {
             this.currentDate = event.detail;
             var timeValue = this.timeFormat(new Date(event.detail), 'yyyy-MM-dd hh:mm');
-            this.form.dates = timeValue;
+            this.form.startTime = timeValue + ':00';
             this.newShow = false;
         },
         // 时间取消按钮
@@ -268,13 +244,14 @@ export default {
         },
         select(e) {
             if (this.closeFlag) {
-                this.form.name = e.detail.name;
+                this.name = e.detail.name;
                 this.show = false;
                 return;
             }
             let data = {
                 seriesId: e.detail.id
             };
+            this.form.seriesId = data.seriesId;
             this.showLoading();
             this.$http
                 .post(
@@ -305,6 +282,7 @@ export default {
                 return item.id == this.time;
             });
             this.initApi(cardBos);
+            this.switchs = true;
         },
         initApi(params) {
             this.showLoading();
@@ -316,9 +294,15 @@ export default {
                 })
                 .then(res => {
                     this.hideLoading();
-                    console.log(res);
-                    this.cardList = { ...res };
-                    console.log(this.cardList);
+                    this.form.groupDTOS = res;
+                    console.log(this.form.groupDTOS);
+                })
+                .catch(e => {
+                    this.hideLoading();
+                    wx.showToast({
+                        icon: 'none',
+                        title: e.error
+                    });
                 });
         },
         afterRead(file) {
@@ -328,9 +312,10 @@ export default {
                 .then(res => {
                     this.hideLoading();
                     console.log(res);
-                    let fileList = [];
-                    fileList.push({ ...file, url: res });
-                    this.fileList = fileList;
+                    let images = [];
+                    images.push({ ...file, url: res });
+                    this.form.images = images;
+                    console.log(this.form.images);
                 })
                 .catch(e => {
                     this.hideLoading();
@@ -341,36 +326,49 @@ export default {
                 });
         },
         deleteImg() {
-            this.fileList = [];
+            this.form.images = [];
         },
         submit() {
-            if (!this.form.name) {
+            if (!this.name) {
                 wx.showToast({
                     icon: 'none',
                     title: '卡牌名称不能为空'
                 });
                 return;
             }
-            if (!this.form.price) {
+            if (!this.form.boxPrice) {
                 wx.showToast({
                     icon: 'none',
                     title: '价格不能为空'
                 });
                 return;
             }
-            if (!this.form.dates) {
+            if (!this.form.startTime) {
                 wx.showToast({
                     icon: 'none',
                     title: '结束时间不能为空'
                 });
                 return;
             }
-            wx.showToast({
-                title: '商品上架成功'
-            });
-        },
-        created(params) {
-            this.initApi(params.group, params.groupCount, params.special);
+            let form = { ...this.form };
+            console.log(form);
+            this.showLoading();
+            this.$http
+                .post('cardCase/save', { form })
+                .then(res => {
+                    this.hideLoading();
+                    console.log(res);
+                    wx.showToast({
+                        title: '商品上架成功'
+                    });
+                })
+                .catch(e => {
+                    this.hideLoading();
+                    wx.showToast({
+                        icon: 'none',
+                        title: e.error
+                    });
+                });
         }
     }
 };
@@ -379,24 +377,9 @@ export default {
 /deep/ .van-uploader {
     margin-top: 20px;
 }
-// /deep/ .van-dropdown-menu {
-//     width: 110px;
-//     border-radius: 4px;
-//     overflow: hidden;
-//     background: aquamarine;
 
-//     .van-cell__value {
-//         &::after {
-//             content: '';
-//         }
-//         &::before {
-//             content: '';
-//         }
-//     }
-// }
 .time-box {
     background-color: @bg;
-    padding: 20px;
     margin-right: 20px;
 }
 /deep/ .van-cell {
@@ -432,6 +415,12 @@ export default {
             margin-left: -3px;
             line-height: 24px;
         }
+        .box-top {
+            .flex();
+            justify-content: space-between;
+            padding-right: 6px;
+            margin-bottom: 10px;
+        }
         .box {
             max-height: 70vh;
             min-height: 50vh;
@@ -449,9 +438,9 @@ export default {
         .top {
             .flex();
             justify-content: space-between;
-            padding: 20px 0;
+            padding: 10px 0;
             flex-shrink: 0;
-
+            justify-content: flex-end;
             span {
                 font-size: 14px;
                 font-weight: bold;