diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..684d827 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "*.ttml": "xml", + "*.ttss": "css" + } +} \ No newline at end of file diff --git a/components/my-components/my-popup-table.vue b/components/my-components/my-popup-table.vue new file mode 100644 index 0000000..bcd3b0e --- /dev/null +++ b/components/my-components/my-popup-table.vue @@ -0,0 +1,268 @@ + + + + + \ No newline at end of file diff --git a/components/my-components/my-table-col.vue b/components/my-components/my-table-col.vue new file mode 100644 index 0000000..02409e3 --- /dev/null +++ b/components/my-components/my-table-col.vue @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/components/my-components/my-table.vue b/components/my-components/my-table.vue new file mode 100644 index 0000000..77cb15b --- /dev/null +++ b/components/my-components/my-table.vue @@ -0,0 +1,76 @@ + + + + + \ No newline at end of file diff --git a/http/php/api.ts b/http/php/api.ts new file mode 100644 index 0000000..b42ecd9 --- /dev/null +++ b/http/php/api.ts @@ -0,0 +1,33 @@ +import { request } from './request' +// 会员签入 登录 +export const douyincheckIn = (data : object | any) => { + return request('douyin/checkIn', 'POST', data, true) +} +// 登出 +export const userlogout = () => { + return request('user/logout', 'POST', '', true) +} +// 查询绑定状态 +export const searchstorestatus = (data : object) => { + return request('meituan/searchstorestatus', 'POST', data, true) +} +// 团购核销准备 +export const fulfilmentcertificateprepare = (data : object) => { + return request('douyin/fulfilmentcertificateprepare', 'POST', data, true) +} +// 获取uisdk 绑定 链接 +export const getuisdk = (data : object) => { + return request('douyin/getuisdk', 'POST', data, true) +} +// 团购核销 +export const certificateprepares = (data : object) => { + return request('douyin/certificateprepare', 'POST', data, true) +} +// 团购核销记录 +export const orderlist = (data : object) => { + return request('douyin/orderlist', 'POST', data, true) +} +// 团购核销撤销 +export const fulfilmentcertificatecanceles = (data : object) => { + return request('douyin/fulfilmentcertificatecancel', 'POST', data, true) +} diff --git a/http/php/request.ts b/http/php/request.ts new file mode 100644 index 0000000..f0ae0a2 --- /dev/null +++ b/http/php/request.ts @@ -0,0 +1,80 @@ +//服务器接口地址 +const baseURL : string = 'https://czgdoumei.sxczgkj.com/index.php/api/' +// 封装公共请求方法 +function request(url : string, method : "GET" | "POST" | undefined, data : object | any, toast : boolean) { + let networkType = '' + uni.getNetworkType({ + success: (res) => { + networkType = res.networkType + } + }); + if (networkType == 'none') { + uni.showToast({ + title: '网络异常,请检查网络', + icon: 'none' + }) + return false; + } + if (toast) { + uni.showLoading({ + title: '加载中', + mask: true + }) + } + return new Promise(async (resolve, reject) => { + let header : any + header = { + 'content-type': 'application/json', + 'clinttype':uni.getStorageSync('clint_type'), + 'bausertoken': uni.getStorageSync('phpuserinfo').token + }; + uni.request({ + url: baseURL + url, + method: method, + data: data, + header: header, + success(res : any) { + if (res.data.code != 1) { + //是否提示错误 + if (toast) { + uni.showToast({ + title: res.data.msg || res.data.message, + icon: 'none' + }) + setTimeout(() => { + uni.hideLoading() + }, 1000) + } + if (res.data.code == 401) { + uni.showToast({ + title: res.message || res.msg, + icon: "none", + success: () => { + // uni.removeStorageSync('logintoken'); + // uni.removeStorageSync('token'); + uni.reLaunch({ + url: '/pages/index/index' + }) + } + }) + } + uni.hideLoading() + reject(res.message | res.msg); + } else { + uni.hideLoading() + resolve(res.data.data); + } + }, + fail(err) { + uni.hideLoading() + //请求失败 + uni.showToast({ + title: '无法连接到服务器', + icon: 'none' + }) + reject(err) + } + }) + }) +} +export { request, baseURL } \ No newline at end of file diff --git a/http/yskApi/Instead.js b/http/yskApi/Instead.js index d964201..9839f3b 100644 --- a/http/yskApi/Instead.js +++ b/http/yskApi/Instead.js @@ -389,4 +389,27 @@ export function $calcDeDuctionPoints(data) { ...data } }); -} \ No newline at end of file +} + +//购物车-临时菜添加 +export function $temporaryDishes(data) { + return request({ + url: '/api/place/temporaryDishes', + method: "post", + data:{ + shopId: uni.getStorageSync("shopId"), + ...data + } + }); +} +//单品改价 +export function $updatePrice(data) { + return request({ + url: '/api/place/updatePrice', + method: "put", + data:{ + shopId: uni.getStorageSync("shopId"), + ...data + } + }); +} diff --git a/http/yskApi/goods.js b/http/yskApi/goods.js index 18e1587..9c369bf 100644 --- a/http/yskApi/goods.js +++ b/http/yskApi/goods.js @@ -119,7 +119,10 @@ export const $productSpec=new $API('/api/tbProductSpec',http.req) // v2 api start - +// 商品列表 后台查询 +export function $tbProductList(data) { + return http.req('/api/tbProduct/list', {...data,shopId:uni.getStorageSync('shopId')}, 'GET') +} /* 商品列表 V2 */ export function $tbProductV2(data) { return http.req('/api/tbProduct/list/v2', {...data,shopId:uni.getStorageSync('shopId')}, 'post') diff --git a/pageProduct/add-Product/add-Product.vue b/pageProduct/add-Product/add-Product.vue index dad2fe6..dbc6850 100644 --- a/pageProduct/add-Product/add-Product.vue +++ b/pageProduct/add-Product/add-Product.vue @@ -10,28 +10,40 @@ - + + + + + + + + + - - - - + + + + + + + + + + + @@ -39,36 +51,29 @@ 注:第一张图为商品封面图,图片尺寸为750x750 - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + - + + - + @@ -515,8 +699,12 @@ + + + + @@ -535,8 +723,12 @@ import color from '@/commons/color.js'; import chooseGoods from './components/choose-goods' + import chooseGuige from './components/choose-guige' import editHaocai from './components/edit-haocai.vue' import chooseGroupCategory from './components/choose-coupon-category' + import priceNumberBox from './components/price-number-box' + + import infoBox from "@/commons/utils/infoBox.js" import { @@ -701,18 +893,44 @@ refChooseGroupCategory.value.close() } + //规格选择 + const refChooseGuige = ref(null) + let proGroupVoGoodsIndex = undefined + + function refChooseGuigeOpen(skuList, groupIndex, goodsIndex) { + console.log(groupIndex, goodsIndex) + proGroupVoIndex = groupIndex + proGroupVoGoodsIndex = goodsIndex + refChooseGuige.value.open(skuList) + } + + function refChooseGuigeConfirm(sku) { + FormData.proGroupVo[proGroupVoIndex].goods[proGroupVoGoodsIndex].skuName = sku.specSnap || sku.name + FormData.proGroupVo[proGroupVoIndex].goods[proGroupVoGoodsIndex].skuId = sku.id + proGroupVoIndex = undefined + proGroupVoGoodsIndex = undefined + } + + //套餐商品选择 const refChooseGoods = ref(null) - let groupSnapIndex = undefined + let proGroupVoIndex = undefined - function groupSnapAddGoods(index, arr) { - console.log(arr); - groupSnapIndex = index - refChooseGoods.value.open(arr.map(v => v.id)) + function proGroupVoAddGoods(index, arr) { + proGroupVoIndex = index + if (!FormData.proGroupVo) { + initDefaultProGroupVo() + } + if (FormData.groupType == 0) { + const goods = FormData.proGroupVo[0].goods + refChooseGoods.value.open(goods) + } else { + refChooseGoods.value.open(arr) + } } function refChooseGoodsOpen() { - groupSnapIndex = undefined + proGroupVoIndex = undefined refChooseGoods.value.open() } @@ -720,41 +938,63 @@ refChooseGoods.value.close() } + function proGroupVoPush() { + FormData.proGroupVo.push({ + title: '', + number: 1, + goods: [] + }) + } + function refChooseGoodsConfirm(arr) { - console.log(arr); refChooseGoodsClose() arr = arr.map(v => { const { + proId, id, name, - groupNum, unitName, - categoryId + lowPrice, + type, + typeEnum, + skuList } = v + if (proId) { + return v + } return { - id, - name, - groupNum, + proId: id, + proName: name, unitName, - categoryId + price: lowPrice, + number: 1, + type, + typeEnum, + skuList, + skuId: '', + skuName: '' } }) - if (groupSnapIndex !== undefined) { - return FormData.groupSnap[groupSnapIndex].goods = arr + + if (FormData.groupType == 0) { + return FormData.proGroupVo[0].goods = arr } - FormData.groupSnap.push({ + if (FormData.groupType == 1 && proGroupVoIndex !== undefined) { + return FormData.proGroupVo[proGroupVoIndex].goods = arr + } + FormData.proGroupVo.push({ title: '', number: 1, goods: arr }) } - function groupSnapGoodsDel(index, goodsIndex) { - FormData.groupSnap[index].goods.splice(goodsIndex, 1) + function proGroupVoGoodsDel(index, goodsIndex) { + FormData.proGroupVo[index].goods.splice(goodsIndex, 1) } - function delGroupSnap(index) { - FormData.groupSnap.splice(index, 1) + function delproGroupVo(index) { + FormData.proGroupVo.splice(index, 1) } @@ -790,6 +1030,9 @@ const min = 0; const max = 100000000; console.log(item[key]); + if (item[key] === '') { + return + } const newval = formatPrice(item[key], min, max, true) console.log(newval) if (typeof newval !== 'number') { @@ -805,7 +1048,17 @@ }) } - + //套餐商品类型 + const packageType = reactive({ + list: [{ + name: '固定套餐', + value: 0 + }, { + name: '可选套餐', + value: 1 + }], + sel: 0 + }) // 库存模式 const InventoryModeData = [{ text: '传统模式', @@ -975,44 +1228,16 @@ let myTest = ref(false) //表单边框 const inputBorder = ref(false) - //商品表单数据 - // const FormData = reactive({ - // images: [], - // name: '', - // goodsCode: '', - // shortTitle: '', - // goodsDetail: '', - // goodsDetail: '', - // categoryId: '', - // salesMethod: 0, - // startTime: '', - // isStock: false, - // isVipDiscount: false, - // packagingFee: 0, - // weight: 0, - // integral: 0, - // openDailySalesLimit: false, - // dailySalesLimit: '', - // openOrderBuyLimit: false, - // orderBuyLimit: 0, - // openEveryoneBuyLimit: false, - // everyoneBuyLimit: 0, - // minBuyLimit: 0, - // specificationsPattern: '', - // specificationsGroup: '', - // paySuccessAfterDay: '', - // openDiscount: false, - // discountPrice: 0, - // isVipDiscount: false, - // vipPrice: 0, - // packagingFee: 0, - // virtualSales: 0, - // isRecommend: false, - // timer: [], - // isShowCash: 1, - // isShowMall: 1, - // }) const FormData = reactive({ + days: "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday", + endTime: "23:59", + startTime: "00:00", + //每日销量上限, + dayLimit: 0, + singleOrderLimit: 0, + singlePeopleLimit: 0, + type: 'normal', + showType: ['table'], specsInfoName: '', id: "", typeEnum: "normal", @@ -1025,18 +1250,24 @@ coverImg: "", images: [], shopId: uni.getStorageSync('shopId'), + groupType: 0, + weight: '', + //套餐组合 + proGroupVo: [], lowPrice: "", skuList: [], isShowMall: 1, isShowCash: 1, isStock: 0, isStock: 0, + //是否允许临时改价 + isTempPrice: 1, isHot: 0, packFee: 0, specId: "", // baseSalesNumber: 0, sort: 0, - groupSnap: [], + proGroupVo: [], specInfo: [], selectSpec: [], specTableHeaders: [], @@ -1057,6 +1288,16 @@ usageRules: "" } }) + + //添加套餐组 + function addProGroupVo() { + FormData.addProGroupVo.push({ + title: '', + goods: [], + number: 0, + count: 0 + }) + } const skuList = reactive({ list: [{ ...$defaultSku, @@ -1122,6 +1363,7 @@ res.specsInfoName = specsInfoName $goodsData = res skuList.list = res.skuList + res.showType = res.showType.split(',') Object.assign(FormData, res) //多规格 if (res.typeEnum === 'sku') { @@ -1249,6 +1491,19 @@ // 商品类型 // types: $types, types: [{ + name: '普通商品', + value: 'normal' + }, + { + name: '套餐商品', + value: 'package' + }, + { + name: '称重商品', + value: 'weigh' + } + ], + typeEnums: [{ name: '单规格', value: 'normal' }, @@ -1264,7 +1519,25 @@ // 规格 specList: [], //库存 - skuList: [] + skuList: [], + //显示 + showTypes: [{ + name: '堂食', + value: 'table' + }, + { + name: '自取', + value: 'dine' + }, + { + name: '配送', + value: 'delivery' + }, + { + name: '快递', + value: 'express' + } + ] }) //查询商品库存 function getProductSku() { @@ -1298,6 +1571,12 @@ getTbShopUnit() getTbProductSpec() }) + const changeFormDatatype = (e) => { + console.log(e) + console.log(FormData) + // 当是称重商品时 默认是单规格 + FormData.typeEnum = 'normal' + } onShow(() => { // if (option.type === 'edit') { @@ -1334,11 +1613,12 @@ if (!bol) { return } - Forms.value.validate().then(res => { const { typeEnum, - groupCategoryId + groupType, + groupCategoryId, + type } = FormData if (typeEnum === 'group' && !groupCategoryId.length) { return infoBox.showToast('请选择团购券分类') @@ -1409,9 +1689,43 @@ return infoBox.showToast('请输入库存数量!') } } - + if (type == 'package') { + if (groupType == 0 && FormData.proGroupVo[0].goods.length <= 0) { + // 固定套餐 + return infoBox.showToast('套餐组合至少需要包含一种商品,请添加商品') + } + if (groupType == 1) { + let ispase = FormData.proGroupVo.length > 0 ? true : false + let tips = ispase ? '' : '请添加至少一种套餐' + for (let i in FormData.proGroupVo) { + FormData.proGroupVo[i].count = FormData.proGroupVo[i].goods.length + const item = FormData.proGroupVo[i] + if (item.goods.length <= 0) { + ispase = false + tips = '套餐组合至少需要包含一种商品,请添加商品' + break + } + if (!item.title) { + ispase = false + tips = '请输入套餐名称' + break + } + } + if (!ispase) { + return infoBox.showToast(tips) + } + // 可选套餐 + } + } + if (type == 'weigh') { + if (!FormData.weight) { + return infoBox.showToast('请输入重量') + } + } const submitData = { ...FormData, + showType: FormData.showType.join(','), + proGroupVo: type != 'package' ? '' : FormData.proGroupVo, images: images, coverImg: images[0] || '', skuList: submitSkuList, @@ -1435,10 +1749,20 @@ settimeoutBack(1500) }) }) - - - } + // 如果套餐没选择规格,默认选中第一条 + console.log(submitData.proGroupVo) + if (submitData.proGroupVo) { + submitData.proGroupVo.forEach((res, index) => { + submitData.proGroupVo[index].goods.forEach(ele => { + if (!ele.skuId) { + ele.skuId = ele.skuList[0].id + ele.skuName = ele.skuList[0].specSnap || ele.skuList[0].name + } + }) + }) + } + submitData.selectSpec = $addProduct(submitData).then(res => { infoBox.showSuccessToast('添加成功') @@ -1462,7 +1786,6 @@ return result.replace(/.$/, "") } }) - /** * 监听规格保存,拿到数据 */ @@ -1475,7 +1798,7 @@ uni.$on('emitspecificationsSave', function(data) { FormData.specificationsGroup = data FormData.specId = data.specId - FormData.specsInfoName=data.specsInfoName + FormData.specsInfoName = data.specsInfoName skuList.list = data.result.map(v => { return { ...v.skus, @@ -1519,27 +1842,46 @@ * @param {Boolean} open //控制开启或关闭监听 */ function watchTimerSave(open = true) { - if (open) { - uni.$on('timerSave', function(timer) { - console.log('timerSave get'); - console.log(timer); - FormData.timer = timer - }) - } else { - uni.$off('timerSave', function(data) { - console.log('timerSave remove'); - }) - } + uni.$off('timerSave') + uni.$on('timerSave', function(timer) { + Object.assign(FormData, timer) + }) } function toTimerPage() { - uni.setStorageSync('timer', FormData.timer) - go.to('PAGES_PRODUCT_TIMER') + go.to('PAGES_PRODUCT_TIMER', { + productId: option.productId + }) } - function returnTimerText() { - return FormData.timer.length ? `当前有${FormData.timer.length}个定时器` : '没有定时器' + const ListDataconstructor = { + cycleChecked: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'], + } + const $week = { + Monday: '周一', + Tuesday: '周二', + Wednesday: '周三', + Thursday: '周四', + Friday: '周无', + Saturday: '周六', + Sunday: '周日', + } + + function returnTimerDayText() { + if (!FormData.days) { + return '' + } + return FormData.days.split(',').filter(v => v).map(v => $week[v]).join(',') + // return FormData.timer.length ? `当前有${FormData.timer.length}个定时器` : '没有定时器' + } + + function returnTimerTimeText() { + if (!FormData.startTime || !FormData.endTime) { + return '' + } + return FormData.startTime + '-' + FormData.endTime + // return FormData.timer.length ? `当前有${FormData.timer.length}个定时器` : '没有定时器' } @@ -1602,6 +1944,50 @@ skuList.list = [] } } + }) + + watch(() => FormData.type, (newval) => { + if (option.type == 'edit') { + if (newval == $goodsData.type) { + if ($goodsData.proGroupVo) { + FormData.proGroupVo = $goodsData.proGroupVo || [] + } else { + initDefaultProGroupVo() + } + } + if (FormData.groupType == null) { + FormData.groupType = 0 + } + } else { + if (newval == 'package') { + initDefaultProGroupVo() + } + } + + }) + + function initDefaultProGroupVo() { + FormData.proGroupVo = [{ + title: '', + count: '', + number: 1, + goods: [] + }] + console.log(FormData.proGroupVo); + } + watch(() => FormData.groupType, (newval) => { + if (newval == 0) { + return initDefaultProGroupVo() + } + if (option.type == 'edit') { + if (newval == $goodsData.groupType) { + FormData.proGroupVo = $goodsData.proGroupVo + } else { + + } + return + } + initDefaultProGroupVo() }) @@ -1637,20 +2023,33 @@ disabledChangeCategory.value = !res } } + + const activeinHouseList = computed(() => { + try { + return pageData.units.filter((item) => { + if (item.id == FormData.unitId) { + return item.name + } + })[0].name + } catch (error) { + //TODO handle the exception + } + }); /** * 权限end */ - watch(() => pageData.types, (newval) => { Forms.value.setRules(rules) }) onShow(() => { watchSpecificationsSave() + watchTimerSave() }) onReady(() => { Forms.value && Forms.value.setRules(rules) }) + onBeforeUnmount(() => { clearTimeout(timer) }) @@ -1661,6 +2060,13 @@ } \ No newline at end of file diff --git a/pageProduct/add-Product/components/choose-guige.vue b/pageProduct/add-Product/components/choose-guige.vue new file mode 100644 index 0000000..29bfa51 --- /dev/null +++ b/pageProduct/add-Product/components/choose-guige.vue @@ -0,0 +1,164 @@ + + + + + \ No newline at end of file diff --git a/pageProduct/add-Product/components/price-number-box.vue b/pageProduct/add-Product/components/price-number-box.vue new file mode 100644 index 0000000..7b00a90 --- /dev/null +++ b/pageProduct/add-Product/components/price-number-box.vue @@ -0,0 +1,109 @@ + + + + + \ No newline at end of file diff --git a/pageProduct/add-Product/timer - 副本.vue b/pageProduct/add-Product/timer - 副本.vue new file mode 100644 index 0000000..3e0c104 --- /dev/null +++ b/pageProduct/add-Product/timer - 副本.vue @@ -0,0 +1,224 @@ + + + + + \ No newline at end of file diff --git a/pageProduct/add-Product/timer.vue b/pageProduct/add-Product/timer.vue index 1e7fdd2..0556a3b 100644 --- a/pageProduct/add-Product/timer.vue +++ b/pageProduct/add-Product/timer.vue @@ -1,42 +1,45 @@ @@ -86,7 +91,7 @@ import myTabs from '@/components/my-components/my-tabs.vue' const props = defineProps({ price: { - type: [Number,String], + type: [Number, String], default: 0 }, title: { @@ -98,12 +103,10 @@ default: [] } }) - - - - function changeCauses(item) { - item.checked = !item.checked - } + + + + const discounts = [95, 90, 85, 80] const causes = reactive([{ @@ -120,6 +123,11 @@ } ]) + function changeCauses(item, index) { + item.checked = !item.checked + form.notes = causes + } + function discountInput(e) { if (e.detail.value >= 100) { nextTick(() => { @@ -127,8 +135,9 @@ }) } } + function discountMoneyInput(e) { - const max=100 + const max = 100 if (e.detail.value >= max) { nextTick(() => { form.discountMoney = 100 @@ -142,7 +151,7 @@ const tabs = ['打折', '减免'] - let current = ref(0) + let current = ref(1) function tabsChange(i) { console.log(i); @@ -158,11 +167,12 @@ const form = reactive({ ...$form }) - watch(()=>props.price,(newval)=>{ + watch(() => props.price, (newval) => { console.log(newval); - form.price=newval - form.currentPrice=newval + form.price = newval + form.currentPrice = newval }) + function resetForm() { Object.assign(form, { ...$form @@ -182,22 +192,23 @@ function confirm() { const { - discount,discountMoney + discount, + discountMoney } = form - if (current.value===0&& discount==='') { + if (current.value === 0 && discount === '') { return uni.showToast({ icon: 'none', title: '请输入有效折扣!' }) } - if (current.value===1&& discountMoney==='') { + if (current.value === 1 && discountMoney === '') { return uni.showToast({ icon: 'none', title: '请输入有效减免价格!' }) } - close() emits('confirm', form) + close() } defineExpose({ open, diff --git a/pagesCreateOrder/confirm-order/confirm-order.vue b/pagesCreateOrder/confirm-order/confirm-order.vue index c7d7939..25b4c9a 100644 --- a/pagesCreateOrder/confirm-order/confirm-order.vue +++ b/pagesCreateOrder/confirm-order/confirm-order.vue @@ -136,10 +136,15 @@ :key="index"> - + + + 临时菜 + - + @@ -154,6 +159,11 @@ custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;" size="small" text="打包" inverted type="success" /> + + + {{item.name}} @@ -174,7 +184,8 @@ ¥{{formatPrice(item.salePrice*item.number) }} - ¥{{formatPrice(item.memberPrice*item.number) }} + ¥{{formatPrice(item.memberPrice*item.number) }} - + + + - + @tap="toggleWait(item)">{{item.isWaitCall?'取消等叫':'等叫'}} + + + + @@ -251,7 +267,7 @@ ¥{{formatPrice(youhui) }} - + 实收金额 ¥{{formatPrice(allPrice) }} @@ -278,8 +294,8 @@ - - + @@ -351,7 +367,26 @@ return Number(n).toFixed(2) } - + // 单品打折 + async function discountconfirm(form) { + if (form.discountMoney != '.') { + let str = '' + if (form.notes) { + form.notes.forEach(ele => { + if (ele.checked) { + str = str + ele.name + ',' + } + }) + } + let obj = { + saleAmount: form.discountMoney, + note: str + form.note, + cartId: modelData.data.id + } + const res = await Api.$updatePrice(obj) + getCart() + } + } //用餐人数 const userNumbers = reactive({ @@ -416,18 +451,46 @@ skuId } par[key] = !item[key] + + const res = await Api.$updateCart(par) goods.list[index][key] = returnBoolean(res[key]) - if (key == 'isPack') { - getCart() - } + getCart() } //等叫 - function toggleWait(item) { - item.isWait = !item.isWait + async function toggleWait(item) { + item.isWaitCall = !item.isWaitCall + let obj = { + cartId: item.id, + isGift: item.isGift, + isPack: item.isPack, + isPrint: item.isPrint, + isWaitCall: item.isWaitCall, + masterId: option.masterId, + num: item.number, // 0会删除此商品 + productId: item.productId, + skuId: item.skuId, + vipUserId: '', + } + let res = await Api.$updateCart(obj) + } + // 打印 + async function toggisPrint(item) { + item.isPrint = !item.isPrint + let obj = { + cartId: item.id, + isGift: item.isGift, + isPack: item.isPack, + isPrint: item.isPrint, + isWaitCall: item.isWaitCall, + masterId: option.masterId, + num: item.number, // 0会删除此商品 + productId: item.productId, + skuId: item.skuId, + vipUserId: '', + } + let res = await Api.$updateCart(obj) } - - const eatTypes = reactive({ list: [{ @@ -479,7 +542,6 @@ function watchChooseuser() { uni.$off('choose-user') uni.$on('choose-user', (data) => { - console.log(data); user.value = data setUser() }) @@ -520,20 +582,25 @@ totalNumber: 0, totalAmount: 0, }) - const isVip=computed(()=>{ - return $shop.value.isMemberPrice&& user.value&&user.value.id&&user.value.isVip + const isVip = computed(() => { + return $shop.value.isMemberPrice && user.value && user.value.id && user.value.isVip + }) + const discountSaleAmount = computed(() => { + return goods.list.filter((v) => v.discountSaleAmount && v.discountSaleAmount > 0) + .reduce((a, b) => { + return a + b.number * b.discountSaleAmount; + }, 0); }) const goodsPrice = computed(() => { const goodsTotalPrice = goods.list.reduce((prve, cur) => { - const memberPrice=cur.memberPrice?cur.memberPrice:cur.salePrice - const tPrice = (isVip.value? memberPrice:cur.salePrice) * cur.number + const memberPrice = cur.memberPrice ? cur.memberPrice : cur.salePrice + const tPrice = (isVip.value ? memberPrice : cur.salePrice) * cur.number const tpackFee = cur.isPack ? cur.packFee * 1 : 0 return prve + (cur.isGift ? 0 : tPrice) + tpackFee }, 0) - return (goodsTotalPrice || 0).toFixed(2) + return ((goodsTotalPrice - discountSaleAmount.value) || 0).toFixed(2) }) const allPrice = computed(() => { - console.log(goodsPrice.value); const n = goodsPrice.value * 1 + $seatFee.totalAmount return n.toFixed(2) // const goodsTotalPrice = goods.list.reduce((prve, cur) => { @@ -541,18 +608,21 @@ // }, 0) // return (goodsTotalPrice + ($seatFee.totalAmount || 0)).toFixed(2) }) - const youhui=computed(()=>{ - if(user.value&&user.value.id&&user.value.isVip){ - const goodsTotalPrice = goods.list.reduce((prve, cur) => { + const youhui = computed(() => { + let goodsTotalPrice = 0 + if (user.value && user.value.id && user.value.isVip) { + goodsTotalPrice = goods.list.reduce((prve, cur) => { const tPrice = cur.salePrice * cur.number const tpackFee = cur.isPack ? cur.packFee * 1 : 0 return prve + tPrice + tpackFee }, 0) - return goodsTotalPrice-allPrice.value - }else{ - return 0 + return goodsTotalPrice - allPrice.value + } else { + console.log(discountSaleAmount.value,'优惠金额') + return (discountSaleAmount.value) } - return goodsTotalPrice + console.log(discountSaleAmount.value,'优惠金额1') + return (goodsTotalPrice + discountSaleAmount.value * 1).toFixed(2) }) function setGoodsItem(key, val) { @@ -573,16 +643,16 @@ records, seatFee } = await Api.getCart(par) - let useType='' + let useType = '' if (seatFee && seatFee.useType) { - useType=seatFee.useType + useType = seatFee.useType $storageManage.useType(useType) - }else{ - useType=records[0].info[0].useType + } else { + useType = records[0].info[0].useType $storageManage.useType(useType) } console.log(useType); - eatTypes.active =useType == 'takeout' ? useType : useType.replace( + eatTypes.active = useType == 'takeout' ? useType : useType.replace( /-after|-before/g, ''); goods.list = getNowCart(records) if (seatFee && seatFee.totalNumber) { diff --git a/pagesCreateOrder/index/components/car.vue b/pagesCreateOrder/index/components/car.vue index 65f5681..13e5a36 100644 --- a/pagesCreateOrder/index/components/car.vue +++ b/pagesCreateOrder/index/components/car.vue @@ -6,7 +6,7 @@ - 已添加{{goodsNumber}}件商品 + 已添加{{goodsNumber.toFixed(0)}}件商品 清空 @@ -36,7 +36,7 @@ - {{item.number}} + {{(item.number).toFixed(2)}} diff --git a/pagesCreateOrder/index/components/list-goods-item.vue b/pagesCreateOrder/index/components/list-goods-item.vue index bd15f0b..6cc9830 100644 --- a/pagesCreateOrder/index/components/list-goods-item.vue +++ b/pagesCreateOrder/index/components/list-goods-item.vue @@ -1,30 +1,34 @@