Parcourir la source

优惠活动指定商品

吕海超 il y a 6 mois
Parent
commit
52b34aaa9f

+ 5 - 2
.env.development

@@ -5,10 +5,13 @@ VUE_APP_TITLE = 一七生活管理系统(测试)
 ENV = 'development'
 
 # 一七生活管理系统/开发环境
-VUE_APP_BASE_API_HOST = 'http://localhost:9801'
-VUE_APP_BASE_API = 'http://localhost:9801'
+# VUE_APP_BASE_API_HOST = 'http://localhost:9801'
+# VUE_APP_BASE_API = 'http://localhost:9801'
 # VUE_APP_BASE_API_HOST = 'http://139.224.65.227:8091/prod-api'
 # VUE_APP_BASE_API = 'http://139.224.65.227:8091/prod-api'
+VUE_APP_BASE_API_HOST = 'http://192.168.98.9:9801'
+VUE_APP_BASE_API = 'http://192.168.98.9:9801/'
+
 
 # 路由懒加载
 VUE_CLI_BABEL_TRANSPILE_MODULES = true

+ 7 - 6
src/components/payStatusPopup/index.vue

@@ -153,7 +153,7 @@ export default {
     },
 
     methods: {
-        open(type, info) {
+        open(type, info, appUserInfo = null) {
             this.orderInfo = info
             this.type = type
             if (type == 1) {
@@ -176,6 +176,11 @@ export default {
                 this.payType = info.payType
                 this.authCode = info.authCode
                 this.showPaySuccessBtn = false
+                console.log(appUserInfo)
+                if (appUserInfo.id) {
+                    this.appUserInfo = appUserInfo
+                }
+                console.log('aasss', this.appUserInfo)
                 this.pay()
             }
             if (type == 4) {
@@ -280,8 +285,6 @@ export default {
         },
 
         pay() {
-            console.log('A1')
-            console.log('A1-1')
             if (this.payType == 0 && !this.authCode) {
                 this.type = 4
                 this.errorMessage = '请先扫码'
@@ -289,9 +292,7 @@ export default {
                 this.changePayType()
                 return
             }
-            console.log('A2')
-
-            if (this.payType == 3 && appUserInfo.rechargeBalance + appUserInfo.giveBalance < this.orderInfo.payAmount) {
+            if (this.payType == 3 && this.appUserInfo.rechargeBalance + this.appUserInfo.giveBalance < this.orderInfo.payAmount) {
                 this.errorMessage = '余额不足'
                 this.type = 4
                 this.authCode = ''

+ 140 - 10
src/views/order/cloth/collectCloth.vue

@@ -199,12 +199,18 @@
                         <el-step title="衣服颜色"></el-step>
                         <el-step title="衣服品牌"></el-step>
                         <el-step title="衣服瑕疵"></el-step>
+                        <el-step title="衣服附件"></el-step>
                     </el-steps>
                 </el-col>
                 <el-col>
                     <div style="height: 20px"></div>
                 </el-col>
                 <el-col :span="24" v-if="addClothActiveTab == 0">
+                    <div style="margin-left: 55px"> 
+                        <el-input v-model="defaultList.type" placeholder="请输入要搜索的衣服分类" style="width: 300px;" clearable>
+                            <el-button slot="append" icon="el-icon-search" @click="searchCloth('type', 'clothTypes')"></el-button>
+                        </el-input>
+                    </div>
                     <div style="margin-left: 40px">
                         <el-tag :key="item.id" type="info" v-for="item in clothTypes" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothTypeSelect(item.id)">
                             {{ item.name }}
@@ -212,6 +218,11 @@
                     </div>
                 </el-col>
                 <el-col :span="24" v-if="addClothActiveTab == 1">
+                    <div style="margin-left: 55px; margin-bottom: 10px"> 
+                        <el-input v-model="defaultList.item" placeholder="请输入要搜索的衣服类型" style="width: 300px;" clearable>
+                            <el-button slot="append" icon="el-icon-search" @click="searchCloth('item', 'clothItems')"></el-button>
+                        </el-input>
+                    </div>
                     <div style="margin-left: 40px">
                         <div class="horizontal-view" style="margin-left: 15px">
                             <span style="font-size: 14px; line-height: 19px">衣服类型:</span>
@@ -226,6 +237,11 @@
                     </div>
                 </el-col>
                 <el-col :span="24" v-if="addClothActiveTab == 2">
+                    <div style="margin-left: 55px; margin-bottom: 10px"> 
+                        <el-input v-model="defaultList.color" placeholder="请输入要搜索的衣服颜色" style="width: 300px;" clearable>
+                            <el-button slot="append" icon="el-icon-search" @click="searchCloth('color', 'clothColors')"></el-button>
+                        </el-input>
+                    </div>
                     <div style="margin-left: 40px; display: flex; flex-wrap: wrap">
                         <template v-for="(item, index) in clothColors">
                             <div class="verticle-view" :style="'text-align: center;margin-top: 15px;margin-left: 15px;border-radius: 5px;border: 1px solid ' + (item.isSelect == true ? '#1890ff' : '#FFFFFF')" @click="onClothColorSelect(index)">
@@ -241,6 +257,11 @@
                     </div>
                 </el-col>
                 <el-col :span="24" v-if="addClothActiveTab == 3">
+                    <div style="margin-left: 55px;"> 
+                        <el-input v-model="defaultList.brand" placeholder="请输入要搜索的衣服品牌" style="width: 300px;" clearable>
+                            <el-button slot="append" icon="el-icon-search" @click="searchCloth('brand', 'clothBrands')"></el-button>
+                        </el-input>
+                    </div>
                     <div style="margin-left: 40px">
                         <el-tag :key="item.id" type="info" v-for="item in clothBrands" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothBrandSelect(item.id)">
                             {{ item.name }}
@@ -248,13 +269,23 @@
                     </div>
                 </el-col>
                 <el-col :span="24" v-if="addClothActiveTab == 4">
-                    <el-tabs type="border-card">
+                    <el-tabs type="border-card" @tab-click="changeClothTab">
                         <el-tab-pane label="全部">
+                            <div style="margin-left: 15px;"> 
+                                <el-input v-model="defaultList.flaw" placeholder="请输入要搜索的衣服瑕疵" style="width: 300px;" clearable>
+                                    <el-button slot="append" icon="el-icon-search" @click="searchCloth('flaw', 'clothFlaws')"></el-button>
+                                </el-input>
+                            </div>
                             <el-tag :key="item.id" :type="item.isSelect ? 'success' : 'info'" v-for="(item, index) in clothFlaws" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothFlawSelect(index)">
                                 {{ item.name }}
                             </el-tag>
                         </el-tab-pane>
                         <el-tab-pane :label="clothFlawType.name" v-for="clothFlawType in clothFlawTypes">
+                            <div style="margin-left: 15px;"> 
+                                <el-input v-model="defaultList.flaw" placeholder="请输入要搜索的衣服瑕疵" style="width: 300px;" clearable>
+                                    <el-button slot="append" icon="el-icon-search" @click="searchCloth('flaw', 'clothFlaws')"></el-button>
+                                </el-input>
+                            </div>
                             <template v-for="(item, index) in clothFlaws">
                                 <el-tag :key="item.id" :type="item.isSelect ? 'success' : 'info'" v-if="item.flawTypeId == clothFlawType.id" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothFlawSelect(index)">
                                     {{ item.name }}
@@ -263,8 +294,38 @@
                         </el-tab-pane>
                     </el-tabs>
                 </el-col>
+                <el-col :span="24" v-if="addClothActiveTab == 5">
+                    <el-row :gutter="20">
+                        <el-col :span="8">
+                            <div>选择附件</div>
+                            <div style="margin-left: 15px; margin-top: 10px;"> 
+                                 <el-input v-model="defaultList.adjunct" placeholder="请输入要搜索的衣服附件" style="width: 300px;" clearable>
+                                    <el-button slot="append" icon="el-icon-search" @click="searchCloth('adjunct', 'clothAdjuncts')"></el-button>
+                                </el-input>
+                            </div>
+                            <el-tag :key="item.id" type="info" v-for="item in clothAdjuncts" style="margin-top: 15px; margin-left: 15px" @click="onClothAdjunctSelect(item)">
+                                {{ item.name }}
+                            </el-tag>
+                        </el-col>
+                        <el-col :span="16">
+                            <el-table :data="addClothAdjuncts" style="width: 100%">
+                                <el-table-column label="附件" align="center" prop="adjunctName" />
+                                <el-table-column label="数量" align="center" prop="num">
+                                    <template slot-scope="scope">
+                                        <el-input-number v-model="scope.row.num" size="small" :precision="0" :min="1" :max="999"></el-input-number>
+                                    </template>
+                                </el-table-column>
+                                <el-table-column label="操作" align="center">
+                                    <template slot-scope="scope">
+                                        <el-button type="text" icon="el-icon-delete" @click="removeClothAdjunct(scope.$index)">删除</el-button>
+                                    </template>
+                                </el-table-column>
+                            </el-table>
+                        </el-col>
+                     </el-row>
+                </el-col>
             </el-row>
-            <div slot="footer" class="dialog-footer" v-if="addClothActiveTab == 2 || addClothActiveTab == 4">
+            <div slot="footer" class="dialog-footer" v-if="addClothActiveTab == 2 || addClothActiveTab == 4 || addClothActiveTab == 5">
                 <el-button type="primary" @click="addClothItemConfirm" style="margin-left: 5%">确定</el-button>
             </div>
         </el-dialog>
@@ -273,6 +334,11 @@
             <el-row :gutter="20">
                 <el-col :span="8">
                     <div>选择附件</div>
+                    <div style="margin-left: 55px"> 
+                        <el-input v-model="defaultList.adjunct" placeholder="请输入要搜索的衣服附件" style="width: 300px;" clearable>
+                            <el-button slot="append" icon="el-icon-search" @click="searchCloth('adjunct', 'clothAdjuncts')"></el-button>
+                        </el-input>
+                    </div>
                     <el-tag :key="item.id" type="info" v-for="item in clothAdjuncts" style="margin-top: 15px; margin-left: 15px" @click="onClothAdjunctSelect(item)">
                         {{ item.name }}
                     </el-tag>
@@ -472,6 +538,20 @@ export default {
             checkOrderIntervalId: null,
 
             addClothActiveTab: 0,
+            defaultList: {
+                type: '',
+                clothTypes: [],
+                item: '',
+                clothItems: [],
+                color: '',
+                clothColors: [],
+                brand: '',
+                clothBrands: [],
+                flaw: '',
+                clothFlaws: [],
+                adjunct: '',
+                clothAdjuncts: []
+            },
             clothBrands: [],
             clothTypes: [],
             clothItems: [],
@@ -572,6 +652,23 @@ export default {
         })
     },
     methods: {
+        // 添加衣物过滤数据
+        searchCloth(k1, k2) {
+            if (!this.defaultList[k1]) {
+                this[k2] = this.defaultList[k2]
+            } else {
+                this[k2] = this.defaultList[k2].filter((item) => {
+                    return item.name.indexOf(this.defaultList[k1]) > -1
+                })
+            }
+        },
+
+        // 切换衣服瑕疵分页
+        changeClothTab() {
+            this.defaultList.flaw = ''
+            this.clothFlaws = this.defaultList.clothFlaws
+        },
+
         // 上传前校检格式和大小
         handleBeforeUpload(file) {
             // 校检文件类型
@@ -672,6 +769,8 @@ export default {
         /** 新增按钮操作 */
         handleAdd() {
             allList().then((res) => {
+                this.defaultList.type = ''
+                this.defaultList.clothTypes = res.data
                 this.clothTypes = res.data
                 this.reset()
                 this.selectClothItemIndex = -1
@@ -703,7 +802,7 @@ export default {
             if (orderInfo.payTimeType == '0') {
                 //第三方支付
                 console.log('第三方支付')
-                this.$refs.payStatusPopup.open(3, orderInfo)
+                this.$refs.payStatusPopup.open(3, orderInfo, this.appUserInfo)
                 // this.checkOrderStatusNum = 0
                 // if (this.checkOrderIntervalId) {
                 //     clearInterval(this.checkOrderIntervalId)
@@ -781,12 +880,13 @@ export default {
         },
         onClothTypeSelect(id) {
             allClothItem({ clothTypeId: id }).then((res) => {
+                this.defaultList.item = ''
+                this.defaultList.clothItems = res.data
                 this.clothItems = res.data
                 this.addClothActiveTab = 1
             })
         },
         onClothItemSelect(index) {
-            console.log(this.clothItems)
             for (let i = 0; i < this.form.clothTypeKeys.length; i++) {
                 var orderClothTypeDTO = { orderClothTypeCode: this.form.clothTypeKeys[i] }
                 if (this.form.clothTypeKeys[i] == '1') {
@@ -835,6 +935,8 @@ export default {
                 this.$forceUpdate()
             } else {
                 allClothColor().then((res) => {
+                    this.defaultList.color = '';
+                    this.defaultList.clothColors = res.data
                     this.clothColors = res.data
                     this.form.clothItemId = this.clothItems[index].id
                     this.form = { ...this.form, ...this.clothItems[index] }
@@ -874,6 +976,8 @@ export default {
                     this.clothFlawTypes = res.data
 
                     allClothFlaw().then((res1) => {
+                        this.defaultList.flaw = '';
+                        this.defaultList.clothFlaws = res1.data
                         this.clothFlaws = res1.data
                         this.addClothActiveTab = 4
                     })
@@ -907,11 +1011,13 @@ export default {
                             id: '0',
                             name: '无'
                         })
+                        this.defaultList.brand = '';
+                        this.defaultList.clothBrands = res.data
                         this.clothBrands = res.data
                         this.addClothActiveTab = 3
                     })
                 }
-            } else {
+            } else if (this.addClothActiveTab == 4) {
                 //选择瑕疵
                 var clothFlawDTOS = []
                 this.clothFlaws.forEach((item) => {
@@ -930,10 +1036,24 @@ export default {
                     this.open = false
                     this.$forceUpdate()
                 } else {
-                    this.orderClothItemDTOS.push(this.form)
-                    console.log(this.orderClothItemDTOS)
-                    this.open = false
-                }
+                    // this.orderClothItemDTOS.push(this.form)
+                    // console.log(this.orderClothItemDTOS)
+                    // this.open = false
+                    allClothAdjunct().then((res) => {
+                        this.defaultList.clothAdjuncts = res.data;
+                        this.defaultList.adjunct = ''
+                        this.clothAdjuncts = res.data
+                        this.addClothActiveTab = 5
+                        let index = this.orderClothItemDTOS.length
+                        this.selectClothItemIndex = index
+                        this.addClothAdjuncts = []
+                        this.$forceUpdate()
+                    })
+                } 
+            } else if (this.addClothActiveTab == 5) {
+                this.orderClothItemDTOS.push(this.form)
+                this.addClothAdjunctSubmit()
+                this.open = false
             }
         },
         onClothFlawSelect(index) {
@@ -954,6 +1074,8 @@ export default {
         },
         handleAddClothFlaw(index) {
             allClothAdjunct().then((res) => {
+                this.defaultList.clothAdjuncts = res.data;
+                this.defaultList.adjunct = ''
                 this.clothAdjuncts = res.data
                 this.addClothAdjunctOpen = true
                 this.selectClothItemIndex = index
@@ -1000,6 +1122,8 @@ export default {
         updateClothItem(index, tabIndex) {
             if (tabIndex == 0) {
                 allList().then((res) => {
+                    this.defaultList.type = ''
+                    this.defaultList.clothTypes = res.data
                     this.clothTypes = res.data
                     this.selectClothItemIndex = index
                     this.form = { ...this.orderClothItemDTOS[index] }
@@ -1011,6 +1135,8 @@ export default {
             }
             if (tabIndex == 2) {
                 allClothColor().then((res) => {
+                    this.defaultList.color = ''
+                    this.defaultList.clothColors = res.data
                     this.clothColors = res.data
                     this.selectClothItemIndex = index
                     this.form = { ...this.orderClothItemDTOS[index] }
@@ -1022,6 +1148,8 @@ export default {
             }
             if (tabIndex == 3) {
                 allBrand().then((res) => {
+                    this.defaultList.brand = ''
+                    this.defaultList.clothBrands = res.data
                     this.clothBrands = res.data
                     this.selectClothItemIndex = index
                     this.form = { ...this.orderClothItemDTOS[index] }
@@ -1037,6 +1165,8 @@ export default {
                     this.clothFlawTypes = res.data
 
                     allClothFlaw().then((res1) => {
+                        this.defaultList.flaw = '';
+                        this.defaultList.clothFlaws = res1.data
                         this.clothFlaws = res1.data
                         this.selectClothItemIndex = index
                         this.form = { ...this.orderClothItemDTOS[index] }
@@ -1268,7 +1398,7 @@ export default {
             params.clothIds = clothIds
             this.orderForm.isSpecial = 'N'
             this.orderForm.authCode = ''
-            this.orderForm.payType = '3'
+            this.orderForm.payType = ''
             getDiscountByStoreId({ appUserId: this.appUserInfo.id }).then((res) => {
                 this.discountCouponVOS = res.data
                 params.discountWay = '0'

+ 26 - 11
src/views/order/cloth/component/cashCloth.vue

@@ -136,7 +136,9 @@
                             <el-table-column label="适用衣服" align="center">
                                 <template slot-scope="scope">
                                     <span v-if="scope.row.clothScope == 0">全部衣服 折扣{{ scope.row.discount * 100 }}%</span>
-                                    <span v-if="scope.row.clothScope == 1">指定衣服</span>
+                                    <div v-if="scope.row.clothScope == 1">
+                                        <div v-for="(item, i) in scope.row.activityClothItemVOList" :key="i">#{{ i + 1 }} {{ item.clothItemName }} 折扣{{ item.discount * 100 }}%</div>
+                                    </div>
                                 </template>
                             </el-table-column>
                             <el-table-column label="适用支付方式" align="center">
@@ -148,7 +150,7 @@
                             </el-table-column>
                             <el-table-column label="可优惠金额(元)" align="center">
                                 <template slot-scope="scope">
-                                    <span>{{ calculateTotalDiscountByActivity(scope.row) }}</span>
+                                    <span>{{ calculateTotalDiscountByActivity(scope.row, scope.row.title) }}</span>
                                 </template>
                             </el-table-column>
                             <!-- <el-table-column label="衣服品牌" align="center" prop="name" width="120"> -->
@@ -213,9 +215,9 @@
                         <span>元</span>
                     </template>
 
-                    <template v-if="calculateTotalDiscountByActivity(activity)">
+                    <template v-if="calculateTotalDiscountByActivity(activity, 'A6')">
                         <span style="margin-left: 10px">平台折扣活动优惠</span>
-                        <span style="color: #ff4949">{{ calculateTotalDiscountByActivity(activity) }}</span>
+                        <span style="color: #ff4949">{{ calculateTotalDiscountByActivity(activity, 'A7') }}</span>
                         <span>元</span>
                     </template>
 
@@ -479,7 +481,6 @@ export default {
         if (process.env.ENV != 'production') {
             window.cashClothDialog = this
         }
-        console.log('a12')
     },
     methods: {
         changePayType() {
@@ -540,7 +541,7 @@ export default {
                 totalDiscountAmount = totalDiscountAmount + cloth.deductAmount
             })
             if (this.activity.id) {
-                totalDiscountAmount = totalDiscountAmount + this.calculateTotalDiscountByActivity(this.activity)
+                totalDiscountAmount = totalDiscountAmount + this.calculateTotalDiscountByActivity(this.activity, 'A1')
             }
             return Math.round(totalDiscountAmount * 100) / 100
         },
@@ -566,9 +567,22 @@ export default {
                 let total = this.calculateTotalPrice() + this.calculateDeliveryPrice() - this.calculateTotalDiscountAmountByCoupon()
                 activityAmount = total * e.discount
             }
+            console.log('平台活动', this.orderClothItemDTOS, e.activityClothItemVOList)
+
             if (e.clothScope == 1) {
-                let total = this.calculateTotalPrice() + this.calculateDeliveryPrice() - this.calculateTotalDiscountAmountByCoupon()
-                activityAmount = total * e.discount
+                for (let i = 0; i < e.activityClothItemVOList.length; i++) {
+                    let cloth = e.activityClothItemVOList[i]
+                    for (let j = 0; j < this.orderClothItemDTOS.length; j++) {
+                       let goods = this.orderClothItemDTOS[j]
+                       console.log(goods.id, Number(cloth.clothId))
+                       if (goods.id === cloth.clothId) {
+                        activityAmount += goods.totalPrice * cloth.discount
+                       }
+                    }
+                }
+                // let total = this.calculateTotalPrice() + this.calculateDeliveryPrice() - this.calculateTotalDiscountAmountByCoupon()
+                // activityAmount = total * e.discount
+                console.log('折扣金额', activityAmount)
             }
             return Math.round(activityAmount * 100) / 100
         },
@@ -619,7 +633,7 @@ export default {
             // this.changeDiscountCouponIndex = index
             this.changeDiscountCouponCanSelectCloths = this.selectCoupons[index].applyCloths.concat()
             this.changeDiscountCouponCanSelectCloths.forEach((item) => {
-                let deductAmount1 = this.handelPrice(item.totalPrice * ( this.selectCoupons[index].discountRate / 100))
+                let deductAmount1 = this.handelPrice(item.totalPrice * (this.selectCoupons[index].discountRate / 100))
                 let deductAmount = deductAmount1 > this.selectCoupons[index].deductAmount ? this.selectCoupons[index].deductAmount : deductAmount1
                 item.deductAmount = deductAmount
                 item.isSelected = item.id == this.selectCoupons[index].orderCouponClothDTOS[0].id
@@ -716,6 +730,7 @@ export default {
                 }
                 e.activityAmount = Math.round(activityAmount * 100) / 100
             }
+            console.log(e)
             this.activity = e
         },
 
@@ -885,9 +900,9 @@ export default {
                     if (payTimeType == 1) {
                         params.payType = 0
                     }
-                    if (this.calculateTotalDiscountByActivity(this.activity)) {
+                    if (this.calculateTotalDiscountByActivity(this.activity, 'A3')) {
                         params.activityId = this.activity.id
-                        params.activityDiscountAmount = this.calculateTotalDiscountByActivity(this.activity)
+                        params.activityDiscountAmount = this.calculateTotalDiscountByActivity(this.activity, 'A4')
                     }
 
                     console.log(params)