|
@@ -36,7 +36,7 @@
|
|
|
<view v-for="(item, index) in goodsList" :key="index" class="goods-item clearfix">
|
|
|
<view class="shoptitle">
|
|
|
<!--选择商店的全部商品"-->
|
|
|
- <view class="checkbox-box" @click.stop="checkShop(item)">
|
|
|
+ <view class="checkbox-box" @click.stop="handleCheckShop(item)">
|
|
|
<view
|
|
|
class="checkbox iconfont"
|
|
|
:class="[item.isChecked ? 'icon-yixuanze' : 'icon-weixuanze']"
|
|
@@ -56,7 +56,7 @@
|
|
|
<view class="goods-pros" v-for="(pros, idx) in item.cartList" :key="idx">
|
|
|
<view class="goods-pros-t">
|
|
|
<!--选择商品-->
|
|
|
- <view class="checkbox-box" @click.stop="ischeck(item, pros)">
|
|
|
+ <view class="checkbox-box" @click.stop="handlsCkecdPros(item, pros)">
|
|
|
<view
|
|
|
class="checkbox iconfont"
|
|
|
:class="[pros.isChecked ? 'icon-yixuanze' : 'icon-weixuanze']"
|
|
@@ -74,7 +74,7 @@
|
|
|
pros.name
|
|
|
}}</view>
|
|
|
<view class="productspec">规格:{{ pros.unit ? pros.unit : '' }}</view>
|
|
|
- <template v-if="pros.stock> 0">
|
|
|
+ <template v-if="pros.number > pros.stock || pros.stock === 0">
|
|
|
<view class="cart-sku-temp" @click.stop="handleShouUnitPopup(pros)">
|
|
|
<view class="cart-sku-text">重新选择商品规格</view>
|
|
|
<view class="cart-sku-btn">重选</view>
|
|
@@ -196,7 +196,7 @@
|
|
|
<view class="title-txt"
|
|
|
>失效商品<text>{{ failureList.length }}件</text></view
|
|
|
>
|
|
|
- <view class="title-btn" @click.stop="deletefailureList"
|
|
|
+ <view class="title-btn" @click.stop="handleDeletefailures"
|
|
|
><text class="butto">清空失效商品</text></view
|
|
|
>
|
|
|
</view>
|
|
@@ -206,7 +206,7 @@
|
|
|
<!--选择商品-->
|
|
|
<view
|
|
|
class="checkbox-box"
|
|
|
- @click.stop="ischeckFailure(failure)"
|
|
|
+ @click.stop="handleCheckFailure(failure)"
|
|
|
v-if="isshowDelbtn"
|
|
|
>
|
|
|
<button
|
|
@@ -258,18 +258,18 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view v-if="!isshowDelbtn" class="footer-ri">
|
|
|
- <view class="btn hanld-btn" @tap="toConfirmation">去结算({{ allCount }})</view>
|
|
|
+ <view class="btn hanld-btn" @tap="hanldlerToConfirm">去结算({{ allCount }})</view>
|
|
|
</view>
|
|
|
<view v-else class="footer-del">
|
|
|
<view class="btn btn-cancel" @tap.stop="hideDelManage">取消</view>
|
|
|
- <view class="btn btn-confirm" @tap.stop="deleteList">删除</view>
|
|
|
+ <view class="btn btn-confirm" @tap.stop="handleDeleteCart">删除</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
<view class="footer" :style="{ paddingBottom: isIphoneX ? '68rpx' : '0rpx' }">
|
|
|
<view class="footer-le">
|
|
|
- <view class="foot-check checkbox-box" @tap.stop="checkAll()">
|
|
|
+ <view class="foot-check checkbox-box" @tap.stop="handleCheckAll">
|
|
|
<button
|
|
|
class="checkbox iconfont"
|
|
|
:class="[isCheckAll ? 'icon-yixuanze' : 'icon-weixuanze']"
|
|
@@ -292,11 +292,11 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view v-if="!isshowDelbtn" class="footer-ri">
|
|
|
- <view class="btn hanld-btn" @tap="toConfirmation">去结算({{ allCount }})</view>
|
|
|
+ <view class="btn hanld-btn" @tap="hanldlerToConfirm">去结算({{ allCount }})</view>
|
|
|
</view>
|
|
|
<view v-else class="footer-del">
|
|
|
<view class="btn btn-cancel" @tap.stop="hideDelManage">取消</view>
|
|
|
- <view class="btn btn-confirm" @tap.stop="deleteList">删除</view>
|
|
|
+ <view class="btn btn-confirm" @tap.stop="handleDeleteCart">删除</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
@@ -317,8 +317,8 @@
|
|
|
<cm-unit-popup
|
|
|
v-if="popupShow2"
|
|
|
:popupShow="popupShow2"
|
|
|
- :product="handlePros"
|
|
|
- @btnConfirm="handleBtnConfirm"
|
|
|
+ :skuProduct="handlePros"
|
|
|
+ @skuBtnConfirm="handleBtnConfirm"
|
|
|
></cm-unit-popup>
|
|
|
<!-- 促销活动弹窗 -->
|
|
|
<activi-popup :product="handlerPros" :popupShow="popupShow"></activi-popup>
|
|
@@ -415,13 +415,13 @@
|
|
|
>
|
|
|
<view
|
|
|
class="icon-used-btn receive"
|
|
|
- @click="toDeductCoupon(coupon)"
|
|
|
+ @click="handleToDeductCoupon(coupon)"
|
|
|
>抵扣</view
|
|
|
>
|
|
|
</template>
|
|
|
<template v-else-if="coupon.couponPayWay == 1">
|
|
|
<view class="icon-used-text">购买</view>
|
|
|
- <view class="icon-used-btn receive" @click="toPayCoupon(coupon)"
|
|
|
+ <view class="icon-used-btn receive" @click="handlePayCoupon(coupon)"
|
|
|
>¥{{ coupon.moneyCouponPrice }}</view
|
|
|
>
|
|
|
</template>
|
|
@@ -511,10 +511,12 @@ import couponTabs from '@/components/cm-module/coupon/tui-tabs.vue'
|
|
|
import cmUnitPopup from './cm-unit-popup.vue'
|
|
|
import modalLayer from '@/components/modal-layer'
|
|
|
import payMixins from '@/mixins/payMixins.js'
|
|
|
+import cartMixins from './mixins/cartMixins.js'
|
|
|
+import apisMixins from './mixins/apisMixins.js'
|
|
|
import { mapState, mapMutations } from 'vuex'
|
|
|
export default {
|
|
|
name: 'cartComponents',
|
|
|
- mixins: [payMixins],
|
|
|
+ mixins: [payMixins,apisMixins,cartMixins],
|
|
|
props: {
|
|
|
pathType: {
|
|
|
type: Number
|
|
@@ -543,7 +545,6 @@ export default {
|
|
|
promotionsList: [], // 促销列表
|
|
|
totalCouponList: [], // 优惠券算列表
|
|
|
eligibleCoupons: [], // 最终需要用到优惠券
|
|
|
- delGoodsList: '', // 要删除的商品
|
|
|
setGoodData: '', // 确认订单的商品
|
|
|
isCheckAll: false, // 是否全选
|
|
|
kindCount: 0, // 购物车宝贝数量
|
|
@@ -718,10 +719,16 @@ export default {
|
|
|
}
|
|
|
if (data.list && data.list.length > 0) {
|
|
|
this.goodsList = data.list
|
|
|
- this.goodsList.forEach((item, index) => {
|
|
|
- item.cartList.forEach(pros => {
|
|
|
- pros.shopId = item.shopId
|
|
|
+ this.goodsList.forEach((supplier, index) => {
|
|
|
+ supplier.cartList.forEach(pros => {
|
|
|
+ pros.shopId = supplier.shopId
|
|
|
pros.isStep = false
|
|
|
+ if(pros.stock === 0 || pros.number > pros.stock ){
|
|
|
+ supplier.isDisable = true
|
|
|
+ pros.isDisable = true
|
|
|
+ }else{
|
|
|
+ pros.isDisable = false
|
|
|
+ }
|
|
|
if (pros.step === 2) {
|
|
|
if (pros.number % pros.min != 0) {
|
|
|
pros.number = pros.min
|
|
@@ -755,20 +762,21 @@ export default {
|
|
|
this.$util.msg(error.msg, 2000)
|
|
|
})
|
|
|
},
|
|
|
- ischeckFailure(failure) {
|
|
|
+ handleCheckFailure(failure) {// 选择失效商品
|
|
|
failure.isChecked = !failure.isChecked
|
|
|
this.updateCheckAllBtn()
|
|
|
},
|
|
|
- ischeck(item, pro) {
|
|
|
+ handlsCkecdPros(item, pro) {
|
|
|
//为未选中的时候改变为true,反之为true
|
|
|
+ if(pro.isDisable){ return }
|
|
|
pro.isChecked = !pro.isChecked
|
|
|
if (pro.isChecked) {
|
|
|
- if (!this.submitIds.includes(pro.productId * 1)) {
|
|
|
- this.submitIds.push(pro.productId)
|
|
|
+ if (!this.submitIds.includes(pro.skuId * 1)) {
|
|
|
+ this.submitIds.push(pro.skuId)
|
|
|
this.checkenProsList.push(pro)
|
|
|
}
|
|
|
} else {
|
|
|
- var lent = this.submitIds.indexOf(pro.productId * 1)
|
|
|
+ var lent = this.submitIds.indexOf(pro.skuId * 1)
|
|
|
if (lent >= 0) {
|
|
|
this.submitIds.splice(lent, 1)
|
|
|
this.checkenProsList.splice(lent, 1)
|
|
@@ -818,23 +826,24 @@ export default {
|
|
|
this.isCheckAll = goodsCheckedLength === goodsList.length
|
|
|
}
|
|
|
},
|
|
|
- checkShop(item) {
|
|
|
+ handleCheckShop(supplier) {
|
|
|
//与单选商品类似
|
|
|
- item.isChecked = !item.isChecked
|
|
|
- this.setProductChecked(item)
|
|
|
+ if(supplier.isDisable){ return }
|
|
|
+ supplier.isChecked = !supplier.isChecked
|
|
|
+ this.setProductChecked(supplier)
|
|
|
this.updateCheckAllBtn()
|
|
|
},
|
|
|
- setProductChecked(item) {
|
|
|
- item.cartList.forEach(pros => {
|
|
|
- if (item.isChecked) {
|
|
|
+ setProductChecked(supplier) {
|
|
|
+ supplier.cartList.forEach(pros => {
|
|
|
+ if (supplier.isChecked && (pros.stock !== 0 || pros.number < pros.stock)) {
|
|
|
pros.isChecked = true
|
|
|
- if (!this.submitIds.includes(pros.productId * 1)) {
|
|
|
- this.submitIds.push(pros.productId)
|
|
|
+ if (!this.submitIds.includes(pros.skuId * 1)) {
|
|
|
+ this.submitIds.push(pros.skuId)
|
|
|
this.checkenProsList.push(pros)
|
|
|
}
|
|
|
} else {
|
|
|
pros.isChecked = false
|
|
|
- var lent = this.submitIds.indexOf(pros.productId * 1)
|
|
|
+ let lent = this.submitIds.indexOf(pros.skuId * 1)
|
|
|
if (lent >= 0) {
|
|
|
this.submitIds.splice(lent, 1)
|
|
|
this.checkenProsList.splice(lent, 1)
|
|
@@ -845,22 +854,22 @@ export default {
|
|
|
updateBothCheckBtn() {
|
|
|
if (this.isshowDelbtn) {
|
|
|
// 当管理删除按钮出现时,失效的商品可被选择
|
|
|
- this.goodsList.forEach(item => {
|
|
|
- item.isChecked = this.isCheckAll
|
|
|
- this.setProductChecked(item)
|
|
|
+ this.goodsList.forEach(supplier => {
|
|
|
+ supplier.isChecked = this.isCheckAll
|
|
|
+ this.setProductChecked(supplier)
|
|
|
})
|
|
|
//删除按钮 全选包括失效商品勾选
|
|
|
this.failureList.forEach(failureItem => {
|
|
|
failureItem.isChecked = this.isCheckAll
|
|
|
})
|
|
|
} else {
|
|
|
- this.goodsList.forEach(item => {
|
|
|
- item.isChecked = this.isCheckAll && !item.isDisabled
|
|
|
- this.setProductChecked(item)
|
|
|
+ this.goodsList.forEach(supplier => {
|
|
|
+ supplier.isChecked = this.isCheckAll && !supplier.isDisabled
|
|
|
+ this.setProductChecked(supplier)
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- checkAll() {
|
|
|
+ handleCheckAll() {
|
|
|
//全选方法内调用方法
|
|
|
this.isCheckAll = !this.isCheckAll
|
|
|
if (!this.isCheckAll) {
|
|
@@ -1074,7 +1083,7 @@ export default {
|
|
|
// 凑单满减计算勾选的凑单商品总价
|
|
|
let price
|
|
|
this.checkenProsList.find(el => {
|
|
|
- if (pros.productId == el.productId) {
|
|
|
+ if (pros.skuId == el.skuId) {
|
|
|
price = el.number * el.price
|
|
|
}
|
|
|
})
|
|
@@ -1224,100 +1233,28 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- updateShoppogNum(pros) {
|
|
|
- //加减购物车商品更新到后台
|
|
|
- this.ProductService.ShoppingCartUpdate({
|
|
|
- userId: this.userId,
|
|
|
- productId: pros.productId,
|
|
|
- productCount: pros.number,
|
|
|
- source: 2
|
|
|
- })
|
|
|
- .then(response => {
|
|
|
- this.isshowDelbtn = false
|
|
|
- // this.initGetCartGoodsList()
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- this.$util.msg(error.msg, 2000)
|
|
|
- })
|
|
|
- },
|
|
|
- toConfirmation() {
|
|
|
- //跳转确认订单页面
|
|
|
- let setGoodsList = []
|
|
|
- this.goodsList.forEach(res => {
|
|
|
- let products = res.cartList
|
|
|
- products.forEach(pros => {
|
|
|
- if (pros.isChecked) {
|
|
|
- setGoodsList.push(pros.productId)
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- if (setGoodsList == '') {
|
|
|
- this.$util.msg('请先选择结算商品~', 2000)
|
|
|
- return
|
|
|
- } else {
|
|
|
- this.isNoConfim = false
|
|
|
- this.goodsList.forEach(el => {
|
|
|
- el.cartList.forEach(pros => {
|
|
|
- if (pros.isChecked) {
|
|
|
- if (pros.number < pros.min) {
|
|
|
- this.isNoConfim = true
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- if (this.isNoConfim) {
|
|
|
- this.$util.modal(
|
|
|
- '',
|
|
|
- '有商品的购买量没达到最小起订量,请修改数量后再次提交结算',
|
|
|
- '去修改',
|
|
|
- '',
|
|
|
- false,
|
|
|
- () => {}
|
|
|
- )
|
|
|
- return
|
|
|
- }
|
|
|
- let productIds = ''
|
|
|
- this.goodsList.forEach(el => {
|
|
|
- //获取勾选的商品ID拼接字符串逗号隔开,最后一个逗号去掉
|
|
|
- el.cartList.forEach(pros => {
|
|
|
- if (pros.isChecked) {
|
|
|
- productIds += pros.productId + ','
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- let cartPramsData = { productIds: productIds.substring(0, productIds.lastIndexOf(',')) }
|
|
|
- // 友盟埋点购物车去结算点击事件
|
|
|
- if (process.env.NODE_ENV != 'development') {
|
|
|
- this.$uma.trackEvent('Um_Event_shoppingCartConfirmOrder', {
|
|
|
- Um_Key_PageName: '去结算',
|
|
|
- Um_Key_SourcePage: '底部菜单购物车'
|
|
|
- })
|
|
|
- }
|
|
|
- this.$api.navigateTo(
|
|
|
- `/pages/user/order/create-order?type=2&data=${JSON.stringify({ data: cartPramsData })}`
|
|
|
- )
|
|
|
- }
|
|
|
- },
|
|
|
showDelManager() {
|
|
|
//显示删除商品管理
|
|
|
this.isshowDelbtn = true
|
|
|
if (this.isCheckAll) {
|
|
|
this.updateBothCheckBtn()
|
|
|
} else {
|
|
|
- this.goodsList.forEach(item => {
|
|
|
- if (item.isChecked) {
|
|
|
- item.cartList.forEach(pros => {
|
|
|
+ this.goodsList = this.goodsList.map(suppler=>{
|
|
|
+ if (suppler.isChecked) {
|
|
|
+ suppler.cartList.forEach(pros => {
|
|
|
pros.isChecked = true
|
|
|
})
|
|
|
}
|
|
|
+ return suppler
|
|
|
})
|
|
|
this.updateCheckAllBtn()
|
|
|
}
|
|
|
// 失效也被勾选
|
|
|
- this.failureList.forEach(failureItem => {
|
|
|
- if (failureItem.isFailureLayer) {
|
|
|
- failureItem.isFailureLayer = false
|
|
|
+ this.failureList = this.failureList.map(el=>{
|
|
|
+ if (el.isFailureLayer) {
|
|
|
+ el.isFailureLayer = false
|
|
|
}
|
|
|
+ return el
|
|
|
})
|
|
|
},
|
|
|
hideDelManage() {
|
|
@@ -1329,87 +1266,29 @@ export default {
|
|
|
this.updateBothCheckBtn()
|
|
|
} else {
|
|
|
// 失效商品取消勾选
|
|
|
- this.goodsList.forEach(item => {
|
|
|
- if (item.isDisabled) {
|
|
|
- item.isChecked = false
|
|
|
+ this.goodsList = this.goodsList.map(suppler=>{
|
|
|
+ if (suppler.isDisabled) {
|
|
|
+ suppler.isChecked = false
|
|
|
}
|
|
|
- item.cartList.forEach(pros => {
|
|
|
+ suppler.cartList.forEach(pros => {
|
|
|
if (pros.validFlag == 3) {
|
|
|
pros.isChecked = false
|
|
|
}
|
|
|
})
|
|
|
+ return suppler
|
|
|
})
|
|
|
this.updateCheckAllBtn()
|
|
|
}
|
|
|
- this.failureList.forEach((failure, index) => {
|
|
|
- if (failure.failureState == 1 || failure.failureState == 2) {
|
|
|
- isFailureLayer = true
|
|
|
+ this.failureList = this.failureList.map(el=>{
|
|
|
+ if (el.failureState == 1 || el.failureState == 2) {
|
|
|
+ el.isFailureLayer = true
|
|
|
} else {
|
|
|
- isFailureLayer = false
|
|
|
- }
|
|
|
- newFailureList.push(Object.assign({}, failure, { isFailureLayer: isFailureLayer }))
|
|
|
- })
|
|
|
- this.failureList = newFailureList
|
|
|
- },
|
|
|
- deleteList() {
|
|
|
- //删除购物车商品
|
|
|
- this.delGoodsList = []
|
|
|
- this.goodsList.forEach(delitem => {
|
|
|
- let products = delitem.cartList
|
|
|
- products.forEach(pros => {
|
|
|
- if (pros.isChecked) {
|
|
|
- this.delGoodsList += pros.productId + ','
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- this.failureList.forEach(failure => {
|
|
|
- if (failure.isChecked) {
|
|
|
- this.delGoodsList += failure.productId + ','
|
|
|
+ el.isFailureLayer = false
|
|
|
}
|
|
|
- })
|
|
|
- if (this.delGoodsList.length == 0) {
|
|
|
- this.$util.msg('请选择要删除的商品~', 2000)
|
|
|
- return
|
|
|
- } else {
|
|
|
- this.$util.modal('', '确定删除选中的商品吗?', '确定', '取消', true, () => {
|
|
|
- this.ProductService.ShoppingCartDelete({
|
|
|
- userId: this.userId,
|
|
|
- productIds: this.delGoodsList
|
|
|
- })
|
|
|
- .then(response => {
|
|
|
- this.$util.msg('删除成功', 2000)
|
|
|
- setTimeout(() => {
|
|
|
- this.isshowDelbtn = false
|
|
|
- this.initGetCartGoodsList()
|
|
|
- }, 2000)
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- this.$util.msg(error.msg, 2000)
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- deletefailureList() {
|
|
|
- this.failureList.forEach(failure => {
|
|
|
- this.delGoodsList += failure.productId + ','
|
|
|
- })
|
|
|
- this.$util.modal('', '确定清空全部失效商品吗?', '确定', '取消', true, () => {
|
|
|
- this.ProductService.ShoppingCartDelete({
|
|
|
- userId: this.userId,
|
|
|
- productIds: this.delGoodsList
|
|
|
- })
|
|
|
- .then(response => {
|
|
|
- this.$util.msg('删除成功', 2000)
|
|
|
- setTimeout(() => {
|
|
|
- this.isshowDelbtn = false
|
|
|
- this.initGetCartGoodsList()
|
|
|
- }, 2000)
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- this.$util.msg(error.msg, 2000)
|
|
|
- })
|
|
|
+ return el
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
goIndex() {
|
|
|
uni.switchTab({
|
|
|
url: '/pages/tabBar/home/index'
|
|
@@ -1489,22 +1368,8 @@ export default {
|
|
|
return false
|
|
|
},
|
|
|
queryPopupCoupons() {
|
|
|
- // 获取弹窗优惠券列表
|
|
|
- this.ProductService.ShoppingCartGetCoupon(this.couponParam)
|
|
|
- .then(response => {
|
|
|
- let data = response.data
|
|
|
- this.navbar[0].num = data.notCouponNum
|
|
|
- this.navbar[1].num = data.couponNum
|
|
|
- if (data.couponList && data.couponList.length > 0) {
|
|
|
- this.productCouponList = data.couponList
|
|
|
- this.isCouponEmpty = false
|
|
|
- } else {
|
|
|
- this.isCouponEmpty = true
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- console.log('获取优惠券列表失败')
|
|
|
- })
|
|
|
+ // 获取优惠券列表调用 apisMixins -> apiShoppingCartGetCoupon
|
|
|
+ this.apiShoppingCartGetCoupon(this.couponParam)
|
|
|
},
|
|
|
receiveCoupon(coupon) {
|
|
|
// 点击优惠券领取按钮,友盟埋点收集领取优惠券
|
|
@@ -1515,24 +1380,10 @@ export default {
|
|
|
Um_Key_CouponId: `${coupon.couponId}`
|
|
|
})
|
|
|
}
|
|
|
- this.ProductService.ReceiveCoupon({
|
|
|
- userId: this.couponParam.userId,
|
|
|
- couponId: coupon.couponId,
|
|
|
- source: 1
|
|
|
- })
|
|
|
- .then(response => {
|
|
|
- this.$util.msg('领取成功', 1500, true, 'success')
|
|
|
- setTimeout(() => {
|
|
|
- this.currentTab = 1
|
|
|
- this.couponParam.status = 2
|
|
|
- this.queryPopupCoupons()
|
|
|
- }, 1500)
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- this.$util.msg(error.msg, 2000)
|
|
|
- })
|
|
|
+ // 领取优惠券调用 apisMixins -> apiReceiveCoupon
|
|
|
+ this.apiReceiveCoupon({userId: this.couponParam.userId,couponId: coupon.couponId,source: 1})
|
|
|
},
|
|
|
- toDeductCoupon(coupon) {
|
|
|
+ handleToDeductCoupon(coupon) {
|
|
|
// 点击采美豆抵扣优惠券
|
|
|
if (process.env.NODE_ENV != 'development') {
|
|
|
this.$uma.trackEvent('Um_Event_userCouponCollectionBuy', {
|
|
@@ -1546,31 +1397,13 @@ export default {
|
|
|
this.$util.msg('您的身份暂不支持领取优惠券', 2000)
|
|
|
return
|
|
|
}
|
|
|
- this.WeChatPayCouponBeans(coupon)
|
|
|
+ // 调用 apisMixins -> apiWeChatPayCouponBeans
|
|
|
+ this.apiWeChatPayCouponBeans({ source: 1, userId: this.couponParam.userId,couponId: coupon.couponId })
|
|
|
} else {
|
|
|
this.$api.navigateTo('/pages/login/login')
|
|
|
}
|
|
|
},
|
|
|
- WeChatPayCouponBeans(coupon) {
|
|
|
- // 采美豆抵扣优惠券
|
|
|
- this.PayService.WeChatPayCouponBeans({
|
|
|
- source: 1, //领取渠道 1 小程序 2 网站
|
|
|
- userId: this.couponParam.userId,
|
|
|
- couponId: coupon.couponId
|
|
|
- })
|
|
|
- .then(response => {
|
|
|
- this.$util.msg('抵扣成功', 1500)
|
|
|
- setTimeout(() => {
|
|
|
- this.currentTab = 1
|
|
|
- this.couponParam.status = 2
|
|
|
- this.queryPopupCoupons()
|
|
|
- }, 1500)
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- this.$util.msg(error.msg, 2000)
|
|
|
- })
|
|
|
- },
|
|
|
- toPayCoupon(coupon) {
|
|
|
+ handlePayCoupon(coupon) {
|
|
|
// 点击购买优惠券,友盟埋点收集购买优惠券
|
|
|
if (process.env.NODE_ENV != 'development') {
|
|
|
this.$uma.trackEvent('Um_Event_cartCouponBuy', {
|
|
@@ -1579,46 +1412,8 @@ export default {
|
|
|
Um_Key_CouponId: `${coupon.couponId}`
|
|
|
})
|
|
|
}
|
|
|
- this.createCouponRecord(coupon)
|
|
|
- },
|
|
|
- createCouponRecord(coupon) {
|
|
|
- // 生成购买优惠券记录Id
|
|
|
- this.PayService.WeChatCouponRecord({
|
|
|
- userId: this.userId,
|
|
|
- couponId: coupon.couponId
|
|
|
- })
|
|
|
- .then(response => {
|
|
|
- this.MiniWxPayFor(coupon, response.data.couponRecordId)
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- if (error.code == -1) {
|
|
|
- //个人机构不能购买
|
|
|
- this.contentModalText = '该优惠券仅限医美机构购买,请升级为医美机构后再次购买。'
|
|
|
- this.modal = true
|
|
|
- } else if (error.code == -2) {
|
|
|
- //会员机构不是医美机构不能购买
|
|
|
- this.$util.msg('该优惠券仅限医美机构购买', 2000)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- async MiniWxPayFor(coupon, couponRecordId) {
|
|
|
- const wechatcode = await authorize.getCode('weixin')
|
|
|
- const params = {
|
|
|
- userId: this.userId,
|
|
|
- couponId: coupon.couponId,
|
|
|
- couponRecordId: couponRecordId,
|
|
|
- payType: 'XCX',
|
|
|
- code: wechatcode,
|
|
|
- source: 1 //支付来源 1 小程序 2 WWW
|
|
|
- }
|
|
|
- this.weChatMiniCouponWxPay(
|
|
|
- params,
|
|
|
- 'Um_Event_cartCouponPay',
|
|
|
- '机构购物车',
|
|
|
- '线上支付优惠券',
|
|
|
- coupon.couponId,
|
|
|
- this.userId
|
|
|
- )
|
|
|
+ // 生成购买优惠券记录Id调用 apisMixins -> apiReceiveCoupon
|
|
|
+ this.apiWeChatCouponRecord({ userId: this.userId,couponId: coupon.couponId },coupon)
|
|
|
},
|
|
|
hideMobel() {
|
|
|
this.modal = false
|