166 lines
3.7 KiB
Vue
166 lines
3.7 KiB
Vue
<template>
|
||
<view>
|
||
<view class="xkl-com-bg">
|
||
<view style="height: 20rpx;"></view>
|
||
<view class="u-flex"
|
||
style="background-color: #ffffff;padding: 20rpx;border-radius: 10rpx;font-size: 30rpx;">
|
||
<u--image width="220rpx" height="220rpx" :src="goodsItem.cover[0]" radius="16rpx"></u--image>
|
||
<view style="padding: 20rpx;">
|
||
<view style="color: #232323;">{{goodsItem.name}}</view>
|
||
<view style="height: 20rpx;"></view>
|
||
<view>
|
||
<text>单价:</text>
|
||
<text style="color: crimson;">
|
||
{{goodsItem.current_price}}元
|
||
</text>
|
||
</view>
|
||
<view style="height: 20rpx;"></view>
|
||
<view>
|
||
<text>总价:</text>
|
||
<text style="color: crimson;">
|
||
{{total_price}}元
|
||
</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view style="height: 20rpx;"></view>
|
||
<view class="u-flex u-flex-between u-flex-y-center "
|
||
style="background-color: #ffffff;padding: 20rpx;border-radius: 10rpx;font-size: 30rpx;">
|
||
<view class="u-flex">
|
||
<view>购买数量</view>
|
||
<view style="width: 10rpx;"></view>
|
||
<text v-if="level.id" style="color: #dd6161;">可升级v{{level.level}}</text>
|
||
</view>
|
||
<view><u-number-box v-model="form.num" inputWidth="100rpx" @change="changenum"></u-number-box></view>
|
||
</view>
|
||
<view style="height: 20rpx;"></view>
|
||
<view style="background-color: #ffffff;padding: 20rpx;border-radius: 10rpx;font-size: 30rpx;">
|
||
<view style="font-weight: 700;">购买须知:</view>
|
||
<view style="height: 20rpx;"></view>
|
||
<view style="color: #dd6161;">付款成功后立即生效,并投入生产安装,不支持退款、退货。</view>
|
||
<view style="height: 20rpx;"></view>
|
||
</view>
|
||
<view style="height: 100rpx;"></view>
|
||
<u-button type="primary" @click="createOrder()">确认订单</u-button>
|
||
</view>
|
||
<view style="height: 50rpx;"></view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import {
|
||
API_URL,
|
||
STATIC_URL
|
||
} from '@/env'
|
||
let self;
|
||
export default {
|
||
data() {
|
||
return {
|
||
goodsItem: {
|
||
id: '',
|
||
cover: [],
|
||
name: '',
|
||
original_price: '',
|
||
current_price: '',
|
||
pre_price: '',
|
||
integral: '',
|
||
sales: '',
|
||
stock: '',
|
||
note: ''
|
||
},
|
||
total_price: 0,
|
||
form: {
|
||
goods_id: '',
|
||
num: 1,
|
||
pay_type: 0,
|
||
},
|
||
level: {
|
||
id: '',
|
||
level: ''
|
||
},
|
||
policy: {
|
||
is_trusteeship: 0,
|
||
is_buy: 0
|
||
}
|
||
}
|
||
},
|
||
mounted() {},
|
||
onLoad(option) {
|
||
self = this;
|
||
if (option && option.num) {
|
||
self.form.num = option.num;
|
||
}
|
||
|
||
if (option && option.id) {
|
||
self.form.goods_id = option.id;
|
||
}
|
||
},
|
||
onShow() {
|
||
self.getGoodsItem();
|
||
self.changenum({
|
||
value: self.form.num
|
||
});
|
||
self.policy = self.$store.state.policy;
|
||
},
|
||
methods: {
|
||
|
||
changenum(e) {
|
||
self.form.num = e.value;
|
||
self.$http.get('/shop/v10/order/pre', self.form).then(({
|
||
data
|
||
}) => {
|
||
self.total_price = data.total_price;
|
||
self.userinfo = data.userinfo;
|
||
if (data.level) {
|
||
self.level = data.level;
|
||
} else {
|
||
self.level = {
|
||
id: '',
|
||
name: ''
|
||
}
|
||
}
|
||
|
||
})
|
||
},
|
||
getGoodsItem() {
|
||
self.$http.get('/shop/v10/goods/item', {
|
||
id: self.form.goods_id
|
||
}).then(({
|
||
data,
|
||
success
|
||
}) => {
|
||
if (success) {
|
||
self.goodsItem = data;
|
||
self.form.goods_id = data.id;
|
||
self.total_price = data.current_price;
|
||
}
|
||
})
|
||
},
|
||
createOrder() {
|
||
self.$http.post('/shop/v10/order/create', self.form).then(({
|
||
data,
|
||
success,
|
||
msg
|
||
}) => {
|
||
if (!success) {
|
||
uni.showToast({
|
||
icon: 'none',
|
||
title: msg
|
||
})
|
||
return;
|
||
}
|
||
|
||
uni.navigateTo({
|
||
url: '/pages/order/pay?order_id=' + data.order_id
|
||
})
|
||
})
|
||
},
|
||
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
|
||
</style> |