xuqiang пре 4 година
родитељ
комит
5fb83e0a79
6 измењених фајлова са 188 додато и 72 уклоњено
  1. 1 0
      package.json
  2. 2 0
      src/main.js
  3. 6 0
      src/mixins/math.js
  4. 116 72
      src/pages/store/productEdit.vue
  5. 1 0
      src/pages/wallet.vue
  6. 62 0
      yarn.lock

+ 1 - 0
package.json

@@ -42,6 +42,7 @@
     "axios": "^0.21.1",
     "babel-loader": "^8.2.2",
     "dayjs": "^1.10.4",
+    "mathjs": "^9.4.4",
     "megalo": "latest",
     "octoparse": "^0.4.2",
     "qs": "^6.10.1",

+ 2 - 0
src/main.js

@@ -7,6 +7,7 @@ import Dialog from './vant/dialog/dialog';
 import common from './mixins/common';
 import './styles/font.less';
 import './styles/vanIndex.less';
+// Vue.prototype.$math = math;
 
 Vue.prototype.$colors = {
     prim: '#FF7F1F',
@@ -15,6 +16,7 @@ Vue.prototype.$colors = {
 
 Vue.use(VHtmlPlugin);
 Vue.use(Vuex);
+// Vue.use(math);
 
 const store = require('./store').default;
 Vue.prototype.$store = store;

+ 6 - 0
src/mixins/math.js

@@ -0,0 +1,6 @@
+const { create, all } = require('mathjs');
+const config = {
+    number: 'BigNumber',
+    precision: 20
+};
+const math = create(all, config);

+ 116 - 72
src/pages/store/productEdit.vue

@@ -217,7 +217,7 @@
                     <div v-for="(item, index) in cardList" :key="index">
                         <div class="con">
                             <div class="con-l">
-                                <img :src="item.images" alt="" />
+                                <img :src="item.image" alt="" />
                                 <span>{{ item.name }}</span>
                             </div>
                             <p>x{{ item.amount }}</p>
@@ -255,12 +255,12 @@
                 <div class="tit">福袋细节图</div>
                 <van-uploader
                     style="margin-left:20px"
-                    :file-list="forms.images"
-                    :after-read="afterReads"
+                    :file-list="forms.image"
+                    :after-read="aaa"
                     @delete="deleteImgs"
                 />
                 <div class="bottom">
-                    <van-button type="primary" block @click="submitNum">完成</van-button>
+                    <van-button type="primary" block @click="submitNum">完成2</van-button>
                 </div>
             </div>
         </div>
@@ -288,7 +288,7 @@ export default {
                 limitOne: false,
                 groupDTOS: []
             },
-            forms: { name: '', amount: '', images: [], imagesList: [], imageUrls: [] },
+            forms: { name: '', amount: '', image: [], imagesList: [], imageUrls: [] },
             name: '',
             soldStatus: '',
             show: false,
@@ -298,6 +298,7 @@ export default {
             newShow: false,
             showId: false,
             id: 0,
+            count: 0,
             images: [],
             cardList: [],
             imagesList: [],
@@ -309,6 +310,7 @@ export default {
             caseJackpots: [],
             time: 0,
             times: 1,
+            chooseType: null,
             typeOptions: [
                 { id: 4, name: '福袋模式' },
                 { id: 0, name: '组队模板(24队每队6人)', group: 24, groupCount: 6, special: false },
@@ -449,7 +451,7 @@ export default {
             this.flags = false;
             this.forms.name = '';
             this.forms.amount = '';
-            this.forms.images = '';
+            this.forms.image = [];
         },
         submitCon() {
             // if (this.cardLists.length < 0) {
@@ -476,10 +478,42 @@ export default {
                 });
                 return;
             }
-            let cardLists = { name: this.forms.name, amount: this.forms.amount, images: this.forms.imageUrls };
-            this.cardList.push(cardLists);
-            console.log(this.cardList);
-            this.flags = true;
+            if (this.forms.imageUrls <= 0) {
+                wx.showToast({
+                    icon: 'none',
+                    title: '请添加福袋图片'
+                });
+                return;
+            }
+            let data = { name: this.forms.name, amount: this.forms.amount };
+            let image = this.forms.imageUrls.join(',');
+            console.log(image);
+            data.image = image;
+            this.$http
+                .post('/jackpot/save', data, {
+                    header: {
+                        'Content-Type': 'application/json'
+                    }
+                })
+                .then(res => {
+                    console.log(res.id);
+                    let cardLists = {
+                        name: this.forms.name,
+                        amount: this.forms.amount,
+                        image: this.forms.imageUrls,
+                        jackpotId: res.id
+                    };
+                    this.cardList.push(cardLists);
+
+                    console.log(this.cardList);
+                    this.flags = true;
+                    this.saving = false;
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.saving = false;
+                    this.$message.error(e.error);
+                });
         },
         // canChoose(info) {
         //     return info.sold;
@@ -552,15 +586,20 @@ export default {
                 });
         },
         change(e) {
+            console.log(e);
+            this.chooseType = e.detail;
             this.time = e.detail;
             let cardBos = [...this.typeOptions].find(item => {
                 return item.id == this.time;
             });
+
+            console.log(this.chooseType);
             if (this.time != 4) {
                 this.initApi(cardBos);
             }
         },
         initApi(params) {
+            console.log(params);
             this.showLoading();
             this.$http
                 .post('/cardCase/genNew', {
@@ -569,7 +608,7 @@ export default {
                     special: params.special
                 })
                 .then(res => {
-                    // console.log(res);
+                    console.log(res);
                     this.hideLoading();
                     this.form.special = params.special;
                     this.form.groupDTOS = res;
@@ -614,37 +653,36 @@ export default {
                 return item.url;
             });
         },
-        afterReads(file) {
-            this.$nextTick(() => {
-                this.showLoading();
-                this.$http
-                    .uploadFile(file.path)
-                    .then(res => {
-                        console.log(res);
-                        if (this.forms.images.length > 0) {
-                            this.toast('最多上传一张图片');
-                            return;
-                        }
-                        this.hideLoading();
-                        this.forms.imagesList.push({ ...file, url: res });
-                        this.forms.images = [...this.forms.imagesList];
-                        this.forms.imageUrls.push(res);
-                        console.log(this.forms.imageUrls);
-                    })
-                    .catch(e => {
-                        this.hideLoading();
-                        wx.showToast({
-                            icon: 'none',
-                            title: e.error
-                        });
+        aaa(file) {
+            console.log(file);
+            this.showLoading();
+            this.$http
+                .uploadFile(file.path)
+                .then(res => {
+                    console.log(res);
+                    if (this.forms.image.length > 0) {
+                        this.toast('最多上传一张图片');
+                        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);
+                })
+                .catch(e => {
+                    this.hideLoading();
+                    wx.showToast({
+                        icon: 'none',
+                        title: e.error
                     });
-            });
+                });
         },
 
         deleteImgs(e) {
-            let list = [...this.forms.images];
+            let list = [...this.forms.image];
             list.splice(e.detail.index, 1);
-            this.forms.images = list;
+            this.forms.image = list;
             this.forms.imageUrls = list.map(item => {
                 return item.url;
             });
@@ -711,54 +749,60 @@ export default {
                 });
         },
         submits() {
-            // if (!this.form.name) {
-            //     wx.showToast({
-            //         icon: 'none',
-            //         title: '请选择卡牌名称'
-            //     });
-            //     return;
-            // }
-            // if (!this.form.name) {
-            //     wx.showToast({
-            //         icon: 'none',
-            //         title: '请填写卡牌名称'
-            //     });
-            //     return;
-            // }
-            // if (!this.form.boxPrice) {
-            //     wx.showToast({
-            //         icon: 'none',
-            //         title: '请填写价格'
-            //     });
-            //     return;
-            // }
-            // if (!this.form.startTime) {
-            //     wx.showToast({
-            //         icon: 'none',
-            //         title: '请选择结束时间'
-            //     });
-            //     return;
-            // }
+            if (!this.form.name) {
+                wx.showToast({
+                    icon: 'none',
+                    title: '请填写卡牌名称'
+                });
+                return;
+            }
+            if (!this.form.boxPrice) {
+                wx.showToast({
+                    icon: 'none',
+                    title: '请填写价格'
+                });
+                return;
+            }
+            if (!this.form.startTime) {
+                wx.showToast({
+                    icon: 'none',
+                    title: '请选择结束时间'
+                });
+                return;
+            }
+
             let newJackpot = {};
+            var count = new Number('0');
             this.cardList.map(item => {
                 newJackpot.name = item.name;
-                newJackpot.images = item.images;
+                newJackpot.image = item.image[0];
                 newJackpot.amount = item.amount;
+                newJackpot.jackpotId = item.jackpotId;
+                var amount = new Number(item.amount);
+                count = count + amount;
                 this.caseJackpots.push(newJackpot);
             });
-            // this.$set(newJackpot, cardCaseInputDTO);
+            console.log(count);
+            if (!this.$mp.query.id) {
+                let box = {
+                    group: 1,
+                    groupCount: count,
+                    special: false
+                };
+
+                this.initApi(box);
+            }
             let caseStatus = 'UNDO';
             delete this.form.collectionId;
             delete this.form.seriesId;
-            delete this.form.groupDTOS;
+            // delete this.form.groupDTOS;
             let cardCaseInputDTO = { ...this.form };
-            // let images = this.imageUrls.join(',');
-            let images = this.imageUrls;
+            let images = this.imageUrls.join(',');
+            // let images = this.imageUrls;
             cardCaseInputDTO.images = images;
             cardCaseInputDTO.caseStatus = caseStatus;
-            cardCaseInputDTO.groupDTOS = this.caseJackpots;
+            cardCaseInputDTO.caseJackpots = this.caseJackpots;
             console.log(this.cardList);
-            console.log(this.cardCaseInputDTOs);
             console.log(cardCaseInputDTO);
             this.showLoading();
             this.$http

+ 1 - 0
src/pages/wallet.vue

@@ -187,6 +187,7 @@ export default {
         }
     },
     onShow() {
+        console.log(this.count);
         this.record({
             detail: 0
         });

+ 62 - 0
yarn.lock

@@ -820,6 +820,13 @@
     "@babel/types" "^7.4.4"
     esutils "^2.0.2"
 
+"@babel/runtime@^7.14.6":
+  version "7.14.8"
+  resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.8.tgz#7119a56f421018852694290b9f9148097391b446"
+  integrity sha512-twj3L8Og5SaCRCErB4x4ajbvBIVV77CGeFglHpeg5WC5FF8TZzBWXtTJ4MqaD9QszLYTtr+IsaAL2rEUevb+eg==
+  dependencies:
+    regenerator-runtime "^0.13.4"
+
 "@babel/runtime@^7.3.4", "@babel/runtime@^7.8.4":
   version "7.13.17"
   resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.17.tgz#8966d1fc9593bf848602f0662d6b4d0069e3a7ec"
@@ -2728,6 +2735,11 @@ commondir@^1.0.1:
   resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
   integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=
 
+complex.js@^2.0.15:
+  version "2.0.15"
+  resolved "https://registry.yarnpkg.com/complex.js/-/complex.js-2.0.15.tgz#7add6848b4c1d12aa9262f7df925ebe7a51a7406"
+  integrity sha512-gDBvQU8IG139ZBQTSo2qvDFP+lANMGluM779csXOr6ny1NUtA3wkUnCFjlDNH/moAVfXtvClYt6G0zarFbtz5w==
+
 component-emitter@^1.2.1:
   version "1.3.0"
   resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
@@ -3212,6 +3224,11 @@ decamelize@^1.1.2, decamelize@^1.2.0:
   resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
   integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
 
+decimal.js@^10.3.1:
+  version "10.3.1"
+  resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.3.1.tgz#d8c3a444a9c6774ba60ca6ad7261c3a94fd5e783"
+  integrity sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==
+
 decode-uri-component@^0.2.0:
   version "0.2.0"
   resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
@@ -3630,6 +3647,11 @@ escape-html@~1.0.3:
   resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
   integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=
 
+escape-latex@^1.2.0:
+  version "1.2.0"
+  resolved "https://registry.yarnpkg.com/escape-latex/-/escape-latex-1.2.0.tgz#07c03818cf7dac250cce517f4fda1b001ef2bca1"
+  integrity sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw==
+
 escape-string-regexp@^1.0.0, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
   version "1.0.5"
   resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
@@ -4349,6 +4371,11 @@ forwarded@~0.1.2:
   resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
   integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=
 
+fraction.js@^4.1.1:
+  version "4.1.1"
+  resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.1.1.tgz#ac4e520473dae67012d618aab91eda09bcb400ff"
+  integrity sha512-MHOhvvxHTfRFpF1geTK9czMIZ6xclsEor2wkIGYYq+PxcQqT7vStJqjhe6S1TenZrMZzo+wlqOufBDVepUEgPg==
+
 fragment-cache@^0.2.1:
   version "0.2.1"
   resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19"
@@ -5463,6 +5490,11 @@ isstream@~0.1.2:
   resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
   integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=
 
+javascript-natural-sort@^0.7.1:
+  version "0.7.1"
+  resolved "https://registry.yarnpkg.com/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz#f9e2303d4507f6d74355a73664d1440fb5a0ef59"
+  integrity sha1-+eIwPUUH9tdDVac2ZNFED7Wg71k=
+
 javascript-stringify@^2.0.0:
   version "2.1.0"
   resolved "https://registry.yarnpkg.com/javascript-stringify/-/javascript-stringify-2.1.0.tgz#27c76539be14d8bd128219a2d731b09337904e79"
@@ -5902,6 +5934,21 @@ map-visit@^1.0.0:
   dependencies:
     object-visit "^1.0.0"
 
+mathjs@^9.4.4:
+  version "9.4.4"
+  resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-9.4.4.tgz#29acd67563c1e720910213062824c3faf61bc858"
+  integrity sha512-5EEJXnWOzLDgMHSFyw623nH+MTBZxquWwXtrzTsingOouJJ6UZG2VNO1lwH31IMt9aMno1axO6TYleIP4YSDaQ==
+  dependencies:
+    "@babel/runtime" "^7.14.6"
+    complex.js "^2.0.15"
+    decimal.js "^10.3.1"
+    escape-latex "^1.2.0"
+    fraction.js "^4.1.1"
+    javascript-natural-sort "^0.7.1"
+    seedrandom "^3.0.5"
+    tiny-emitter "^2.1.0"
+    typed-function "^2.0.0"
+
 md5.js@^1.3.4:
   version "1.3.5"
   resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
@@ -8004,6 +8051,11 @@ scss-tokenizer@^0.2.3:
     js-base64 "^2.1.8"
     source-map "^0.4.2"
 
+seedrandom@^3.0.5:
+  version "3.0.5"
+  resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7"
+  integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==
+
 select-hose@^2.0.0:
   version "2.0.0"
   resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca"
@@ -8812,6 +8864,11 @@ timsort@^0.3.0:
   resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4"
   integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=
 
+tiny-emitter@^2.1.0:
+  version "2.1.0"
+  resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz#1d1a56edfc51c43e863cbb5382a72330e3555423"
+  integrity sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==
+
 tmp@^0.0.33:
   version "0.0.33"
   resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
@@ -8958,6 +9015,11 @@ type-is@~1.6.17, type-is@~1.6.18:
     media-typer "0.3.0"
     mime-types "~2.1.24"
 
+typed-function@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/typed-function/-/typed-function-2.0.0.tgz#15ab3825845138a8b1113bd89e60cd6a435739e8"
+  integrity sha512-Hhy1Iwo/e4AtLZNK10ewVVcP2UEs408DS35ubP825w/YgSBK1KVLwALvvIG4yX75QJrxjCpcWkzkVRB0BwwYlA==
+
 typedarray@^0.0.6:
   version "0.0.6"
   resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"