update:新增预订单
This commit is contained in:
parent
4bdab41028
commit
16ff7c351a
324
components/delivery-time-op/delivery-time-op.vue
Normal file
324
components/delivery-time-op/delivery-time-op.vue
Normal file
@ -0,0 +1,324 @@
|
||||
<template>
|
||||
<view>
|
||||
<!-- 模态框 -->
|
||||
<view @tap="Modal" :class="{ mask: model }"></view>
|
||||
<!-- 弹窗主体 -->
|
||||
<view
|
||||
:style="{ height: barHidth + 'rpx' }"
|
||||
class="active"
|
||||
:class="{ add: model }"
|
||||
>
|
||||
<view class="title">
|
||||
<text class="title-text">{{ title }}</text>
|
||||
<text @tap="close" class="close-btn">×</text>
|
||||
</view>
|
||||
<view class="cont" :style="{ height: barHidth - 80 + 'rpx' }">
|
||||
<!-- 天 -->
|
||||
<scroll-view class="day" :scroll-y="true">
|
||||
<view
|
||||
:class="index === isIndex ? 'active_copy' : ''"
|
||||
v-for="(item, index) in content"
|
||||
:key="item.date"
|
||||
@tap="dataCallback(index, item)"
|
||||
>
|
||||
<view class="date-week">{{ item.date_title }}</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 时 -->
|
||||
<scroll-view class="content" :scroll-y="true" :scroll-top="scrollTop">
|
||||
<view
|
||||
class="appoint"
|
||||
:class="index === Indexes ? 'longActive' : ''"
|
||||
@tap="timeCallback(index, item)"
|
||||
v-for="(item, index) in Days"
|
||||
:key="index"
|
||||
>
|
||||
{{ item.time_title }}
|
||||
<text :class="index === Indexes ? 'cuIcon-check' : ''"></text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: "选择预送达时间",
|
||||
},
|
||||
content: {
|
||||
type: Array,
|
||||
default: () => [
|
||||
{
|
||||
date_title: "B-12 (周五)",
|
||||
date_str: "B-12",
|
||||
date: "2025-10-12",
|
||||
items: [
|
||||
{
|
||||
time_title: "16:35",
|
||||
booking_at: 1,
|
||||
booking_state: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
date_title: "B-13 (周六)",
|
||||
date_str: "B-13",
|
||||
date: "2025-10-13",
|
||||
items: [
|
||||
{
|
||||
time_title: "17:05",
|
||||
booking_at: 2,
|
||||
booking_state: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
date_title: "B-14 (周日)",
|
||||
date_str: "B-14",
|
||||
date: "2025-10-14",
|
||||
items: [
|
||||
{
|
||||
time_title: "17:35",
|
||||
booking_at: 3,
|
||||
booking_state: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
date_title: "B-15 (周一)",
|
||||
date_str: "B-15",
|
||||
date: "2025-10-15",
|
||||
items: [
|
||||
{
|
||||
time_title: "18:05",
|
||||
booking_at: 4,
|
||||
booking_state: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
date_title: "B-15 (周二)",
|
||||
date_str: "B-15",
|
||||
date: "2025-10-16",
|
||||
items: [
|
||||
{
|
||||
time_title: "18:35",
|
||||
booking_at: 5,
|
||||
booking_state: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
barHidth: {
|
||||
type: Number,
|
||||
default: 500,
|
||||
},
|
||||
dodge: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
scrollTop: 0,
|
||||
isIndex: 0,
|
||||
Indexes: 0,
|
||||
Days: [],
|
||||
model: false,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
content: {
|
||||
immediate: true,
|
||||
handler(newValue) {
|
||||
if (newValue && newValue.length > 0 && newValue[0].items) {
|
||||
this.Days = newValue[0].items;
|
||||
} else {
|
||||
console.warn('content 数据格式不正确', newValue);
|
||||
this.Days = [];
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
this.model = false;
|
||||
},
|
||||
open() {
|
||||
this.model = true;
|
||||
},
|
||||
Modal() {
|
||||
if (this.dodge) {
|
||||
this.close();
|
||||
}
|
||||
},
|
||||
gotop() {
|
||||
this.scrollTop = 1;
|
||||
this.$nextTick(() => {
|
||||
this.scrollTop = 0;
|
||||
});
|
||||
},
|
||||
dataCallback(index, item) {
|
||||
this.isIndex = index;
|
||||
this.Days = this.content[index].items;
|
||||
this.Indexes = 0;
|
||||
this.gotop();
|
||||
this.$emit("dataCallback", item);
|
||||
},
|
||||
timeCallback(index, item) {
|
||||
this.Indexes = index;
|
||||
const selectedDate = this.content[this.isIndex]; // 获取当前选中的日期对象
|
||||
const selectedTime = item; // 当前选中的时间对象
|
||||
this.$emit("timeCallback", {
|
||||
date_title: selectedDate.date_title, // 日期标题
|
||||
time_title: selectedTime.time_title, // 时间标题
|
||||
booking_at: selectedTime.booking_at, // 预约时间戳
|
||||
booking_begin_time: selectedTime.booking_begin_time, // 预约开始时间
|
||||
booking_end_time: selectedTime.booking_end_time, // 预约结束时间
|
||||
});
|
||||
this.$emit("close"); // 触发关闭事件
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.active {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 1000;
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
border-top-left-radius: 20rpx;
|
||||
border-top-right-radius: 20rpx;
|
||||
overflow: hidden;
|
||||
transform: translateY(100%);
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.add {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 24rpx 30rpx;
|
||||
border-bottom: 2rpx solid #eee;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.title-text {
|
||||
font-size: 34rpx;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
max-width: 80%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 关闭按钮样式 */
|
||||
.close-btn {
|
||||
font-size: 50rpx;
|
||||
color: #999;
|
||||
padding: 10rpx; /* 增加点击区域 */
|
||||
border-radius: 50%;
|
||||
/* 右对齐(通过 flex 布局已实现,无需绝对定位) */
|
||||
}
|
||||
|
||||
.close-btn:active {
|
||||
background-color: #f5f5f5; /* 点击时轻微反馈 */
|
||||
}
|
||||
.cont {
|
||||
display: flex;
|
||||
height: calc(100% - 80rpx);
|
||||
}
|
||||
|
||||
.day {
|
||||
flex: 2;
|
||||
background-color: #f5f5f5;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.day view {
|
||||
padding: 28rpx 0;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.date-week {
|
||||
font-weight: 500;
|
||||
color: #333; /* 日期颜色 */
|
||||
}
|
||||
|
||||
.active_copy {
|
||||
background-color: #fff;
|
||||
color: #27c866;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 3;
|
||||
font-size: 28rpx;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.appoint {
|
||||
position: relative;
|
||||
text-align: left;
|
||||
padding: 30rpx 36rpx;
|
||||
border-bottom: 2rpx solid #f5f5f5;
|
||||
color: #333; /* 时间颜色 */
|
||||
}
|
||||
|
||||
.longActive {
|
||||
color: #27c866;
|
||||
background-color: #f6fffa;
|
||||
}
|
||||
|
||||
.cuIcon-check {
|
||||
position: absolute;
|
||||
right: 36rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
background-color: #27c866;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.cuIcon-check::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 10rpx;
|
||||
top: 16rpx;
|
||||
width: 12rpx;
|
||||
height: 6rpx;
|
||||
border-bottom: 4rpx solid white;
|
||||
border-left: 4rpx solid white;
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
scroll-view ::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@ -383,6 +383,7 @@ export default {
|
||||
"sel": ip + "shop/userCart/sel",
|
||||
// "checkout": iu + "?ctl=Cart&met=checkout&typ=json",
|
||||
"checkout": ip + "shop/userCart/checkout",
|
||||
"getTimeSlots":ip+"/shop/userOrder/booking_time_args",
|
||||
"checkDelivery": iu + "?ctl=Cart&met=checkDelivery&typ=json",
|
||||
"order": iu + "?ctl=Cart&met=order&typ=e",
|
||||
// "getselect":iu + "?ctl=Cart&met=getselect&typ=json",
|
||||
|
||||
@ -302,6 +302,14 @@
|
||||
deliveryTypeName(OrderInfo.delivery_type_id)
|
||||
}}</view>
|
||||
</view>
|
||||
|
||||
<view class="order-info-item" v-if="OrderInfo.booking_state==2">
|
||||
<view class="order-info-item-left">预约时间</view>
|
||||
<view class="order-inof-item-right">{{
|
||||
OrderInfo.booking_begin_time
|
||||
}}</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="order-info-item"
|
||||
v-if="
|
||||
@ -597,7 +605,7 @@
|
||||
><text v-if="item.show_typename" class="tag tag-orange">{{
|
||||
item.show_typename
|
||||
}}</text
|
||||
>{{ item.product_name }}
|
||||
>{{ item.product_name }}_
|
||||
<text>x{{ item.order_item_quantity }} </text>
|
||||
</label>
|
||||
|
||||
@ -615,10 +623,10 @@
|
||||
</label>
|
||||
</view>
|
||||
<view class="m-product-price">
|
||||
<block v-if="item.item_unit_price">
|
||||
<block v-if="item.order_item_amount">
|
||||
<view class="m-product-price-amount-block">
|
||||
¥<text class="m-product-price-amount">{{
|
||||
item.item_unit_price
|
||||
item.order_item_amount
|
||||
}}</text>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
18
package.json
Normal file
18
package.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"id": "delivery-time-op",
|
||||
"name": "仿美团选择预送达时间组件delivery-time-op",
|
||||
"displayName": "仿美团选择预送达时间组件delivery-time-op",
|
||||
"version": "1.0.5",
|
||||
"description": "简单实用的选择时间组件,源码简单易懂注释清楚,可根据需求随意更改方案。",
|
||||
"keywords": [
|
||||
"点餐",
|
||||
"时间选择",
|
||||
"送达时间"
|
||||
],
|
||||
"dcloudext": {
|
||||
"category": [
|
||||
"前端组件",
|
||||
"通用组件"
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -46,7 +46,7 @@
|
||||
style="border-radius:50%;width:26rpx;height:26rpx;border:1px solid #db384c" />
|
||||
<view style="margin-left:10rpx">{{__('门店自提')}}</view>
|
||||
</view> -->
|
||||
<view style="display:flex;align-items: center;" v-if="(delivery)" @click="express">
|
||||
<view style="display:flex;align-items: center;" v-if="(delivery)" @click="express">
|
||||
<image v-if="(addressFlag)" style="width:32rpx;height:32rpx;border-radius:50%"
|
||||
src="/static/images/ziti.png" />
|
||||
<view v-else class="border"
|
||||
@ -99,7 +99,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</navigator>
|
||||
<view v-if="((selfpickFlag || storeServeFlag) && false)" class="m-cells m-cells-form"
|
||||
<!-- <view v-if="((selfpickFlag || storeServeFlag) && false)" class="m-cells m-cells-form"
|
||||
style="margin-top:20rpx;z-index:1">
|
||||
<view class="m-cell">
|
||||
<view class="m-cell-hd" style="width:20%">
|
||||
@ -126,14 +126,41 @@
|
||||
<uni-icons class="m-icon-warn" type="warn"></uni-icons>
|
||||
</div>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</block>
|
||||
<!-- 自提 -->
|
||||
|
||||
</block>
|
||||
|
||||
|
||||
<view class="m-cells m-cells-form" v-if="(false)">
|
||||
<block>
|
||||
<template>
|
||||
<view class="distribution" v-if="(true)" style="display: flex;flex-direction: column;">
|
||||
<view class="check" style="width: 100%;">
|
||||
<view style="width:100%;height: 40px;display: flex; border: 1px gray solid;border-radius: 5px;padding-left: 6px;margin: 3px 0px;align-items: center;"
|
||||
:class="{ active: activeTab === 'immediate' }"
|
||||
@click="setActiveTab('immediate')">
|
||||
<text style="width: 30%;">立即配送</text>
|
||||
<text style="width: 70%;">{{ immediateDeliveryTime }}</text>
|
||||
</view>
|
||||
<view style="width:100%;height: 40px;display: flex; border: 1px gray solid;border-radius: 5px;padding-left: 6px;margin: 3px 0px;align-items: center;"
|
||||
:class="{ active: activeTab === 'scheduled' }" @click="openTimePicker">
|
||||
<text style="width:30%;">预约配送</text>
|
||||
<text style="width:70%;" >{{ activeTab === 'scheduled' ? dateTitle && selectedTime ? dateTitle + ' ' + selectedTime : '请选择时间' : '请选择时间' }} ></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</block>
|
||||
<delivery-time-op
|
||||
@dataCallback="dataCallback"
|
||||
@timeCallback="timeCallback"
|
||||
@close="closeTimePicker"
|
||||
:dodge="true"
|
||||
ref='model'
|
||||
:content="content"
|
||||
:barHidth='600'
|
||||
title="选择预送达时间">
|
||||
> </delivery-time-op>
|
||||
<!-- <view class="m-cells m-cells-form" v-if="(false)">
|
||||
<view class="m-cell">
|
||||
<view class="m-cell-hd" style="width: 140rpx;"><label class="u-label">{{__('导购员')}}</label></view>
|
||||
<view class="m-cell-bd">
|
||||
@ -143,8 +170,8 @@
|
||||
<uni-icons class="m-icon-warn" type="warn"></uni-icons>
|
||||
</div>
|
||||
</view>
|
||||
</view>
|
||||
<view class="m-cells m-cells-form" v-if="(false)">
|
||||
</view> -->
|
||||
<!-- <view class="m-cells m-cells-form" v-if="(false)">
|
||||
<view class="m-cell">
|
||||
<view class="m-cell-hd"><label class="u-label">{{__('预约人')}}</label></view>
|
||||
<view class="m-cell-bd">
|
||||
@ -165,7 +192,7 @@
|
||||
<uni-icons class="m-icon-warn" type="warn"></uni-icons>
|
||||
</div>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="m-product-all">
|
||||
<view class="m-product-list">
|
||||
<block v-for="(store_items, store_index) in submitinfo.items" :key="store_index">
|
||||
@ -766,7 +793,7 @@
|
||||
import paymentBox from "../../components/payment-box.vue";
|
||||
import loginPopup from "../../components/loginPopup.vue";
|
||||
import { mapState, mapMutations } from "vuex";
|
||||
|
||||
import deliveryTimeOp from '@/components/delivery-time-op/delivery-time-op.vue'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -783,6 +810,10 @@ export default {
|
||||
items: [],
|
||||
UserMembership: {},
|
||||
},
|
||||
selectedTime:"",
|
||||
dateTitle:"",
|
||||
activeTab: "immediate",
|
||||
content:[],
|
||||
user_voucher_ids: [],
|
||||
redemption_ids: [],
|
||||
order_message: {},
|
||||
@ -792,6 +823,7 @@ export default {
|
||||
paymentData: {},
|
||||
integral: "",
|
||||
discount: 0,
|
||||
immediateDeliveryTime:"",
|
||||
disbursements: "",
|
||||
IsUseCoupon: 1,
|
||||
canSelfpick: 0, //是否允许自提
|
||||
@ -874,6 +906,7 @@ export default {
|
||||
components: {
|
||||
paymentBox,
|
||||
loginPopup,
|
||||
deliveryTimeOp
|
||||
},
|
||||
computed: mapState([
|
||||
"Config",
|
||||
@ -1001,6 +1034,7 @@ export default {
|
||||
});
|
||||
// var n = this.shopInfo.VendorFeatureSet;
|
||||
// n.indexOf("Membership") > -1 ? this.setData({isMembership: true}) : this.setData({isMembership: false}), n.indexOf("ECashCard") > -1 ? this.setData({isECashCard: true}) : this.setData({isECashCard: false}), n.indexOf("Coupon") > -1 ? this.setData({isCoupon: true}) : this.setData({isCoupon: false}), n.indexOf("TmplMsg") > -1 ? this.setData({isTmplMsg: true}) : this.setData({isTmplMsg: false})
|
||||
this.getTimeSlots();
|
||||
},
|
||||
onUnload: function () {
|
||||
//移除通知
|
||||
@ -1039,6 +1073,50 @@ export default {
|
||||
that.getCartList();
|
||||
});
|
||||
},
|
||||
setActiveTab(tab) {
|
||||
this.activeTab = tab;
|
||||
if (tab === 'immediate') {
|
||||
this.selectedTime = "";
|
||||
this.dateTitle = "";
|
||||
this.booking_state = 1; // 立即下单
|
||||
} else {
|
||||
this.booking_state = 2; // 预订单
|
||||
}
|
||||
},
|
||||
openTimePicker(){
|
||||
this.$refs.model.open();
|
||||
},
|
||||
closeTimePicker() {
|
||||
this.$refs.model.model = false; // 关闭时间选择器
|
||||
},
|
||||
// 处理日期选择回调
|
||||
dataCallback(item) {
|
||||
console.log('日期选择回调', item);
|
||||
// 你可以在这里处理日期选择的逻辑
|
||||
},
|
||||
timeCallback(item) {
|
||||
console.log('时间选择回调', item);
|
||||
this.selectedTime = item.time_title; // 选中的时间
|
||||
this.dateTitle = item.date_title; // 选中的日期
|
||||
|
||||
if (this.selectedTime !== "立即送出") {
|
||||
this.activeTab = 'scheduled'; // 如果选择的时间不是“立即送出”,激活“预约配送”
|
||||
|
||||
// 直接使用从接口获取的时间参数
|
||||
this.booking_at = item.booking_at; // 预约时间戳
|
||||
this.booking_begin_time = item.booking_begin_time; // 预约开始时间
|
||||
this.booking_end_time = item.booking_end_time; // 预约结束时间
|
||||
this.booking_state = 2; // 预订单状态
|
||||
} else {
|
||||
this.activeTab = 'immediate'; // 如果选择的时间是“立即送出”,激活“立即配送”
|
||||
this.booking_state = 1; // 立即下单状态
|
||||
}
|
||||
|
||||
// 打印确认字段是否正确赋值
|
||||
console.log('booking_at:', this.booking_at);
|
||||
console.log('booking_begin_time:', this.booking_begin_time);
|
||||
console.log('booking_end_time:', this.booking_end_time);
|
||||
},
|
||||
inputud_name: function (e) {
|
||||
this.setData({
|
||||
ud_name: e.detail.value,
|
||||
@ -1157,6 +1235,30 @@ export default {
|
||||
});
|
||||
//this.getCartList()
|
||||
},
|
||||
async getTimeSlots() {
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: this.Config.URL.cart.getTimeSlots, // 替换为实际的接口地址
|
||||
method: 'GET',
|
||||
data: {
|
||||
store_ids: 80
|
||||
}
|
||||
});
|
||||
|
||||
if (res[1].statusCode === 200) {
|
||||
console.log("接口返回的数据", res[1].data); // 打印返回的数据
|
||||
if (res[1].data && Array.isArray(res[1].data.data)) {
|
||||
this.content = res[1].data.data;
|
||||
} else {
|
||||
console.error('接口返回的数据格式不正确', res[1].data);
|
||||
}
|
||||
} else {
|
||||
console.error('获取时间槽列表失败:', res[1].data.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('请求时间槽列表时发生错误:', error);
|
||||
}
|
||||
},
|
||||
RefreshRedemption: function (options) {
|
||||
var that = this;
|
||||
var redemption_items = that.$.parseJSON(options.val);
|
||||
@ -1537,260 +1639,211 @@ export default {
|
||||
) || null
|
||||
);
|
||||
},
|
||||
submitorder: function (e) {
|
||||
let that = this;
|
||||
if (that.$.isNull(that.order_id)) {
|
||||
var params = that.urlArgs;
|
||||
submitorder: function (e) {
|
||||
let that = this;
|
||||
if (that.$.isNull(that.order_id)) {
|
||||
var params = that.urlArgs;
|
||||
|
||||
if (that.user_voucher_ids.length == 1) {
|
||||
params.user_voucher_id = that.user_voucher_ids[0];
|
||||
}
|
||||
if (that.user_voucher_ids.length == 1) {
|
||||
params.user_voucher_id = that.user_voucher_ids[0];
|
||||
}
|
||||
|
||||
if (this.ud_id == 0) {
|
||||
let msg = that.__("请选择你的收货地址!");
|
||||
if (this.ud_id == 0) {
|
||||
let msg = that.__("请选择你的收货地址!");
|
||||
if (that.isVirtual) {
|
||||
msg = that.__("请选择你的个人联系信息!");
|
||||
}
|
||||
that.$.showModal({
|
||||
title: that.__("提示"),
|
||||
showCancel: false,
|
||||
content: msg,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (that.isVirtual) {
|
||||
msg = that.__("请选择你的个人联系信息!");
|
||||
}
|
||||
if (this.isVirtual) {
|
||||
var datetime = this.date + " " + this.time,
|
||||
n = datetime.replace(/-/g, "/");
|
||||
var r = new Date();
|
||||
var i = new Date(n);
|
||||
var s = r.getTime(),
|
||||
o = i.getTime();
|
||||
|
||||
if (o - s < 0) {
|
||||
that.$.showModal({
|
||||
title: "提示",
|
||||
showCancel: false,
|
||||
content: "您选择的预约时间已不在服务预约时间范围内!",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.product_service_date_flag)
|
||||
if (that.$.isNull(this.date) || that.$.isNull(this.time)) {
|
||||
that.$.showModal({
|
||||
title: that.__("提示"),
|
||||
title: "提示",
|
||||
showCancel: false,
|
||||
content: msg,
|
||||
content: "请选择预约服务日期与时间!",
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isVirtual) {
|
||||
var datetime = this.date + " " + this.time,
|
||||
n = datetime.replace(/-/g, "/");
|
||||
var r = new Date();
|
||||
var i = new Date(n);
|
||||
var s = r.getTime(),
|
||||
o = i.getTime();
|
||||
// 设置预约相关字段
|
||||
if (that.booking_state === 2) {
|
||||
// 预订单
|
||||
params.booking_at = that.booking_at; // 预约时间戳
|
||||
params.booking_begin_time = that.booking_begin_time; // 预约开始时间
|
||||
params.booking_end_time = that.booking_end_time; // 预约结束时间
|
||||
params.booking_state = that.booking_state; // 预订单状态
|
||||
} else {
|
||||
// 立即下单
|
||||
params.booking_state = 1; // 立即下单状态
|
||||
}
|
||||
|
||||
if (o - s < 0) {
|
||||
that.$.showModal({
|
||||
title: "提示",
|
||||
showCancel: false,
|
||||
content: "您选择的预约时间已不在服务预约时间范围内!",
|
||||
});
|
||||
return;
|
||||
}
|
||||
var paymentTypeId = that.submitinfo.items[0].items[0].payment_type_id;
|
||||
params.payment_form_id = paymentTypeId;
|
||||
|
||||
if (this.product_service_date_flag)
|
||||
if (that.$.isNull(this.date) || that.$.isNull(this.time)) {
|
||||
that.$.showModal({
|
||||
title: "提示",
|
||||
showCancel: false,
|
||||
content: "请选择预约服务日期与时间!",
|
||||
});
|
||||
return;
|
||||
}
|
||||
params.user_voucher_ids = JSON.stringify(that.user_voucher_ids);
|
||||
params.redemption_ids = JSON.stringify(that.redemption_ids);
|
||||
params.ud_id = params.ud_id || that.ud_id;
|
||||
params.ifcart = that.ifcart; // 传入cart_id时直接购买,未传时走购物车
|
||||
params.cart_id = that.cart_id;
|
||||
params.payment_type_id = that.StateCode.PAYMENT_TYPE_ONLINE;
|
||||
|
||||
/*
|
||||
if (!/^1[23456789]\d{9}$/.test(this.phone) && this.product_service_contactor_flag) {
|
||||
that.$.showModal({title: "提示", showCancel: false, content: "手机号有误!"});
|
||||
return
|
||||
}
|
||||
if (that.selfpickFlag || that.storeServeFlag) {
|
||||
params.delivery_type_id = 5;
|
||||
} else if (that.addressFlag) {
|
||||
params.delivery_type_id = 10;
|
||||
} else if (that.intraCityService) {
|
||||
params.delivery_type_id = 16;
|
||||
}
|
||||
|
||||
if (this.sp == 1) {
|
||||
if (that.$.isNull(this.ud_name) && this.product_service_contactor_flag) {
|
||||
that.$.showModal({title: "提示", showCancel: false, content: "请填写预约人姓名!"});
|
||||
return
|
||||
}
|
||||
if (that.$.isNull(this.phone) && this.product_service_contactor_flag) {
|
||||
that.$.showModal({title: "提示", showCancel: false, content: "请填写预约人手机号码!"});
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (that.$.isNull(this.ud_name) && this.product_service_contactor_flag) {
|
||||
that.$.showModal({title: "提示", showCancel: false, content: "请填写预约人姓名!"});
|
||||
return
|
||||
}
|
||||
if (that.$.isNull(this.phone) && this.product_service_contactor_flag) {
|
||||
that.$.showModal({title: "提示", showCancel: false, content: "请填写预约人手机号码!"});
|
||||
return
|
||||
}
|
||||
if (that.$.isNull(this.detail)) {
|
||||
that.$.showModal({title: "提示", showCancel: false, content: "请填写预约人服务地址!"});
|
||||
return
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
var paymentTypeId = that.submitinfo.items[0].items[0].payment_type_id;
|
||||
params.payment_form_id = paymentTypeId;
|
||||
params.invoice_type_id = 1;
|
||||
params.order_invoice_title = "";
|
||||
|
||||
params.user_voucher_ids = JSON.stringify(that.user_voucher_ids);
|
||||
params.redemption_ids = JSON.stringify(that.redemption_ids);
|
||||
params.ud_id = params.ud_id || that.ud_id;
|
||||
params.ifcart = that.ifcart; // 传入cart_id时直接购买,未传时走购物车
|
||||
params.cart_id = that.cart_id;
|
||||
params.payment_type_id = that.StateCode.PAYMENT_TYPE_ONLINE;
|
||||
params.order_message = JSON.stringify(that.order_message);
|
||||
|
||||
// 决定配送方式
|
||||
if (that.selfpickFlag || that.storeServeFlag) {
|
||||
params.delivery_type_id = 5;
|
||||
} else if (that.addressFlag) {
|
||||
params.delivery_type_id = 10;
|
||||
} else if (that.intraCityService) {
|
||||
params.delivery_type_id = 16;
|
||||
}
|
||||
// params.delivery_type_id = that.selfpickFlag ? 5 : 10; //是否自提; //DELIVERY_TYPE_SELF_PICK_UP = 5
|
||||
params.delivery_time_id = 1;
|
||||
params.virtual_service_date = that.date;
|
||||
params.virtual_service_time = that.date + " " + that.time;
|
||||
params.chain_id = that.chain_id;
|
||||
params.checked_store = that.checked_store;
|
||||
|
||||
params.invoice_type_id = 1;
|
||||
params.order_invoice_title = "";
|
||||
params.distributor_id = uni.getStorageSync("store_id");
|
||||
params.salesperson_id = that.salesperson_id;
|
||||
params.user_invoice_id = that.user_invoice_id;
|
||||
|
||||
params.order_message = JSON.stringify(that.order_message);
|
||||
let source_item_id = uni.getStorageSync("source_item_id");
|
||||
params.source_item_id = source_item_id;
|
||||
|
||||
params.virtual_service_date = that.date;
|
||||
params.virtual_service_time = that.date + " " + that.time;
|
||||
params.chain_id = that.chain_id;
|
||||
params.checked_store = that.checked_store;
|
||||
params.is_delivery = that.selfpickFlag ? 0 : 1; //是否自提
|
||||
params.kind_id = that.kind_id;
|
||||
params.kind_id = that.kind_id;
|
||||
console.log("哈哈哈哈哈哈",params)
|
||||
that.$.request({
|
||||
url: this.Config.URL.user.order_add,
|
||||
data: params,
|
||||
method: "POST",
|
||||
success: function (data, status, msg, code) {
|
||||
if (200 == status) {
|
||||
// 删除旧数据
|
||||
if (source_item_id) {
|
||||
let source_item_id_row = JSON.parse(source_item_id);
|
||||
for (
|
||||
let store_idx = 0;
|
||||
store_idx < data.items.length;
|
||||
store_idx++
|
||||
) {
|
||||
for (
|
||||
let item_idx = 0;
|
||||
item_idx < data.items[store_idx].items.length;
|
||||
item_idx++
|
||||
) {
|
||||
let order_item_id =
|
||||
data.items[store_idx].items[item_idx].item_id;
|
||||
|
||||
params.distributor_id = uni.getStorageSync("store_id");
|
||||
params.salesperson_id = that.salesperson_id;
|
||||
params.user_invoice_id = that.user_invoice_id;
|
||||
|
||||
let source_item_id = uni.getStorageSync("source_item_id");
|
||||
params.source_item_id = source_item_id;
|
||||
|
||||
params.is_delivery = that.selfpickFlag ? 0 : 1; //是否自提
|
||||
params.kind_id = that.kind_id;
|
||||
that.$.request({
|
||||
url: this.Config.URL.user.order_add,
|
||||
data: params,
|
||||
method: "POST",
|
||||
success: function (data, status, msg, code) {
|
||||
//console.info(JSON.stringify(data));
|
||||
if (200 == status) {
|
||||
//删除旧数据
|
||||
if (source_item_id) {
|
||||
let source_item_id_row = JSON.parse(source_item_id);
|
||||
for (
|
||||
let store_idx = 0;
|
||||
store_idx < data.items.length;
|
||||
store_idx++
|
||||
) {
|
||||
for (
|
||||
let item_idx = 0;
|
||||
item_idx < data.items[store_idx].items.length;
|
||||
item_idx++
|
||||
) {
|
||||
let order_item_id =
|
||||
data.items[store_idx].items[item_idx].item_id;
|
||||
|
||||
//完成后删除数据吧
|
||||
if (source_item_id) {
|
||||
for (var tk in source_item_id_row) {
|
||||
if (source_item_id_row[tk].u) {
|
||||
if (tk == order_item_id) {
|
||||
delete source_item_id_row[tk];
|
||||
} else {
|
||||
let time = parseInt(Date.parse(new Date()) / 100);
|
||||
//判断是否超时
|
||||
if (time - source_item_id_row[tk].t > 86400 * 30) {
|
||||
delete source_item_id_row[tk];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (source_item_id) {
|
||||
for (var tk in source_item_id_row) {
|
||||
if (source_item_id_row[tk].u) {
|
||||
if (tk == order_item_id) {
|
||||
delete source_item_id_row[tk];
|
||||
} else {
|
||||
let time = parseInt(Date.parse(new Date()) / 100);
|
||||
if (time - source_item_id_row[tk].t > 86400 * 30) {
|
||||
delete source_item_id_row[tk];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
delete source_item_id_row[tk];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uni.setStorageSync(
|
||||
"source_item_id",
|
||||
JSON.stringify(source_item_id_row)
|
||||
);
|
||||
}
|
||||
|
||||
that.setData({
|
||||
order_id: data.order_id.join(","),
|
||||
});
|
||||
|
||||
if (data.gb_id) {
|
||||
that.isFightGroup = data.gb_id;
|
||||
}
|
||||
|
||||
that.setData({
|
||||
paymentData: {
|
||||
order_id: that.order_id,
|
||||
orderSelMoneyAmount: data.orderSelMoneyAmount.toFixed(2),
|
||||
|
||||
user_money: data.user_money,
|
||||
user_points: data.user_points,
|
||||
user_recharge_card: that.userInfo.user_recharge_card,
|
||||
user_sp: that.userInfo.user_sp,
|
||||
},
|
||||
});
|
||||
|
||||
that.reloadUserResource(function (user_info) {});
|
||||
|
||||
/*
|
||||
that.$.showToast({
|
||||
title: "添加订单成功!"
|
||||
});
|
||||
*/
|
||||
//
|
||||
// that.gotopay();
|
||||
// 判断如果是虚拟商品
|
||||
// const item = that.submitinfo.items[0].items[0];
|
||||
// if(item.payment_type_id === 1){
|
||||
// that.$.gotopage("/member/order/detail?on=" + that.order_id)
|
||||
// } else {
|
||||
that.notice.postNotificationName("GotoPayCheckout");
|
||||
// }
|
||||
} else {
|
||||
/*
|
||||
setTimeout(() => {
|
||||
|
||||
that.setData({
|
||||
showPopupFlag: true,
|
||||
popupMsg: msg
|
||||
});
|
||||
|
||||
}, 10);
|
||||
*/
|
||||
if (
|
||||
(data && data.hasOwnProperty("mobile_is_bind")) ||
|
||||
code == 77011
|
||||
) {
|
||||
that.$.confirm(
|
||||
msg,
|
||||
function (data) {
|
||||
if (data.confirm) {
|
||||
//绑定手机操作
|
||||
that.$.gopage("/member/member/bindphone");
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
} else {
|
||||
that.$.confirm(msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: function (data, status, msg, code) {
|
||||
that.$.showToast({
|
||||
title: msg,
|
||||
});
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const item = that.submitinfo.items[0].items[0];
|
||||
if (item.payment_type_id === 1) {
|
||||
that.$.gotopage(`/member/order/detail?on=${that.order_id}&subscribe=1`);
|
||||
|
||||
uni.setStorageSync(
|
||||
"source_item_id",
|
||||
JSON.stringify(source_item_id_row)
|
||||
);
|
||||
}
|
||||
|
||||
that.setData({
|
||||
order_id: data.order_id.join(","),
|
||||
});
|
||||
|
||||
if (data.gb_id) {
|
||||
that.isFightGroup = data.gb_id;
|
||||
}
|
||||
|
||||
that.setData({
|
||||
paymentData: {
|
||||
order_id: that.order_id,
|
||||
orderSelMoneyAmount: data.orderSelMoneyAmount.toFixed(2),
|
||||
|
||||
user_money: data.user_money,
|
||||
user_points: data.user_points,
|
||||
user_recharge_card: that.userInfo.user_recharge_card,
|
||||
user_sp: that.userInfo.user_sp,
|
||||
},
|
||||
});
|
||||
|
||||
that.reloadUserResource(function (user_info) {});
|
||||
|
||||
that.notice.postNotificationName("GotoPayCheckout");
|
||||
} else {
|
||||
that.gotopay();
|
||||
if (
|
||||
(data && data.hasOwnProperty("mobile_is_bind")) ||
|
||||
code == 77011
|
||||
) {
|
||||
that.$.confirm(
|
||||
msg,
|
||||
function (data) {
|
||||
if (data.confirm) {
|
||||
that.$.gopage("/member/member/bindphone");
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
} else {
|
||||
that.$.confirm(msg);
|
||||
}
|
||||
}
|
||||
//that.gotopay()
|
||||
}
|
||||
},
|
||||
},
|
||||
fail: function (data, status, msg, code) {
|
||||
that.$.showToast({
|
||||
title: msg,
|
||||
});
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const item = that.submitinfo.items[0].items[0];
|
||||
if (item.payment_type_id === 1) {
|
||||
that.$.gotopage(`/member/order/detail?on=${that.order_id}&subscribe=1`);
|
||||
} else {
|
||||
that.gotopay();
|
||||
}
|
||||
}
|
||||
},
|
||||
gotopay: function (e) {
|
||||
//console.info('gotopay');
|
||||
setTimeout(() => {
|
||||
@ -2251,12 +2304,28 @@ export default {
|
||||
urlArgs: urlArgs,
|
||||
});
|
||||
},
|
||||
calculateImmediateDeliveryTime() {
|
||||
const now = new Date();
|
||||
const startTime = new Date(now.getTime() + 25 * 60 * 1000); // 当前时间 + 25 分钟
|
||||
const endTime = new Date(now.getTime() + 35 * 60 * 1000); // 当前时间 + 35 分钟
|
||||
|
||||
const formatTime = (date) => {
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
return `${hours}:${minutes}`;
|
||||
};
|
||||
|
||||
this.immediateDeliveryTime = `预计${formatTime(startTime)}-${formatTime(endTime)}送达`;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.calculateImmediateDeliveryTime();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
<style lang="scss">
|
||||
<style lang="scss" scoped>
|
||||
@import "../../styles/_variables";
|
||||
|
||||
.page-container {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user