|
@@ -2,7 +2,9 @@
|
|
<view class="order-create">
|
|
<view class="order-create">
|
|
<tui-skeleton v-if="isRequest" :loadingType="3" :isLoading="true"></tui-skeleton>
|
|
<tui-skeleton v-if="isRequest" :loadingType="3" :isLoading="true"></tui-skeleton>
|
|
<!-- 地址选择 -->
|
|
<!-- 地址选择 -->
|
|
- <order-choose-address class="sticky-top" :addressInfo="addressInfo"></order-choose-address>
|
|
|
|
|
|
+ <view class="sticky-top">
|
|
|
|
+ <order-choose-address class="sticky-top" :addressInfo="addressInfo"></order-choose-address>
|
|
|
|
+ </view>
|
|
<!-- 供应商商品列表 -->
|
|
<!-- 供应商商品列表 -->
|
|
<view class="shop-list">
|
|
<view class="shop-list">
|
|
<view class="section" v-for="(shopInfo, index) in shopList" :key="shopInfo.shopId">
|
|
<view class="section" v-for="(shopInfo, index) in shopList" :key="shopInfo.shopId">
|
|
@@ -19,25 +21,34 @@
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!-- 优惠券 -->
|
|
<!-- 优惠券 -->
|
|
- <view class="cell-section" @click="couponVisiable = true">
|
|
|
|
|
|
+ <view class="cell-section" @click="couponVisiable = true" v-if="receiveCouponList.length > 0">
|
|
<tui-list-cell :arrow="true" :padding="cellPadding" :unlined="true">
|
|
<tui-list-cell :arrow="true" :padding="cellPadding" :unlined="true">
|
|
<view class="cell-content">
|
|
<view class="cell-content">
|
|
- <text>优惠券</text> <text class="reduce tip">-¥{{ couponAmount | priceFormat }}</text>
|
|
|
|
|
|
+ <text class="label">优惠券</text>
|
|
|
|
+ <text class="reduce tip">-¥{{ couponAmount | priceFormat }}</text>
|
|
</view>
|
|
</view>
|
|
</tui-list-cell>
|
|
</tui-list-cell>
|
|
</view>
|
|
</view>
|
|
<!-- 分享减免 -->
|
|
<!-- 分享减免 -->
|
|
- <view class="cell-section" @click="$refs.sharePopup.open()">
|
|
|
|
|
|
+ <view class="cell-section" @click="onShare" v-if="reduction">
|
|
<tui-list-cell :arrow="false" :padding="cellPadding" :unlined="true">
|
|
<tui-list-cell :arrow="false" :padding="cellPadding" :unlined="true">
|
|
<button class="cell-content share-btn">
|
|
<button class="cell-content share-btn">
|
|
- <text>金额满99元,分享可立减20元</text> <text class="reduce tip">点击分享</text>
|
|
|
|
|
|
+ <text v-if="!shareStatus" class="active label">
|
|
|
|
+ 金额满¥{{ reduction.touchPrice }}元,分享可立减¥{{ reduction.reducedAmount }}元
|
|
|
|
+ </text>
|
|
|
|
+ <text class="label" v-else>分享减免</text>
|
|
|
|
+ <text class="reduce tip" v-if="!shareStatus">点击分享</text>
|
|
|
|
+ <text class="active" v-else>-¥{{ reduction.reducedAmount | priceFormat }}</text>
|
|
</button>
|
|
</button>
|
|
</tui-list-cell>
|
|
</tui-list-cell>
|
|
</view>
|
|
</view>
|
|
<!-- 运费 -->
|
|
<!-- 运费 -->
|
|
<view class="cell-section">
|
|
<view class="cell-section">
|
|
<tui-list-cell :arrow="false" :padding="cellPadding" :unlined="true">
|
|
<tui-list-cell :arrow="false" :padding="cellPadding" :unlined="true">
|
|
- <view class="cell-content"> <text>运费</text> <text class="tip postage">免邮</text> </view>
|
|
|
|
|
|
+ <view class="cell-content">
|
|
|
|
+ <text class="label">运费</text>
|
|
|
|
+ <text class="tip postage">免邮</text>
|
|
|
|
+ </view>
|
|
</tui-list-cell>
|
|
</tui-list-cell>
|
|
</view>
|
|
</view>
|
|
<!-- 提交订单 -->
|
|
<!-- 提交订单 -->
|
|
@@ -56,14 +67,19 @@
|
|
@checkedNone="onCheckedNone"
|
|
@checkedNone="onCheckedNone"
|
|
></cm-coupon-popup>
|
|
></cm-coupon-popup>
|
|
<!-- 分享 -->
|
|
<!-- 分享 -->
|
|
- <cm-share-popup ref="sharePopup"></cm-share-popup>
|
|
|
|
|
|
+ <cm-share-popup ref="sharePopup" :data="posterData" type="normal" @close="onAfterShare"></cm-share-popup>
|
|
|
|
+ <!-- 订单提交拦截 -->
|
|
|
|
+ <tui-modal :show="preventModal" :content="preventText" @click="onPreventModalConfirm"></tui-modal>
|
|
|
|
+ <!-- 安全区域 -->
|
|
|
|
+ <cm-safe-area-bottom></cm-safe-area-bottom>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { orderConfirm, orderSubmit } from '@/services/api/order.js'
|
|
|
|
|
|
+import { orderConfirm, orderSubmit, orderReductionShare } from '@/services/api/order.js'
|
|
import { fetchAddressList } from '@/services/api/user.js'
|
|
import { fetchAddressList } from '@/services/api/user.js'
|
|
import { initFormatCouponList, splitCouponList, chooseBestCoupon } from '@/common/business.helper.js'
|
|
import { initFormatCouponList, splitCouponList, chooseBestCoupon } from '@/common/business.helper.js'
|
|
|
|
+import { queryStringify } from '@/common/utils.js'
|
|
import { mapGetters } from 'vuex'
|
|
import { mapGetters } from 'vuex'
|
|
import wechatPayMixins from '@/pages/views/order/mixins/wechatPay.js'
|
|
import wechatPayMixins from '@/pages/views/order/mixins/wechatPay.js'
|
|
export default {
|
|
export default {
|
|
@@ -79,7 +95,8 @@ export default {
|
|
productId: '',
|
|
productId: '',
|
|
productCount: '',
|
|
productCount: '',
|
|
heUserId: '',
|
|
heUserId: '',
|
|
- collageFlag: 0
|
|
|
|
|
|
+ collageFlag: 0,
|
|
|
|
+ couponId: ''
|
|
},
|
|
},
|
|
|
|
|
|
// 订单提交参数
|
|
// 订单提交参数
|
|
@@ -117,13 +134,18 @@ export default {
|
|
shareReductStatus: false,
|
|
shareReductStatus: false,
|
|
reduction: null,
|
|
reduction: null,
|
|
reductionUserId: 0, //分享抵扣用户id
|
|
reductionUserId: 0, //分享抵扣用户id
|
|
- shareData: {
|
|
|
|
- type: 0
|
|
|
|
- },
|
|
|
|
|
|
|
|
allCount: 0, // 全部商品数量
|
|
allCount: 0, // 全部商品数量
|
|
// 统计价格(接口返回)
|
|
// 统计价格(接口返回)
|
|
- totalPrice: 0
|
|
|
|
|
|
+ totalPrice: 0,
|
|
|
|
+
|
|
|
|
+ preventModal: false,
|
|
|
|
+ preventText: '',
|
|
|
|
+
|
|
|
|
+ // 分享数据
|
|
|
|
+ posterData: {},
|
|
|
|
+
|
|
|
|
+ shareStatus: false
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -139,9 +161,13 @@ export default {
|
|
return 0
|
|
return 0
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ // 分享减免金额
|
|
|
|
+ shareReducedAmount() {
|
|
|
|
+ return this.reduction && this.shareStatus ? this.reduction.reducedAmount : 0
|
|
|
|
+ },
|
|
// 减免金额
|
|
// 减免金额
|
|
discountedPrice() {
|
|
discountedPrice() {
|
|
- return this.couponAmount
|
|
|
|
|
|
+ return this.couponAmount + this.shareReducedAmount
|
|
},
|
|
},
|
|
// 支付金额
|
|
// 支付金额
|
|
payAllPrice() {
|
|
payAllPrice() {
|
|
@@ -161,7 +187,6 @@ export default {
|
|
},
|
|
},
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
this.initOptions(options)
|
|
this.initOptions(options)
|
|
- this.orderPaySuccess() // 支付回调
|
|
|
|
},
|
|
},
|
|
onShow() {
|
|
onShow() {
|
|
this.resetAddress()
|
|
this.resetAddress()
|
|
@@ -171,17 +196,34 @@ export default {
|
|
uni.removeStorageSync('COMMIT_PRODUCT_INFO')
|
|
uni.removeStorageSync('COMMIT_PRODUCT_INFO')
|
|
uni.removeStorageSync('CHOOSE_ADDRESS')
|
|
uni.removeStorageSync('CHOOSE_ADDRESS')
|
|
},
|
|
},
|
|
|
|
+ onShareAppMessage() {
|
|
|
|
+ // 加密
|
|
|
|
+ const state_str = encodeURIComponent(this.$crypto.encrypt({ type: 0 }))
|
|
|
|
+ return {
|
|
|
|
+ title: '护肤上颜选,正品有好货~',
|
|
|
|
+ path: `/pages/index/index?state_str=${state_str}`,
|
|
|
|
+ imageUrl: this.staticUrl + 'icon-share.png'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
- // 支付成功回调
|
|
|
|
- orderPaySuccess() {
|
|
|
|
- this.$on('orderPaySuccess', orderInfo => {
|
|
|
|
- if (this.collageFlag === 1) {
|
|
|
|
- uni.redirectTo({ url: `share-buy/share-buy-detail?collageId=${this.collageId}` })
|
|
|
|
- } else {
|
|
|
|
- uni.setStorageSync('PAY_ORDER_INFO', orderInfo)
|
|
|
|
- this.$router.redirectTo('order/pay-success')
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ // 分享事件
|
|
|
|
+ onShare() {
|
|
|
|
+ this.posterData = { query: queryStringify({ type: 0 }) }
|
|
|
|
+ this.$refs.sharePopup.open()
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 分享结束
|
|
|
|
+ async onAfterShare() {
|
|
|
|
+ try {
|
|
|
|
+ if (!this.reduction) return
|
|
|
|
+ const { reductionId } = this.reduction
|
|
|
|
+ const res = await orderReductionShare({ reductionId, shareType: 1, userId: this.userId })
|
|
|
|
+ this.reductionUserId = res.data
|
|
|
|
+ this.$toast('以为您减免金额')
|
|
|
|
+ this.shareStatus = true
|
|
|
|
+ } catch (e) {
|
|
|
|
+ this.$toast('分享失败')
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
// 商品数量变化
|
|
// 商品数量变化
|
|
@@ -189,27 +231,28 @@ export default {
|
|
this.confirmParams.productCount = value
|
|
this.confirmParams.productCount = value
|
|
this.initOrderInfo()
|
|
this.initOrderInfo()
|
|
},
|
|
},
|
|
|
|
+
|
|
// 初始化参数信息
|
|
// 初始化参数信息
|
|
initOptions(options) {
|
|
initOptions(options) {
|
|
this.submitType = options.type
|
|
this.submitType = options.type
|
|
this.confirmParams.userId = this.userId
|
|
this.confirmParams.userId = this.userId
|
|
if (this.submitType === 'product' || this.submitType === 'shareBuy') {
|
|
if (this.submitType === 'product' || this.submitType === 'shareBuy') {
|
|
const productInfo = uni.getStorageSync('COMMIT_PRODUCT_INFO')
|
|
const productInfo = uni.getStorageSync('COMMIT_PRODUCT_INFO')
|
|
- this.submitParams.cartType = 2 // 从商品详情 / 拼单入口提交
|
|
|
|
|
|
+ this.submitParams.cartType = 2 // 从商品详情 / 拼单入口提交(标识)
|
|
this.confirmParams.productCount = productInfo.productCount
|
|
this.confirmParams.productCount = productInfo.productCount
|
|
this.confirmParams.productId = productInfo.productId
|
|
this.confirmParams.productId = productInfo.productId
|
|
this.confirmParams.heUserId = productInfo.heUserId || 0
|
|
this.confirmParams.heUserId = productInfo.heUserId || 0
|
|
- this.confirmParams.collageFlag = this.collageFlag = productInfo.collageFlag
|
|
|
|
- this.collageId = parseInt(productInfo.collageId) || 0
|
|
|
|
|
|
+ this.confirmParams.collageFlag = this.collageFlag = productInfo.collageFlag // 是否是拼团商品
|
|
|
|
+ this.confirmParams.couponId = productInfo.couponId
|
|
|
|
+ this.collageId = parseInt(productInfo.collageId) || 0 // 拼团id
|
|
this.allCount = productInfo.allCount
|
|
this.allCount = productInfo.allCount
|
|
} else {
|
|
} else {
|
|
const cartInfo = uni.getStorageSync('COMMIT_CART_INFO')
|
|
const cartInfo = uni.getStorageSync('COMMIT_CART_INFO')
|
|
- this.submitParams.cartType = 1 // 从购物车提交
|
|
|
|
|
|
+ this.submitParams.cartType = 1 // 从购物车提交(标识)
|
|
this.confirmParams.cartIds = cartInfo.cartIds.join()
|
|
this.confirmParams.cartIds = cartInfo.cartIds.join()
|
|
this.allCount = cartInfo.allCount
|
|
this.allCount = cartInfo.allCount
|
|
}
|
|
}
|
|
this.initOrderInfo()
|
|
this.initOrderInfo()
|
|
- // this.getUserAddress()
|
|
|
|
},
|
|
},
|
|
|
|
|
|
// 提交订单
|
|
// 提交订单
|
|
@@ -222,6 +265,8 @@ export default {
|
|
this.$toast('请先添加收货地址~')
|
|
this.$toast('请先添加收货地址~')
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //设置收货地址
|
|
this.submitParams.addressId = this.addressInfo.addressId
|
|
this.submitParams.addressId = this.addressInfo.addressId
|
|
|
|
|
|
// 优惠券,分享活动相关参数
|
|
// 优惠券,分享活动相关参数
|
|
@@ -234,10 +279,10 @@ export default {
|
|
this.submitParams.orderInfo = this.shopList.map(shop => {
|
|
this.submitParams.orderInfo = this.shopList.map(shop => {
|
|
const productInfo = shop.productList.map(product => ({
|
|
const productInfo = shop.productList.map(product => ({
|
|
productId: product.productId,
|
|
productId: product.productId,
|
|
- productNum: product.productCount,
|
|
|
|
|
|
+ productNum: product.num,
|
|
heUserId: product.heUserId
|
|
heUserId: product.heUserId
|
|
}))
|
|
}))
|
|
- return { shopId: shop.shopId, note: shop.note, productInfo }
|
|
|
|
|
|
+ return { shopId: shop.shopId, note: shop.note, productInfo, splitCode: shop.splitCode }
|
|
})
|
|
})
|
|
|
|
|
|
// 提交订单
|
|
// 提交订单
|
|
@@ -250,13 +295,22 @@ export default {
|
|
uni.setStorageSync('PAY_ORDER_INFO', res.data)
|
|
uni.setStorageSync('PAY_ORDER_INFO', res.data)
|
|
this.$router.redirectTo('order/pay-success')
|
|
this.$router.redirectTo('order/pay-success')
|
|
} else {
|
|
} else {
|
|
- this.miniWxPayFor(res.data)
|
|
|
|
|
|
+ // 子订单支付
|
|
|
|
+ this.$router.redirectTo(`order/order-pay?orderId=${res.data.orderId}`)
|
|
}
|
|
}
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.log(e)
|
|
console.log(e)
|
|
|
|
+ this.preventModal = true
|
|
|
|
+ this.preventText = e.msg
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // 订单提交拦截确认
|
|
|
|
+ onPreventModalConfirm() {
|
|
|
|
+ this.preventModal = false
|
|
|
|
+ uni.navigateBack({ delta: 1 })
|
|
|
|
+ },
|
|
|
|
+
|
|
// 优惠券,分享活动相关参数
|
|
// 优惠券,分享活动相关参数
|
|
getDiscountInfo() {
|
|
getDiscountInfo() {
|
|
return {
|
|
return {
|
|
@@ -310,8 +364,12 @@ export default {
|
|
try {
|
|
try {
|
|
const res = await orderConfirm(this.confirmParams)
|
|
const res = await orderConfirm(this.confirmParams)
|
|
this.totalPrice = res.data.totalPrice
|
|
this.totalPrice = res.data.totalPrice
|
|
|
|
+ this.reduction = res.data.reduction
|
|
this.shopList = this.bindNoteMessage(res.data.shopList)
|
|
this.shopList = this.bindNoteMessage(res.data.shopList)
|
|
- this.initCouponList(res.data.receiveCouponList)
|
|
|
|
|
|
+ // 只有存在优惠券时才执行后续操作(阻止不必要的计算统计)
|
|
|
|
+ if (res.data.receiveCouponList.length > 0) {
|
|
|
|
+ this.initCouponList(res.data.receiveCouponList)
|
|
|
|
+ }
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.log(e)
|
|
console.log(e)
|
|
} finally {
|
|
} finally {
|
|
@@ -453,6 +511,10 @@ export default {
|
|
margin-right: 0;
|
|
margin-right: 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ .label {
|
|
|
|
+ font-weight: bold;
|
|
|
|
+ }
|
|
|
|
+
|
|
&.share-btn {
|
|
&.share-btn {
|
|
padding: 0;
|
|
padding: 0;
|
|
margin: 0;
|
|
margin: 0;
|
|
@@ -460,6 +522,10 @@ export default {
|
|
font-size: 26rpx;
|
|
font-size: 26rpx;
|
|
line-height: inherit;
|
|
line-height: inherit;
|
|
|
|
|
|
|
|
+ .active {
|
|
|
|
+ color: #f83c6c;
|
|
|
|
+ }
|
|
|
|
+
|
|
.tip {
|
|
.tip {
|
|
margin-right: 0;
|
|
margin-right: 0;
|
|
}
|
|
}
|