购物车历史订单增加,代码优化
This commit is contained in:
parent
5a655ba09e
commit
5e6646b574
8
App.vue
8
App.vue
|
|
@ -16,6 +16,11 @@ App.vue本身不是页面,这里不能编写视图元素,也就是没有<tem
|
|||
|
||||
});
|
||||
onLaunch(() => {
|
||||
// 非开发工具移除 console.log console.info
|
||||
if (uni.getSystemInfoSync().platform !== "devtools") {
|
||||
console.log = () => {};
|
||||
console.info = () => {};
|
||||
}
|
||||
let that = this
|
||||
uni.hideTabBar()
|
||||
// #ifdef MP-WEIXIN
|
||||
|
|
@ -32,7 +37,8 @@ App.vue本身不是页面,这里不能编写视图元素,也就是没有<tem
|
|||
// 新版本下载失败
|
||||
})
|
||||
// #endif
|
||||
|
||||
// console.log("getSystemSetting==",uni.getSystemInfoSync())
|
||||
// console.log("getSystemSetting==",uni.getSystemSetting())
|
||||
|
||||
|
||||
//#ifdef APP-PLUS
|
||||
|
|
|
|||
|
|
@ -28,3 +28,10 @@ export function getThisMonthTimestamps() {
|
|||
return { start, end ,label:'本月'};
|
||||
}
|
||||
|
||||
// 获取上个月的开始和结束时间
|
||||
export function getThisLastMonthTimestamps() {
|
||||
const start = dayjs().subtract(1, 'month').startOf('month').format('YYYY-MM-DD HH:mm:ss');
|
||||
const end = dayjs().subtract(1, 'month').endOf('month').format('YYYY-MM-DD HH:mm:ss');
|
||||
return { start, end ,label:'上月'};
|
||||
}
|
||||
|
||||
|
|
@ -8,7 +8,6 @@ export const utils = {
|
|||
* @param {Object} e
|
||||
*/
|
||||
isNumber (e) {
|
||||
console.log(e)
|
||||
return e.replace(/[^\d]/g, '')
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import {
|
||||
getCurrentInstance,
|
||||
} from 'vue';
|
||||
|
||||
import { getCurrentInstance } from 'vue';
|
||||
export async function getElRect(elClass, instance,option) {
|
||||
instance = instance ? instance : getCurrentInstance();
|
||||
const query = uni.createSelectorQuery().in(instance.proxy);
|
||||
|
|
|
|||
|
|
@ -249,7 +249,6 @@ const model = {
|
|||
if (envMode) {
|
||||
uni.setStorageSync(appConfig.storeEnvEnumKey, envMode) // 改变存储
|
||||
}
|
||||
console.log(appConfig.storeEnvEnumKey)
|
||||
|
||||
return uni.getStorageSync(appConfig.storeEnvEnumKey)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
</view>
|
||||
<view class="u-p-30 u-flex u-flex-wrap gap-20 fastTime" v-if="props.isArea">
|
||||
<view class="item" v-for="(item,index) in fastTime" :key="index" @tap="changeTime(item.key)">
|
||||
{{item.title}}
|
||||
<view class="item" v-for="(item,index) in fastTime" :key="index" @tap="changeTime(item)">
|
||||
{{item.label}}
|
||||
</view>
|
||||
</view>
|
||||
<picker-view :immediate-change="true" @pickend="pickend" :value="value" @change="bindChange"
|
||||
|
|
@ -95,12 +95,10 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, nextTick, ref } from 'vue';
|
||||
import * as $time from '@/commons/utils/dayjs-time.js';
|
||||
import myButton from "@/components/my-components/my-button.vue"
|
||||
import {
|
||||
reactive,
|
||||
nextTick,
|
||||
ref
|
||||
} from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
selTime:{
|
||||
type: [String,Number],
|
||||
|
|
@ -178,24 +176,28 @@
|
|||
const seconds = new Array(60).fill(1).map((v, index) => {
|
||||
return index
|
||||
})
|
||||
const fastTime = reactive([{
|
||||
title: '今日',
|
||||
key: 'now'
|
||||
},
|
||||
{
|
||||
title: '昨日',
|
||||
key: 'prve'
|
||||
},
|
||||
{
|
||||
title: '本月',
|
||||
key: 'nowMonth'
|
||||
},
|
||||
{
|
||||
title: '上月',
|
||||
key: 'prveMonth'
|
||||
}
|
||||
])
|
||||
|
||||
// const fastTime = reactive([{
|
||||
// title: '今日',
|
||||
// key: 'now'
|
||||
// },
|
||||
// {
|
||||
// title: '昨日',
|
||||
// key: 'prve'
|
||||
// },
|
||||
// {
|
||||
// title: '本月',
|
||||
// key: 'nowMonth'
|
||||
// },
|
||||
// {
|
||||
// title: '上月',
|
||||
// key: 'prveMonth'
|
||||
// }
|
||||
// ])
|
||||
const today = $time.getTodayTimestamps();
|
||||
const yesterday = $time.getYesterdayTimestamps();
|
||||
const thisMonth = $time.getThisMonthTimestamps();
|
||||
const thisLastMonth = $time.getThisLastMonthTimestamps()
|
||||
const fastTime = reactive([today, yesterday, thisMonth, thisLastMonth])
|
||||
|
||||
|
||||
function setPrveDay() {
|
||||
|
|
@ -230,84 +232,10 @@
|
|||
]
|
||||
}
|
||||
|
||||
function changeTime(key) {
|
||||
const yearIndex = years.findIndex(v => v == nowDate.year)
|
||||
const prveyearIndex = years.findIndex(v => v == nowDate.year) - 1
|
||||
const nowMonthIndex = nowDate.month - 1
|
||||
const nowDayIndex = nowDate.day - 1
|
||||
const dataMap = {
|
||||
now: function() {
|
||||
return {
|
||||
start: {
|
||||
year: yearIndex,
|
||||
month: nowMonthIndex,
|
||||
day: nowDayIndex
|
||||
},
|
||||
end: {
|
||||
year: yearIndex,
|
||||
month: nowMonthIndex,
|
||||
day: nowDayIndex
|
||||
}
|
||||
}
|
||||
},
|
||||
prve: function() {
|
||||
const oneDay = 1000 * 60 * 60 * 24
|
||||
const date = new Date(new Date(nowDate.year, nowDate.month, nowDate.day, 0, 0, 0).getTime() -
|
||||
oneDay)
|
||||
return {
|
||||
start: {
|
||||
year: years.findIndex(v => v == date.getFullYear()),
|
||||
month: date.getMonth() - 1 < 0 ? 11 : date.getMonth() - 1,
|
||||
day: date.getDate() - 1
|
||||
},
|
||||
end: {
|
||||
year: years.findIndex(v => v == date.getFullYear()),
|
||||
month: date.getMonth() - 1 < 0 ? 11 : date.getMonth() - 1,
|
||||
day: date.getDate() - 1
|
||||
}
|
||||
}
|
||||
},
|
||||
nowMonth: function() {
|
||||
return {
|
||||
start: {
|
||||
year: yearIndex,
|
||||
month: nowMonthIndex,
|
||||
day: 0
|
||||
},
|
||||
end: {
|
||||
year: yearIndex,
|
||||
month: nowMonthIndex,
|
||||
day: new Date(nowDate.year, nowDate.month, 0).getDate() - 1
|
||||
}
|
||||
}
|
||||
},
|
||||
prveMonth: function() {
|
||||
const oneDay = 1000 * 60 * 60 * 24
|
||||
const date = new Date(new Date(nowDate.year, nowDate.month - 1, 0, 0, 0).getTime() - oneDay)
|
||||
console.log(date.getMonth());
|
||||
return {
|
||||
start: {
|
||||
year: years.findIndex(v => v == date.getFullYear()),
|
||||
month: date.getMonth(),
|
||||
day: 0
|
||||
},
|
||||
end: {
|
||||
year: years.findIndex(v => v == date.getFullYear()),
|
||||
month: date.getMonth(),
|
||||
day: date.getDate()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const data = dataMap[key]()
|
||||
setDay(data.start, data.end)
|
||||
changeDays(false, value.value)
|
||||
changeDays(true, value1.value)
|
||||
|
||||
console.log(value1.value);
|
||||
const start = returnDateString(value.value)
|
||||
const end = returnDateString(value1.value)
|
||||
|
||||
function changeTime(e) {
|
||||
console.log(e)
|
||||
const start = e.start
|
||||
const end = e.end
|
||||
emits('confirm', {
|
||||
text: `${start}——${end}`,
|
||||
start,
|
||||
|
|
|
|||
|
|
@ -30,13 +30,7 @@ const processEnv = process.env.NODE_ENV
|
|||
// 改变env环境
|
||||
function changeEnv(envMode){
|
||||
appConfig.env = allEnvMap[envMode || processEnv]
|
||||
|
||||
// // 动态导包的方式:设置全局env配置项目 : 当参数不存在, 那么获取node环境
|
||||
// import(`./env.${envMode || processEnv}.js`).then(module => {
|
||||
// appConfig.env = module.default
|
||||
// }).catch(() => {
|
||||
// appConfig.env = production //当出现错误, 比如本地没有复制dev文件时, 默认使用生产环境
|
||||
// })
|
||||
appConfig.wss = allEnvMap[envMode || processEnv].JEEPAY_BASE_URL_WSS
|
||||
}
|
||||
|
||||
export default { changeEnv: changeEnv }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
export default {
|
||||
'JEEPAY_BASE_URL': 'https://b.rscygroup.com', // 请求URL(生产环境)
|
||||
'JEEPAY_BASE_URL_H5': 'https://b.rscygroup.com'
|
||||
// 'JEEPAY_BASE_URL': 'http://192.168.1.8:9218' // 请求URL(测试环境)
|
||||
// 'JEEPAY_BASE_URL': 'https://b.qilinshuzi.com' //支付网关URL
|
||||
'JEEPAY_BASE_URL': 'http://192.168.1.31/', // 请求URL(生产环境)
|
||||
'JEEPAY_BASE_URL_H5': 'http://192.168.1.31/',
|
||||
'JEEPAY_BASE_URL_WSS': 'ws://192.168.1.31:2348' ,// sockets
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
export default {
|
||||
'JEEPAY_BASE_URL': 'https://b.rscygroup.com', // 请求URL(生产环境)
|
||||
'JEEPAY_BASE_URL_H5': 'https://b.rscygroup.com'
|
||||
// 'JEEPAY_BASE_URL': 'http://192.168.1.8:9218' // 请求URL(测试环境)
|
||||
// 'JEEPAY_BASE_URL': 'https://b.qilinshuzi.com' //支付网关URL
|
||||
'JEEPAY_BASE_URL': 'https://cashier.sxczgkj.com/', // 请求URL(生产环境)
|
||||
'JEEPAY_BASE_URL_H5': 'https://cashier.sxczgkj.com/',
|
||||
'JEEPAY_BASE_URL_WSS': 'wss://czgeatws.sxczgkj.com/wss' // sockets
|
||||
}
|
||||
|
|
@ -85,5 +85,32 @@ export function printOrder(data, urlType = 'order') {
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空历史订单
|
||||
* @returns
|
||||
*/
|
||||
export function cancelOrder(data, urlType = 'order') {
|
||||
return request({
|
||||
url: `${urlType}/admin/order/cancelOrder`,
|
||||
method: "POST",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空某一次历史订单
|
||||
* @returns
|
||||
*/
|
||||
export function rmPlaceOrder(data, urlType = 'order') {
|
||||
return request({
|
||||
url: `${urlType}/admin/order/rmPlaceOrder`,
|
||||
method: "POST",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
16
http/http.js
16
http/http.js
|
|
@ -6,16 +6,17 @@
|
|||
* @site https://www.jeequan.com
|
||||
* @date 2021/12/16 18:35
|
||||
*/
|
||||
|
||||
// 设置env配置文件
|
||||
import envConfig from '@/env/config.js'
|
||||
// 导入全局属性
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import storageManage from '@/commons/utils/storageManage.js'
|
||||
import {
|
||||
sm4DecryptByResData
|
||||
} from '@/commons/utils/encryptUtil.js'
|
||||
import { sm4DecryptByResData } from '@/commons/utils/encryptUtil.js'
|
||||
import infoBox from "@/commons/utils/infoBox.js"
|
||||
import go from '@/commons/utils/go.js';
|
||||
import { reject } from 'lodash';
|
||||
// 设置node环境
|
||||
envConfig.changeEnv(storageManage.env())
|
||||
|
||||
// 测试服
|
||||
// #ifdef H5
|
||||
|
|
@ -27,13 +28,12 @@ let baseUrl = '/api/'
|
|||
// let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn'
|
||||
|
||||
//正式
|
||||
let baseUrl = 'https://cashier.sxczgkj.com/'
|
||||
// let baseUrl = 'https://cashier.sxczgkj.com/'
|
||||
let baseUrl = appConfig.env.JEEPAY_BASE_URL
|
||||
// #endif
|
||||
|
||||
|
||||
const loadingShowTime = 200
|
||||
|
||||
|
||||
function getHeader(){
|
||||
const headerObject={}
|
||||
headerObject["token"] = storageManage.token()
|
||||
|
|
@ -134,7 +134,7 @@ function commonsProcess(showLoading, httpReqCallback) {
|
|||
console.log(res)
|
||||
if(res.code==501){
|
||||
storageManage.token(null, true)
|
||||
infoBox.showToast(res.msg||'请登录').then(() => {
|
||||
infoBox.showToast('登录过期,请重新登录').then(() => {
|
||||
uni.redirectTo({url: '/pages/login/index'})
|
||||
reject()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
</view>
|
||||
<view class="boxconstantbox_tow">
|
||||
<text>用户消费结账时,成功充值</text>
|
||||
<input class="text" type="digit" v-model="form.rechargeTimes" @change="form.rechargeTimes = $utils.isMoney(form.rechargeTimes)"/>
|
||||
<input class="text" type="number" :min='2' v-model="form.rechargeTimes" @change="rechargeTimesInput"/>
|
||||
<text>倍的金额本单即可享受免单</text>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
import { getFreeDing, updateFreeDing } from '@/http/api/freeDing.js'
|
||||
const form = reactive({
|
||||
rechargeTimes: '',
|
||||
rechargeTimes: 2,
|
||||
rechargeThreshold: '',
|
||||
enable: false,
|
||||
rechargeDesc: '',
|
||||
|
|
@ -71,6 +71,14 @@
|
|||
Object.assign(form, res)
|
||||
}
|
||||
|
||||
let rechargeTimesInput = (e) => {
|
||||
if( uni.$utils.isNumber(e.detail.value) == '' || uni.$utils.isNumber(e.detail.value) < 2 ){
|
||||
form.rechargeTimes = 2;
|
||||
return;
|
||||
}
|
||||
form.rechargeTimes = uni.$utils.isNumber(e.detail.value)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配置信息
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,13 +27,12 @@
|
|||
<up-button type="primary" style="background-color: #318AFE;color: #fff;" @tap="sumbit" :plain="true"
|
||||
text="保存"></up-button>
|
||||
</view>
|
||||
<!-- 消息提示 -->
|
||||
<up-toast ref="uToastRef"></up-toast>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, getCurrentInstance } from 'vue';
|
||||
import { ref, reactive } from 'vue';
|
||||
import { addVendor } from '@/http/api/vendor.js';
|
||||
|
||||
|
||||
|
|
@ -42,7 +41,6 @@
|
|||
shopId: uni.getStorageSync("shopId"),
|
||||
},
|
||||
})
|
||||
const currentInstance = getCurrentInstance()
|
||||
|
||||
function sumbit() {
|
||||
if (!datas.form.name || !datas.form.telephone || !datas.form.address) {
|
||||
|
|
@ -53,10 +51,7 @@
|
|||
return
|
||||
}
|
||||
addVendor(datas.form).then(res => {
|
||||
currentInstance.ctx.$refs.uToastRef.show({
|
||||
message: "添加成功",
|
||||
type: 'default',
|
||||
})
|
||||
uni.$utils.showToast("添加成功")
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1000)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, reactive, getCurrentInstance } from 'vue';
|
||||
import { ref, computed, onMounted, reactive } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import go from '@/commons/utils/go.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -58,13 +58,11 @@
|
|||
<up-button type="primary" style="background-color: #318AFE;color: #fff;" @tap="sumbit" :plain="true"
|
||||
text="保存"></up-button>
|
||||
</view>
|
||||
<!-- 消息提示 -->
|
||||
<up-toast ref="uToastRef"></up-toast>
|
||||
</template>
|
||||
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, reactive, onMounted, getCurrentInstance } from 'vue';
|
||||
import { ref, computed, reactive, onMounted } from 'vue';
|
||||
import { onShow, onLoad } from '@dcloudio/uni-app';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import dayjs from 'dayjs';
|
||||
|
|
@ -73,7 +71,6 @@
|
|||
import { stockOut } from '@/http/api/cons.js';
|
||||
|
||||
let showStatus = ref(false)
|
||||
const refs = getCurrentInstance()
|
||||
let datas = reactive({
|
||||
show: false,
|
||||
// 供应商列表
|
||||
|
|
@ -144,17 +141,11 @@
|
|||
let sumbit = uni.$utils.debounce(() => {
|
||||
|
||||
if (!datas.form.bodyList.inOutNumber) {
|
||||
refs.ctx.$refs.uToastRef.show({
|
||||
type: 'default',
|
||||
message: "请输入必填项",
|
||||
})
|
||||
uni.$utils.showToast("请输入必填项")
|
||||
return
|
||||
}
|
||||
if (!datas.form.bodyList.purchasePrice) {
|
||||
refs.ctx.$refs.uToastRef.show({
|
||||
type: 'default',
|
||||
message: "请输入必填项",
|
||||
})
|
||||
uni.$utils.showToast("请输入必填项")
|
||||
return
|
||||
}
|
||||
datas.form.bodyList.conId = datas.item.id
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, getCurrentInstance, ref, reactive } from 'vue';
|
||||
import { onMounted, ref, reactive } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import go from '@/commons/utils/go.js'
|
||||
import datePickerview from './components/my-date-pickerview.vue'
|
||||
|
|
@ -139,7 +139,7 @@
|
|||
PopUp: false,
|
||||
form: {}
|
||||
})
|
||||
const currentInstance = getCurrentInstance()
|
||||
const datePicker = ref()
|
||||
const props = defineProps({
|
||||
id: {
|
||||
type: Number
|
||||
|
|
@ -256,7 +256,7 @@
|
|||
function changeTime(e) {
|
||||
selected.value = e
|
||||
if (e == 'custom') {
|
||||
currentInstance.ctx.$refs.datePicker.toggle()
|
||||
datePicker.value.toggle()
|
||||
} else {
|
||||
getlist()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref, computed, getCurrentInstance } from 'vue';
|
||||
import { onMounted, reactive, ref, computed } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { stockFlow,consStatistics } from '@/http/api/cons.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, reactive, getCurrentInstance } from 'vue';
|
||||
import { ref, computed, reactive } from 'vue';
|
||||
import { onShow, onLoad } from '@dcloudio/uni-app';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import dayjs from 'dayjs';
|
||||
|
|
@ -94,7 +94,6 @@
|
|||
console.log(options)
|
||||
datas.item = JSON.parse(options.item)
|
||||
datas.form = Object.assign(datas.form, datas.item)
|
||||
console.log(datas.form)
|
||||
// 单位列表
|
||||
datas.unitList = [ datas.form.conUnit, datas.form.conUnitTwo]
|
||||
datas.form.bodyList.unit = datas.form.defaultUnit
|
||||
|
|
@ -105,8 +104,6 @@
|
|||
getList()
|
||||
})
|
||||
|
||||
const refs = getCurrentInstance()
|
||||
|
||||
function toggle() {
|
||||
go.to('PAGES_ADD_SUPPLIER')
|
||||
}
|
||||
|
|
@ -149,17 +146,11 @@
|
|||
|
||||
let sumbit = uni.$utils.debounce(() => {
|
||||
if (!datas.form.bodyList.inOutNumber) {
|
||||
refs.ctx.$refs.uToastRef.show({
|
||||
type: 'default',
|
||||
message: "请输入必填项",
|
||||
})
|
||||
uni.$utils.showToast("请输入必填项")
|
||||
return
|
||||
}
|
||||
if (!datas.form.bodyList.purchasePrice) {
|
||||
refs.ctx.$refs.uToastRef.show({
|
||||
type: 'default',
|
||||
message: "请输入必填项",
|
||||
})
|
||||
uni.$utils.showToast("请输入必填项")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -172,10 +163,7 @@
|
|||
vendorId: datas.list[nowStatusIndex.value].id,
|
||||
amountPayable: datas.form.bodyList[0].inOutNumber * datas.form.bodyList[0].purchasePrice,
|
||||
}).then(res => {
|
||||
refs.ctx.$refs.uToastRef.show({
|
||||
type: 'default',
|
||||
message: "保存成功",
|
||||
})
|
||||
uni.$utils.showToast("保存成功")
|
||||
setTimeout(() => {
|
||||
go.back()
|
||||
}, 1000)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
</template>
|
||||
<script setup>
|
||||
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app';
|
||||
import { reactive, ref, computed, getCurrentInstance } from 'vue';
|
||||
import { reactive, ref, computed } from 'vue';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import myRepayment from './components/my-repayment';
|
||||
import datePickerview from './components/my-date-pickerview.vue'
|
||||
|
|
@ -107,9 +107,8 @@
|
|||
let statusHeight = computed(() => {
|
||||
return 30 * pageData.statusList.length + 40 + 'px'
|
||||
})
|
||||
const currentInstance = getCurrentInstance()
|
||||
let repayment = ref(null)
|
||||
|
||||
const datePicker = ref()
|
||||
onLoad((options) => {
|
||||
if ( options.id ) {
|
||||
pageData.query.creditBuyerId = options.id;
|
||||
|
|
@ -187,7 +186,7 @@
|
|||
function changeTime(e) {
|
||||
pageData.selected = e
|
||||
if (e == 'custom') {
|
||||
currentInstance.ctx.$refs.datePicker.toggle()
|
||||
datePicker.value.toggle()
|
||||
} else {
|
||||
pageData.query.page = 1;
|
||||
pageData.list = [];
|
||||
|
|
|
|||
|
|
@ -107,16 +107,15 @@
|
|||
<up-button text="确认" @tap="confirmtow" type="primary" class="buttomStyle" shape="circle"></up-button>
|
||||
</view>
|
||||
</up-popup>
|
||||
<!-- <up-toast ref="uToastRef"></up-toast> -->
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, getCurrentInstance, onMounted } from 'vue';
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import go from '@/commons/utils/go.js'
|
||||
|
||||
import { getCallTableQueue, getCallTable, callTableTakeNumber, callTableCall, updateCallTableState } from '@/http/api/callTable.js'
|
||||
|
||||
let getrefs = getCurrentInstance()
|
||||
let datas = reactive({
|
||||
msgType: "",
|
||||
// 关闭取号弹窗
|
||||
|
|
@ -143,6 +142,8 @@
|
|||
getList()
|
||||
})
|
||||
|
||||
const alertDialog = ref()
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*/
|
||||
|
|
@ -209,7 +210,7 @@
|
|||
callQueueId: item.id
|
||||
}).then((res) => {
|
||||
datas.profilepicturedata = res
|
||||
getrefs.ctx.$refs.alertDialog.open()
|
||||
alertDialog.value.open()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,8 +109,6 @@
|
|||
<my-button shape="circle" @click="save">保存</my-button>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 消息提示 -->
|
||||
<up-toast ref="uToastRef"></up-toast>
|
||||
|
||||
</view>
|
||||
|
||||
|
|
@ -118,7 +116,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, getCurrentInstance } from 'vue';
|
||||
import { ref, reactive } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import go from '@/commons/utils/go.js';
|
||||
import pickerItem from './components/picker-item.vue';
|
||||
|
|
@ -176,8 +174,6 @@
|
|||
|
||||
})
|
||||
|
||||
const refs = getCurrentInstance()
|
||||
|
||||
onLoad((options) => {
|
||||
getlist()
|
||||
if (options.id) {
|
||||
|
|
@ -233,17 +229,11 @@
|
|||
async function save() {
|
||||
// 效验
|
||||
if (!form.contentType || !form.subType || !form.name || !form.address) {
|
||||
refs.ctx.$refs.uToastRef.show({
|
||||
type: 'default',
|
||||
message: "请输入必填项",
|
||||
})
|
||||
uni.$utils.showToast("请输入必填项")
|
||||
return
|
||||
}
|
||||
if (form.classifyPrint == 1 && form.selectcheckbox.length == 0) {
|
||||
refs.ctx.$refs.uToastRef.show({
|
||||
type: 'default',
|
||||
message: "请选择部分分类",
|
||||
})
|
||||
uni.$utils.showToast("请选择部分分类")
|
||||
return
|
||||
}
|
||||
// 部分分类处理
|
||||
|
|
|
|||
|
|
@ -72,12 +72,13 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, getCurrentInstance, ref } from 'vue';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import datePickerview from './components/my-date-pickerview.vue'
|
||||
import dayjs from 'dayjs' //时间格式库
|
||||
import go from '@/commons/utils/go.js'
|
||||
import { getTrade, productSaleDate } from '@/http/api/summary.js'
|
||||
|
||||
const datePicker=ref()
|
||||
const timeList = [{
|
||||
label: '今天',
|
||||
value: 'today'
|
||||
|
|
@ -100,7 +101,6 @@
|
|||
]
|
||||
let selected = ref('today')
|
||||
let list = ref({})
|
||||
const currentInstance = getCurrentInstance()
|
||||
let tableList = ref([])
|
||||
let day = ref(1)
|
||||
onMounted(() => {
|
||||
|
|
@ -209,7 +209,7 @@
|
|||
function changeTime(e) {
|
||||
selected.value = e
|
||||
if (e == 'custom') {
|
||||
currentInstance.ctx.$refs.datePicker.toggle()
|
||||
datePicker.value.toggle()
|
||||
} else {
|
||||
getlist()
|
||||
gettableData()
|
||||
|
|
|
|||
|
|
@ -67,14 +67,14 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { getCurrentInstance, reactive, ref } from 'vue';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import go from '@/commons/utils/go.js';
|
||||
|
||||
import { shopStaffDetail,getShopStaffPermission,shopStaffAdd,shopStaffPut } from "@/http/api/staff.js"
|
||||
import { getShopPermission } from "@/http/api/index.js"
|
||||
import { getRoleList } from "@/http/api/role.js"
|
||||
const currentInstance = getCurrentInstance()
|
||||
|
||||
const props = defineProps({
|
||||
type: {
|
||||
type: String
|
||||
|
|
@ -99,6 +99,7 @@
|
|||
[]
|
||||
]);
|
||||
const show = ref(false)
|
||||
const message = ref()
|
||||
onShow(() => {
|
||||
init()
|
||||
})
|
||||
|
|
@ -170,16 +171,13 @@
|
|||
async function sumbitEvent() {
|
||||
// 效验
|
||||
if (!datas.formData.name || !datas.formData.phone || !datas.formData.code || !datas.formData.accountPwd) {
|
||||
currentInstance.ctx.$refs.uToastRef.show({
|
||||
message: "请填写必填项",
|
||||
type: 'default',
|
||||
})
|
||||
uni.$utils.showToast("请输入必填项")
|
||||
return
|
||||
}
|
||||
|
||||
let rolesId = datas.rolesList.filter(ele => ele.name == datas.rolesdata)
|
||||
if (rolesId.length == 0) {
|
||||
currentInstance.ctx.$refs.message.open()
|
||||
message.value.open()
|
||||
return
|
||||
}
|
||||
datas.formData.roleId = rolesId[0].id
|
||||
|
|
|
|||
|
|
@ -259,11 +259,7 @@
|
|||
* @param {Object} item
|
||||
*/
|
||||
function scanCode(item) {
|
||||
console.log(item)
|
||||
if ( item.tableCode != '') {
|
||||
uni.$utils.showToast('当前桌台已绑定')
|
||||
return;
|
||||
}
|
||||
|
||||
uni.scanCode({
|
||||
onlyFromCamera: true,
|
||||
success: function(res) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { getCurrentInstance, ref, reactive } from 'vue';
|
||||
import { ref, reactive } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
|
||||
import dayjs from 'dayjs' //时间格式库
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
value: 'custom'
|
||||
}
|
||||
]
|
||||
const currentInstance = getCurrentInstance()
|
||||
const datePicker = ref()
|
||||
onShow((options) => {
|
||||
let iToken = uni.getStorageSync('iToken').tokenValue
|
||||
if (iToken) {
|
||||
|
|
@ -185,7 +185,7 @@
|
|||
function changeTime(e) {
|
||||
selected.value = e
|
||||
if (e == 'custom') {
|
||||
currentInstance.ctx.$refs.datePicker.toggle()
|
||||
datePicker.value.toggle()
|
||||
} else {
|
||||
getlist()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@
|
|||
|
||||
<script setup>
|
||||
import { onLoad, onReady, onShow,onHide } from '@dcloudio/uni-app'
|
||||
import { ref, inject, onUnmounted, reactive, computed, watch } from 'vue';
|
||||
import { ref, inject, onUnmounted, nextTick, reactive, computed, watch } from 'vue';
|
||||
|
||||
import modelDiscount from './components/discount'
|
||||
import giveFood from './components/give-food'
|
||||
|
|
@ -369,6 +369,7 @@
|
|||
pageData.table.id = opt.tableId
|
||||
pageData.table.tableCode = opt.tableCode
|
||||
}
|
||||
pageData.shopInfo = uni.getStorageSync('shopInfo')
|
||||
getTbShopInfo()
|
||||
|
||||
})
|
||||
|
|
@ -399,6 +400,7 @@
|
|||
console.log("onUnmounted")
|
||||
websocketUtil.offMessage()
|
||||
});
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
* @param {Object} tableCode
|
||||
|
|
@ -457,6 +459,7 @@
|
|||
return prve + (cur.is_gift ? 0 : tPrice)
|
||||
}, 0)
|
||||
const tpackFee = $packFee.value > 0 ? $packFee.value*1 : 0
|
||||
|
||||
return ((goodsTotalPrice - discount_sale_amount.value + tpackFee) || 0).toFixed(2)
|
||||
})
|
||||
|
||||
|
|
@ -490,6 +493,9 @@
|
|||
* init
|
||||
*/
|
||||
async function init() {
|
||||
nextTick(()=>{
|
||||
onMessage()
|
||||
})
|
||||
// 获取商品列表
|
||||
$goods = await getProductList({},'product', false)
|
||||
// console.log("商品列表===",$goods)
|
||||
|
|
@ -500,84 +506,92 @@
|
|||
/**
|
||||
* socket消息监听
|
||||
*/
|
||||
websocketUtil.offMessage()
|
||||
websocketUtil.onMessage(res => {
|
||||
let msg = JSON.parse(res);
|
||||
let cartItem;
|
||||
if( msg.msg_id ){
|
||||
websocketUtil.send(JSON.stringify({
|
||||
type: 'receipt',
|
||||
msg_id: msg.msg_id,
|
||||
}))
|
||||
}
|
||||
if( msg.status == 0 ){
|
||||
infoBox.showToast('添加失败')
|
||||
return false;
|
||||
}
|
||||
function onMessage() {
|
||||
websocketUtil.offMessage()
|
||||
websocketUtil.onMessage(res => {
|
||||
let msg = JSON.parse(res);
|
||||
console.log(msg)
|
||||
let cartItem;
|
||||
if( msg.msg_id ){
|
||||
websocketUtil.send(JSON.stringify({
|
||||
type: 'receipt',
|
||||
msg_id: msg.msg_id,
|
||||
}))
|
||||
}
|
||||
if( msg.status == 0 ){
|
||||
infoBox.showToast('添加失败')
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (msg.operate_type) {
|
||||
case 'onboc_init':
|
||||
goods.list = []
|
||||
msg.data.map(item=>{
|
||||
cartItem = getNowCart(item,$goods,pageData.user)
|
||||
if( cartItem.isGrounding||cartItem.is_temporary == 1 ){
|
||||
cartControls(cartItem,'add')
|
||||
} else {
|
||||
delCart(cartItem.id)
|
||||
switch (msg.operate_type) {
|
||||
case 'onboc_init':
|
||||
goods.list = []
|
||||
console.log(msg.data)
|
||||
msg.data.map(item=>{
|
||||
cartItem = getNowCart(item,$goods,pageData.user)
|
||||
console.log(cartItem)
|
||||
if( cartItem.isGrounding||cartItem.is_temporary == 1 ){
|
||||
cartControls(cartItem,'add')
|
||||
} else {
|
||||
delCart(cartItem.id)
|
||||
}
|
||||
|
||||
})
|
||||
if( pageData.eatTypes.isShow ){
|
||||
if( pageData.eatTypes.active == 'take-out') {
|
||||
cartItem.pack_number = cartItem.number
|
||||
} else {
|
||||
cartItem.pack_number = 0
|
||||
}
|
||||
let par = {
|
||||
type:'onboc',
|
||||
account: uni.getStorageSync("iToken").loginId,
|
||||
shop_id: uni.getStorageSync("shopInfo").id,
|
||||
operate_type:'batch',
|
||||
table_code: pageData.table.tableCode,
|
||||
is_pack: pageData.eatTypes.active == 'take-out' ? 1 : 0,
|
||||
}
|
||||
updateCart(par)
|
||||
}
|
||||
// 是否更新就餐人数
|
||||
if (!$seatFee.totalNumber) {
|
||||
updateChoseCount()
|
||||
}
|
||||
|
||||
})
|
||||
if( pageData.eatTypes.isShow ){
|
||||
if( pageData.eatTypes.active == 'take-out') {
|
||||
cartItem.pack_number = cartItem.number
|
||||
} else {
|
||||
cartItem.pack_number = 0
|
||||
}
|
||||
let par = {
|
||||
type:'onboc',
|
||||
account: uni.getStorageSync("iToken").loginId,
|
||||
shop_id: uni.getStorageSync("shopInfo").id,
|
||||
operate_type:'batch',
|
||||
table_code: pageData.table.tableCode,
|
||||
is_pack: pageData.eatTypes.active == 'take-out' ? 1 : 0,
|
||||
}
|
||||
updateCart(par)
|
||||
}
|
||||
// 是否更新就餐人数
|
||||
if (!$seatFee.totalNumber) {
|
||||
updateChoseCount()
|
||||
}
|
||||
pageData.eatTypes.isShow = false
|
||||
break;
|
||||
case 'onboc_add':
|
||||
case 'add':
|
||||
cartItem = getNowCart(msg.data,$goods,pageData.user)
|
||||
cartControls(cartItem,'add')
|
||||
break;
|
||||
case 'onboc_edit':
|
||||
case 'edit':
|
||||
getCart()
|
||||
break;
|
||||
case 'onboc_del':
|
||||
case 'del':
|
||||
cartItem = getNowCart(msg.data,$goods,pageData.user)
|
||||
cartControls(cartItem,'del')
|
||||
break;
|
||||
case 'onboc_cleanup':
|
||||
case 'cleanup':
|
||||
goods.list = []
|
||||
$seatFee.totalNumber = 0
|
||||
$seatFee.totalAmount = 0
|
||||
userNumbers.defaultCateIndex = 0
|
||||
init()
|
||||
break;
|
||||
case 'product_update':
|
||||
init()
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
pageData.eatTypes.isShow = false
|
||||
break;
|
||||
case 'onboc_add':
|
||||
case 'add':
|
||||
cartItem = getNowCart(msg.data,$goods,pageData.user)
|
||||
cartControls(cartItem,'add')
|
||||
break;
|
||||
case 'onboc_edit':
|
||||
case 'edit':
|
||||
getCart()
|
||||
break;
|
||||
case 'onboc_del':
|
||||
case 'del':
|
||||
cartItem = getNowCart(msg.data,$goods,pageData.user)
|
||||
cartControls(cartItem,'del')
|
||||
break;
|
||||
case 'onboc_cleanup':
|
||||
case 'cleanup':
|
||||
goods.list = []
|
||||
$seatFee.totalNumber = 0
|
||||
$seatFee.totalAmount = 0
|
||||
userNumbers.defaultCateIndex = 0
|
||||
init()
|
||||
break;
|
||||
case 'product_update':
|
||||
init()
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除购物车菜品
|
||||
|
|
@ -840,9 +854,11 @@
|
|||
userNumbers.defaultCateIndex = maxCapacity - 1
|
||||
return
|
||||
}
|
||||
|
||||
console.log(pageData.shopInfo)
|
||||
console.log(!pageData.shopInfo.isTableFee)
|
||||
if (!pageData.shopInfo.isTableFee && pageData.table && pageData.table.id && goods.list.length > 0) {
|
||||
//不免餐位费
|
||||
console.log("不免餐位费")
|
||||
let seatFee = {
|
||||
totalNumber: userNumbers.defaultCateIndex * 1 + 1,
|
||||
totalAmount: (userNumbers.defaultCateIndex * 1 + 1) * pageData.shopInfo.tableFee,
|
||||
|
|
@ -897,7 +913,7 @@
|
|||
}
|
||||
|
||||
let vipPrice = isVip.value ? 1 : 0
|
||||
let placeNum = pageData.shopInfo.registerType == 'after'&&pageData.orderInfo ? pageData.orderInfo.placeNum + 1 : 1;
|
||||
let placeNum = pageData.orderInfo ? pageData.orderInfo.placeNum + 1 : 1;
|
||||
let originAmount = goodsPrice.value*1+youhui.value*1
|
||||
let par = {
|
||||
shopId: pageData.shopInfo.id, //店铺Id
|
||||
|
|
@ -915,7 +931,7 @@
|
|||
if(!pageData.shopInfo.isTableFee&&pageData.table&&pageData.table.id){
|
||||
par.seatNum = userNumbers.defaultCateIndex * 1 + 1
|
||||
}
|
||||
if(pageData.shopInfo.registerType == 'after'&&pageData.orderInfo){
|
||||
if(pageData.orderInfo){
|
||||
par.orderId = pageData.orderInfo.id
|
||||
}
|
||||
|
||||
|
|
@ -928,6 +944,7 @@
|
|||
operate_type:'cleanup',
|
||||
table_code: pageData.table.tableCode,
|
||||
}))
|
||||
uni.removeStorageSync("table_code")
|
||||
if (pageData.shopInfo.registerType == 'before' || pageData.eatTypes.active == 'take-out') {
|
||||
//先付
|
||||
return go.to('PAGES_ORDER_PAY', {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<view>已添加{{goodsNumber.toFixed(0)}}件商品</view>
|
||||
<view class="color-666">
|
||||
<uni-icons color="#666" type="trash"></uni-icons>
|
||||
<text class="u-m-l-10" @tap="setModalShow('clear',true)">清空</text>
|
||||
<text class="u-m-l-10" @tap="setModalShow('clear',true,'cart','是否清空全部已添加的商品')">清空购物车</text>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view scroll-y="true" class="tranistion" :style="{height:switchGoods?'50vh':0 }">
|
||||
|
|
@ -45,9 +45,44 @@
|
|||
|
||||
</view>
|
||||
</view>
|
||||
<my-empty v-if="!data.length" text="暂未有添加商品"></my-empty>
|
||||
</scroll-view>
|
||||
<view style="margin: 50rpx auto 110rpx auto;" v-if="!data.length">
|
||||
<my-empty text="暂未有添加商品"></my-empty>
|
||||
</view>
|
||||
|
||||
<!-- 历史订单 -->
|
||||
|
||||
<view v-if="historyOrder.length > 0"
|
||||
class="u-p-t-32 u-p-b-32 u-p-r-28 u-p-l-28 u-m-t-40 bg-fff u-flex u-row-between">
|
||||
<view class="color-333" style="font-weight: bold;">历史订单</view>
|
||||
<view class="color-666">
|
||||
<uni-icons color="#666" type="trash"></uni-icons>
|
||||
<text class="u-m-l-10" @tap="setModalShow('clear',true,'allHistoryOrder','清空历史订单')">清空历史订单</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-for="(item,index) in historyOrder" :key="index">
|
||||
<view v-if="historyOrder.length > 0"
|
||||
class="u-p-t-32 border-top bg-fff u-p-r-28 u-p-b-32 u-p-l-28 u-flex u-row-between">
|
||||
<view class="color-333" style="font-size: 30rpx;">第{{item.placeNum}}次下单</view>
|
||||
<view class="color-666">
|
||||
<uni-icons color="#666" type="trash"></uni-icons>
|
||||
<text class="u-m-l-10" @tap="setModalShow('clear',true,item.placeNum,'清空第'+item.placeNum+'次下单历史订单')">清空</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="color-333 item border-top u-flex u-row-center u-row-between"
|
||||
v-for="(v,i) in item.info" :key="i">
|
||||
<view style="display: flex;align-items: center;">
|
||||
<view class="up-line-1" style="margin-right: 10rpx;">{{v.productName}}</view>
|
||||
<uni-tag v-if="v.returnNum>0" :text="'退菜X'+v.returnNum"
|
||||
custom-style="background-color: #EB4F4F; border-color: #EB4F4F; color: #fff;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-flex" style="flex-shrink: 0;">
|
||||
<view class="font-bold red u-m-r-32">¥{{formatPrice(v.price*(v.num - v.returnNum)) }}</view>
|
||||
<view class="u-m-l-30 u-m-r-30 color-333"> X{{v.num.toFixed(2)}} </view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view class="icon-car-box" @tap="toggleGoods">
|
||||
<image src="/pagesCreateOrder/static/images/icon-car.svg" class="icon-car" />
|
||||
|
|
@ -63,15 +98,15 @@
|
|||
|
||||
|
||||
</view>
|
||||
<up-modal title="提示" content="是否清空全部已添加的商品?" :show="modal.clear" showCancelButton closeOnClickOverlay
|
||||
<up-modal title="提示" :content="modal.title" :show="modal.clear" showCancelButton closeOnClickOverlay
|
||||
@confirm="confirmModelConfirm" @cancel="setModalShow('clear',false)" @close="setModalShow('clear',false)"
|
||||
width="300px"></up-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
import go from '@/commons/utils/go.js';
|
||||
import infoBox from '@/commons/utils/infoBox.js';
|
||||
import { formatPrice } from '@/commons/utils/format.js';
|
||||
|
|
@ -83,10 +118,24 @@
|
|||
return []
|
||||
}
|
||||
},
|
||||
historyOrder: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return []
|
||||
}
|
||||
},
|
||||
isCreateOrderToDetail: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
orderInfo: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
id: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
table: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
|
|
@ -96,8 +145,43 @@
|
|||
}
|
||||
}
|
||||
})
|
||||
let allHistoryOrder = ref([]);
|
||||
const allPrice = computed(() => {
|
||||
let cartPrice = props.data.reduce((prve, cur) => {
|
||||
let price = Math.floor((cur.lowPrice * cur.number)*100)/100
|
||||
return prve + price
|
||||
}, 0)
|
||||
let historyOrderPrice = allHistoryOrder.value.reduce((prve, cur) => {
|
||||
let price = Math.floor((cur.price * (cur.num-cur.returnNum))*100)/100
|
||||
return prve + price
|
||||
}, 0)
|
||||
|
||||
return (cartPrice + historyOrderPrice).toFixed(2)
|
||||
})
|
||||
|
||||
const goodsNumber = computed(() => {
|
||||
let result = 0
|
||||
let cart = props.data.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
|
||||
let historyOrderNum = allHistoryOrder.value.reduce((prve, cur) => {
|
||||
return prve + cur.num
|
||||
}, 0)
|
||||
result = cart + historyOrderNum
|
||||
result = result > 0 ? result.toFixed(2) : 0
|
||||
return result >= 99 ? 99 : parseFloat(result)
|
||||
})
|
||||
watch(() => props.historyOrder, (newval) => {
|
||||
allHistoryOrder.value = [];
|
||||
newval.forEach(item=>{
|
||||
allHistoryOrder.value = [...allHistoryOrder.value,...item.info]
|
||||
})
|
||||
})
|
||||
const modal = reactive({
|
||||
key: '',
|
||||
title: '',
|
||||
type: '',
|
||||
clear: false
|
||||
})
|
||||
|
||||
|
|
@ -107,10 +191,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
function setModalShow(key = 'show', show = true) {
|
||||
function setModalShow(key = 'show',show = true, type = '' , title = '') {
|
||||
// if (key == 'clear' && show && props.data.length <= 0) {
|
||||
// return infoBox.showToast('购物车是空的!')
|
||||
// }
|
||||
if( title ){ modal.title = title }
|
||||
if( type ){ modal.type = type }
|
||||
modal.key = key
|
||||
modal[key] = show
|
||||
console.log(modal);
|
||||
|
|
@ -134,12 +220,19 @@
|
|||
}
|
||||
|
||||
function toConfimOrder() {
|
||||
if (props.data.length <= 0) {
|
||||
if ( props.data.length <= 0 && allHistoryOrder.value.length <= 0 ) {
|
||||
return infoBox.showToast('还没有选择商品')
|
||||
}
|
||||
const { name, status, type } = props.table
|
||||
console.log(props.table)
|
||||
if (props.table.id == ''&&props.table.tableCode == '') {
|
||||
if ( props.data.length <= 0 && allHistoryOrder.value.length > 0 ) {
|
||||
go.to('PAGES_ORDER_PAY', {
|
||||
orderId: props.orderInfo.id,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (props.table.id == '' && props.table.tableCode == '') {
|
||||
go.to('PAGES_CONFIRM_ORDER', {
|
||||
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
|
||||
})
|
||||
|
|
@ -155,21 +248,7 @@
|
|||
})
|
||||
}
|
||||
|
||||
const allPrice = computed(() => {
|
||||
return props.data.reduce((prve, cur) => {
|
||||
let price = Math.floor((cur.lowPrice * cur.number)*100)/100
|
||||
return prve + price
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
|
||||
const goodsNumber = computed(() => {
|
||||
let result = 0
|
||||
result = props.data.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
result = result > 0 ? result.toFixed(2) : 0
|
||||
return result >= 99 ? 99 : parseFloat(result)
|
||||
})
|
||||
|
||||
function updateNumber(isAdd, index, goods) {
|
||||
const step = isAdd ? 1 : -1
|
||||
|
|
@ -183,12 +262,13 @@
|
|||
}
|
||||
|
||||
function clear() {
|
||||
if ( modal.type == 'cart') {
|
||||
hideGoods()
|
||||
}
|
||||
setModalShow('clear', false)
|
||||
edmits('clear')
|
||||
hideGoods()
|
||||
edmits('clear',modal.type)
|
||||
}
|
||||
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, getCurrentInstance, reactive, ref, watch } from 'vue';
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
import infobox from '@/commons/utils/infoBox.js'
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
|
|
@ -48,6 +48,7 @@
|
|||
},
|
||||
})
|
||||
const model = ref(null)
|
||||
const popup = ref()
|
||||
let datas = reactive({
|
||||
item: "",
|
||||
title: "",
|
||||
|
|
@ -75,7 +76,6 @@
|
|||
})
|
||||
|
||||
const emits = defineEmits(['confirm', 'updateSku'])
|
||||
const instance = getCurrentInstance();
|
||||
|
||||
function confirm() {
|
||||
// 将数据保存进对应的值
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
emits('confirm', arr, datas.item)
|
||||
close()
|
||||
} else {
|
||||
instance.ctx.$refs.popup.open()
|
||||
popup.value.open()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@
|
|||
|
||||
<view class="bottom w-full">
|
||||
<my-car :isCreateOrderToDetail="isCreateOrderToDetail" @updateNumber="carsNumberChange"
|
||||
:table="data.table" :data="cars" @clear="cleaCart"></my-car>
|
||||
:table="data.table" :data="cars" :orderInfo="data.orderInfo" :historyOrder="data.historyOrder" @clear="cleaCart"></my-car>
|
||||
</view>
|
||||
<!-- 套餐选择规格 -->
|
||||
<taocanModel ref="taocanModelRef" @confirm="taocanConfirm" :goodsData="selGoods"></taocanModel>
|
||||
|
|
@ -132,7 +132,7 @@
|
|||
import { getProductList } from '@/http/api/product.js'
|
||||
import { categoryPage } from '@/http/api/cateGory.js'
|
||||
import { getShopInfo } from '@/http/api/shop.js'
|
||||
|
||||
import { getHistoryOrder, cancelOrder, rmPlaceOrder } from '@/http/api/order.js'
|
||||
|
||||
const modal = reactive({
|
||||
key: '',
|
||||
|
|
@ -178,6 +178,8 @@
|
|||
orderId: null,
|
||||
isGoodsAdd: true,
|
||||
goodsData: null,
|
||||
orderInfo: null,
|
||||
historyOrder: [],
|
||||
})
|
||||
const guigeModelData = reactive({
|
||||
title: '',
|
||||
|
|
@ -192,12 +194,12 @@
|
|||
let option = {
|
||||
type: ''
|
||||
}
|
||||
|
||||
const taocanModelRef = ref()
|
||||
const websocketUtil = inject('websocketUtil'); // 注入 WebSocket 工具类实例
|
||||
onLoad((opt) => {
|
||||
option = opt
|
||||
Object.assign(data.table, opt)
|
||||
|
||||
console.log(opt)
|
||||
uni.setNavigationBarTitle({
|
||||
title: (opt && opt.type == 'add') ? '顾客加菜' : '代客下单'
|
||||
})
|
||||
|
|
@ -296,6 +298,21 @@
|
|||
initCart()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
*/
|
||||
async function getHistoryOrderDetail(){
|
||||
data.historyOrder = [];
|
||||
let res = await getHistoryOrder({tableCode:data.table.tableCode});
|
||||
data.orderInfo = res;
|
||||
if( res ){
|
||||
data.historyOrder = Object.entries(data.orderInfo.detailMap).map(([key, value]) => ({
|
||||
info: value,
|
||||
placeNum: key
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听socket是否连接正常
|
||||
*/
|
||||
|
|
@ -361,6 +378,7 @@
|
|||
delCart(cartItem.id)
|
||||
}
|
||||
})
|
||||
getHistoryOrderDetail()
|
||||
uni.hideLoading()
|
||||
break;
|
||||
case 'onboc_add':
|
||||
|
|
@ -388,6 +406,7 @@
|
|||
data.tabbar[i].foods[k].chooseNumber = 0
|
||||
}
|
||||
}
|
||||
getHistoryOrderDetail()
|
||||
break;
|
||||
case 'init':
|
||||
case 'rottable':
|
||||
|
|
@ -403,6 +422,9 @@
|
|||
case 'product_update':
|
||||
init()
|
||||
break;
|
||||
case 'clearOrder':
|
||||
getHistoryOrderDetail()
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -458,14 +480,35 @@
|
|||
/**
|
||||
* 清除购物车
|
||||
*/
|
||||
function cleaCart () {
|
||||
let params = {
|
||||
...data.socketData,
|
||||
operate_type:'cleanup',
|
||||
table_code: data.table.tableCode,
|
||||
async function cleaCart (e) {
|
||||
if( e == 'cart' ){
|
||||
let params = {
|
||||
...data.socketData,
|
||||
operate_type:'cleanup',
|
||||
table_code: data.table.tableCode,
|
||||
}
|
||||
console.log('购物车清空菜品参数===',params)
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
} else if ( e == 'allHistoryOrder' ) {
|
||||
await cancelOrder({orderId: data.orderInfo.id, shopId: uni.getStorageSync("shopInfo").id })
|
||||
let params = {
|
||||
...data.socketData,
|
||||
operate_type:'clearOrder',
|
||||
table_code: data.table.tableCode,
|
||||
}
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
initCart()
|
||||
} else {
|
||||
await rmPlaceOrder({orderId: data.orderInfo.id, placeNum: e, shopId: uni.getStorageSync("shopInfo").id })
|
||||
let params = {
|
||||
...data.socketData,
|
||||
operate_type:'clearOrder',
|
||||
table_code: data.table.tableCode,
|
||||
}
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
initCart()
|
||||
}
|
||||
console.log('购物车清空菜品参数===',params)
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -755,7 +798,7 @@
|
|||
selGoods.value = $goods
|
||||
if ($goods.groupType == 1) {
|
||||
data.goodsData = $goods
|
||||
instance.ctx.$refs.taocanModelRef.open()
|
||||
taocanModelRef.value.open()
|
||||
} else {
|
||||
guigeModelData.title = $goods.name
|
||||
const skuMap = returnSelGoodsSkuMap($goods.skuList)
|
||||
|
|
|
|||
|
|
@ -64,26 +64,12 @@
|
|||
const yesterday = $time.getYesterdayTimestamps();
|
||||
const thisWeek = $time.getThisWeekTimestamps();
|
||||
const thisMonth = $time.getThisMonthTimestamps();
|
||||
const thisLastMonth = $time.getThisLastMonthTimestamps()
|
||||
const timeData = reactive({
|
||||
list: [today, yesterday, thisWeek, thisMonth],
|
||||
sel: 0
|
||||
})
|
||||
|
||||
function changeTimeDataSel(i) {
|
||||
timeData.sel = i
|
||||
if (i == -1) {
|
||||
datePicker.value.open()
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => timeData.sel, (newval) => {
|
||||
|
||||
const data = timeData.list[newval]
|
||||
if (newval != -1) {
|
||||
emits('update:time', [data.start, data.end])
|
||||
}
|
||||
})
|
||||
|
||||
const statusData = reactive({
|
||||
allList: uni.$dict.orderStatus,
|
||||
moreShow: false,
|
||||
|
|
@ -116,6 +102,20 @@
|
|||
sel: ''
|
||||
})
|
||||
|
||||
function changeTimeDataSel(i) {
|
||||
timeData.sel = i
|
||||
if (i == -1) {
|
||||
datePicker.value.open()
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => timeData.sel, (newval) => {
|
||||
const data = timeData.list[newval]
|
||||
if (newval != -1) {
|
||||
emits('update:time', [data.start, data.end])
|
||||
}
|
||||
})
|
||||
|
||||
function moreShowHide() {
|
||||
statusData.moreShow = false
|
||||
}
|
||||
|
|
@ -126,21 +126,20 @@
|
|||
|
||||
function changeStatusSel(i) {
|
||||
statusData.sel = i
|
||||
statusData.allListSel = -1
|
||||
emits('updateStatus', i)
|
||||
}
|
||||
|
||||
function datePickerConfirm(e) {
|
||||
console.log(e);
|
||||
emits('update:time', [e.start, e.end])
|
||||
}
|
||||
|
||||
function changeAllListSel(i,item) {
|
||||
statusData.allListSel = i
|
||||
console.log(i);
|
||||
}
|
||||
function statusConfirm(){
|
||||
const status=statusData.allList[statusData.allListSel].type
|
||||
statusData.sel=status
|
||||
const status = statusData.allList[statusData.allListSel].type
|
||||
statusData.sel = status
|
||||
emits('updateStatus',status)
|
||||
moreShowHide()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1000,7 +1000,6 @@
|
|||
uni.$utils.showToast('支付成功')
|
||||
payStatus = 'success'
|
||||
setTimeout(() => {
|
||||
uni.removeStorageSync("table_code")
|
||||
// uni.$emit('orderDetail:update')
|
||||
uni.$emit('get:table')
|
||||
uni.$emit('update:orderDetail')
|
||||
|
|
|
|||
Loading…
Reference in New Issue