完成普通订单下单
This commit is contained in:
parent
b02f492aef
commit
db32c26c24
|
@ -93,6 +93,16 @@ export default {
|
|||
},
|
||||
goodsDetail: {
|
||||
url: "/index/goodsinfobyid",
|
||||
showLoading: true,
|
||||
}
|
||||
},
|
||||
order: {
|
||||
pay: {
|
||||
url: "/wxpay/payordera",
|
||||
showLoading: true,
|
||||
},
|
||||
createOrder: {
|
||||
url: "/order/submitordera",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import order from "@/core/models/order";
|
||||
import user from "@/core/models/user";
|
||||
import worker from "@/core/models/worker";
|
||||
import service from "@/core/models/service";
|
||||
|
||||
export default {
|
||||
order,
|
||||
user,
|
||||
worker,
|
||||
service,
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import Vue from "vue"
|
||||
let prototype = Vue.prototype;
|
||||
|
||||
export default {
|
||||
type: {
|
||||
NORMAL: 1,
|
||||
|
@ -73,5 +76,32 @@ export default {
|
|||
default:
|
||||
return '未知状态';
|
||||
}
|
||||
},
|
||||
createOrder(order) {
|
||||
return new Promise((resolve, reject) => {
|
||||
prototype.$request({
|
||||
api: "order.createOrder",
|
||||
data: order,
|
||||
}).then((response) => {
|
||||
if (response.code == 1) {
|
||||
return resolve(response.data);
|
||||
}
|
||||
return reject(response.msg);
|
||||
}).catch(e => { });
|
||||
});
|
||||
},
|
||||
payOrder(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
prototype.$request({
|
||||
api: "order.pay",
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}).then(response => {
|
||||
console.log(response);
|
||||
}).catch(e => {
|
||||
throw e
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,5 +13,21 @@ export default {
|
|||
}
|
||||
}).catch(e => { });
|
||||
});
|
||||
},
|
||||
getServiceDetail(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
prototype.$request({
|
||||
api: "service.goodsDetail",
|
||||
data: {
|
||||
id: id,
|
||||
},
|
||||
}).then((response) => {
|
||||
if (response.code == 1) {
|
||||
return resolve(response.data);
|
||||
}
|
||||
|
||||
return reject(response.msg);
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<text class="title">留言</text>
|
||||
<textarea
|
||||
class="text-area"
|
||||
v-model="message"
|
||||
v-model="content"
|
||||
placeholder="补充描述您的需求,或其他特殊情况"
|
||||
placeholder-class="placeholder-style-2"
|
||||
/>
|
||||
|
@ -48,7 +48,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="common-bottom-components" :style="{ bottom: pageConfig.safeAreaInsets.bottom + 'px' }">
|
||||
<text class="price">¥306.00</text>
|
||||
<text class="price">¥ {{ utils.formatNumber(total) }}</text>
|
||||
<view class="pay" @click="pay">
|
||||
<div class="text">去支付</div>
|
||||
</view>
|
||||
|
@ -67,27 +67,17 @@ export default {
|
|||
name: "order-create",
|
||||
data() {
|
||||
return {
|
||||
utils: this.$utils,
|
||||
pageConfig: {},
|
||||
addressId: 0,
|
||||
addressText: "",
|
||||
datetime: "",
|
||||
message: "",
|
||||
content: "",
|
||||
insurance: false,
|
||||
isAgree: false,
|
||||
serviceList: [
|
||||
{
|
||||
id: 2,
|
||||
name: "空调安装",
|
||||
cover: require("@/static/temp/cate/1.png"),
|
||||
buyNumber: 1,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "空调拆卸",
|
||||
cover: require("@/static/temp/cate/2.png"),
|
||||
buyNumber: 1,
|
||||
},
|
||||
],
|
||||
total: 0,
|
||||
orderData: [],
|
||||
serviceList: [],
|
||||
};
|
||||
},
|
||||
components: {
|
||||
|
@ -102,9 +92,31 @@ export default {
|
|||
insurancePrice: (state) => state.service.insurancePrice,
|
||||
}),
|
||||
},
|
||||
onLoad() {
|
||||
onLoad(e) {
|
||||
this.pageConfig = getApp().globalData.pageConfig;
|
||||
this.$store.dispatch("service/insurancePrice");
|
||||
if (!e.orderData) {
|
||||
this.$utils.toast("参数错误");
|
||||
return;
|
||||
}
|
||||
this.orderData = JSON.parse(decodeURIComponent(e.orderData));
|
||||
this.orderData.forEach((item) => {
|
||||
this.$models.service.getServiceDetail(item.id).then((response) => {
|
||||
let cover = "";
|
||||
if (response.goods.image.length > 0) {
|
||||
cover = response.goods.image[0];
|
||||
}
|
||||
this.serviceList.push({
|
||||
id: response.goods.id,
|
||||
name: response.goods.post_title,
|
||||
times: response.goods.post_hits,
|
||||
cover: cover,
|
||||
content: response.goods.post_content,
|
||||
price: response.goods.money,
|
||||
});
|
||||
this.total += parseFloat(response.goods.money);
|
||||
});
|
||||
});
|
||||
},
|
||||
onShow() {},
|
||||
onReady() {},
|
||||
|
@ -125,20 +137,36 @@ export default {
|
|||
},
|
||||
});
|
||||
},
|
||||
selectDateTime() {
|
||||
console.log("选择时间");
|
||||
},
|
||||
changeInsuranceState(state) {
|
||||
if (state) {
|
||||
this.total += this.insurancePrice;
|
||||
} else {
|
||||
this.total -= this.insurancePrice;
|
||||
}
|
||||
this.insurance = state;
|
||||
},
|
||||
pay() {
|
||||
if (!this.isAgree) {
|
||||
uni.showToast({
|
||||
title: "请先阅读并同意《熊熊安装服务协议》《隐私政策》",
|
||||
title: "请先阅读并同意《服务协议》《隐私政策》",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.$models.order
|
||||
.createOrder({
|
||||
ids: this.orderData,
|
||||
addid: this.addressId,
|
||||
times: this.datetime,
|
||||
baoxian: this.insurance ? 1 : 0,
|
||||
desc: this.content,
|
||||
})
|
||||
.then((id) => {
|
||||
this.$models.order.payOrder(id);
|
||||
})
|
||||
.catch((e) => {
|
||||
this.$utils.toast(e);
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -61,7 +61,11 @@
|
|||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view class="common-bottom-components" v-if="tabIndex == 0" :style="{ bottom: pageConfig.safeAreaInsets.bottom + 'px' }">
|
||||
<view
|
||||
class="common-bottom-components"
|
||||
v-if="tabIndex == 0"
|
||||
:style="{ bottom: pageConfig.safeAreaInsets.bottom + 'px' }"
|
||||
>
|
||||
<view class="price">
|
||||
<text class="text">¥{{ detail.price }}</text>
|
||||
</view>
|
||||
|
@ -112,40 +116,41 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
this.getDetail();
|
||||
},
|
||||
onShow() {},
|
||||
onReady() {},
|
||||
onReachBottom() {},
|
||||
onPullDownRefresh() {},
|
||||
methods: {
|
||||
getDetail() {
|
||||
this.$request({
|
||||
api: "service.goodsDetail",
|
||||
data: {
|
||||
id: this.id,
|
||||
},
|
||||
}).then((response) => {
|
||||
this.$models.service.getServiceDetail(this.id).then((response) => {
|
||||
this.detail = {
|
||||
title: response.data.goods.post_title,
|
||||
times: response.data.goods.post_hits,
|
||||
images: response.data.goods.image,
|
||||
content: response.data.goods.post_content,
|
||||
price: response.data.goods.money,
|
||||
title: response.goods.post_title,
|
||||
times: response.goods.post_hits,
|
||||
images: response.goods.image,
|
||||
content: response.goods.post_content,
|
||||
price: response.goods.money,
|
||||
};
|
||||
this.$nextTick(() => {
|
||||
this.setTabHeight();
|
||||
});
|
||||
});
|
||||
},
|
||||
onShow() {},
|
||||
onReady() {},
|
||||
onReachBottom() {},
|
||||
onPullDownRefresh() {},
|
||||
methods: {
|
||||
share() {
|
||||
uni.showToast({
|
||||
title: "分享",
|
||||
icon: "none",
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 创建订单
|
||||
*/
|
||||
createOrder() {
|
||||
this.$utils.toPage("/pages/order/create");
|
||||
let orderdata = [
|
||||
{
|
||||
id: this.id,
|
||||
count: 1,
|
||||
},
|
||||
];
|
||||
this.$utils.toPage("/pages/order/create?orderData=" + encodeURIComponent(JSON.stringify(orderdata)));
|
||||
},
|
||||
changeTab(e) {
|
||||
this.tabIndex = e.detail.current;
|
||||
|
|
Loading…
Reference in New Issue