Compare commits
3 Commits
68993a05de
...
c28509474d
| Author | SHA1 | Date | |
|---|---|---|---|
| c28509474d | |||
| e37cab4692 | |||
| 21c667312f |
7
http/api/product/stick.js
Normal file
7
http/api/product/stick.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import http from "@/http/http.js";
|
||||
const request = http.request;
|
||||
const urlType = "product";
|
||||
|
||||
export function stickCount(file, data) {
|
||||
return http.upload(`${urlType}/admin/stick/count`,data,file)
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
"pinia-plugin-unistorage": "^0.1.2",
|
||||
"to-arraybuffer": "^1.0.1",
|
||||
"uview-plus": "^3.3.32",
|
||||
"ysk-utils": "^1.0.78"
|
||||
"ysk-utils": "^1.0.82"
|
||||
},
|
||||
"devDependencies": {
|
||||
"copy-webpack-plugin": "^12.0.2",
|
||||
|
||||
@@ -257,6 +257,13 @@
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加临时菜"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "stick/stick",
|
||||
"pageId": "PAGES_CREATE_ORDER_STICK",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -94,6 +94,19 @@
|
||||
></up-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="page-cell m">
|
||||
<view class="label">是否开启数签子</view>
|
||||
<view class="right">
|
||||
<up-switch
|
||||
v-model="vdata.shopInfo.isCountStick"
|
||||
size="20"
|
||||
:inactiveValue="0"
|
||||
:activeValue="1"
|
||||
activeColor="#0FC161"
|
||||
@change="switchChange('isCountStick')"
|
||||
></up-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="page-cell m" style="display: block">
|
||||
<view class="u-flex u-row-between">
|
||||
<view class="label">点餐电子围栏</view>
|
||||
@@ -449,6 +462,9 @@ let switchChange = (type) => {
|
||||
case "isOrderFence":
|
||||
params.isOrderFence = vdata.shopInfo.isOrderFence;
|
||||
break;
|
||||
case "isCountStick":
|
||||
params.isCountStick = vdata.shopInfo.isCountStick;
|
||||
break;
|
||||
}
|
||||
updateShopInfo(params);
|
||||
};
|
||||
|
||||
@@ -169,6 +169,7 @@
|
||||
>
|
||||
<image class="img" :src="item.coverImg" mode=""></image>
|
||||
</view>
|
||||
|
||||
<view
|
||||
style="
|
||||
background-color: #3f9eff;
|
||||
@@ -180,7 +181,7 @@
|
||||
"
|
||||
v-else
|
||||
>
|
||||
临时菜
|
||||
{{ item.name }}
|
||||
</view>
|
||||
<view class="u-m-l-32">
|
||||
<view class="u-flex">
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
<template>
|
||||
<view class="u-wrap">
|
||||
<view
|
||||
class="u-fixed position-all"
|
||||
style="z-index: 999"
|
||||
v-if="!canXiadan"
|
||||
@click="xiadanClick"
|
||||
></view>
|
||||
<view class="u-fixed position-all" style="z-index: 999" v-if="!canXiadan" @click="xiadanClick"></view>
|
||||
<view class="top bg-fff w-full">
|
||||
<template v-if="option.type != 'add'">
|
||||
<view class="u-flex u-row-between choose-user" @tap="chooseTable">
|
||||
@@ -23,93 +18,52 @@
|
||||
|
||||
<view class="search u-flex u-col-center">
|
||||
<view class="u-flex-1">
|
||||
<uni-search-bar
|
||||
bgColor="#F9F9F9"
|
||||
cancelButton="none"
|
||||
placeholder="搜索店内商品"
|
||||
@confirm="search"
|
||||
@clear="clearSearch"
|
||||
v-model="searchValue"
|
||||
></uni-search-bar>
|
||||
<uni-search-bar bgColor="#F9F9F9" cancelButton="none" placeholder="搜索店内商品" @confirm="search"
|
||||
@clear="clearSearch" v-model="searchValue"></uni-search-bar>
|
||||
</view>
|
||||
<view class="u-flex" @click="scanCode">
|
||||
<image
|
||||
src="/pagesCreateOrder/static/images/icon-saoma.svg"
|
||||
class="icon-saoma"
|
||||
mode=""
|
||||
></image>
|
||||
<image src="/pagesCreateOrder/static/images/icon-saoma.svg" class="icon-saoma" mode=""></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<template v-if="!isSearch">
|
||||
<view class="u-menu-wrap">
|
||||
<scroll-view
|
||||
scroll-y
|
||||
scroll-with-animation
|
||||
class="u-tab-view menu-scroll-view"
|
||||
:scroll-top="data.scrollTop"
|
||||
:scroll-into-view="data.itemId"
|
||||
>
|
||||
<view
|
||||
v-for="(item, index) in data.tabbar"
|
||||
:key="index"
|
||||
class="u-tab-item"
|
||||
:class="[data.current == index ? 'u-tab-item-active' : '']"
|
||||
@tap.stop="swichMenu(index)"
|
||||
>
|
||||
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view"
|
||||
:scroll-top="data.scrollTop" :scroll-into-view="data.itemId">
|
||||
<view v-for="(item, index) in data.tabbar" :key="index" class="u-tab-item"
|
||||
:class="[data.current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
|
||||
<text class="u-line-3">{{ item.name }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<scroll-view
|
||||
:scroll-top="data.scrollRightTop"
|
||||
scroll-y
|
||||
scroll-with-animation
|
||||
class="right-box"
|
||||
@scroll="rightScroll"
|
||||
>
|
||||
<scroll-view :scroll-top="data.scrollRightTop" scroll-y scroll-with-animation class="right-box"
|
||||
@scroll="rightScroll">
|
||||
<view class="page-view u-p-l-24">
|
||||
<view class="list-tight-top">
|
||||
<template v-if="lingshi.show">
|
||||
<view id="lingshi" class="lingshi u-m-b-32" @tap="toLinshi">
|
||||
<uni-icons
|
||||
type="plus-filled"
|
||||
size="24"
|
||||
:color="$utils.ColorMain"
|
||||
></uni-icons>
|
||||
<uni-icons type="plus-filled" size="24" :color="$utils.ColorMain"></uni-icons>
|
||||
<view class="u-m-t-24 color-main">临时菜</view>
|
||||
</view>
|
||||
<view id="lingshi" class="lingshi u-m-b-32" @tap="toStick" v-if="shopInfo.isCountStick">
|
||||
<uni-icons type="plus-filled" size="24" :color="$utils.ColorMain"></uni-icons>
|
||||
<view class="u-m-t-24 color-main">拍照数签</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view style="height: 24px"></view>
|
||||
</template>
|
||||
</view>
|
||||
<view
|
||||
class="class-item"
|
||||
:id="'item' + index"
|
||||
v-for="(item, index) in data.tabbar"
|
||||
:key="index"
|
||||
>
|
||||
<view
|
||||
class="item-title"
|
||||
:class="{ active: data.current == index }"
|
||||
>
|
||||
<view class="class-item" :id="'item' + index" v-for="(item, index) in data.tabbar" :key="index">
|
||||
<view class="item-title" :class="{ active: data.current == index }">
|
||||
<text>{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="item-container">
|
||||
<view
|
||||
class="thumb-box"
|
||||
v-for="(goodsItem, goodsIndex) in item.foods"
|
||||
:key="goodsIndex"
|
||||
>
|
||||
<list-goods-item
|
||||
:limitTimeDiscount="data.limitTimeDiscount"
|
||||
<view class="thumb-box" v-for="(goodsItem, goodsIndex) in item.foods" :key="goodsIndex">
|
||||
<list-goods-item :limitTimeDiscount="data.limitTimeDiscount"
|
||||
@chooseGuige="chooseGuige($event, index)"
|
||||
@add="goodsUpdate($event, index, true)"
|
||||
@reduce="goodsUpdate($event, index, false)"
|
||||
@tapweigh="tapweigh($event, index)"
|
||||
:index="goodsIndex"
|
||||
:data="goodsItem"
|
||||
></list-goods-item>
|
||||
@reduce="goodsUpdate($event, index, false)" @tapweigh="tapweigh($event, index)"
|
||||
:index="goodsIndex" :data="goodsItem"></list-goods-item>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -123,77 +77,51 @@
|
||||
<view class="u-p-l-30 u-p-r-30">
|
||||
<view class="u-font-28 color-666">搜索</view>
|
||||
<view class="u-flex u-m-t-20 u-flex-wrap u-row-between">
|
||||
<view
|
||||
class="u-m-b-30"
|
||||
v-for="(goodsItem, goodsIndex) in searchResult"
|
||||
:key="goodsIndex"
|
||||
>
|
||||
<list-goods-item
|
||||
:img="{ width: '330rpx', height: '330rpx' }"
|
||||
:limitTimeDiscount="data.limitTimeDiscount"
|
||||
@chooseGuige="
|
||||
<view class="u-m-b-30" v-for="(goodsItem, goodsIndex) in searchResult" :key="goodsIndex">
|
||||
<list-goods-item :img="{ width: '330rpx', height: '330rpx' }"
|
||||
:limitTimeDiscount="data.limitTimeDiscount" @chooseGuige="
|
||||
chooseGuige(goodsItem.goodsIndex, goodsItem.index)
|
||||
"
|
||||
@add="searchGoodsUpdate(goodsItem, goodsIndex, true)"
|
||||
" @add="searchGoodsUpdate(goodsItem, goodsIndex, true)"
|
||||
@reduce="searchGoodsUpdate(goodsItem, goodsIndex, false)"
|
||||
@tapweigh="tapweigh(goodsItem.goodsIndex, goodsItem.index)"
|
||||
:index="goodsItem.goodsIndex"
|
||||
:data="goodsItem"
|
||||
></list-goods-item>
|
||||
:index="goodsItem.goodsIndex" :data="goodsItem"></list-goods-item>
|
||||
</view>
|
||||
</view>
|
||||
<my-img-empty
|
||||
v-if="!searchResult.length"
|
||||
tips="未搜索到相关商品"
|
||||
></my-img-empty>
|
||||
<my-img-empty v-if="!searchResult.length" tips="未搜索到相关商品"></my-img-empty>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<view class="bottom w-full">
|
||||
<my-car
|
||||
:isCreateOrderToDetail="isCreateOrderToDetail"
|
||||
@updateNumber="carsNumberChange"
|
||||
:table="data.table"
|
||||
:data="cars"
|
||||
:orderInfo="data.orderInfo"
|
||||
:limitTimeDiscount="data.limitTimeDiscount"
|
||||
@clear="cleaCart"
|
||||
></my-car>
|
||||
<my-car :isCreateOrderToDetail="isCreateOrderToDetail" @updateNumber="carsNumberChange" :table="data.table"
|
||||
:data="cars" :orderInfo="data.orderInfo" :limitTimeDiscount="data.limitTimeDiscount"
|
||||
@clear="cleaCart"></my-car>
|
||||
</view>
|
||||
<!-- 套餐选择规格 -->
|
||||
<taocanModel
|
||||
ref="taocanModelRef"
|
||||
@confirm="taocanConfirm"
|
||||
:goodsData="selGoods"
|
||||
></taocanModel>
|
||||
<taocanModel ref="taocanModelRef" @confirm="taocanConfirm" :goodsData="selGoods"></taocanModel>
|
||||
<!-- 选择规格 -->
|
||||
<guige-model
|
||||
@update-sku="updateSkuSel"
|
||||
:limitTimeDiscount="data.limitTimeDiscount"
|
||||
@confirm="guigeConfirm"
|
||||
ref="chooseGuigeModel"
|
||||
:goodsData="selGoods"
|
||||
:title="guigeModelData.title"
|
||||
:sku-map="guigeModelData.chooseGoods.skuMap"
|
||||
:skus="guigeModelData.chooseGoods.skus"
|
||||
></guige-model>
|
||||
<guige-model @update-sku="updateSkuSel" :limitTimeDiscount="data.limitTimeDiscount" @confirm="guigeConfirm"
|
||||
ref="chooseGuigeModel" :goodsData="selGoods" :title="guigeModelData.title"
|
||||
:sku-map="guigeModelData.chooseGoods.skuMap" :skus="guigeModelData.chooseGoods.skus"></guige-model>
|
||||
<!-- 称重 -->
|
||||
<weigh-item ref="refweighitem" @weighgoodsUpdate="goodsUpdate"></weigh-item>
|
||||
<!-- 历史订单按钮 -->
|
||||
<view
|
||||
class="history-button"
|
||||
v-if="data.historyOrderNum > 0 && data.table.id"
|
||||
@click="go.to('PAGES_ORDER_DETAIL', { id: data.orderInfo.id })"
|
||||
>
|
||||
<view class="history-button" v-if="data.historyOrderNum > 0 && data.table.id"
|
||||
@click="go.to('PAGES_ORDER_DETAIL', { id: data.orderInfo.id })">
|
||||
<text>历史订单</text>
|
||||
<text class="num">{{ data.historyOrderNum }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { onLoad, onReady, onShow, onUnload, onHide } from "@dcloudio/uni-app";
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow,
|
||||
onUnload,
|
||||
onHide
|
||||
} from "@dcloudio/uni-app";
|
||||
import {
|
||||
inject,
|
||||
computed,
|
||||
@@ -206,7 +134,9 @@ import {
|
||||
onUnmounted,
|
||||
onBeforeUnmount,
|
||||
} from "vue";
|
||||
|
||||
import {
|
||||
stickCount
|
||||
} from '@/http/api/product/stick.js'
|
||||
import guigeModel from "./components/guige";
|
||||
import taocanModel from "./components/taocanModel.vue";
|
||||
import weighItem from "./components/weigh.vue";
|
||||
@@ -215,21 +145,39 @@ import myCar from "./components/car";
|
||||
|
||||
import util from "./util.js";
|
||||
import go from "@/commons/utils/go.js";
|
||||
import { getNowCart } from "@/pagesCreateOrder/util.js";
|
||||
import {
|
||||
getNowCart
|
||||
} from "@/pagesCreateOrder/util.js";
|
||||
import storageManage from "@/commons/utils/storageManage.js";
|
||||
import { hasPermission } from "@/commons/utils/hasPermission.js";
|
||||
import {
|
||||
hasPermission
|
||||
} from "@/commons/utils/hasPermission.js";
|
||||
// import WebsocketUtil from '@/commons/utils/websocket.js';
|
||||
import yskUtils from "ysk-utils";
|
||||
import { getDiscountByUserId } from "@/http/api/market/consumeDiscount.js";
|
||||
import { limitTimeDiscount } from "@/http/api/market/limitTimeDiscount.js";
|
||||
import {
|
||||
getDiscountByUserId
|
||||
} from "@/http/api/market/consumeDiscount.js";
|
||||
import {
|
||||
limitTimeDiscount
|
||||
} from "@/http/api/market/limitTimeDiscount.js";
|
||||
provide("yskUtils", yskUtils);
|
||||
const shopInfo=uni.getStorageSync("shopInfo");
|
||||
const shopInfo = reactive({}) ;
|
||||
Object.assign(shopInfo,uni.getStorageSync("shopInfo"))
|
||||
provide("shopInfo", uni.getStorageSync("shopInfo"));
|
||||
|
||||
import { getShopTable, getShopTableDetail } from "@/http/api/table.js";
|
||||
import { getProductList } from "@/http/api/product.js";
|
||||
import { categoryPage } from "@/http/api/cateGory.js";
|
||||
import { getShopInfo } from "@/http/api/shop.js";
|
||||
import {
|
||||
getShopTable,
|
||||
getShopTableDetail
|
||||
} from "@/http/api/table.js";
|
||||
import {
|
||||
getProductList
|
||||
} from "@/http/api/product.js";
|
||||
import {
|
||||
categoryPage
|
||||
} from "@/http/api/cateGory.js";
|
||||
import {
|
||||
getShopInfo
|
||||
} from "@/http/api/shop.js";
|
||||
import {
|
||||
getHistoryOrder,
|
||||
cancelOrder,
|
||||
@@ -333,6 +281,7 @@ onLoad(async (opt) => {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// init()
|
||||
xiadanClick();
|
||||
});
|
||||
@@ -391,10 +340,16 @@ async function init() {
|
||||
if (option.type == "add") {
|
||||
setTabBar($category, $originGoods, []);
|
||||
}
|
||||
let shopInfo = await getShopInfo({ id: uni.getStorageSync("shopInfo").id });
|
||||
uni.setStorageSync("shopInfo", shopInfo);
|
||||
let shopInfoRes = await getShopInfo({
|
||||
id: uni.getStorageSync("shopInfo").id
|
||||
});
|
||||
Object.assign(shopInfo,shopInfoRes)
|
||||
uni.setStorageSync("shopInfo", shopInfoRes);
|
||||
// 获取分类数据
|
||||
let categoryRes = await categoryPage({ page: 1, size: 300 });
|
||||
let categoryRes = await categoryPage({
|
||||
page: 1,
|
||||
size: 300
|
||||
});
|
||||
$category = categoryRes.records;
|
||||
// 获取商品数据
|
||||
const goodsRes = await getGoods();
|
||||
@@ -427,7 +382,9 @@ async function getHistoryOrderDetail() {
|
||||
return
|
||||
}
|
||||
data.historyOrder = [];
|
||||
let res = await getHistoryOrder({ tableCode: data.table.tableCode });
|
||||
let res = await getHistoryOrder({
|
||||
tableCode: data.table.tableCode
|
||||
});
|
||||
data.orderInfo = res;
|
||||
if (res) {
|
||||
data.historyOrder = Object.entries(data.orderInfo.detailMap).map(
|
||||
@@ -801,15 +758,17 @@ async function goodsUpdate(
|
||||
let $goods = data.tabbar[index].foods[foodsindex];
|
||||
|
||||
if (is_time_discount === undefined) {
|
||||
is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount(
|
||||
{ ...$goods, salePrice: $goods.lowPrice },
|
||||
is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount({
|
||||
...$goods,
|
||||
salePrice: $goods.lowPrice
|
||||
},
|
||||
data.limitTimeDiscount,
|
||||
shopInfo,
|
||||
null,
|
||||
"id"
|
||||
)
|
||||
? 1
|
||||
: 0;
|
||||
) ?
|
||||
1 :
|
||||
0;
|
||||
}
|
||||
if ($goods.type !== "sku") {
|
||||
//单规格
|
||||
@@ -840,8 +799,7 @@ async function goodsUpdate(
|
||||
number = Number(showCurrentInput);
|
||||
}
|
||||
|
||||
editCart(
|
||||
{
|
||||
editCart({
|
||||
id: cartItem.id,
|
||||
suitNum: cartItem.suitNum || 1,
|
||||
number: number,
|
||||
@@ -870,8 +828,7 @@ async function goodsUpdate(
|
||||
// 套餐和单规格
|
||||
if ($goods.groupType != 1) {
|
||||
//增加
|
||||
editCart(
|
||||
{
|
||||
editCart({
|
||||
number: suitNum,
|
||||
product_id: product_id,
|
||||
product_type: product_type,
|
||||
@@ -951,14 +908,16 @@ async function carsNumberChange(e) {
|
||||
if (e.goods.is_temporary != 1) {
|
||||
data.tabbar.map((tabbarItem) => {
|
||||
if (tabbarItem.foods.find((v) => v.id == e.goods.product_id)) {
|
||||
$goods = !e.goods.product_id
|
||||
? undefined
|
||||
: tabbarItem.foods.find((v) => v.id == e.goods.product_id);
|
||||
$goods = !e.goods.product_id ?
|
||||
undefined :
|
||||
tabbarItem.foods.find((v) => v.id == e.goods.product_id);
|
||||
}
|
||||
});
|
||||
$sku = !e.goods.product_id
|
||||
? { suitNum: 1 }
|
||||
: $goods.skuList.find((v) => v.id == e.goods.sku_id);
|
||||
$sku = !e.goods.product_id ?
|
||||
{
|
||||
suitNum: 1
|
||||
} :
|
||||
$goods.skuList.find((v) => v.id == e.goods.sku_id);
|
||||
params.suitNum = $sku.suitNum || 1;
|
||||
if (e.num === 0 || e.num < $sku.suitNum) {
|
||||
//移除
|
||||
@@ -985,8 +944,7 @@ async function carsNumberChange(e) {
|
||||
* @param {Object} item
|
||||
*/
|
||||
async function taocanConfirm(d, item) {
|
||||
editCart(
|
||||
{
|
||||
editCart({
|
||||
number: item.skuList[0].suitNum,
|
||||
product_id: item.id,
|
||||
product_type: item.type,
|
||||
@@ -1075,14 +1033,15 @@ async function guigeConfirm(sku, suitNum,is_time_discount) {
|
||||
let res = findGoodsInCar(goods, sku_id);
|
||||
if (res) {
|
||||
//更新
|
||||
let { index } = res;
|
||||
let {
|
||||
index
|
||||
} = res;
|
||||
let carGoods = cars[index];
|
||||
let cartId = carGoods.id;
|
||||
let newNumber = carGoods.number * 1 + suitNum;
|
||||
let suitNum = goods.skuList[0].suitNum || 1;
|
||||
|
||||
editCart(
|
||||
{
|
||||
editCart({
|
||||
id: cartId,
|
||||
number: newNumber,
|
||||
suitNum: carGoods.suitNum || 1,
|
||||
@@ -1097,8 +1056,7 @@ async function guigeConfirm(sku, suitNum,is_time_discount) {
|
||||
data.isGoodsAdd = false;
|
||||
} else {
|
||||
//添加
|
||||
editCart(
|
||||
{
|
||||
editCart({
|
||||
number: suitNum,
|
||||
product_id: product_id,
|
||||
product_type: product_type,
|
||||
@@ -1124,12 +1082,12 @@ function findGoodsInCar($goods, sku_id) {
|
||||
return carsGoods.sku_id == sku_id && carsGoods.product_id == product_id;
|
||||
});
|
||||
const carGoods = cars[goodsInCarIndex];
|
||||
return carGoods
|
||||
? {
|
||||
return carGoods ?
|
||||
{
|
||||
index: goodsInCarIndex,
|
||||
carGoods,
|
||||
}
|
||||
: false;
|
||||
} :
|
||||
false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1191,8 +1149,7 @@ function setTagDisabled() {
|
||||
const selArr = skuList.reduce((prve, cur) => {
|
||||
if (cur.sel) {
|
||||
prve.push(cur.sel);
|
||||
} else {
|
||||
}
|
||||
} else {}
|
||||
return prve;
|
||||
}, []);
|
||||
|
||||
@@ -1252,7 +1209,9 @@ function scanCode() {
|
||||
if (res.result.includes("codeplate?code=")) {
|
||||
const par = returnUrlPar(res.result);
|
||||
const tableCode = par.code;
|
||||
let resData = await getShopTableDetail({ tableCode: tableCode });
|
||||
let resData = await getShopTableDetail({
|
||||
tableCode: tableCode
|
||||
});
|
||||
onChooseTable(resData);
|
||||
} else {
|
||||
uni.showToast({
|
||||
@@ -1374,6 +1333,43 @@ function toLinshi() {
|
||||
});
|
||||
}
|
||||
|
||||
function toStick() {
|
||||
uni.chooseImage({
|
||||
count: 1, //默认9
|
||||
sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
|
||||
sourceType: ["album", "camera "],
|
||||
success: async function (res) {
|
||||
uni.showLoading({
|
||||
title: "上传中",
|
||||
});
|
||||
console.log(res);
|
||||
const fileRes = await stickCount(res.tempFiles[0]);
|
||||
console.log(fileRes)
|
||||
uni.hideLoading();
|
||||
if (fileRes) {
|
||||
uni.setStorageSync('stickData',{
|
||||
table:data.table,
|
||||
orderInfo:data.orderInfo
|
||||
})
|
||||
go.to("PAGES_CREATE_ORDER_STICK", {
|
||||
tableCode: data.table.tableCode,
|
||||
number:fileRes,
|
||||
isCreateOrderToDetail:isCreateOrderToDetail.value,
|
||||
limitTimeDiscount:data.limitTimeDiscount
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "上传失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 称重
|
||||
*/
|
||||
@@ -1428,8 +1424,7 @@ function getElRect(elClass, dataVal) {
|
||||
const query = uni.createSelectorQuery().in(instance.proxy);
|
||||
query
|
||||
.select("." + elClass)
|
||||
.fields(
|
||||
{
|
||||
.fields({
|
||||
size: true,
|
||||
},
|
||||
(res) => {
|
||||
@@ -1724,6 +1719,16 @@ $u-main-color: $my-main-color;
|
||||
}
|
||||
}
|
||||
|
||||
.list-tight-top {
|
||||
display: flex;
|
||||
|
||||
.lingshi {
|
||||
margin-right: 24rpx;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.item-menu-name {
|
||||
font-weight: normal;
|
||||
font-size: 24rpx;
|
||||
@@ -1754,6 +1759,7 @@ $u-main-color: $my-main-color;
|
||||
right: 30upx;
|
||||
color: #fff;
|
||||
border-radius: 8upx;
|
||||
|
||||
.num {
|
||||
padding: 0 6px;
|
||||
border-radius: 50px;
|
||||
|
||||
407
pagesCreateOrder/stick/stick.vue
Normal file
407
pagesCreateOrder/stick/stick.vue
Normal file
@@ -0,0 +1,407 @@
|
||||
<template>
|
||||
<view class="min-page bg-f7 u-font-28 color-333 u-p-30">
|
||||
<view v-for="(item,index) in list" :key="index" class="block">
|
||||
<view class="font-bold u-font-32 ">序号{{index+1}}</view>
|
||||
<view class="u-m-t-32">
|
||||
<view class="font-bold u-m-b-14">单价</view>
|
||||
<view class="u-flex ">
|
||||
<up-input type="digit" placeholder="请输入单价" v-model="item.salePrice"
|
||||
@blur="salePriceBlur(item)"></up-input>
|
||||
<text class="u-m-l-24">元/根</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-32">
|
||||
<view class="font-bold u-m-b-14">数量</view>
|
||||
<up-input type="number" placeholder="请输入数量" v-model="item.number" @blur="numberBlur(item)"></up-input>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bottom">
|
||||
<view class="font-bold">
|
||||
<text>合计:</text>
|
||||
<text class="color-red">{{totalMoney}}元</text>
|
||||
<text>/</text>
|
||||
<text>{{totalNumber}}根</text>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class="btn main" @click="chooseImage">继续拍照</view>
|
||||
<view class="btn" @click="confirmOrder">下单</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
BigNumber
|
||||
} from "bignumber.js";
|
||||
import {
|
||||
computed,
|
||||
inject,
|
||||
onUnmounted,
|
||||
ref
|
||||
} from 'vue';
|
||||
import {
|
||||
hasPermission
|
||||
} from "@/commons/utils/hasPermission.js";
|
||||
import {
|
||||
stickCount
|
||||
} from '@/http/api/product/stick.js'
|
||||
import {
|
||||
onLoad,
|
||||
onShow,
|
||||
onHide
|
||||
} from '@dcloudio/uni-app'
|
||||
import go from "@/commons/utils/go.js";
|
||||
import {
|
||||
createOrder,
|
||||
getHistoryOrder
|
||||
} from "@/http/api/order.js";
|
||||
|
||||
|
||||
const websocketUtil = inject("websocketUtil"); // 注入 WebSocket 工具类实例
|
||||
const totalMoney = computed(() => {
|
||||
return list.value.reduce((prve, cur) => {
|
||||
return prve.plus(BigNumber(cur.number || 0).times(cur.salePrice || 0))
|
||||
}, BigNumber(0)).toNumber()
|
||||
})
|
||||
const totalNumber = computed(() => {
|
||||
return list.value.reduce((prve, cur) => {
|
||||
return prve.plus(BigNumber(cur.number || 0))
|
||||
}, BigNumber(0)).toNumber()
|
||||
})
|
||||
|
||||
function chooseImage() {
|
||||
uni.chooseImage({
|
||||
count: 1, //默认9
|
||||
sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
|
||||
sourceType: ["album", "camera "],
|
||||
success: async function(res) {
|
||||
uni.showLoading({
|
||||
title: "上传中",
|
||||
});
|
||||
console.log(res);
|
||||
const fileRes = await stickCount(res.tempFiles[0]);
|
||||
uni.hideLoading();
|
||||
if (fileRes) {
|
||||
list.value.push({
|
||||
number: fileRes,
|
||||
salePrice: 0
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "上传失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
const list = ref([])
|
||||
const options = {}
|
||||
|
||||
function salePriceBlur(item) {
|
||||
console.log('item', item)
|
||||
if (item.salePrice * 1 <= 0) {
|
||||
item.salePrice = 0
|
||||
}
|
||||
if (item.salePrice.split('.')[1] && item.salePrice.split('.')[1].length > 2) {
|
||||
item.salePrice = Number(item.salePrice).toFixed(2)
|
||||
}
|
||||
}
|
||||
|
||||
function numberBlur(item) {
|
||||
if (item.number * 1 <= 0) {
|
||||
item.number = 0
|
||||
}
|
||||
if (item.number.split('.')[1] && item.number.split('.')[1].length >= 1) {
|
||||
item.number = Number(item.number.split('.')[0])
|
||||
}
|
||||
}
|
||||
|
||||
function init(opt) {
|
||||
Object.assign(options, opt)
|
||||
initCart()
|
||||
if (opt.number) {
|
||||
list.value = [{
|
||||
number: opt.number,
|
||||
salePrice: 0
|
||||
}]
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 初始化购物车
|
||||
*/
|
||||
function initCart() {
|
||||
let params = {
|
||||
type: "onboc",
|
||||
account: uni.getStorageSync("iToken").loginId,
|
||||
shop_id: uni.getStorageSync("shopInfo").id,
|
||||
operate_type: "init",
|
||||
table_code: options.tableCode,
|
||||
};
|
||||
console.log("购物车初始化参数===", params);
|
||||
websocketUtil.send(JSON.stringify(params));
|
||||
}
|
||||
/**
|
||||
* socket消息监听
|
||||
*/
|
||||
|
||||
let hasReciveMsgLen = 0
|
||||
|
||||
function onMessage() {
|
||||
websocketUtil.offMessage();
|
||||
websocketUtil.onMessage(async (res) => {
|
||||
let msg = JSON.parse(res);
|
||||
if (msg.msg_id) {
|
||||
websocketUtil.send(
|
||||
JSON.stringify({
|
||||
type: "receipt",
|
||||
msg_id: msg.msg_id,
|
||||
})
|
||||
);
|
||||
}
|
||||
if (statWatchMsg && msg.operate_type == "onboc_add") {
|
||||
if (sendMsgsku_names.value.find(v => msg.data.sku_name == v)) {
|
||||
hasReciveMsgLen++
|
||||
}
|
||||
}
|
||||
if (statWatchMsg && hasReciveMsgLen) {
|
||||
createAnOrder()
|
||||
hasReciveMsgLen = 0
|
||||
statWatchMsg = false;
|
||||
sendMsgsku_names.value = []
|
||||
}
|
||||
console.log('msg', msg)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
let sendMsgsku_names = ref([])
|
||||
let statWatchMsg = false
|
||||
|
||||
function confirmOrder() {
|
||||
const isPas = list.value.every(v => {
|
||||
if (!v.number) {
|
||||
return false
|
||||
}
|
||||
if (v.salePrice < 0) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
if (!isPas) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的数量和单价',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
statWatchMsg = true;
|
||||
for (let item of list.value) {
|
||||
const shop_id = uni.getStorageSync("shopInfo").id
|
||||
const roundNum = Math.floor(Math.random() * 10)
|
||||
const roundNum1 = Math.floor(Math.random() * 1000)
|
||||
const sku_name = `签子_${roundNum}_${shop_id}_${options.tableCode}_${roundNum1}`
|
||||
sendMsgsku_names.value.push(sku_name)
|
||||
websocketUtil.send(
|
||||
JSON.stringify({
|
||||
account: uni.getStorageSync("iToken").loginId,
|
||||
shop_id,
|
||||
type: "onboc",
|
||||
operate_type: "add",
|
||||
table_code: options.tableCode,
|
||||
product_name: '签子',
|
||||
is_gift: 0,
|
||||
pack_number: 0,
|
||||
discount_sale_amount: item.salePrice,
|
||||
number: item.number * 1,
|
||||
sku_name,
|
||||
is_temporary: 1, //是否是临时菜
|
||||
is_qz: 1
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
// createAnOrder()
|
||||
// toConfimOrder()
|
||||
}, 200)
|
||||
}
|
||||
|
||||
|
||||
async function createAnOrder() {
|
||||
const shopInfo = uni.getStorageSync('shopInfo')
|
||||
if (
|
||||
shopInfo.registerType == "before"
|
||||
) {
|
||||
const canJiesuan = await hasPermission("允许收款");
|
||||
if (!canJiesuan) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const stickData = uni.getStorageSync('stickData')
|
||||
const orderInfo = stickData.orderInfo
|
||||
|
||||
let placeNum = orderInfo ? orderInfo.placeNum + 1 : 1;
|
||||
let par = {
|
||||
shopId: shopInfo.id, //店铺Id
|
||||
userId: '', //用户Id
|
||||
tableCode: options.tableCode, //台桌编码
|
||||
dineMode: 'dine-in', //用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
|
||||
remark: '', //备注
|
||||
seatNum: 0, //用餐人数
|
||||
packFee: 0, //打包费
|
||||
originAmount: 0, //订单原金额(不包含打包费+餐位费)
|
||||
placeNum: placeNum, //当前订单下单次数
|
||||
waitCall: 0, //是否等叫 0 否 1 等叫
|
||||
vipPrice: 0, //是否使用会员价
|
||||
limitRate: stickData.limitTimeDiscount,
|
||||
};
|
||||
|
||||
if (stickData.orderInfo && shopInfo.registerType != "before") {
|
||||
par.orderId = stickData.orderInfo.id;
|
||||
}
|
||||
let res = null;
|
||||
res = await createOrder(par);
|
||||
console.log(res, "创建订单");
|
||||
if (!res) {
|
||||
uni.showToast({
|
||||
title: res.msg || "创建订单失败!",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.$emit("update:createOrderIndex");
|
||||
websocketUtil.send(
|
||||
JSON.stringify({
|
||||
type: "onboc",
|
||||
account: uni.getStorageSync("iToken").loginId,
|
||||
shop_id: uni.getStorageSync("shopInfo").id,
|
||||
operate_type: "cleanup",
|
||||
table_code: stickData.table.tableCode,
|
||||
})
|
||||
);
|
||||
uni.removeStorageSync("table_code");
|
||||
|
||||
if (
|
||||
shopInfo.registerType == "before"
|
||||
) {
|
||||
//先付
|
||||
return go.to(
|
||||
"PAGES_ORDER_DETAIL", {
|
||||
id: res.id || stickData.orderInfo.id,
|
||||
dinnerType: 'dine-in',
|
||||
},
|
||||
"redirect"
|
||||
);
|
||||
} else {
|
||||
if (!res.id && stickData.orderInfo.id) {
|
||||
return go.to(
|
||||
"PAGES_ORDER_PAY", {
|
||||
orderId: stickData.orderInfo.id,
|
||||
isNowPay: true,
|
||||
dinnerType: 'dine-in',
|
||||
},
|
||||
"redirect"
|
||||
);
|
||||
}
|
||||
//后付
|
||||
if (options.isCreateOrderToDetail != "0") {
|
||||
go.to(
|
||||
"PAGES_ORDER_DETAIL", {
|
||||
id: res.id || stickData.orderInfo.id,
|
||||
dinnerType: 'dine-in',
|
||||
},
|
||||
"redirect"
|
||||
);
|
||||
} else {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
}
|
||||
}
|
||||
uni.showToast({
|
||||
title: "提交成功",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
|
||||
function toConfimOrder() {
|
||||
const stickData = uni.getStorageSync('stickData')
|
||||
console.log(stickData);
|
||||
const {
|
||||
name,
|
||||
status,
|
||||
type
|
||||
} = stickData.table;
|
||||
|
||||
|
||||
let shopInfo = uni.getStorageSync("shopInfo");
|
||||
|
||||
go.to("PAGES_CONFIRM_ORDER", {
|
||||
type: type,
|
||||
tableId: stickData.table.id,
|
||||
tableCode: stickData.table.tableCode,
|
||||
name: name,
|
||||
status: status,
|
||||
isCreateOrderToDetail: options.isCreateOrderToDetail ? 1 : 0,
|
||||
});
|
||||
}
|
||||
|
||||
onLoad(init)
|
||||
|
||||
onHide(() => {
|
||||
console.log("onHide");
|
||||
websocketUtil.offMessage();
|
||||
});
|
||||
onShow(() => {
|
||||
onMessage();
|
||||
})
|
||||
onUnmounted(() => {
|
||||
console.log("onUnmounted");
|
||||
websocketUtil.offMessage();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.block {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 32rpx 28rpx;
|
||||
margin-bottom: 32rpx;
|
||||
|
||||
}
|
||||
|
||||
.bottom {
|
||||
display: flex;
|
||||
padding: 24rpx 32rpx;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding-bottom: 40rpx;
|
||||
background-color: #fff;
|
||||
z-index: 10;
|
||||
|
||||
.btn {
|
||||
padding: 16rpx 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #f2f2f2;
|
||||
margin-left: 24rpx;
|
||||
min-width: 188rpx;
|
||||
text-align: center;
|
||||
|
||||
&.main {
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<image v-if="item.isTemporary == 0" class="img" :src="item.coverImg||item.productImg" mode=""></image>
|
||||
<view v-else style="background-color: #3f9eff; width: 152rpx;height: 152rpx;line-height: 152rpx;text-align: center;color: #fff;" >
|
||||
临时菜
|
||||
{{item.name||item.productName||'临时菜'}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-p-l-32 u-flex-1">
|
||||
|
||||
1455
pnpm-lock.yaml
generated
1455
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user