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