|
@@ -4,8 +4,8 @@
|
|
|
<img :src="productBox.pics[0].url" alt="">
|
|
|
<!--extra-->
|
|
|
<div class="extra">
|
|
|
- <div v-if="extraB" v-for="(itemExtra,index) in productBox.extra">
|
|
|
- <div class="extra-text" v-bind:class="{active: index == isActive}" v-on:click="btnAction(index, $event)">
|
|
|
+ <div v-if="extraB" v-for="(itemExtra,index) in productBox.extra" @click="btnAction(index, $event)">
|
|
|
+ <div class="extra-text" v-bind:class="{active: index == isActive}">
|
|
|
{{itemExtra.type}}
|
|
|
</div>
|
|
|
</div>
|
|
@@ -51,7 +51,7 @@
|
|
|
<!--费用总计-->
|
|
|
<div class="order-amount">
|
|
|
<span>费用总计:</span>
|
|
|
- <span>90</span>
|
|
|
+ <span>{{orderPrice}}</span>
|
|
|
</div>
|
|
|
<!--确认预约-->
|
|
|
<div class="btn-order" v-on:click="btnOrder">立即下单</div>
|
|
@@ -66,7 +66,7 @@
|
|
|
import selectTime from '../config/selectTime'
|
|
|
import {Group, DatetimeRange, TransferDom, Datetime, XNumber, Cell, CellBox, XTextarea, Alert} from 'vux'
|
|
|
import {mapState, mapActions} from 'vuex'
|
|
|
- // import axios from 'axios'
|
|
|
+ import api from '../config/api'
|
|
|
export default {
|
|
|
name: 'placeOrder',
|
|
|
data () {
|
|
@@ -81,6 +81,7 @@
|
|
|
addressContent: config.addressContent, // 只做显示用户地址内容
|
|
|
xNumberValue: config.xNumberValue, // 选择数量
|
|
|
remarks: '', // 备注
|
|
|
+ orderPrice: config.orderPrice, // 价格
|
|
|
showAlert: false, // 是否显示弹出框
|
|
|
alertTitle: '', // 弹窗标题
|
|
|
alertContent: '' // 弹窗内容
|
|
@@ -106,7 +107,9 @@
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
-// console.log(config.addressContent.name)
|
|
|
+ if (config.orderPrice === '') {
|
|
|
+ config.orderPrice = 0
|
|
|
+ }
|
|
|
if (config.addressContent.name === undefined) {
|
|
|
if (config.shopAddress.length === 0) {
|
|
|
this.addressContent.name = '暂无地址信息'
|
|
@@ -123,6 +126,12 @@
|
|
|
orderChange: state => state.orderChange
|
|
|
})
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ 'isActive' (val, oldVal) {
|
|
|
+ // 计算商品价格
|
|
|
+ this.orderPrice = config.orderPrice = payCharge(parseInt(config.productInfo.extra[val].price), config.xNumberValue)
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
// 监听时间插件值得变化
|
|
|
clearConfig () {
|
|
@@ -135,12 +144,21 @@
|
|
|
// 商品数量
|
|
|
xNumberValueChange (val) {
|
|
|
config.xNumberValue = val
|
|
|
+ // 计算商品价格
|
|
|
+ if (config.productInfo.price === '') {
|
|
|
+ if (config.isActive === '') {
|
|
|
+ config.isActive = 0
|
|
|
+ }
|
|
|
+ this.orderPrice = config.orderPrice = payCharge(parseInt(config.productInfo.extra[config.isActive].price), config.xNumberValue)
|
|
|
+ } else {
|
|
|
+ this.orderPrice = config.orderPrice = payCharge(parseInt(config.productInfo.price), config.xNumberValue)
|
|
|
+ }
|
|
|
},
|
|
|
change (val) {
|
|
|
this.$store.state.order.time = val
|
|
|
config.order.time = val
|
|
|
},
|
|
|
- btnOrder: function (cb) {
|
|
|
+ btnOrder: function () {
|
|
|
// 判断服务是否选择
|
|
|
if (localStorage.getItem('extra') === null && config.productInfo.extra.length !== 0) {
|
|
|
// config.order.extra = ''
|
|
@@ -150,55 +168,48 @@
|
|
|
}
|
|
|
// 判断时间
|
|
|
// 判断地址
|
|
|
-// config.order.userId = config.userId
|
|
|
-// config.order.memo = this.remarks
|
|
|
-// config.order.id = config.productInfo.id
|
|
|
-// config.order.products = JSON.stringify([{
|
|
|
-// product_id: config.productInfo.id, // 产品ID
|
|
|
-// count: this.xNumberValue // 产品数量
|
|
|
-// }])
|
|
|
+ config.order.userId = config.userId
|
|
|
+ config.order.memo = this.remarks
|
|
|
+ config.order.id = config.productInfo.id
|
|
|
+ config.order.products = JSON.stringify([{
|
|
|
+ product_id: config.productInfo.id, // 产品ID
|
|
|
+ count: this.xNumberValue // 产品数量
|
|
|
+ }])
|
|
|
+ console.log(this.$store.state.user.userInfo.balance)
|
|
|
|
|
|
-// console.log(config.order)
|
|
|
+ // 获得余额支付的金额
|
|
|
|
|
|
- // products
|
|
|
-// config.formData = new FormData()
|
|
|
-// const balance = 0
|
|
|
-// let productParamJson = ''
|
|
|
-// // let coupons = qs.stringify({0: '5836a1979f5160a7048b5a51'})
|
|
|
-// // let coupons = JSON.stringify({0: ''})
|
|
|
-// let extraJson = ''
|
|
|
-// extraJson = JSON.stringify([{type: '整间日常清洁', price: '388'}])
|
|
|
-// const channel = 'wx_pub'
|
|
|
-// const addressId = this.$store.state.user.userInfo.shop_address[0].address_id
|
|
|
-// const time = '2017-06-21 11:00'
|
|
|
-// config.orderInfo = ''
|
|
|
-// config.formData.append('balance', balance)
|
|
|
-// config.formData.append('products', productParamJson)
|
|
|
-// config.formData.append('precedence', 0)
|
|
|
-// config.formData.append('booking_time', time)
|
|
|
-// config.formData.append('order_channel', channel)
|
|
|
-// config.formData.append('user_id', config.userId)
|
|
|
-// config.formData.append('address_id', addressId)
|
|
|
-// config.formData.append('station', '57db39709f5160bb048b456a')
|
|
|
-// config.formData.append('counts', '1')
|
|
|
-// config.formData.append('extra', extraJson)
|
|
|
-// config.formData.append('order_channel', 'wx_pub')
|
|
|
-// let tmp = {
|
|
|
-// balance: balance,
|
|
|
-// products: productParamJson,
|
|
|
-// precedence: 0,
|
|
|
-// booking_time: time,
|
|
|
-// order_channel: channel,
|
|
|
-// user_id: config.userId,
|
|
|
-// address_id: addressId,
|
|
|
-// station: '57db39709f5160bb048b456a',
|
|
|
-// // coupons: coupons,
|
|
|
-// counts: 1,
|
|
|
-// extra: extraJson
|
|
|
-// }
|
|
|
-// config.orderInfo = tmp
|
|
|
+ // 判断用户余额大于等于订单金额,满足条件走余额支付
|
|
|
+ if (this.$store.state.user.userInfo.balance >= this.orderPrice) {
|
|
|
+ config.order.balance = this.orderPrice
|
|
|
+ this.orderPrice = 0
|
|
|
+ } else {
|
|
|
+ // 不满足条件走混合支付
|
|
|
+ config.order.balance = this.$store.state.user.userInfo.balance
|
|
|
+ this.orderPrice = this.orderPrice - config.order.balance
|
|
|
+ }
|
|
|
+ let productParamJson = [{'product_id': config.productInfo.id, 'count': JSON.stringify(config.xNumberValue)}]
|
|
|
+ let tmp = {
|
|
|
+ balance: config.order.balance,
|
|
|
+ products: JSON.stringify(productParamJson),
|
|
|
+ memo: config.order.memo,
|
|
|
+ precedence: config.productInfo.order,
|
|
|
+ booking_time: this.bookingTime,
|
|
|
+ address_id: this.addressContent.address_id,
|
|
|
+ coupons: [],
|
|
|
+ station: config.station,
|
|
|
+ type: config.productInfo.type,
|
|
|
+ counts: config.xNumberValue,
|
|
|
+ extra: config.order.extra,
|
|
|
+ order_channel: 'wx_pub',
|
|
|
+ tech_id: '',
|
|
|
+ user_id: config.userId
|
|
|
+ }
|
|
|
+ config.orderInfo = tmp
|
|
|
+ api.addOrder()
|
|
|
},
|
|
|
btnAction: function (index, event) {
|
|
|
+ this.xNumberValue = config.xNumberValue = 0
|
|
|
localStorage.setItem('extra', index)
|
|
|
config.order.extra = JSON.stringify(config.productInfo.extra[index])
|
|
|
this.isActive = index
|
|
@@ -206,6 +217,11 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ function payCharge (price, count) {
|
|
|
+ let p = ''
|
|
|
+ p = price * count
|
|
|
+ return p
|
|
|
+ }
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|