代码更新
This commit is contained in:
@@ -29,10 +29,7 @@
|
||||
<picker @change="categoryChange" :value="categoryCurrent" range-key="name" :range="category">
|
||||
<view class=" u-flex u-row-between border-bottom u-relative ">
|
||||
<view class="zhezhao u-absolute position-all" style="z-index: 1;"></view>
|
||||
<!-- <view>
|
||||
<text class="" v-if="form.category!==''">{{category[form.category].name}}</text>
|
||||
<text class="color-999 " v-else>选择分类</text>
|
||||
</view> -->
|
||||
|
||||
<view class="u-flex-1">
|
||||
<uni-easyinput :inputBorder="false" paddingNone v-model="form.category"
|
||||
placeholder="选择分类"></uni-easyinput>
|
||||
@@ -111,26 +108,12 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
returnAllCategory
|
||||
} from '@/pageProduct/util.js'
|
||||
import {
|
||||
$tbShopCategory,
|
||||
$tbShopUnit
|
||||
} from '@/http/yskApi/goods.js'
|
||||
import {
|
||||
$temporaryDishes
|
||||
} from '@/http/yskApi/Instead.js'
|
||||
import {
|
||||
reactive,
|
||||
onMounted,
|
||||
ref,
|
||||
onBeforeMount,
|
||||
} from 'vue';
|
||||
import {
|
||||
onLoad,
|
||||
onShow
|
||||
} from '@dcloudio/uni-app'
|
||||
import { reactive, onMounted, ref, onBeforeMount } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { getCategoryList, getProdUnitList } from '@/api/product.js'
|
||||
import { inject } from 'vue';
|
||||
|
||||
const websocketUtil = inject('websocketUtil'); // 注入 WebSocket 工具类实例
|
||||
const units = reactive({
|
||||
list: [],
|
||||
current: ''
|
||||
@@ -138,17 +121,6 @@
|
||||
let category = reactive([])
|
||||
let categoryCurrent = ref('')
|
||||
|
||||
function categoryChange(e) {
|
||||
console.log(e);
|
||||
categoryCurrent.value = e.detail.value
|
||||
form.category = category[e.detail.value].name
|
||||
}
|
||||
|
||||
function unitChange(e) {
|
||||
units.current = e.detail.value
|
||||
form.unit = units.list[e.detail.value].name
|
||||
}
|
||||
|
||||
const refform = ref(null)
|
||||
const form = reactive({
|
||||
name: '',
|
||||
@@ -191,97 +163,107 @@
|
||||
},
|
||||
}
|
||||
let timer = null
|
||||
|
||||
const option = reactive({
|
||||
|
||||
})
|
||||
onLoad((opt) => {
|
||||
Object.assign(option, opt)
|
||||
setTimeout(() => {
|
||||
getTbShopUnit()
|
||||
getCategory()
|
||||
}, 600)
|
||||
})
|
||||
|
||||
onBeforeMount(() => {
|
||||
clearInterval(timer)
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取单位数据
|
||||
*/
|
||||
async function getTbShopUnit() {
|
||||
const res = await getProdUnitList({
|
||||
page: 1,
|
||||
size: 200,
|
||||
sort: "id"
|
||||
})
|
||||
units.list = res.map(v => {
|
||||
return {
|
||||
...v,
|
||||
value: v.id
|
||||
}
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 获取分类数据
|
||||
*/
|
||||
async function getCategory() {
|
||||
const res = await getCategoryList({
|
||||
page: 1,
|
||||
size: 600
|
||||
})
|
||||
category = res.map(v => {
|
||||
return {
|
||||
...v,
|
||||
value: v.id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function categoryChange(e) {
|
||||
categoryCurrent.value = e.detail.value
|
||||
form.category = category[e.detail.value].name
|
||||
}
|
||||
|
||||
function unitChange(e) {
|
||||
units.current = e.detail.value
|
||||
form.unit = units.list[e.detail.value].name
|
||||
}
|
||||
|
||||
|
||||
function submit() {
|
||||
refform.value.validate(res => {
|
||||
console.log(res)
|
||||
if (!res) {
|
||||
$temporaryDishes({
|
||||
"useType": option.useType,
|
||||
"masterId": option.masterId,
|
||||
"tableId": option.tableId,
|
||||
"name": form.name,
|
||||
"categoryId": category[categoryCurrent.value].id,
|
||||
"price": form.price,
|
||||
"num": form.num,
|
||||
unit: units.list[units.current].id,
|
||||
"note": form.note,
|
||||
"vipUserId": option.vipUserId
|
||||
}).then(r => {
|
||||
uni.$emit('add:cashCai')
|
||||
clearInterval(timer)
|
||||
timer = setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 500)
|
||||
let params = {
|
||||
type:'onboc',
|
||||
account: uni.getStorageSync("iToken").loginId,
|
||||
shop_id: uni.getStorageSync("shopInfo").id,
|
||||
operate_type: 'add',
|
||||
table_code: option.tableCode,
|
||||
product_name: form.name,
|
||||
sku_name: form.category, //
|
||||
number: form.num, //数量
|
||||
discount_sale_amount: form.price, //数量
|
||||
pack_number: 0, //数量
|
||||
is_gift: 0,
|
||||
is_temporary: 1, //是否是临时菜
|
||||
}
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
|
||||
uni.$emit('add:cashCai',{
|
||||
name: form.name,
|
||||
lowPrice: form.price,
|
||||
number: form.num,
|
||||
is_temporary: 1, //是否是临时菜
|
||||
})
|
||||
clearInterval(timer)
|
||||
timer = setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 500)
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
//获取单位数据
|
||||
async function getTbShopUnit() {
|
||||
const res = await $tbShopUnit({
|
||||
page: 0,
|
||||
size: 200,
|
||||
sort: "id"
|
||||
})
|
||||
units.list = res.content.map(v => {
|
||||
return {
|
||||
...v,
|
||||
value: v.id
|
||||
}
|
||||
})
|
||||
}
|
||||
async function getCategory() {
|
||||
const res = await $tbShopCategory({
|
||||
page: 0,
|
||||
size: 600
|
||||
})
|
||||
const arr = forList(res.content).map(v => {
|
||||
return {
|
||||
...v,
|
||||
value: v.id
|
||||
}
|
||||
})
|
||||
category.length = arr.length
|
||||
for (let i in arr) {
|
||||
category[i] = arr[i]
|
||||
}
|
||||
}
|
||||
|
||||
function forList(arr) {
|
||||
let arrs = []
|
||||
arr.forEach(ele => {
|
||||
arrs.push(ele)
|
||||
if (ele.childrenList.length) {
|
||||
ele.childrenList.forEach(res => {
|
||||
arrs.push(res)
|
||||
})
|
||||
}
|
||||
})
|
||||
return arrs
|
||||
}
|
||||
async function init() {
|
||||
getTbShopUnit()
|
||||
getCategory()
|
||||
}
|
||||
// onMounted(() => {
|
||||
// init()
|
||||
// })
|
||||
onLoad((opt) => {
|
||||
Object.assign(option, opt)
|
||||
setTimeout(() => {
|
||||
init()
|
||||
}, 600)
|
||||
})
|
||||
|
||||
|
||||
onBeforeMount(() => {
|
||||
clearInterval(timer)
|
||||
})
|
||||
const option = reactive({
|
||||
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -67,53 +67,113 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
$table,
|
||||
$tableArea
|
||||
} from '@/http/yskApi/table.js'
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import {
|
||||
$status
|
||||
} from '@/commons/table-status.js'
|
||||
import {
|
||||
onLoad
|
||||
} from '@dcloudio/uni-app'
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { $status } from '@/commons/table-status.js'
|
||||
|
||||
import { getShopTable } from '@/api/table.js'
|
||||
import { getShopArea} from '@/api/area.js'
|
||||
|
||||
let nouser = ref(false)
|
||||
|
||||
function returnStutasText(key) {
|
||||
const item = $status[key]
|
||||
return item ? item.label : ''
|
||||
}
|
||||
|
||||
function returnStutasColor(key) {
|
||||
// if(key=='using'){
|
||||
// return 'rgb(250,85,85)'
|
||||
// }else{
|
||||
// return ''
|
||||
// }
|
||||
const item = $status[key]
|
||||
return item ? item.type : ''
|
||||
}
|
||||
|
||||
function emitChooeTable(data) {
|
||||
uni.$emit('choose-table', data)
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 100)
|
||||
|
||||
|
||||
//分类
|
||||
const area = reactive({
|
||||
list: [{
|
||||
name: '全部'
|
||||
}],
|
||||
defaultCateIndex: 0,
|
||||
sel: ''
|
||||
})
|
||||
const query = {
|
||||
page: 1,
|
||||
size: 10,
|
||||
areaId: 0,
|
||||
totalElements:0
|
||||
}
|
||||
const tables = reactive({
|
||||
hasAjax: false,
|
||||
selIndex: -1,
|
||||
list: []
|
||||
})
|
||||
let searchValue = ref('')
|
||||
|
||||
let option = {}
|
||||
watch(() => area.sel, (newval) => {
|
||||
getTable()
|
||||
})
|
||||
onLoad(opt => {
|
||||
Object.assign(option, opt)
|
||||
console.log(option);
|
||||
getTable()
|
||||
getArea()
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取桌台列表
|
||||
*/
|
||||
async function getTable() {
|
||||
const areaId=area.list[area.defaultCateIndex].id||''
|
||||
let res = await getShopTable({...query,areaId,name:searchValue.value,status:'idle'})
|
||||
tables.list = res.records
|
||||
tables.selIndex = res.records.findIndex(v => v.tableId == option.tableId)
|
||||
query.totalElements= res.totalRow;
|
||||
tables.hasAjax = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区域列表
|
||||
*/
|
||||
async function getArea() {
|
||||
const res = await getShopArea({
|
||||
page: 1,
|
||||
size: 300
|
||||
})
|
||||
res.records.unshift({
|
||||
name: '全部'
|
||||
})
|
||||
area.list = res.records.map(v => {
|
||||
return {
|
||||
...v,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function search() {
|
||||
query.page=1
|
||||
getTable()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 桌台状态显示处理
|
||||
* @param {Object} key
|
||||
*/
|
||||
function returnStutasText(key) {
|
||||
const item = $status[key]
|
||||
return item ? item.label : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 桌台颜色显示处理
|
||||
* @param {Object} key
|
||||
*/
|
||||
function returnStutasColor(key) {
|
||||
const item = $status[key]
|
||||
return item ? item.type : ''
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 桌台选择
|
||||
* @param {Object} index
|
||||
* @param {Object} item
|
||||
*/
|
||||
function chooseTable(index, item) {
|
||||
if (item.status == 'closed') {
|
||||
if (item.status == 'done') {
|
||||
return uni.showToast({
|
||||
title: '该桌台已关闭!',
|
||||
icon: 'none'
|
||||
@@ -127,83 +187,31 @@
|
||||
emitChooeTable(item)
|
||||
}
|
||||
}
|
||||
|
||||
function emitChooeTable(data) {
|
||||
uni.$emit('choose-table', data)
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 100)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//分类
|
||||
const area = reactive({
|
||||
list: [{
|
||||
name: '全部'
|
||||
}],
|
||||
defaultCateIndex: 0,
|
||||
sel: ''
|
||||
})
|
||||
|
||||
/**
|
||||
* 区域修改
|
||||
* @param {Object} e
|
||||
*/
|
||||
function areaChange(e) {
|
||||
area.defaultCateIndex = e.detail.value
|
||||
area.sel = area.list[e.detail.value]
|
||||
query.page=1
|
||||
query.page = 1
|
||||
getTable()
|
||||
}
|
||||
const query = {
|
||||
page: 1,
|
||||
size: 10,
|
||||
areaId: 0,
|
||||
totalElements:0
|
||||
}
|
||||
|
||||
// 页数改变事件
|
||||
function pageChange(page) {
|
||||
console.log(page);
|
||||
query.page = page
|
||||
getTable()
|
||||
}
|
||||
const tables = reactive({
|
||||
hasAjax: false,
|
||||
selIndex: -1,
|
||||
originList: [],
|
||||
list: []
|
||||
})
|
||||
async function getTable() {
|
||||
// let state=status.list[status.active].key
|
||||
// state=state?(state=='all'?'':state):''
|
||||
const areaId=area.list[area.defaultCateIndex].id||''
|
||||
let {
|
||||
content,total
|
||||
} = await $table.get({...query,areaId,name:searchValue.value,state:'idle'})
|
||||
query.totalElements=total||0;
|
||||
tables.hasAjax = true;
|
||||
console.log(content);
|
||||
tables.list = content
|
||||
tables.selIndex = content.findIndex(v => v.tableId == option.tableId)
|
||||
tables.originList = content
|
||||
}
|
||||
async function getArea() {
|
||||
const {
|
||||
content
|
||||
} = await $tableArea.get({
|
||||
page: 0,
|
||||
size: 300
|
||||
})
|
||||
content.unshift({
|
||||
name: '全部'
|
||||
})
|
||||
area.list = content.map(v => {
|
||||
return {
|
||||
...v,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
watch(() => area.sel, (newval) => {
|
||||
getTable()
|
||||
})
|
||||
let option = {}
|
||||
onLoad(opt => {
|
||||
Object.assign(option, opt)
|
||||
console.log(option);
|
||||
getTable()
|
||||
getArea()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<view class="u-flex">
|
||||
<view>{{item.nickName}}</view>
|
||||
</view>
|
||||
<view class="u-m-t-12 ">手机号:{{item.telephone}}</view>
|
||||
<view class="u-m-t-12 ">手机号:{{item.phone}}</view>
|
||||
<view class=" u-font-24 u-m-t-12 u-flex">
|
||||
<text class="color-999" v-if="!item.isVip">非会员</text>
|
||||
<text class="color-main" v-else>会员</text>
|
||||
@@ -63,28 +63,49 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import * as Api from '@/http/yskApi/shop-user.js'
|
||||
import {
|
||||
onLoad
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
reactive,
|
||||
onBeforeMount,
|
||||
ref
|
||||
} from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { reactive, onBeforeMount, ref } from 'vue';
|
||||
import { shopUserList } from '@/api/shopUser.js';
|
||||
|
||||
let nouser = ref(false)
|
||||
let timer = null
|
||||
|
||||
function emitChooser(data) {
|
||||
uni.$emit('choose-user', data)
|
||||
timer = setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 100)
|
||||
}
|
||||
onBeforeMount(() => {
|
||||
clearInterval(timer)
|
||||
})
|
||||
|
||||
const query = reactive({
|
||||
page: 1,
|
||||
name: '',
|
||||
totalElements: 0,
|
||||
size: 10,
|
||||
isVip: 1
|
||||
})
|
||||
const list = reactive([])
|
||||
let hasAjax = ref(false)
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
async function getUser() {
|
||||
const res = await shopUserList(query)
|
||||
hasAjax.value = true
|
||||
list.length = res.records.length
|
||||
for (let i in res.records) {
|
||||
list[i] = {
|
||||
...res.records[i],
|
||||
checked: false
|
||||
}
|
||||
}
|
||||
query.totalElements = res.totalRow
|
||||
console.log(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户选择
|
||||
* @param {Object} index
|
||||
* @param {Object} item
|
||||
*/
|
||||
function chooseUser(index, item) {
|
||||
if (index === undefined || item === undefined) {
|
||||
nouser.value = true
|
||||
@@ -100,33 +121,12 @@
|
||||
emitChooser(item)
|
||||
}
|
||||
}
|
||||
|
||||
const query = reactive({
|
||||
page: 1,
|
||||
name: '',
|
||||
totalElements: 0,
|
||||
size: 10,
|
||||
isVip: 1
|
||||
})
|
||||
const list = reactive([])
|
||||
let hasAjax = ref(false)
|
||||
async function getUser() {
|
||||
const {
|
||||
content,
|
||||
totalElements
|
||||
} = await Api.queryAllShopUser(query)
|
||||
hasAjax.value = true
|
||||
list.length = content.length
|
||||
for (let i in content) {
|
||||
list[i] = {
|
||||
...content[i],
|
||||
checked: false
|
||||
}
|
||||
}
|
||||
query.totalElements = totalElements
|
||||
console.log(list);
|
||||
function emitChooser(data) {
|
||||
uni.$emit('choose-user', data)
|
||||
timer = setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 100)
|
||||
}
|
||||
|
||||
function pageChange(e) {
|
||||
query.page = e
|
||||
getUser()
|
||||
|
||||
@@ -99,8 +99,7 @@
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
function confirm() {
|
||||
const {remark
|
||||
} = form
|
||||
const { remark } = form
|
||||
emits('confirm', {
|
||||
remark
|
||||
})
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@
|
||||
<!-- 占位 -->
|
||||
<view class="u-p-t-32 color-666 border-bottom u-p-r-28 u-p-b-32 u-p-l-28 u-flex u-row-between"
|
||||
style="opacity: 0;">
|
||||
<view>已添加{{goodsNumber}}件商品</view>
|
||||
<view>已添加{{goodsNumber.toFixed(0)}}件商品</view>
|
||||
<view class="color-666">
|
||||
<uni-icons color="#666" type="trash"></uni-icons>
|
||||
<text class="u-m-l-10">清空</text>
|
||||
@@ -30,13 +30,13 @@
|
||||
<view class="u-m-t-10 u-font-24 color-666 u-line-1">{{item.specSnap||''}}</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class="font-bold red u-m-r-32">¥{{formatPrice(item.salePrice*item.number) }}</view>
|
||||
<view class="font-bold red u-m-r-32">¥{{formatPrice(item.lowPrice*item.number) }}</view>
|
||||
<view class="u-flex" @tap="updateNumber(false,index,item)">
|
||||
<image src="/pagesCreateOrder/static/images/icon-reduce-black.svg" class="icon" mode="">
|
||||
</image>
|
||||
</view>
|
||||
<view class="u-m-l-30 u-m-r-30 color-333">
|
||||
{{(item.number).toFixed(2)}}
|
||||
{{item.number.toFixed(2)}}
|
||||
</view>
|
||||
<view class="u-flex" @tap="updateNumber(true,index,item)">
|
||||
<image src="/pagesCreateOrder/static/images/icon-add-black.svg" class="icon" mode="">
|
||||
@@ -107,10 +107,6 @@
|
||||
tableId: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
masterId: {
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
const modal = reactive({
|
||||
@@ -125,9 +121,9 @@
|
||||
}
|
||||
|
||||
function setModalShow(key = 'show', show = true) {
|
||||
if (key == 'clear' && show && props.data.length <= 0) {
|
||||
return infoBox.showToast('购物车是空的!')
|
||||
}
|
||||
// if (key == 'clear' && show && props.data.length <= 0) {
|
||||
// return infoBox.showToast('购物车是空的!')
|
||||
// }
|
||||
modal.key = key
|
||||
modal[key] = show
|
||||
console.log(modal);
|
||||
@@ -153,38 +149,36 @@
|
||||
}
|
||||
|
||||
function toConfimOrder() {
|
||||
console.log(props.user);
|
||||
console.log(props.table);
|
||||
if (props.data.length <= 0) {
|
||||
return infoBox.showToast('还没有选择商品')
|
||||
}
|
||||
const {
|
||||
tableId,
|
||||
name,
|
||||
maxCapacity,
|
||||
status,
|
||||
type
|
||||
} = props.table
|
||||
if (props.table.tableId == '') {
|
||||
|
||||
if (props.table.id == '') {
|
||||
go.to('PAGES_CONFIRM_ORDER', {
|
||||
masterId: props.masterId,
|
||||
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
|
||||
})
|
||||
return
|
||||
}
|
||||
go.to('PAGES_CONFIRM_ORDER', {
|
||||
masterId: props.masterId,
|
||||
type,
|
||||
tableId,
|
||||
name,
|
||||
maxCapacity,
|
||||
status,
|
||||
type: type,
|
||||
tableId: props.table.id,
|
||||
name:name,
|
||||
maxCapacity:maxCapacity,
|
||||
status:status,
|
||||
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
|
||||
})
|
||||
}
|
||||
|
||||
const allPrice = computed(() => {
|
||||
return props.data.reduce((prve, cur) => {
|
||||
return prve + cur.salePrice * cur.number
|
||||
return prve + cur.lowPrice * cur.number
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
|
||||
@@ -193,6 +187,7 @@
|
||||
result = props.data.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
// console.log(result)
|
||||
return result >= 99 ? 99 : result
|
||||
})
|
||||
|
||||
|
||||
@@ -51,12 +51,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
import util from '../util.js';
|
||||
import infobox from '@/commons/utils/infoBox.js'
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
@@ -82,20 +77,15 @@
|
||||
return []
|
||||
}
|
||||
},
|
||||
defaultIndex: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm', 'updateSku'])
|
||||
const model = ref(null)
|
||||
let number = ref(1)
|
||||
function to2(number) {
|
||||
return Number(number).toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
|
||||
const selSku = computed(() => {
|
||||
return props.skus.reduce((prve, cur) => {
|
||||
prve.push(cur.sel)
|
||||
@@ -103,16 +93,13 @@
|
||||
}, []).join()
|
||||
})
|
||||
|
||||
|
||||
const goods = computed(() => {
|
||||
return props.skuMap[selSku.value]
|
||||
})
|
||||
watch(() => goods.value, (newval) => {
|
||||
console.log(props.goodsData.isStock);
|
||||
number.value = newval.suit || 1
|
||||
number.value = newval.suitNum || 1
|
||||
})
|
||||
|
||||
|
||||
const isCanBuy = computed(() => {
|
||||
if (!goods.value) {
|
||||
return false
|
||||
@@ -124,23 +111,22 @@
|
||||
|
||||
})
|
||||
|
||||
//全部规格是否都无法使用
|
||||
/**
|
||||
* 全部规格是否都无法使用
|
||||
*/
|
||||
const isAllDisabled = computed(() => {
|
||||
console.log(props.skus);
|
||||
return props.skus.reduce((prve, cur) => {
|
||||
return prve && cur.values.filter(v => v.disabled).length === cur.values.length
|
||||
}, true)
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm', 'updateSku'])
|
||||
let number = ref(1)
|
||||
|
||||
|
||||
/**
|
||||
* 规格选择
|
||||
* @param {Object} skusIndex
|
||||
* @param {Object} skd
|
||||
*/
|
||||
function chooseSkd(skusIndex, skd) {
|
||||
const {
|
||||
name,
|
||||
disabled
|
||||
} = skd
|
||||
const { name, disabled } = skd
|
||||
if (disabled) {
|
||||
return
|
||||
}
|
||||
@@ -148,50 +134,42 @@
|
||||
emits('updateSku', skusIndex, name)
|
||||
}
|
||||
}
|
||||
const defaultIndex = reactive(new Array(props.skus.length).fill(''))
|
||||
for (let i in props.defaultIndex) {
|
||||
defaultIndex[i] = props.defaultIndex[i]
|
||||
}
|
||||
const activeArr = defaultIndex
|
||||
|
||||
console.log(activeArr);
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁止操作
|
||||
*/
|
||||
const isDisabled = computed(() => {
|
||||
return isAllDisabled.value || !isCanBuy.value
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 数量减少
|
||||
*/
|
||||
function reduce() {
|
||||
if (isDisabled.value) {
|
||||
return
|
||||
}
|
||||
const suit = goods.value.suit || 1
|
||||
const suitNum = goods.value.suitNum || 1
|
||||
const newval = number.value - 1
|
||||
if (newval < suit) {
|
||||
return infobox.showToast(suit + '个起售')
|
||||
if (newval < suitNum) {
|
||||
return infobox.showToast(suitNum + '个起售')
|
||||
}
|
||||
number.value = newval <= 1 ? 1 : newval
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数量增加
|
||||
*/
|
||||
function add() {
|
||||
if (isDisabled.value) {
|
||||
return
|
||||
}
|
||||
const newval = number.value + 1
|
||||
number.value = newval
|
||||
number.value = number.value + 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 都规格选择确认
|
||||
*/
|
||||
function confirm() {
|
||||
close()
|
||||
if (isDisabled.value) {
|
||||
@@ -199,6 +177,15 @@
|
||||
}
|
||||
emits('confirm', goods.value, number.value)
|
||||
}
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
<view class="u-relative u-flex item">
|
||||
|
||||
<up-image :src="data.coverImg" mode="aspectFill" :width="img.width" :height="img.height"></up-image>
|
||||
<!-- <image lazy-load class="img" :src="data.coverImg" mode="aspectFill" :style="computedImgStyle()"></image> -->
|
||||
<view class="info u-flex u-row-between u-col-top u-flex-col">
|
||||
<view>
|
||||
<view>
|
||||
<text class="u-line-2">{{data.name}}
|
||||
</text>
|
||||
<text class="u-line-2">{{data.name}}</text>
|
||||
</view>
|
||||
<view class="u-font-32 font-bold u-m-t-16">
|
||||
¥{{data.price}}
|
||||
¥{{data.lowPrice}}
|
||||
</view>
|
||||
<template v-if="data.type=='weigh'">
|
||||
<view class="btnweigh">称重</view>
|
||||
@@ -18,7 +16,7 @@
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<template v-if="!isSellout">
|
||||
<template v-if="!data.isDan||data.groupType==1">
|
||||
<template v-if="data.type == 'sku'||data.groupType==1">
|
||||
<button class="btn" hover-class="btn-hover-class" @tap="emitEvent('chooseGuige')">选规格</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -84,27 +82,23 @@
|
||||
}
|
||||
})
|
||||
|
||||
function computedImgStyle() {
|
||||
return {
|
||||
width: props.img.width,
|
||||
height: props.img.height
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否是菜品
|
||||
/**
|
||||
* 判断是否是菜品
|
||||
*/
|
||||
function isGoods() {
|
||||
return props.data.hasOwnProperty('id')
|
||||
}
|
||||
|
||||
//判断商品是否售尽
|
||||
/**
|
||||
* 判断商品是否售尽
|
||||
*/
|
||||
const isSellout = computed(() => {
|
||||
const item = props.data
|
||||
if (!isGoods()) {
|
||||
return false
|
||||
}
|
||||
return (
|
||||
item.isPauseSale ||
|
||||
(item.typeEnum !== "sku" && item.isStock == 1 && item.stockNumber <= 0)
|
||||
item.isPauseSale || (item.type !== "sku" && item.isStock == 1 && item.stockNumber <= 0)
|
||||
);
|
||||
})
|
||||
|
||||
|
||||
@@ -36,27 +36,18 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
getCurrentInstance,
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import util from '../util.js';
|
||||
import { computed, getCurrentInstance, 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'
|
||||
import {
|
||||
onShow,
|
||||
} from '@dcloudio/uni-app';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
const props = defineProps({
|
||||
goodsData: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
})
|
||||
|
||||
const model = ref(null)
|
||||
let datas = reactive({
|
||||
item: "",
|
||||
title: "",
|
||||
@@ -65,34 +56,60 @@
|
||||
// 几选几,的和
|
||||
selectNumber: 0,
|
||||
})
|
||||
|
||||
|
||||
// const selSku = computed(() => {
|
||||
// return props.skus.reduce((prve, cur) => {
|
||||
// prve.push(cur.sel)
|
||||
// return prve
|
||||
// }, []).join()
|
||||
// })
|
||||
|
||||
|
||||
// const goods = computed(() => {
|
||||
// return props.skuMap[selSku.value]
|
||||
// })
|
||||
|
||||
watch(() => props.goodsData, (newval) => {
|
||||
newval.proGroupVo.forEach(ele => {
|
||||
newval.groupSnap.forEach(ele => {
|
||||
ele.selectData = []
|
||||
})
|
||||
datas.item = newval
|
||||
datas.title = newval.name
|
||||
datas.price = newval.price
|
||||
datas.skus = newval.proGroupVo
|
||||
datas.skus.forEach(ele => {
|
||||
datas.skus = newval.groupSnap
|
||||
})
|
||||
|
||||
const selectNumber = computed(() => {
|
||||
return datas.skus.reduce((prve, cur) => {
|
||||
console.log(prve)
|
||||
return 0 + cur.number
|
||||
}, 0)
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm', 'updateSku'])
|
||||
const instance = getCurrentInstance();
|
||||
|
||||
function confirm() {
|
||||
// 将数据保存进对应的值
|
||||
let arr = []
|
||||
let arrlength = 0
|
||||
datas.skus.map(ele => {
|
||||
let group = {
|
||||
...ele,
|
||||
goods: [],
|
||||
}
|
||||
if(ele.goods&&ele.goods.length>0){
|
||||
ele.goods.map(item=>{
|
||||
if(item.select){
|
||||
group.goods.push(item)
|
||||
arrlength++
|
||||
}
|
||||
})
|
||||
}
|
||||
arr.push(group)
|
||||
datas.selectNumber += ele.number
|
||||
})
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm', 'updateSku'])
|
||||
|
||||
if (arrlength == datas.selectNumber) {
|
||||
emits('confirm', arr, datas.item)
|
||||
close()
|
||||
} else {
|
||||
instance.ctx.$refs.popup.open()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 套餐选择处理
|
||||
* @param {Object} skd
|
||||
* @param {Object} item
|
||||
*/
|
||||
function chooseSkd(skd, item) {
|
||||
if (item.selectData.includes(skd.proId)) {
|
||||
skd.select = false
|
||||
@@ -107,10 +124,6 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
@@ -119,21 +132,7 @@
|
||||
datas.selectNumber = 0
|
||||
model.value.close()
|
||||
}
|
||||
const instance = getCurrentInstance();
|
||||
|
||||
function confirm() {
|
||||
// 将数据保存进对应的值
|
||||
let arr = []
|
||||
datas.item.proGroupVo.forEach(ele => {
|
||||
arr.push(...ele.selectData)
|
||||
})
|
||||
if (arr.length == datas.selectNumber) {
|
||||
emits('confirm', arr, datas.item)
|
||||
close()
|
||||
} else {
|
||||
instance.ctx.$refs.popup.open()
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="">
|
||||
<up-overlay :show="overlayshow" @click="overlayshow = false">
|
||||
<view class="boxoverlay">
|
||||
<view class="boxoverlay" v-if="form&&form.goods">
|
||||
<view class="rect" @tap.stop>
|
||||
<view class="title">
|
||||
<view>
|
||||
@@ -43,19 +43,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onShow,
|
||||
onReachBottom
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref,
|
||||
watch,
|
||||
defineExpose,
|
||||
defineEmits
|
||||
} from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { reactive, ref, watch, defineExpose, defineEmits } from 'vue';
|
||||
|
||||
const emit = defineEmits(['refresh'])
|
||||
const currentInput = ref('');
|
||||
|
||||
@@ -82,6 +72,7 @@
|
||||
currentInput.value = currentInput.value.slice(0, -1);
|
||||
}
|
||||
};
|
||||
|
||||
const deleteLast = () => {
|
||||
currentInput.value = currentInput.value.slice(0, -1);
|
||||
};
|
||||
@@ -102,6 +93,7 @@
|
||||
const overlayshow = ref(false);
|
||||
const form = reactive({})
|
||||
const open = (foodsindex, index, goods) => {
|
||||
console.log("222",goods)
|
||||
currentInput.value = ''
|
||||
Object.assign(form, {
|
||||
foodsindex,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,39 +1,27 @@
|
||||
import {
|
||||
returnBoolean
|
||||
} from '@/commons/utils/format.js';
|
||||
|
||||
// 返回购物车未下单的数据
|
||||
export function getNowCart(records) {
|
||||
const nowCart = records.find(v => v.placeNum == 0)
|
||||
const Cart = nowCart ? nowCart.info : []
|
||||
const goodsMap = {}
|
||||
export function getNowCart(carItem,goodsList) {
|
||||
// console.log("carItem===",carItem)
|
||||
// console.log("goodsList===",goodsList)
|
||||
// const nowCart = records.find(v => v.placeNum == 0)
|
||||
const arr = []
|
||||
for (let i in Cart) {
|
||||
const item=Cart[i]
|
||||
const productId=item.productId
|
||||
const skuId=item.skuId
|
||||
const isLinShiCai=!productId&&!skuId?true:false
|
||||
const key =isLinShiCai?item.name: (item.productId + '_' + item.skuId)
|
||||
if (goodsMap.hasOwnProperty(key)) {
|
||||
const index = goodsMap[key]
|
||||
arr[index].number = arr[index].number * 1 + item.number
|
||||
arr[index].totalNumber = arr[index].totalNumber * 1 + item.totalNumber
|
||||
arr[index].totalAmount = arr[index].totalAmount * 1 + item.totalAmount
|
||||
arr[index].packFee = arr[index].packFee * 1 + item.packFee
|
||||
} else {
|
||||
arr.push({
|
||||
...item,
|
||||
isPack: returnBoolean(item.isPack),
|
||||
isGift: returnBoolean(item.isGift)
|
||||
})
|
||||
goodsMap[key] = arr.length - 1;
|
||||
}
|
||||
if( carItem.is_temporary != 1 ){
|
||||
goodsList.map(goodsItem => {
|
||||
if(carItem.product_id == goodsItem.id){
|
||||
carItem.lowPrice = goodsItem.lowPrice
|
||||
carItem.lowMemberPrice = goodsItem.lowMemberPrice
|
||||
carItem.name = goodsItem.name
|
||||
carItem.coverImg = goodsItem.coverImg
|
||||
carItem.packFee = goodsItem.packFee
|
||||
}
|
||||
})
|
||||
carItem.number = parseFloat(carItem.number)
|
||||
} else {
|
||||
// 临时菜
|
||||
carItem.number = parseFloat(carItem.number)
|
||||
carItem.name = carItem.product_name
|
||||
carItem.lowPrice = carItem.discount_sale_amount
|
||||
}
|
||||
// const result = Cart.map(item => {
|
||||
// return {
|
||||
// ...item,
|
||||
// isPack: returnBoolean(item.isPack),
|
||||
// isGift: returnBoolean(item.isGift)
|
||||
// }
|
||||
// })
|
||||
return arr
|
||||
|
||||
return carItem
|
||||
}
|
||||
Reference in New Issue
Block a user