提交 2b43f708 编写于 作者: guangjun.yang's avatar guangjun.yang

格式化代码

上级 7c61e7bb
<template> <template>
<section> <section>
<button @click="createOrder" >点击创建订单</button> <button @click="createOrder">点击创建订单</button>
<div class="detailsAndBuy" v-show="orderId"> <div class="detailsAndBuy" v-show="orderId">
<div> <div>
<p>订单详情</p> <p>订单详情</p>
<p>商品名:{{orderDetails.goodsLabel}}</p> <p>商品名:{{orderDetails.goodsLabel}}</p>
<p>单价:{{orderDetails.price}}</p> <p>单价:{{orderDetails.price}}</p>
<p>数量:{{orderDetails.quantity}}</p> <p>数量:{{orderDetails.quantity}}</p>
<p>总价:{{orderDetails.totalFee}}</p> <p>总价:{{orderDetails.totalFee}}</p>
<p>付款状态:{{orderDetails.status}}</p> <p>付款状态:{{orderDetails.status}}</p>
</div> </div>
<button class="buy" @click="goPrePay">购买</button> <button class="buy" @click="goPrePay">购买</button>
</div> </div>
</section> </section>
</template> </template>
<script> <script>
export default { export default {
name: "index.vue", name: "index.vue",
data() { data() {
return { return {
token: '08A7A6D8AA224AB7BC2E7BC44D44F34E', token: "08A7A6D8AA224AB7BC2E7BC44D44F34E",
orderId: null, orderId: null,
prePayId: null, prePayId: null,
isDisabled: false, isDisabled: false,
orderDetails: {} orderDetails: {}
} };
},
mounted() {},
methods: {
createOrder() {
if (this.isDisabled) {
alert("订单已创建");
return;
}
const data = {
goodsId: 123,
goodsVersion: 1,
price: 0.01,
quantity: 1
};
this.axios({
method: "POST",
headers: {
token: this.token
}, },
mounted() { url: `${this.APIDOMAIN}/trade/center/order`,
data: data
})
.then(res => {
if (res.data.code == "000000") {
this.orderId = res.data.data;
this.isDisabled = true;
this.getOrderDetails();
}
})
.catch(res => {
//do somethings
});
},
getOrderDetails() {
this.axios({
method: "GET",
headers: {
token: this.token
}, },
methods: { url: `${this.APIDOMAIN}/trade/center/order/${this.orderId}`
createOrder() { })
if(this.isDisabled) { .then(res => {
alert('订单已创建'); if (res.data.code == "000000") {
return; this.orderDetails = res.data.data;
} }
const data = { })
goodsId: 123, .catch(res => {
goodsVersion: 1, //do somethings
price: 0.01, });
quantity: 1 },
} goPrePay() {
this.axios( this.axios({
{ method: "POST",
method: 'POST', headers: {
headers: { token: this.token
token: this.token,
},
url: `${this.APIDOMAIN}/trade/center/order`,
data: data
}
).then((res)=>{
if(res.data.code == "000000") {
this.orderId = res.data.data;
this.isDisabled = true;
this.getOrderDetails();
}
}).catch((res)=>{
//do somethings
})
},
getOrderDetails() {
this.axios(
{
method: 'GET',
headers: {
token: this.token,
},
url: `${this.APIDOMAIN}/trade/center/order/${this.orderId}`,
}
).then((res)=>{
if(res.data.code == "000000") {
this.orderDetails = res.data.data
}
}).catch((res)=>{
//do somethings
})
},
goPrePay() {
this.axios(
{
method: 'POST',
headers: {
token: this.token,
},
url: `${this.APIDOMAIN}/trade/center/prepay`,
data: {
payChannel: 1,
orderId: this.orderId
}
}
).then((res)=>{
if(res.data.code == "000000") {
this.prePayId = res.data.data;
}
}).catch((res)=>{
//do somethings
})
},
}, },
url: `${this.APIDOMAIN}/trade/center/prepay`,
data: {
payChannel: 1,
orderId: this.orderId
}
})
.then(res => {
if (res.data.code == "000000") {
this.prePayId = res.data.data;
}
})
.catch(res => {
//do somethings
});
} }
}
};
</script> </script>
<style scoped> <style scoped>
input { input {
margin: 0 auto; margin: 0 auto;
border: 1px solid #000; border: 1px solid #000;
margin-bottom: 10px; margin-bottom: 10px;
} }
button { button {
display: block; display: block;
margin: 0 auto; margin: 0 auto;
background: #42b983; background: #42b983;
color: #fff; color: #fff;
} }
</style> </style>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册