代码更新
This commit is contained in:
parent
b4a0393d2d
commit
fd0c452a76
|
|
@ -8,7 +8,7 @@ const request = http.request
|
|||
export function getOrderList(data, urlType = 'order') {
|
||||
return request({
|
||||
url: `${urlType}/admin/order`,
|
||||
method: "POST",
|
||||
method: "GET",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ export function getHistoryOrder(data, urlType = 'order') {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成订单
|
||||
* @returns
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
import http from '@/http/http.js'
|
||||
const request = http.request
|
||||
|
||||
/**
|
||||
* 获取店铺订单支付URL
|
||||
* @returns
|
||||
*/
|
||||
export function getOrderPayUrl(data, urlType = 'order') {
|
||||
return request({
|
||||
url: `${urlType}/pay/shopPayApi/orderPayUrl`,
|
||||
method: "GET",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码支付
|
||||
* @returns
|
||||
*/
|
||||
export function scanPay(data, urlType = 'order') {
|
||||
return request({
|
||||
url: `${urlType}/pay/scanPay`,
|
||||
method: "POST",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 现金支付
|
||||
* @returns
|
||||
*/
|
||||
export function cashPay(data, urlType = 'order') {
|
||||
return request({
|
||||
url: `${urlType}/pay/cashPay`,
|
||||
method: "POST",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码/储值支付
|
||||
* @returns
|
||||
*/
|
||||
export function microPay(data, urlType = 'order') {
|
||||
return request({
|
||||
url: `${urlType}/pay/microPay`,
|
||||
method: "POST",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员支付
|
||||
* @returns
|
||||
*/
|
||||
export function vipPay(data, urlType = 'order') {
|
||||
return request({
|
||||
url: `${urlType}/pay/vipPay`,
|
||||
method: "POST",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -61,9 +61,12 @@ export function updatePrinter(data, urlType = 'account') {
|
|||
* 删除打印机
|
||||
* @returns
|
||||
*/
|
||||
export function delPrinter(id, urlType = 'account') {
|
||||
export function delPrinter(data, urlType = 'account') {
|
||||
return request({
|
||||
url: `${urlType}/admin/product/vendor/${id}`,
|
||||
url: `${urlType}/admin/printer`,
|
||||
method: "DELETE",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ export function updateProduct(data, urlType = 'product') {
|
|||
* 绑定耗材
|
||||
* @returns
|
||||
*/
|
||||
export function productBind(data, urlType = 'product') {
|
||||
export function productBindCons(data, urlType = 'product') {
|
||||
return request({
|
||||
url: `${urlType}/admin/product/bind`,
|
||||
method: "POST",
|
||||
|
|
@ -181,6 +181,20 @@ export function updateSpec(data, urlType = 'product') {
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 快捷添加商品规格
|
||||
* @returns
|
||||
*/
|
||||
export function addSpecQuic(data, urlType = 'product') {
|
||||
return request({
|
||||
url: `${urlType}/admin/prod/spec/quickAdd`,
|
||||
method: "POST",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品规格
|
||||
* @returns
|
||||
|
|
|
|||
28
api/shop.js
28
api/shop.js
|
|
@ -28,3 +28,31 @@ export function editShopInfo(data, urlType = 'account') {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前店铺拓展参数
|
||||
* @returns
|
||||
*/
|
||||
export function getShopExtend(data, urlType = 'account') {
|
||||
return request({
|
||||
url: `${urlType}/admin/shopExtend`,
|
||||
method: "GET",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前店铺拓展参数
|
||||
* @returns
|
||||
*/
|
||||
export function editShopExtend(data, urlType = 'account') {
|
||||
return request({
|
||||
url: `${urlType}/admin/shopExtend`,
|
||||
method: "PUT",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,20 @@ export function shopUserList(data, urlType = 'account') {
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺用户详情
|
||||
* @returns
|
||||
*/
|
||||
export function shopUserDetail(data, urlType = 'account') {
|
||||
return request({
|
||||
url: `${urlType}/admin/shopUser/detail`,
|
||||
method: "GET",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺用户新增
|
||||
* @returns
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export function getShopTableDetail(data, urlType = 'account') {
|
|||
export function shopTableBind(data, urlType = 'account') {
|
||||
return request({
|
||||
url: `${urlType}/admin/shopTable/bind`,
|
||||
method: "GET",
|
||||
method: "POST",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export function isTui(item) {
|
|||
return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
|
||||
}
|
||||
export function isGift(item) {
|
||||
return !isTui(item) && item.gift
|
||||
return !isTui(item) && item.payAmount<=0
|
||||
}
|
||||
export function numSum(arr) {
|
||||
const sum = arr.reduce((a, b) => {
|
||||
|
|
|
|||
|
|
@ -44,24 +44,15 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
nextTick,
|
||||
ref,watch
|
||||
} from 'vue';
|
||||
import { reactive, nextTick, ref,watch } from 'vue';
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
import myTabs from '@/components/my-components/my-tabs.vue'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
discount:{
|
||||
type: [Number,String],
|
||||
default:100
|
||||
|
|
@ -70,13 +61,10 @@
|
|||
type: [Number,String],
|
||||
default: 0
|
||||
},
|
||||
nowPrice:{
|
||||
type: [Number,String],
|
||||
default: 0
|
||||
}
|
||||
|
||||
})
|
||||
function currentPriceInput(newval){
|
||||
form.discount=(newval*100/form.price)
|
||||
form.discount = (newval*100/form.price).toFixed(2)
|
||||
}
|
||||
function discountInput(newval){
|
||||
form.currentPrice=(form.price*newval/100).toFixed(2)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
<view class="">{{item.name}}</view>
|
||||
</view>
|
||||
<view class="u-flex-1 u-p-l-4 u-p-r-4 box-size-border">
|
||||
{{item.typeEnum}}
|
||||
{{item.type}}
|
||||
</view>
|
||||
<view class="u-flex-1">
|
||||
¥{{ item.lowPrice }}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<view class="">{{item.name}}</view>
|
||||
</view>
|
||||
<view class="u-flex-1 u-p-l-4 u-p-r-4 box-size-border">
|
||||
{{item.typeEnum}}
|
||||
{{item.type}}
|
||||
</view>
|
||||
<view class="u-flex-1">
|
||||
¥{{ item.lowPrice }}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ const loadingShowTime = 200
|
|||
function getHeader(){
|
||||
const headerObject={}
|
||||
headerObject["token"] = storageManage.token()
|
||||
headerObject["shopId"] = uni.getStorageSync("shopInfo").id
|
||||
headerObject["platformType"] = 'APP'
|
||||
|
||||
return headerObject
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,12 +49,9 @@
|
|||
|
||||
import { getFreeDing, updateFreeDing } from '@/api/freeDing.js'
|
||||
const form = reactive({
|
||||
id: '',
|
||||
rechargeTimes: '',
|
||||
rechargeThreshold: '',
|
||||
enable: false,
|
||||
withCoupon: '',
|
||||
withPoints: '',
|
||||
rechargeDesc: '',
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<view>
|
||||
<view class="">排序:</view>
|
||||
<view class="u-m-t-24">
|
||||
<uni-easyinput v-model="sort" placeholder="请输入排序"></uni-easyinput>
|
||||
<uni-easyinput type="number" v-model="sort" placeholder="请输入排序"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -5,56 +5,23 @@
|
|||
<view class="addConsumables">
|
||||
<view>
|
||||
<view>
|
||||
<view>
|
||||
单位
|
||||
<view> 单位 </view>
|
||||
<view> <input type="text" placeholder="请输入单位" v-model="datas.form.conUnit" name="" id=""> </view>
|
||||
</view>
|
||||
<view>
|
||||
<input type="text" placeholder="请输入单位" v-model="datas.form.conUnit" name="" id="">
|
||||
</view>
|
||||
<view> 耗材名称 </view>
|
||||
<view> <input type="text" placeholder="请输入耗材名称" v-model="datas.form.conName" name="" id=""> </view>
|
||||
</view>
|
||||
<view>
|
||||
<view>
|
||||
耗材名称
|
||||
<view> 耗材价格 </view>
|
||||
<view> <input class="uni-input" placeholder="请输入耗材价格" type="number" v-model="datas.form.price"> </view>
|
||||
</view>
|
||||
<view>
|
||||
<input type="text" placeholder="请输入耗材名称" v-model="datas.form.conName" name="" id="">
|
||||
<view> 预警值 </view>
|
||||
<view> <input type="number" placeholder="请输入预警值" v-model="datas.form.conWarning" name="" id=""> </view>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view>
|
||||
耗材价格
|
||||
</view>
|
||||
<view>
|
||||
<input class="uni-input" placeholder="请输入耗材价格" type="number" v-model="datas.form.price">
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view>
|
||||
预警值
|
||||
</view>
|
||||
<view>
|
||||
<input type="number" placeholder="请输入预警值" v-model="datas.form.conWarning" name="" id="">
|
||||
</view>
|
||||
</view>
|
||||
<!-- <li style="justify-content: space-between;">
|
||||
<view>
|
||||
耗材类型
|
||||
</view>
|
||||
<view style="width: 54%;" @tap="datas.showStatus = !datas.showStatus">
|
||||
{{datas.typelist[datas.nowStatusIndex]}}
|
||||
</view>
|
||||
<uni-icons type="bottom" size="16"></uni-icons>
|
||||
</li> -->
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view :style="{height:datas.showStatus?statusHeight:0}" class="tranistion status overflow-hide">
|
||||
<view @tap="changeNowStatusIndex(index)" class="u-flex u-p-l-30 lh30 u-p-r-30 u-row-between"
|
||||
v-for="(item,index) in datas.typelist" :key="index">
|
||||
<view :class="{'color-main':datas.nowStatusIndex===index}">{{item}}</view>
|
||||
<uni-icons v-if="datas.nowStatusIndex===index" type="checkmarkempty" :color="color.ColorMain"></uni-icons>
|
||||
</view>
|
||||
<view :style="{height: '14px'}"></view>
|
||||
</view> -->
|
||||
<view class="bottombutton">
|
||||
<up-button type="primary" style="background-color: #318AFE;color: #fff;" @tap="sumbit" :plain="true"
|
||||
text="保存"></up-button>
|
||||
|
|
@ -62,72 +29,34 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
computed,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import {
|
||||
tbConsTypeList,
|
||||
tbConsTypeput
|
||||
} from '@/http/yskApi/requestAll.js';
|
||||
import { reactive, computed, onMounted } from 'vue';
|
||||
import { editCons } from '@/api/cons.js';
|
||||
import color from '@/commons/color.js';
|
||||
import go from '@/commons/utils/go.js';
|
||||
let datas = reactive({
|
||||
form: {
|
||||
conWarning: 999
|
||||
},
|
||||
showStatus: false,
|
||||
list: [],
|
||||
typelist: [],
|
||||
nowStatusIndex: 0
|
||||
})
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
item: {
|
||||
type: String
|
||||
}
|
||||
})
|
||||
let datas = reactive({
|
||||
form: {
|
||||
conWarning: 999
|
||||
},
|
||||
})
|
||||
onMounted(() => {
|
||||
let obj = JSON.parse(props.item)
|
||||
datas.form = obj
|
||||
|
||||
gettbConsTypeList()
|
||||
})
|
||||
|
||||
let gettbConsTypeList = () => {
|
||||
datas.typelist = []
|
||||
tbConsTypeList({
|
||||
page: 0,
|
||||
size: 30,
|
||||
shopId: uni.getStorageSync("shopId"),
|
||||
}).then(res => {
|
||||
datas.list = res.content
|
||||
res.content.forEach(ele => {
|
||||
datas.typelist.push(ele.conTypeName)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let sumbit = () => {
|
||||
tbConsTypeput([{
|
||||
...datas.form,
|
||||
status: datas.form.status * 1,
|
||||
isCheck: datas.form.isCheck * 1,
|
||||
conWarning: datas.form.conWarning * 1,
|
||||
shopId: uni.getStorageSync("shopId"),
|
||||
conTypeId: datas.list[datas.nowStatusIndex].id,
|
||||
id: datas.form.id
|
||||
}]).then(res => {
|
||||
editCons(datas.form).then(res => {
|
||||
go.back()
|
||||
})
|
||||
}
|
||||
const statusHeight = computed(() => {
|
||||
return 30 * datas.typelist.length + 14 + 'px'
|
||||
})
|
||||
|
||||
function changeNowStatusIndex(i) {
|
||||
datas.nowStatusIndex = i
|
||||
datas.showStatus = false
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
page {
|
||||
|
|
@ -135,11 +64,6 @@
|
|||
}
|
||||
</style>
|
||||
<style scoped lang="less">
|
||||
ul,
|
||||
li {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.topTitle {
|
||||
font-weight: 400;
|
||||
|
|
@ -195,16 +119,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.status {
|
||||
margin: 0 32rpx;
|
||||
position: absolute;
|
||||
// top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 10;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.df() {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
<view>
|
||||
<view> <text style="color: red;">*</text> 出库时间 </view>
|
||||
<view >
|
||||
<input type="text" @click="datas.show=true" placeholder="选择出库时间" v-model="datas.inOutDate" readonly >
|
||||
<!-- <input type="text" @click="datas.show=true" placeholder="选择出库时间" v-model="datas.inOutDate" readonly > -->
|
||||
<up-datetime-picker
|
||||
hasInput
|
||||
:show="datas.show"
|
||||
|
|
@ -189,7 +189,9 @@
|
|||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
::v-deep.u-input{
|
||||
border: none!important;
|
||||
}
|
||||
|
||||
.status {
|
||||
margin: 0 32rpx;
|
||||
|
|
|
|||
|
|
@ -12,13 +12,11 @@
|
|||
<view>
|
||||
<view> <text style="color: red;">*</text> 入库时间 </view>
|
||||
<view >
|
||||
<input type="text" @click="datas.show=true" placeholder="选择入库时间" v-model="datas.inOutDate" readonly >
|
||||
<up-datetime-picker
|
||||
border='none'
|
||||
:show="datas.show"
|
||||
<!-- hasInput -->
|
||||
v-model="datas.form.inOutDate"
|
||||
mode="date"
|
||||
@change="inOutDateChange"
|
||||
|
||||
></up-datetime-picker>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -87,7 +85,7 @@
|
|||
form: {
|
||||
bodyList: {},
|
||||
actualPaymentAmount: 0,
|
||||
inOutDate: ""
|
||||
inOutDate: Date.now()
|
||||
},
|
||||
item: ""
|
||||
})
|
||||
|
|
@ -219,7 +217,9 @@
|
|||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
::v-deep.u-input{
|
||||
border: none!important;
|
||||
}
|
||||
.status {
|
||||
margin: 0 32rpx;
|
||||
position: absolute;
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@
|
|||
uni.showToast({ title: '请输入优惠券名称' })
|
||||
return false;
|
||||
}
|
||||
if( !formData.fullAmount ){
|
||||
if( !formData.fullAmount || !formData.discountAmount ){
|
||||
uni.showToast({ title: '请输入使用门槛' })
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
</view>
|
||||
<view class="couponContentListbottom">
|
||||
<button @tap="editCoupon(item)">编辑</button>
|
||||
<button @tap="delCoupon(item)">删除</button>
|
||||
<!-- <button @tap="delCoupon(item)">删除</button> -->
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@
|
|||
* 删除分类确认
|
||||
*/
|
||||
async function delModelConfirm() {
|
||||
const res = await delPrinter(props.data.id)
|
||||
const res = await delPrinter({id:props.data.id})
|
||||
emit('init', '')
|
||||
delModel.value.close()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -466,7 +466,8 @@
|
|||
getProductDetail,
|
||||
addProduct,
|
||||
updateProduct,
|
||||
delProduct
|
||||
delProduct,
|
||||
productBindCons
|
||||
} from '@/api/product.js'
|
||||
import {
|
||||
uploadFile
|
||||
|
|
@ -575,6 +576,7 @@
|
|||
watch(() => FormData.type, (newval) => {
|
||||
if (option.type == 'edit') {
|
||||
FormData.specId = newval != 'sku' ? '' : ($goodsData.specId || '')
|
||||
console.log($goodsData)
|
||||
if (newval == $goodsData.type) {
|
||||
skuList.list = $goodsData.skuList
|
||||
if ($goodsData.groupSnap) {
|
||||
|
|
@ -665,17 +667,17 @@
|
|||
url: v
|
||||
}
|
||||
})
|
||||
for (let i in res.conInfos) {
|
||||
const con = res.conInfos[i]
|
||||
const item = res.skuList.find(v => v.id == con.productSkuId)
|
||||
res.consList.map(v=>{
|
||||
const item = res.skuList.find(v => v.productId == v.productId)
|
||||
if (item) {
|
||||
if (item.hasOwnProperty('haoCaiList')) {
|
||||
item.haoCaiList.push(con)
|
||||
item.haoCaiList.push(v)
|
||||
} else {
|
||||
item.haoCaiList = [con]
|
||||
}
|
||||
item.haoCaiList = [v]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
res.skuList = (res.skuList.length ? res.skuList : [])
|
||||
|
||||
$goodsData = res
|
||||
|
|
@ -758,6 +760,7 @@
|
|||
}else{
|
||||
FormData.groupType = null
|
||||
}
|
||||
console.log(FormData)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1074,7 +1077,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (type == 'single') {
|
||||
if (type != 'sku') {
|
||||
let lowPrice = skuList.list[0] ? skuList.list[0].salePrice : FormData.salePrice
|
||||
let suitNum = skuList.list[0] ? skuList.list[0].suitNum : 0
|
||||
if (lowPrice === '') {
|
||||
|
|
@ -1088,7 +1091,9 @@
|
|||
}
|
||||
}
|
||||
if (type == 'sku') {
|
||||
|
||||
if ( selectSpecInfo.length ==0 || JSON.stringify(selectSpecInfo) == '{}') {
|
||||
return infoBox.showToast('请选择规格!')
|
||||
}
|
||||
}
|
||||
if (type == 'package') {
|
||||
if (groupType == 0 && FormData.proGroupVo[0].goods.length <= 0) {
|
||||
|
|
@ -1218,6 +1223,9 @@
|
|||
*/
|
||||
function toTimerPage() {
|
||||
go.to('PAGES_PRODUCT_TIMER', {
|
||||
days: FormData.days,
|
||||
startTime: FormData.startTime,
|
||||
endTime: FormData.endTime
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,75 +3,11 @@
|
|||
<view class="default-box-padding bg-fff border-r-18">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>商品名称</view>
|
||||
<view class="u-flex u-font-24 color-666">
|
||||
<view class="u-m-r-20">绑定至规格</view>
|
||||
<view class="u-flex u-relative">
|
||||
<up-switch :size="18" v-model="pageData.isBindGuige" :disabled="!isSku">绑定至规格</up-switch>
|
||||
<view class="u-absolute position-all" style="z-index: 1;" v-if="!isSku"
|
||||
@click="infoBox.showToast('只有单规格或者多规格商品可绑定至规格',3)"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="border-bottom u-m-t-16 u-p-b-32">{{skuList.length}}{{goods.name}}</view>
|
||||
<view class="">
|
||||
<template v-if="pageData.isBindGuige&&isSku">
|
||||
<view class="list">
|
||||
<view class="u-p-b-32 u-p-t-32 border-bottom" v-for="(sku,index) in skuList" :key="index">
|
||||
<view>规格名称</view>
|
||||
<view class="u-m-t-16">{{sku.specInfo}}</view>
|
||||
<view class="color-666 u-m-t-24 u-flex">
|
||||
<view class="xuhao">序号</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
||||
<view class="u-flex-1">耗材名称</view>
|
||||
<view class="u-flex-1">单位</view>
|
||||
<view class="u-flex-1">用量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-32 color-666">
|
||||
<view class="u-m-t-24" v-for="(item,haocaiIndex) in sku.haoCaiList" :key="haocaiIndex">
|
||||
<view class=" u-flex">
|
||||
<view class="xuhao">{{haocaiIndex+1}}</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
||||
<view class="u-flex-1 ">
|
||||
<choose-haocai @change="conInfosChange($event,item)"
|
||||
:listMap="$haocaiMap" :list="haoCaiList"
|
||||
v-model="item.consInfoId"></choose-haocai>
|
||||
</view>
|
||||
<view class="u-flex-1 ">
|
||||
<choose-danwei :listMap="$danweiMap" :list="danweiList"
|
||||
v-model="item.conUnit"></choose-danwei>
|
||||
</view>
|
||||
<view class="u-flex input">
|
||||
<up-input border="none" v-model="item.surplusStock"></up-input>
|
||||
<up-icon @click="delGuigeHaocao(index,haocaiIndex)" color="#EA4025"
|
||||
:size="16" name="minus-circle-fill"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-16 color-666 u-font-24">
|
||||
<view class="xuhao">
|
||||
</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">库存:{{item.stockNumber}}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class=" u-p-t-32 u-flex" @click="addGuigeHaocai(index)">
|
||||
<up-icon :size="18" color="#318AFE" name="plus-circle-fill"></up-icon>
|
||||
<view class="u-m-l-16">添加耗材</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="list">
|
||||
<view class="u-p-b-32 u-p-t-32 border-bottom" v-for="(item,index) in conInfos" :key="index">
|
||||
<view class="u-p-b-32 u-p-t-32 border-bottom" v-for="(item,index) in consList" :key="index">
|
||||
<view class="color-666 u-flex">
|
||||
<view class="xuhao">序号</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
||||
|
|
@ -112,8 +48,6 @@
|
|||
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="!pageData.isBindGuige">
|
||||
<view class="u-flex">
|
||||
<view class=" u-p-t-32 u-flex" @click="addHaocai">
|
||||
<up-icon :size="18" color="#318AFE" name="plus-circle-fill"></up-icon>
|
||||
|
|
@ -121,13 +55,11 @@
|
|||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="default-box-padding bg-fff border-r-18 u-flex u-row-between u-m-t-32">
|
||||
<view>当某个耗材的使用库存不足时,商品自动
|
||||
售罄。</view>
|
||||
<view>当某个耗材的使用库存不足时,商品自动售罄。</view>
|
||||
|
||||
</view>
|
||||
<view class="bottom">
|
||||
|
|
@ -146,10 +78,10 @@
|
|||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import chooseHaocai from './choose-haocai.vue';
|
||||
import chooseDanwei from './choose-danwei.vue';
|
||||
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js';
|
||||
|
||||
import { getConsList } from '@/api/cons.js';
|
||||
import { productBind } from '@/api/product.js';
|
||||
import { productBindCons } from '@/api/product.js';
|
||||
|
||||
const emits = defineEmits(['cancel', 'updateGoods'])
|
||||
|
||||
|
|
@ -158,9 +90,9 @@
|
|||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
conInfos: [],
|
||||
consList: [],
|
||||
skuList: [],
|
||||
typeEnum: ''
|
||||
type: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -173,30 +105,19 @@
|
|||
let haoCaiList = ref([])
|
||||
let $haocaiMap = reactive({})
|
||||
const skuList = ref(props.goods.skuList)
|
||||
const conInfos = ref(props.goods.conInfos||[])
|
||||
watch(() => props.goods.conInfos, (newval) => {
|
||||
conInfos.value = newval
|
||||
const consList = ref(props.goods.consList||[])
|
||||
watch(() => props.goods.consList, (newval) => {
|
||||
consList.value = newval
|
||||
})
|
||||
watch(() => props.goods.skuList, (newval) => {
|
||||
skuList.value = newval
|
||||
})
|
||||
watch(() => props.goods.type, (newval) => {
|
||||
if(!newval){
|
||||
pageData.isBindGuige = false
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
init()
|
||||
if(props.goods.conInfos){
|
||||
const firstItem= props.goods.conInfos[0]
|
||||
pageData.isBindGuige = firstItem?(firstItem.productSkuId==0?false:true):false
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
function init() {
|
||||
console.log(skuList)
|
||||
getConsList({
|
||||
"status": 1,
|
||||
}).then(res => {
|
||||
|
|
@ -227,101 +148,35 @@
|
|||
item.conUnit = newval.conUnit
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const $baseicHaocaiData = {
|
||||
consInfoId: '',
|
||||
conUnit: '',
|
||||
surplusStock: ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品耗材
|
||||
*/
|
||||
function addHaocai() {
|
||||
conInfos.value.push({
|
||||
...$baseicHaocaiData
|
||||
consList.value.push({
|
||||
consInfoId: '',
|
||||
conUnit: '',
|
||||
surplusStock: ''
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加规格耗材
|
||||
* @param {Object} index
|
||||
*/
|
||||
function addGuigeHaocai(index) {
|
||||
console.log(skuList.value[index])
|
||||
if (skuList.value[index].haoCaiList) {
|
||||
skuList.value[index].haoCaiList.push({
|
||||
...$baseicHaocaiData
|
||||
})
|
||||
} else {
|
||||
skuList.value[index]['haoCaiList'] = [{
|
||||
...$baseicHaocaiData
|
||||
}]
|
||||
}
|
||||
console.log(skuList.value[index]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品耗材
|
||||
* @param {Object} index
|
||||
*/
|
||||
function delHaocai(index) {
|
||||
const item = conInfos.value[index]
|
||||
console.log(item);
|
||||
const item = consList.value[index]
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否删除该耗材',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
if (item.id) {
|
||||
deletetbProskuCon([item.id]).then(res1 => {
|
||||
conInfos.value.splice(index, 1)
|
||||
})
|
||||
} else {
|
||||
conInfos.value.splice(index, 1)
|
||||
}
|
||||
|
||||
consList.value.splice(index, 1)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除规格耗材
|
||||
* @param {Object} guigeIndex
|
||||
* @param {Object} haocaiIndex
|
||||
*/
|
||||
function delGuigeHaocao(guigeIndex, haocaiIndex) {
|
||||
const item = skuList.value[guigeIndex].haoCaiList[haocaiIndex]
|
||||
console.log(item);
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否删除该耗材',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
if (item && item.id) {
|
||||
deletetbProskuCon([item.id]).then(res1 => {
|
||||
skuList.value[guigeIndex].haoCaiList.splice(haocaiIndex, 1)
|
||||
})
|
||||
} else {
|
||||
skuList.value[guigeIndex].haoCaiList.splice(haocaiIndex, 1)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是多规格商品
|
||||
*/
|
||||
const isSku = computed(() => {
|
||||
return props.goods.type == 'sku'||props.goods.type == 'single'
|
||||
})
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
|
|
@ -330,21 +185,9 @@
|
|||
if (!bol) {
|
||||
return
|
||||
}
|
||||
console.log('save');
|
||||
let isPas = false
|
||||
if (!pageData.isBindGuige) {
|
||||
//绑定至商品
|
||||
isPas = conInfos.value.every(v => {
|
||||
let isPas = consList.value.every(v => {
|
||||
return v.consInfoId && v.conUnit && v.surplusStock > 0
|
||||
})
|
||||
} else {
|
||||
//绑定至规格
|
||||
isPas = skuList.value.filter(v => v.haoCaiList && v.haoCaiList.length).every(sku => {
|
||||
return sku.haoCaiList.every(v => {
|
||||
return v.consInfoId && v.conUnit && v.surplusStock > 0
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (!isPas) {
|
||||
return infoBox.showToast('请填写全部耗材选项值')
|
||||
|
|
@ -353,9 +196,7 @@
|
|||
id: props.goods.id,
|
||||
consList: []
|
||||
}
|
||||
if (!pageData.isBindGuige) {
|
||||
//绑定至商品
|
||||
ajaxData.consList = conInfos.value.map(v => {
|
||||
ajaxData.consList = consList.value.map(v => {
|
||||
return {
|
||||
id: v.id || '',
|
||||
consInfoId: v.consInfoId,
|
||||
|
|
@ -363,23 +204,7 @@
|
|||
surplusStock: v.surplusStock * 1,
|
||||
}
|
||||
})
|
||||
} else {
|
||||
for (let i in skuList.value) {
|
||||
const haocaiList = skuList.value[i].haoCaiList || []
|
||||
for (let k in haocaiList) {
|
||||
const v = haocaiList[k]
|
||||
ajaxData.consList.push({
|
||||
id: v.id || '',
|
||||
consInfoId: v.consInfoId,
|
||||
productId: props.goods.id,
|
||||
surplusStock: v.surplusStock * 1,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
console.log(ajaxData);
|
||||
await productBind(ajaxData)
|
||||
await productBindCons(ajaxData)
|
||||
emits('updateGoods')
|
||||
infoBox.showToast('修改成功')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,72 +40,18 @@
|
|||
</view>
|
||||
|
||||
<view class="u-flex u-row-center u-m-t-60">
|
||||
<my-button width="580" shape="circle" @click="save">保存</my-button>
|
||||
<my-button width="580" shape="circle" @click="emitTimerSave">保存</my-button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onReady
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
computed,
|
||||
ref
|
||||
} from 'vue';
|
||||
import { onLoad, onReady } from '@dcloudio/uni-app';
|
||||
import { computed, ref } from 'vue';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import color from '@/commons/color.js'
|
||||
import {
|
||||
$getProductDetail,
|
||||
} from '@/http/yskApi/goods.js'
|
||||
//返回一天的时间 时分格式
|
||||
function returnDayTime() {
|
||||
return new Array(3).fill(1).map((v, index) => {
|
||||
if (index === 0) {
|
||||
return new Array(24).fill(1).map((hour, index) => {
|
||||
return `0${index}`.slice(-2)
|
||||
})
|
||||
}
|
||||
if (index === 1 || index === 2) {
|
||||
return new Array(60).fill(1).map((hour, index) => {
|
||||
return `0${index}`.slice(-2)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
const times = ref(returnDayTime())
|
||||
let defaultTimeIndex = ref(0)
|
||||
|
||||
function getTime(indexArr) {
|
||||
const hour = times.value[0][indexArr[0]]
|
||||
const month = times.value[1][indexArr[1]]
|
||||
const s = times.value[2][indexArr[2]]
|
||||
// return `${hour}:${month}:${s}`
|
||||
return `${hour}:${month}`
|
||||
}
|
||||
//获取$event.detail.value
|
||||
function getEnentDetailValue(e) {
|
||||
return e.detail.value
|
||||
}
|
||||
|
||||
function setListTimeValue(index, key, time) {
|
||||
list.value[index][key].value = time
|
||||
}
|
||||
|
||||
function startTimeChange(e, index) {
|
||||
const indexArr = getEnentDetailValue(e)
|
||||
const time = getTime(indexArr)
|
||||
setListTimeValue(index, 'startTime', time)
|
||||
}
|
||||
|
||||
function endTimeChange(e, index) {
|
||||
const indexArr = getEnentDetailValue(e)
|
||||
const time = getTime(indexArr)
|
||||
setListTimeValue(index, 'endTime', time)
|
||||
}
|
||||
|
||||
import { getProductDetail } from '@/api/product.js'
|
||||
|
||||
|
||||
const cycle = [{
|
||||
|
|
@ -140,15 +86,89 @@
|
|||
const ListDataconstructor = {
|
||||
cycleChecked: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
|
||||
}
|
||||
let goodsDetail = ref({})
|
||||
onLoad(async (opt) => {
|
||||
console.log(opt)
|
||||
const arr = opt ? returnTimer(opt) : [];
|
||||
console.log(arr);
|
||||
if (arr.length) {
|
||||
list.value = arr
|
||||
}
|
||||
})
|
||||
|
||||
function returnTimer(res) {
|
||||
return [{
|
||||
cycleChecked: res.days ? res.days.split(',').filter(v => v) : [],
|
||||
startTime: res.startTime ? {
|
||||
value: res.startTime,
|
||||
index: returnTimeIndex(res.startTime)
|
||||
} : returnBasicTimeConstructor.startTime,
|
||||
endTime: res.endTime ? {
|
||||
value: res.endTime,
|
||||
index: returnTimeIndex(res.endTime)
|
||||
} : returnBasicTimeConstructor.endTime
|
||||
}]
|
||||
}
|
||||
|
||||
function returnTimeIndex(time) {
|
||||
return time.split(':').map(v => {
|
||||
return v * 1
|
||||
})
|
||||
}
|
||||
const times = ref(returnDayTime())
|
||||
//返回一天的时间 时分格式
|
||||
function returnDayTime() {
|
||||
return new Array(3).fill(1).map((v, index) => {
|
||||
if (index === 0) {
|
||||
return new Array(24).fill(1).map((hour, index) => {
|
||||
return `0${index}`.slice(-2)
|
||||
})
|
||||
}
|
||||
if (index === 1 || index === 2) {
|
||||
return new Array(60).fill(1).map((hour, index) => {
|
||||
return `0${index}`.slice(-2)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
let defaultTimeIndex = ref(0)
|
||||
function getTime(indexArr) {
|
||||
const hour = times.value[0][indexArr[0]]
|
||||
const month = times.value[1][indexArr[1]]
|
||||
const s = times.value[2][indexArr[2]]
|
||||
// return `${hour}:${month}:${s}`
|
||||
return `${hour}:${month}:${s}`
|
||||
}
|
||||
|
||||
//获取$event.detail.value
|
||||
function getEnentDetailValue(e) {
|
||||
return e.detail.value
|
||||
}
|
||||
|
||||
function setListTimeValue(index, key, time) {
|
||||
list.value[index][key].value = time
|
||||
}
|
||||
|
||||
function startTimeChange(e, index) {
|
||||
const indexArr = getEnentDetailValue(e)
|
||||
const time = getTime(indexArr)
|
||||
setListTimeValue(index, 'startTime', time)
|
||||
}
|
||||
|
||||
function endTimeChange(e, index) {
|
||||
const indexArr = getEnentDetailValue(e)
|
||||
const time = getTime(indexArr)
|
||||
setListTimeValue(index, 'endTime', time)
|
||||
}
|
||||
|
||||
function returnBasicTimeConstructor() {
|
||||
return {
|
||||
startTime: {
|
||||
value: '00:00',
|
||||
value: '00:00:00',
|
||||
index: [0, 0, 0]
|
||||
},
|
||||
endTime: {
|
||||
value: '23:59',
|
||||
value: '23:59:59',
|
||||
index: [0, 0, 0]
|
||||
}
|
||||
}
|
||||
|
|
@ -184,51 +204,17 @@
|
|||
function emitTimerSave() {
|
||||
const par = {
|
||||
days: list.value[0].cycleChecked.join(','),
|
||||
startTime: list.value[0].startTime.value+':00',
|
||||
endTime: list.value[0].endTime.value+':00'
|
||||
startTime: list.value[0].startTime.value,
|
||||
endTime: list.value[0].endTime.value
|
||||
}
|
||||
console.log(par);
|
||||
uni.$emit('timerSave', par)
|
||||
go.back()
|
||||
}
|
||||
|
||||
function save() {
|
||||
emitTimerSave()
|
||||
}
|
||||
let goodsDetail = ref({})
|
||||
|
||||
function returnTimeIndex(time) {
|
||||
console.log(time);
|
||||
return time.split(':').map(v => {
|
||||
return v * 1
|
||||
})
|
||||
}
|
||||
|
||||
function returnTimer(res) {
|
||||
return [{
|
||||
cycleChecked: res.days ? res.days.split(',').filter(v => v) : [],
|
||||
startTime: res.startTime ? {
|
||||
value: res.startTime,
|
||||
index: returnTimeIndex(res.startTime)
|
||||
} : returnBasicTimeConstructor.startTime,
|
||||
endTime: res.endTime ? {
|
||||
value: res.endTime,
|
||||
index: returnTimeIndex(res.endTime)
|
||||
} : returnBasicTimeConstructor.endTime
|
||||
}]
|
||||
}
|
||||
onLoad(async (opt) => {
|
||||
let res = null
|
||||
if (opt.productId) {
|
||||
res = await $getProductDetail(opt.productId)
|
||||
goodsDetail.value = res
|
||||
}
|
||||
const arr = res ? returnTimer(res) : [];
|
||||
console.log(arr);
|
||||
if (arr.length) {
|
||||
list.value = arr
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
|
|
|||
|
|
@ -2,173 +2,304 @@
|
|||
<view class="page min-page">
|
||||
<view class="box">
|
||||
<view class="block border-top-0 u-p-t-32 u-p-b-32">
|
||||
|
||||
<!-- 注意,如果需要兼容微信小程序,最好通过setRules方法设置rules规则 -->
|
||||
<up-form ref="formRef" labelPosition="top" :model="vdata.formData" :rules="vdata.rules" labelWidth="80" :labelStyle="{fontWeight:'bold'}">
|
||||
<up-form-item label="规格名称" prop="name" borderBottom >
|
||||
<up-input v-model="vdata.formData.name" border="none" placeholder="规格名称,如:衣服" ></up-input>
|
||||
</up-form-item>
|
||||
<up-form-item label="规格级别" prop="level" borderBottom @click="vdata.showLevel = true;">
|
||||
<up-input v-model="vdata.levelName" readonly border="none" placeholder="请选择规格级别" ></up-input>
|
||||
</up-form-item>
|
||||
<up-form-item label="排序" prop="sort" borderBottom >
|
||||
<up-input v-model="vdata.formData.sort" border="none" placeholder="请输入排序" ></up-input>
|
||||
</up-form-item>
|
||||
<up-form-item label="上级规格" prop="pid" borderBottom @click="vdata.showSpec = true;">
|
||||
<up-input v-model="vdata.pidName" readonly border="none" placeholder="请选择上级规格" ></up-input>
|
||||
</up-form-item>
|
||||
</up-form>
|
||||
<uni-forms ref="nameFormRef" :model="specifications" :rules="rules" :label-width="350"
|
||||
label-position="top" validateTrigger="blur">
|
||||
<uni-forms-item label="模版名称" required name="name">
|
||||
<uni-easyinput padding-none :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||
v-model="specifications.name" placeholder="模版名称,如:衣服" />
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
</view>
|
||||
<view v-for="(item,index) in specifications.children" :key="index">
|
||||
<uni-forms :model="item" :rules="rules" err-show-type="undertext" validateTrigger="blur"
|
||||
:ref="setFormRef(index)" :border="true" label-position="top" label-width="350">
|
||||
<view class="block">
|
||||
<view class="border-top-0">
|
||||
<uni-forms-item label="规格组名" required name="name">
|
||||
<uni-easyinput padding-none :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||
v-model="item.name" placeholder="规格组名,如:尺码" />
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<view class="u-p-b-8">
|
||||
<uni-forms-item label="规格值">
|
||||
<view class="option ">
|
||||
<view class="">
|
||||
<view class="u-flex option-item u-m-t-8" v-for="(option,optionIndex) in item.children"
|
||||
:key="optionIndex">
|
||||
<view class="u-flex-1">
|
||||
<uni-forms-item :key="optionIndex" :name="['children',optionIndex,'name']"
|
||||
:ref="setFormInputRef(index,optionIndex)"
|
||||
:rules="[{'required': true,errorMessage: '必填'}]" label-width="0"
|
||||
label="" required :showRequired="false">
|
||||
<view class="bg-fff u-p-t-12 u-p-b-12" style="border-radius: 8rpx;">
|
||||
<uni-easyinput
|
||||
v-model="specifications.children[index].children[optionIndex].name"
|
||||
@input="inpuChange(index,optionIndex)"
|
||||
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||
placeholder="请输入规格值,如:S、M" />
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<view class=" u-flex" v-if="item.children.length>1">
|
||||
<uni-forms-item :key="optionIndex" label-width="0" label=""
|
||||
:showRequired="false">
|
||||
<view class="u-flex">
|
||||
<view class="icon icon-reduce u-m-l-38"
|
||||
@click="delOption(index,optionIndex)">
|
||||
</view>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-24 " @click="addOptions(index)">
|
||||
<view class="icon icon-add u-m-r-22 "></view>
|
||||
<view class="color-main">添加规格</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<template v-if="specifications.children.length>1">
|
||||
<view class="u-p-b-32">
|
||||
<view class="u-flex " @click="delSpecificationsGroup(index)">
|
||||
<view class="icon icon-reduce u-m-r-22 "></view>
|
||||
<view class="color-red">删除规格组</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</uni-forms>
|
||||
</view>
|
||||
|
||||
<view class="u-flex block u-p-l-20 u-p-r-20 u-p-t-28 u-p-b-28" @click="addSpecificationsGroup">
|
||||
<view class="icon icon-add u-m-r-22 "></view>
|
||||
<view class="color-main">添加规格组</view>
|
||||
</view>
|
||||
|
||||
<view class="save-btn-box">
|
||||
<button class="save-btn " hover-class="btn-hover-class" @click="save">保存</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<up-action-sheet
|
||||
:show="vdata.showLevel"
|
||||
:actions="vdata.levelList"
|
||||
title="请选择规格级别"
|
||||
@close="vdata.showLevel = false"
|
||||
@select="levelSelect"
|
||||
></up-action-sheet>
|
||||
<up-action-sheet
|
||||
:show="vdata.showSpec"
|
||||
:actions="vdata.specList"
|
||||
title="请选择规格级别"
|
||||
@close="vdata.showSpec = false"
|
||||
@select="specSelect"
|
||||
></up-action-sheet>
|
||||
<view class="bottom" ref="bottom"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, nextTick, ref } from 'vue';
|
||||
import { onLoad, onReady, } from '@dcloudio/uni-app';
|
||||
|
||||
import {
|
||||
$productSpec
|
||||
} from '@/http/yskApi/goods.js'
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import { getSpecList, addSpec, updateSpec } from '@/api/product.js'
|
||||
import { reactive, nextTick, ref, } from 'vue';
|
||||
import { addSpecQuic } from '@/api/product.js'
|
||||
|
||||
const nameFormRef = ref(null)
|
||||
// 表单样式
|
||||
const placeholderStyle = ref('font-size:28rpx;')
|
||||
//表单边框
|
||||
const inputBorder = ref(false)
|
||||
const form = ref(null)
|
||||
const bottom = ref(null)
|
||||
//表单验证
|
||||
const rules = {
|
||||
name: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '必填'
|
||||
}]
|
||||
},
|
||||
MinOptional: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '必填'
|
||||
}]
|
||||
},
|
||||
MaxOptional: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '必填'
|
||||
}]
|
||||
},
|
||||
optionPrice: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '必填'
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
const option = {
|
||||
type: 'add',
|
||||
id: undefined
|
||||
}
|
||||
const formRef = ref(null)
|
||||
const vdata = reactive({
|
||||
showLevel: false,
|
||||
showSpec: false,
|
||||
levelList: [
|
||||
{ name: "一级", value: 1},
|
||||
{ name: "二级", value: 2},
|
||||
{ name: "三级", value: 3}
|
||||
],
|
||||
levelName: "",
|
||||
pidName: "",
|
||||
formData: {
|
||||
id: null,
|
||||
name: "",
|
||||
level: "",
|
||||
sort: "",
|
||||
pid: "",
|
||||
// 规格列表
|
||||
const specifications = reactive({
|
||||
name: '',
|
||||
children: [
|
||||
{
|
||||
name: '',
|
||||
children: []
|
||||
},
|
||||
rules: {
|
||||
"name": {
|
||||
required: true,
|
||||
message: '请输入规格名称',
|
||||
trigger: ['blur', 'change'],
|
||||
},
|
||||
"level": {
|
||||
required: true,
|
||||
message: '请选择规格级别',
|
||||
trigger: ['blur', 'input'],
|
||||
},
|
||||
"sort": {
|
||||
required: true,
|
||||
message: '请输入排序',
|
||||
trigger: ['blur', 'change'],
|
||||
},
|
||||
"pid": {
|
||||
required: true,
|
||||
message: '请选择上级规格',
|
||||
trigger: ['blur', 'input'],
|
||||
},
|
||||
},
|
||||
specList: []
|
||||
]
|
||||
})
|
||||
|
||||
onReady(()=>{
|
||||
})
|
||||
//表单验证
|
||||
onLoad(opt => {
|
||||
console.log(opt);
|
||||
if (opt && JSON.stringify(opt) !== '{}' && opt.type) {
|
||||
option.type = opt.type
|
||||
const data = uni.getStorageSync('spec')
|
||||
uni.removeStorageSync('spec')
|
||||
if(data){
|
||||
vdata.formData.id = data.id
|
||||
vdata.formData.name = data.name
|
||||
vdata.formData.level = data.level
|
||||
vdata.formData.sort = data.sort
|
||||
vdata.formData.pid = data.pid
|
||||
vdata.levelName = vdata.levelList.filter(item => item.value == vdata.formData.level)[0].name
|
||||
}
|
||||
}
|
||||
uni.setNavigationBarTitle({
|
||||
title: option.type === 'edit' ? '编辑规格模版' : '添加规格模版'
|
||||
title: '添加规格模版'
|
||||
})
|
||||
getSpecData()
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取规格列表
|
||||
* 添加规格组
|
||||
*/
|
||||
function getSpecData(){
|
||||
getSpecList({page: 0, size:10}).then(res=>{
|
||||
vdata.specList = [{name: '顶级',id: 0},...res]
|
||||
if(vdata.formData.id){
|
||||
vdata.pidName = vdata.specList.filter(item => item.id == vdata.formData.pid)[0].name
|
||||
function addSpecificationsGroup() {
|
||||
specifications.children.push({
|
||||
name: '',
|
||||
children: []
|
||||
})
|
||||
scrollPageBottom()
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除规格组
|
||||
* @param {Object} index
|
||||
*/
|
||||
function delSpecificationsGroup(index) {
|
||||
if(specifications.children.length<=1) return;
|
||||
specifications.children.splice(index, 1)
|
||||
}
|
||||
|
||||
/**
|
||||
* 向指定索引的规格组添加规格项
|
||||
* @param {Object} index
|
||||
*/
|
||||
function addOptions(index) {
|
||||
specifications.children[index].children.push({
|
||||
name: '',
|
||||
children: []
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 删除指定索引的规格组添加规格项
|
||||
* @param {Object} index
|
||||
* @param {Object} optionIndex
|
||||
*/
|
||||
function delOption(index, optionIndex) {
|
||||
if(specifications.children[index].children.length<=1){
|
||||
return
|
||||
}
|
||||
specifications.children[index].children.splice(optionIndex, 1)
|
||||
}
|
||||
|
||||
//页面滚动到最底部
|
||||
function scrollPageBottom() {
|
||||
nextTick(() => {
|
||||
uni.pageScrollTo({
|
||||
duration: 100, // 过渡时间
|
||||
scrollTop: 100000, // 滚动的实际距离
|
||||
})
|
||||
})
|
||||
}
|
||||
//设置表单验证规则
|
||||
function setFormRules() {
|
||||
form.value.setRules(rules)
|
||||
}
|
||||
const formRefs = ref([]);
|
||||
/**
|
||||
* 绑定表单元素
|
||||
* @param {Object} index
|
||||
*/
|
||||
function setFormRef(index) {
|
||||
formRefs.value[index] = null;
|
||||
return (el) => {
|
||||
if (el) {
|
||||
formRefs.value[index] = el;
|
||||
}
|
||||
};
|
||||
}
|
||||
// 绑定option input元素
|
||||
const refFormInput = ref([])
|
||||
function setFormInputRef(index, index1) {
|
||||
const newIndex = index * 10000 + index1
|
||||
return (el) => {
|
||||
if (el) {
|
||||
if (!refFormInput.value[newIndex]) {
|
||||
refFormInput.value[newIndex] = el;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当表单内容输入变化根据配置的rules进行验证
|
||||
* @param {Object} index
|
||||
* @param {Object} index1
|
||||
*/
|
||||
function inpuChange(index, index1) {
|
||||
const newIndex = index * 10000 + index1
|
||||
refFormInput.value[newIndex].onFieldChange()
|
||||
}
|
||||
|
||||
function onFieldChange(e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
|
||||
function returnPromise(prosise, index) {
|
||||
return new Promise((resolve, reject) => {
|
||||
prosise.then(res => {
|
||||
console.log(res);
|
||||
resolve({
|
||||
sucees: true
|
||||
})
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
resolve({
|
||||
sucees: false
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function levelSelect (e) {
|
||||
console.log(e)
|
||||
vdata.levelName = e.name;
|
||||
vdata.formData.level = e.value;
|
||||
}
|
||||
|
||||
function specSelect (e) {
|
||||
console.log(e)
|
||||
vdata.pidName = e.name;
|
||||
vdata.formData.pid = e.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
async function save() {
|
||||
|
||||
if (option.type === 'add') {
|
||||
return addSpec(vdata.formData).then(res => {
|
||||
infoBox.showToast('添加成功')
|
||||
settimeoutBack(1500)
|
||||
let isAllPassForm = 0
|
||||
const nameFormRes = await returnPromise(nameFormRef.value.validate())
|
||||
if (!nameFormRes.sucees) {
|
||||
isAllPassForm -= 1
|
||||
}
|
||||
for (let i in specifications.children) {
|
||||
const res = await returnPromise(formRefs.value[i].validate(), i)
|
||||
isAllPassForm += res.sucees ? 1 : 0
|
||||
}
|
||||
//判断验证是否通过
|
||||
if (isAllPassForm === specifications.children.length) {
|
||||
console.log('pass');
|
||||
const data = {
|
||||
name: specifications.name,
|
||||
children: specifications.children.map(v => {
|
||||
return {
|
||||
...v
|
||||
}
|
||||
})
|
||||
}
|
||||
updateSpec(vdata.formData).then(res => {
|
||||
infoBox.showToast('修改成功')
|
||||
settimeoutBack(1500)
|
||||
})
|
||||
}
|
||||
let timer = null
|
||||
function settimeoutBack(time) {
|
||||
clearTimeout(timer)
|
||||
timer = setTimeout(() => {
|
||||
addSpecQuic(data).then(res => {
|
||||
infoBox.showSuccessToast('添加成功')
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, time)
|
||||
}, 1500)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
page {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
<view class="u-m-b-32" v-for="(item,index) in list" :key="index">
|
||||
<view>{{item.text}}:</view>
|
||||
<view class="u-m-t-16">
|
||||
<up-input v-model="item.value">
|
||||
<up-input type="number" v-model="item.value">
|
||||
<template #suffix>
|
||||
<up-button @click="itemClick(item)" type="primary" text="修改" size="mini"></up-button>
|
||||
</template>
|
||||
|
|
@ -116,7 +116,7 @@
|
|||
}
|
||||
})
|
||||
const isSku = computed(() => {
|
||||
// return data.value.typeEnum == '多规格'
|
||||
// return data.value.type == 'sku'
|
||||
return false
|
||||
})
|
||||
watch(() => popShow.value, (newval) => {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,179 @@
|
|||
<template>
|
||||
<view class="page min-page">
|
||||
<view class="box">
|
||||
<view class="block border-top-0 u-p-t-32 u-p-b-32">
|
||||
<up-form ref="formRef" labelPosition="top" :model="vdata.formData" :rules="vdata.rules" labelWidth="80" :labelStyle="{fontWeight:'bold'}">
|
||||
<up-form-item label="规格名称" prop="name" borderBottom >
|
||||
<up-input v-model="vdata.formData.name" border="none" placeholder="规格名称,如:衣服" ></up-input>
|
||||
</up-form-item>
|
||||
<up-form-item label="排序" prop="sort" borderBottom >
|
||||
<up-input v-model="vdata.formData.sort" border="none" placeholder="请输入排序" ></up-input>
|
||||
</up-form-item>
|
||||
</up-form>
|
||||
</view>
|
||||
<view class="save-btn-box">
|
||||
<button class="save-btn " hover-class="btn-hover-class" @click="save">保存</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import { updateSpec } from '@/api/product.js'
|
||||
|
||||
const option = {
|
||||
type: 'add',
|
||||
id: undefined
|
||||
}
|
||||
const formRef = ref(null)
|
||||
const vdata = reactive({
|
||||
formData: {
|
||||
id: null,
|
||||
name: "",
|
||||
level: "",
|
||||
sort: "",
|
||||
pid: "",
|
||||
},
|
||||
rules: {
|
||||
"name": {
|
||||
required: true,
|
||||
message: '请输入规格名称',
|
||||
trigger: ['blur', 'change'],
|
||||
},
|
||||
"sort": {
|
||||
required: true,
|
||||
message: '请输入排序',
|
||||
trigger: ['blur', 'change'],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
onLoad(opt => {
|
||||
if (opt && JSON.stringify(opt) !== '{}' && opt.type) {
|
||||
const data = uni.getStorageSync('spec')
|
||||
uni.removeStorageSync('spec')
|
||||
if(data){
|
||||
vdata.formData.id = data.id
|
||||
vdata.formData.name = data.name
|
||||
vdata.formData.sort = data.sort
|
||||
vdata.formData.level = data.level
|
||||
vdata.formData.pid = data.pid
|
||||
}
|
||||
}
|
||||
uni.setNavigationBarTitle({
|
||||
title: '编辑规格模版'
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
async function save() {
|
||||
updateSpec(vdata.formData).then(res => {
|
||||
infoBox.showToast('修改成功')
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<style scoped>
|
||||
page {
|
||||
background: #F9F9F9;
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.page {
|
||||
background: #F9F9F9;
|
||||
padding: 32rpx 30rpx 0 30rpx;
|
||||
padding-bottom: 200rpx;
|
||||
}
|
||||
::v-deep .uni-forms-item--border {
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
::v-deep .uni-forms-item.is-direction-top .uni-forms-item__label{
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
::v-deep .uni-easyinput__content-input{
|
||||
height: inherit;
|
||||
}
|
||||
::v-deep.uni-forms-item {
|
||||
min-height: inherit;
|
||||
}
|
||||
::v-deep .uni-forms-item__error {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
::v-deep .option .uni-forms-item {
|
||||
padding: 0;
|
||||
min-height: inherit;
|
||||
background-color: transparent;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
|
||||
.box {
|
||||
font-size: 28rpx;
|
||||
.block {
|
||||
background: #FFFFFF;
|
||||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||
padding: 0 24rpx;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.save-btn-box {
|
||||
position: fixed;
|
||||
left: 30rpx;
|
||||
right: 30rpx;
|
||||
bottom: 60rpx;
|
||||
|
||||
}
|
||||
|
||||
::v-deep.uni-forms-item {
|
||||
align-items: inherit;
|
||||
}
|
||||
|
||||
::v-deep .uni-forms-item .uni-forms-item__label {
|
||||
text-indent: 0;
|
||||
font-size: 28rpx !important;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
::v-deep .border-top-0 .uni-forms-item.is-direction-top {
|
||||
border-color: transparent !important;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
border-radius: 12rpx;
|
||||
font-size: 28rpx;
|
||||
border-radius: 100rpx;
|
||||
}
|
||||
|
||||
.btn-hover-class {
|
||||
opacity: .6;
|
||||
}
|
||||
|
||||
::v-deep .uni-input-placeholder {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.option {
|
||||
padding: 8rpx 24rpx 32rpx 24rpx;
|
||||
background: #F9F9F9;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
|
@ -10,9 +10,9 @@
|
|||
<view class="u-m-t-48">
|
||||
<up-form labelPosition="left" :model="data" :rules="rules" ref="refForm">
|
||||
<view>商品名称</view>
|
||||
<view class="u-m-t-16" v-if="isSku">{{data.name}}</view>
|
||||
<view class="u-m-t-16" v-if="data.type == 'sku'">{{data.name}}</view>
|
||||
<view class="u-m-t-38">
|
||||
<template v-if="!isSku">
|
||||
<template v-if="data.type != 'sku'">
|
||||
<view class="u-m-b-32">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>{{data.name}}</view>
|
||||
|
|
@ -84,41 +84,11 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref,
|
||||
watch,
|
||||
nextTick,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import {
|
||||
returnSkuSnap,
|
||||
returnTypeEnum,
|
||||
returnCategory
|
||||
} from '@/pageProduct/util.js'
|
||||
import {
|
||||
formatPrice
|
||||
} from "@/commons/utils/format.js";
|
||||
|
||||
function priceFormat(item, key, val) {
|
||||
let min = 0;
|
||||
let max = 100000000;
|
||||
const returnNewVal = formatPrice(val, min, max, true)
|
||||
const newval = typeof returnNewVal !== 'number' ? returnNewVal.value : returnNewVal
|
||||
if (typeof returnNewVal !== 'number') {
|
||||
uni.showToast({
|
||||
title: `请输入${min}到${max}范围内的数字`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
item[key] = newval
|
||||
}, 100)
|
||||
}
|
||||
const refForm = ref(null)
|
||||
|
||||
import { computed, reactive, ref, watch, onMounted } from 'vue';
|
||||
import { returnSkuSnap, returnTypeEnum, returnCategory } from '@/pageProduct/util.js'
|
||||
import { formatPrice } from "@/commons/utils/format.js";
|
||||
|
||||
const emits = defineEmits(['update:show', 'save'])
|
||||
const props = defineProps({
|
||||
show: {
|
||||
type: Boolean,
|
||||
|
|
@ -139,6 +109,7 @@
|
|||
}
|
||||
}
|
||||
})
|
||||
let popShow = ref(props.show)
|
||||
let data = ref({
|
||||
lowPrice: 0,
|
||||
skuList: []
|
||||
|
|
@ -159,37 +130,57 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
const emits = defineEmits(['update:show', 'save'])
|
||||
const refForm = ref(null)
|
||||
onMounted(()=>{
|
||||
// #ifndef H5
|
||||
refForm.value.setRules(rules)
|
||||
// #endif
|
||||
})
|
||||
watch(() => popShow.value, (newval) => {
|
||||
emits('update:show', newval)
|
||||
})
|
||||
|
||||
/**
|
||||
* 金额处理
|
||||
* @param {Object} item
|
||||
* @param {Object} key
|
||||
* @param {Object} val
|
||||
*/
|
||||
function priceFormat(item, key, val) {
|
||||
let min = 0;
|
||||
let max = 100000000;
|
||||
const returnNewVal = formatPrice(val, min, max, true)
|
||||
const newval = typeof returnNewVal !== 'number' ? returnNewVal.value : returnNewVal
|
||||
if (typeof returnNewVal !== 'number') {
|
||||
uni.showToast({
|
||||
title: `请输入${min}到${max}范围内的数字`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
item[key] = newval
|
||||
}, 100)
|
||||
}
|
||||
|
||||
|
||||
const form = reactive({
|
||||
note: ''
|
||||
})
|
||||
let popShow = ref(props.show)
|
||||
watch(() => props.show, (newval) => {
|
||||
popShow.value = newval
|
||||
if (newval) {
|
||||
data.value = {
|
||||
...props.goods
|
||||
}
|
||||
}
|
||||
})
|
||||
const isSku = computed(() => {
|
||||
return data.value.typeEnum == '多规格'
|
||||
})
|
||||
watch(() => popShow.value, (newval) => {
|
||||
emits('update:show', newval)
|
||||
})
|
||||
|
||||
function close() {
|
||||
popShow.value = false
|
||||
}
|
||||
|
||||
function open() {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function save() {
|
||||
refForm.value.validate().then(valid => {
|
||||
if (valid) {
|
||||
console.log(data)
|
||||
emits('save', {
|
||||
...data.value,
|
||||
})
|
||||
|
|
@ -200,37 +191,16 @@
|
|||
// 处理验证错误
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function close() {
|
||||
popShow.value = false
|
||||
}
|
||||
|
||||
function open() {
|
||||
|
||||
}
|
||||
|
||||
// function save() {
|
||||
// const skuSnap = returnSkuSnap(data.value)
|
||||
// let typeEnum = returnTypeEnum(data.value.typeEnum)
|
||||
// let lowPrice = undefined
|
||||
// typeEnum = typeEnum ? typeEnum : 'normal'
|
||||
// const findCategory = returnCategory(data.value.categoryName, props.category)
|
||||
// console.log(typeEnum);
|
||||
// console.log(findCategory);
|
||||
// const categoryId = findCategory ? findCategory.id : ''
|
||||
// if (typeEnum == 'normal') {
|
||||
// // 单规格
|
||||
// lowPrice = data.value.skuList[0].salePrice
|
||||
// }
|
||||
// emits('save', {
|
||||
// ...data.value,
|
||||
// lowPrice,
|
||||
// typeEnum,
|
||||
// images: data.value.images ? data.value.images : [data.value.coverImg],
|
||||
// categoryId,
|
||||
// skuSnap: JSON.stringify(skuSnap)
|
||||
// })
|
||||
// }
|
||||
|
||||
onMounted(()=>{
|
||||
// #ifndef H5
|
||||
refForm.value.setRules(rules)
|
||||
// #endif
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -32,15 +32,11 @@
|
|||
<view class="info-p-l color-333 u-flex u-row-between">
|
||||
<view class="u-flex">
|
||||
<text class="u-m-r-24">{{data.name}}</text>
|
||||
<!-- <uni-tag size="small" type="primary"
|
||||
custom-style="background-color: #318AFE;" :text="data.typeEnum"></uni-tag> -->
|
||||
</view>
|
||||
<view class="u-font-32">
|
||||
<text v-if="data.type=='single'">¥</text>
|
||||
<text>{{data.lowPrice}}</text>
|
||||
<!-- <text>¥</text>
|
||||
<text>{{data.lowPrice}}</text>
|
||||
<text v-if="data.typeEnum == '多规格'">~¥{{data.maxPrice }}</text> -->
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-24">
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
<view class="u-flex">
|
||||
<view class="u-p-l-16 item u-p-r-16 u-p-t-6 u-p-b-6 tranistion u-text-center color-333"
|
||||
:class="{'active':pageData.stateCurrent==index}" @tap="statesTableClick(index)"
|
||||
v-for="(item,index) in statesTabsList" :key="index">
|
||||
{{item}}
|
||||
v-for="(item,index) in pageData.statesTabsList" :key="index">
|
||||
{{item.laber}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-col-center" @click="go.to('PAGES_PRODUCT_SPECIF_TEMPLATE')">
|
||||
|
|
@ -83,31 +83,6 @@
|
|||
<my-switch v-model="goodsStockData.isStock"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-flex u-m-t-32">
|
||||
<view class="">共享库存:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isDistribute"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32">
|
||||
<view class="">售罄:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isSoldStock"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32">
|
||||
<view class="">上架:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isSale"></my-switch>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- <view class="u-m-t-24 u-m-t-32" v-if="goodsStockData.isStock">
|
||||
<view class="">数量:</view>
|
||||
<view class="u-m-t-24">
|
||||
<uni-easyinput v-model="goodsStockData.stockNumber" placeholder="请输入库存数量"></uni-easyinput>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
|
@ -138,22 +113,10 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow,
|
||||
onPageScroll,
|
||||
onPullDownRefresh
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import {
|
||||
hasPermission
|
||||
} from '@/commons/utils/hasPermission.js';
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js';
|
||||
import myGoods from './components/goods.vue'
|
||||
import myControl from './components/control.vue'
|
||||
import myCategory from './components/category.vue'
|
||||
|
|
@ -163,8 +126,6 @@
|
|||
import editStock from './components/edit-stock.vue';
|
||||
import baosunVue from './components/baosun.vue';
|
||||
import {
|
||||
$tbProduct,
|
||||
$upProSort,
|
||||
$updateProduct,
|
||||
$getProductDetail,
|
||||
$delProduct,
|
||||
|
|
@ -175,7 +136,8 @@
|
|||
} from "@/http/yskApi/goods.js"
|
||||
import {
|
||||
getProductList,
|
||||
getCategoryList
|
||||
getCategoryList,
|
||||
updateProduct
|
||||
} from '@/api/product.js'
|
||||
|
||||
import {
|
||||
|
|
@ -190,6 +152,12 @@
|
|||
value: '',
|
||||
placeholder: '输入搜索的商品'
|
||||
},
|
||||
statesTabsList: [
|
||||
{ laber: '全部', value: ''},
|
||||
{ laber: '已售罄', value: 'sold_out'},
|
||||
{ laber: '在售中', value: 'on_sale'},
|
||||
{ laber: '已下架', value: 'off_sale'},
|
||||
],
|
||||
showGoodsDetail: false,
|
||||
selGoodsIndex: '',
|
||||
selGoods: {},
|
||||
|
|
@ -202,8 +170,7 @@
|
|||
categoryId: '',
|
||||
name: '',
|
||||
orderBy: "create_time desc",
|
||||
isSoldStock: '',
|
||||
isSale: ''
|
||||
status: '',
|
||||
},
|
||||
category: '',
|
||||
categoryList: [], //分类列表
|
||||
|
|
@ -211,6 +178,11 @@
|
|||
categoryName: '',
|
||||
hasAjax: false
|
||||
})
|
||||
const tabsList = ['简洁', '详情']
|
||||
const control = ref(null)
|
||||
const model = ref(null)
|
||||
const goodsStockModel = ref(null)
|
||||
let reportDamage = ref(null) //报损组件
|
||||
watch(() => pageData.query.categoryId, (newval) => {
|
||||
getGoodsList()
|
||||
})
|
||||
|
|
@ -292,16 +264,19 @@
|
|||
*/
|
||||
function changePriceShow(index) {
|
||||
pageData.selGoodsIndex = index
|
||||
const goods = pageData.goodsList[index]
|
||||
let goods = pageData.goodsList[index]
|
||||
console.log(goods)
|
||||
if(goods.type != 'sku') {
|
||||
goods.lowPrice = goods.skuList[0].salePrice
|
||||
}
|
||||
goods.skuList = goods.skuList.map(v => {
|
||||
return {
|
||||
...v,
|
||||
_lowPrice: v.lowPrice
|
||||
_lowPrice: v.salePrice
|
||||
}
|
||||
})
|
||||
console.log(goods)
|
||||
const lowPrice = goods.lowPrice.toString().replace('¥', '') * 1
|
||||
let lowPrice = goods.lowPrice.toString().replace('¥', '') * 1
|
||||
pageData.selGoods = {
|
||||
...goods,
|
||||
lowPrice,
|
||||
|
|
@ -310,20 +285,14 @@
|
|||
popup.price.show = true
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改价格确认
|
||||
* @param {Object} goods
|
||||
*/
|
||||
async function changePriceConfirm(goods) {
|
||||
|
||||
let goodsArr = []
|
||||
if (goods.typeEnum == '单规格') {
|
||||
goodsArr = [{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
isSku: false,
|
||||
id: goods.id,
|
||||
key: 'salePrice',
|
||||
value: goods.lowPrice
|
||||
}]
|
||||
} else {
|
||||
if (goods.type == 'sku') {
|
||||
goodsArr = goods.skuList.map(v => {
|
||||
return {
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
|
|
@ -333,8 +302,17 @@
|
|||
value: v.lowPrice
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
goodsArr = [{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
isSku: false,
|
||||
id: goods.id,
|
||||
key: 'salePrice',
|
||||
value: goods.lowPrice
|
||||
}]
|
||||
}
|
||||
const res = await $updateProductData(goodsArr)
|
||||
const res = await updateProduct(goodsArr)
|
||||
infoBox.showToast('修改成功')
|
||||
popup.price.show = false
|
||||
getGoodsList()
|
||||
|
|
@ -365,25 +343,7 @@
|
|||
}
|
||||
async function changeStockConfirm(goods) {
|
||||
let goodsArr = []
|
||||
// if (goods.typeEnum == '单规格') {
|
||||
// goodsArr = [{
|
||||
// shopId: uni.getStorageSync('shopId'),
|
||||
// isSku: false,
|
||||
// id: goods.id,
|
||||
// key: 'stockNumber',
|
||||
// value: goods.stockNumber
|
||||
// }]
|
||||
// } else {
|
||||
// goodsArr = goods.skuList.map(v => {
|
||||
// return {
|
||||
// shopId: uni.getStorageSync('shopId'),
|
||||
// isSku: true,
|
||||
// id: v.id,
|
||||
// key: 'stockNumber',
|
||||
// value: v.stockNumber
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
goodsArr = [{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
isSku: false,
|
||||
|
|
@ -454,12 +414,7 @@
|
|||
}
|
||||
|
||||
|
||||
const tabsList = ['简洁', '详情']
|
||||
const statesTabsList = ['全部', '已售罄', '在售中', '已下架']
|
||||
const control = ref(null)
|
||||
const model = ref(null)
|
||||
const goodsStockModel = ref(null)
|
||||
let reportDamage = ref(null) //报损组件
|
||||
|
||||
// 商品报损
|
||||
function reportDamageClick(index) {
|
||||
pageData.reportData = pageData.goodsList[index]
|
||||
|
|
@ -537,6 +492,7 @@
|
|||
function resetQuery() {
|
||||
pageData.totalElements = 0;
|
||||
pageData.query.page = 1;
|
||||
getGoodsList()
|
||||
}
|
||||
|
||||
async function toGoodsDetail(id) {
|
||||
|
|
@ -550,30 +506,14 @@
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品类型切换
|
||||
* @param {Object} index
|
||||
*/
|
||||
function statesTableClick(index) {
|
||||
pageData.stateCurrent = index;
|
||||
pageData.query.status = pageData.statesTabsList[index].value
|
||||
resetQuery()
|
||||
console.log(index);
|
||||
if (index == 0) {
|
||||
pageData.query.isSoldStock = ''
|
||||
pageData.query.isSale = ''
|
||||
return
|
||||
}
|
||||
if (index == 1) {
|
||||
pageData.query.isSoldStock = 1
|
||||
pageData.query.isSale = ''
|
||||
return
|
||||
}
|
||||
if (index == 2) {
|
||||
pageData.query.isSoldStock = ''
|
||||
pageData.query.isSale = 1
|
||||
return
|
||||
}
|
||||
if (index == 3) {
|
||||
pageData.query.isSoldStock = ''
|
||||
pageData.query.isSale = 0
|
||||
return
|
||||
}
|
||||
}
|
||||
let test = ref(false)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import { reactive, ref } from 'vue';
|
|||
}
|
||||
function edit(){
|
||||
uni.setStorageSync('spec',props.data)
|
||||
go.to('PAGES_PRODUCT_GUIGE_ADD', {
|
||||
go.to('PAGES_PRODUCT_GUIGE_EDIT', {
|
||||
type: 'edit'
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import {
|
||||
$types
|
||||
} from '@/commons/goodsData.js'
|
||||
import { $types } from '@/commons/goodsData.js'
|
||||
export function returnSkuSnap(goods) {
|
||||
const selectSpec = typeof goods.selectSpec === 'string' ? JSON.parse(goods.selectSpec) : goods.selectSpec
|
||||
let result = selectSpec.map(v => {
|
||||
|
|
@ -11,8 +9,8 @@ export function returnSkuSnap(goods) {
|
|||
})
|
||||
return result
|
||||
}
|
||||
export function returnTypeEnum(typeEnum) {
|
||||
const item = $types.find(v => v.title == typeEnum)
|
||||
export function returnTypeEnum(type) {
|
||||
const item = $types.find(v => v.title == type)
|
||||
let result = item ? item.value : undefined
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,71 +2,51 @@
|
|||
<view class="h7">基本信息设置</view>
|
||||
<view class="content">
|
||||
<view>
|
||||
<view>
|
||||
<text style="color: red;">*</text>员工姓名
|
||||
</view>
|
||||
<view> <text style="color: red;">*</text>员工姓名 </view>
|
||||
<input type="text" v-model="datas.formData.name" placeholder="请填写员工名称" />
|
||||
</view>
|
||||
<view>
|
||||
<view>
|
||||
<text style="color: red;">*</text>手机号
|
||||
</view>
|
||||
<view> <text style="color: red;">*</text>手机号 </view>
|
||||
<input type="text" v-model="datas.formData.phone" placeholder="请填写手机号" />
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<view>
|
||||
<text style="color: red;">*</text>员工编号
|
||||
</view>
|
||||
<view> <text style="color: red;">*</text>员工编号 </view>
|
||||
<input type="text" v-model="datas.formData.code" placeholder="请填写员工编号" />
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<view>
|
||||
<text style="color: red;">*</text>员工账号
|
||||
</view>
|
||||
<view> <text style="color: red;">*</text>员工账号 </view>
|
||||
<input type="text" v-model="datas.formData.accountName" placeholder="请填写员工账号,建议使用手机号" />
|
||||
</view>
|
||||
<view>
|
||||
<view>
|
||||
登录密码
|
||||
</view>
|
||||
<view> <text style="color: red;">*</text>登录密码 </view>
|
||||
<view style="margin: 24rpx 0;display: flex;justify-content: space-between;align-items: center;">
|
||||
<input type="text" v-model="datas.formData.accountPwd" @change="datas.isPassword = true" placeholder="请输入登录密码,不填写默认123456" />
|
||||
<view style="color: #2979ff;" @click="datas.isPassword = true">重置密码</view>
|
||||
<input type="text" v-model="datas.formData.accountPwd" @change="datas.isPassword = true" placeholder="请输入登录密码" />
|
||||
<view style="color: #2979ff;" @click="datas.isPassword = true;datas.formData.accountPwd=''">重置密码</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view>
|
||||
<view style="margin-bottom: 24rpx;">
|
||||
优惠类型
|
||||
</view>
|
||||
<view style="margin-bottom: 24rpx;"> 优惠类型 </view>
|
||||
<up-radio-group v-model="datas.formData.discountType" placement="row" >
|
||||
<up-radio label="折扣" name="1"></up-radio>
|
||||
<up-radio label="金额" name="0"></up-radio>
|
||||
</up-radio-group>
|
||||
</view>
|
||||
<view>
|
||||
<view>
|
||||
最低优惠折扣
|
||||
</view>
|
||||
<view> 最低优惠折扣 </view>
|
||||
<input v-if="datas.formData.discountType==1" @blur="maxdisinput" type="number"
|
||||
v-model="datas.formData.maxDiscountAmount" placeholder="请输入最低优惠折扣" />
|
||||
<input v-if="datas.formData.discountType==0" type="number" v-model="datas.formData.maxDiscountAmount"
|
||||
placeholder="请输入最低优惠折扣" />
|
||||
</view>
|
||||
<view>
|
||||
<view>
|
||||
<text style="color: red;">*</text> 角色
|
||||
</view>
|
||||
<view> <text style="color: red;">*</text> 角色 </view>
|
||||
<view @tap="show=true" style="height: 50rpx;font-size: 28rpx;color: #999999;margin-top: 24rpx;">{{datas.rolesdata }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="h7">员工权限设置</view>
|
||||
<view class="contentBottom" v-for="item in datas.permissions" :key="item.id">
|
||||
<view>
|
||||
{{item.label}}
|
||||
</view>
|
||||
<view> {{item.label}} </view>
|
||||
<view class="">
|
||||
<up-checkbox shape='circle' :customStyle="{marginBottom: '8px'}" v-model:checked="ele.hasPermission"
|
||||
usedAlone v-for="(ele, index) in item.children" :key="index" :label="ele.label"
|
||||
|
|
@ -74,9 +54,7 @@
|
|||
</up-checkbox>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottomBotton" @tap="sumbitEvent">
|
||||
保存
|
||||
</view>
|
||||
<view class="bottomBotton" @tap="sumbitEvent"> 保存 </view>
|
||||
|
||||
<!-- 消息提示 -->
|
||||
<up-toast ref="uToastRef"></up-toast>
|
||||
|
|
@ -89,15 +67,8 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
getCurrentInstance,
|
||||
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
import {
|
||||
onShow,
|
||||
} from '@dcloudio/uni-app';
|
||||
import { getCurrentInstance, reactive, ref } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import go from '@/commons/utils/go.js';
|
||||
|
||||
import { shopStaffDetail,getShopStaffPermission,shopStaffAdd,shopStaffPut } from "@/api/staff.js"
|
||||
|
|
@ -129,8 +100,6 @@
|
|||
]);
|
||||
const show = ref(false)
|
||||
onShow(() => {
|
||||
|
||||
|
||||
init()
|
||||
})
|
||||
|
||||
|
|
@ -140,6 +109,7 @@
|
|||
//获取权限列表
|
||||
let res = await getShopPermission()
|
||||
datas.permissions = res
|
||||
Object.assign(datas.permissions, res)
|
||||
if (props.type == 'edit') {
|
||||
uni.setNavigationBarTitle({
|
||||
title: '编辑员工'
|
||||
|
|
@ -172,7 +142,6 @@
|
|||
|
||||
datas.permissions.forEach(ele => {
|
||||
ele.children.forEach(res => {
|
||||
console.log(res)
|
||||
res2.forEach(v => {
|
||||
if (res.id == v ) {
|
||||
res.hasPermission = 1
|
||||
|
|
@ -180,7 +149,6 @@
|
|||
})
|
||||
})
|
||||
})
|
||||
console.log(datas.permissions)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +159,7 @@
|
|||
*/
|
||||
function getShopStaffDetail(id) {
|
||||
shopStaffDetail({id:id}).then(res => {
|
||||
datas.formData = res
|
||||
Object.assign(datas.formData, res)
|
||||
if (datas.rolesList) {
|
||||
let rolefilter = datas.rolesList.filter(ele => ele.id == res.roleId)
|
||||
datas.rolesdata = rolefilter[0].name
|
||||
|
|
@ -218,7 +186,10 @@
|
|||
if(datas.permissions){
|
||||
datas.permissions.forEach(ele => {
|
||||
ele.children.forEach(res => {
|
||||
|
||||
if (res.hasPermission) {
|
||||
console.log(res)
|
||||
console.log(datas.formData.shopPermissionIds)
|
||||
res.hasPermission = 1
|
||||
datas.formData.shopPermissionIds.push(res.id)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<view class="">
|
||||
<view style="display: flex;justify-content: center;align-items: center;">
|
||||
<span style="font-size: 28rpx;color: #999999;">是否启用</span>
|
||||
<up-switch :activeValue="true" :inactiveValue="false" v-model="item.status" size="18"
|
||||
<up-switch :activeValue="1" :inactiveValue="0" v-model="item.status" size="18"
|
||||
@change="switch2Change($event,item)"></up-switch>
|
||||
</view>
|
||||
<view class="df">
|
||||
|
|
|
|||
|
|
@ -276,7 +276,8 @@
|
|||
* @param {Object} item
|
||||
*/
|
||||
function scanCode(item) {
|
||||
if ( !item.tableCode) {
|
||||
console.log(item)
|
||||
if ( item.tableCode != '') {
|
||||
infoBox.showToast('当前桌台已绑定')
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,13 @@
|
|||
// "navigationBarTitleText": "编辑规格"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pageId": "PAGES_PRODUCT_GUIGE_EDIT",
|
||||
"path": "add-specifications/edit-specifications",
|
||||
"style": {
|
||||
// "navigationBarTitleText": "编辑规格"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pageId": "PAGES_PRODUCT_GUIGE_CHOOSE",
|
||||
"path": "add-specifications/choose-specifications",
|
||||
|
|
|
|||
|
|
@ -82,20 +82,20 @@
|
|||
v-for="(item,index) in vdata.extendList" :key="index"
|
||||
:class="{'active':vdata.extendIndex==index}"
|
||||
@click="extendTabClick(item,index)"
|
||||
>{{item.title}}</view>
|
||||
>{{item.name}}</view>
|
||||
</view>
|
||||
<view class="extend_content">
|
||||
<view class="preview">
|
||||
<view class="index_bg"><up-image v-if="'index_bg' == vdata.extendInfo.autokey" :src="vdata.extendInfo.value"></up-image></view>
|
||||
<view class="my_bg"><up-image v-if="'my_bg' == vdata.extendInfo.autokey" :src="vdata.extendInfo.value"></up-image></view>
|
||||
<view class="bg"><up-image v-if="'member_bg' == vdata.extendInfo.autokey" :src="'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/cashier_admin_app_shopSet/'+vdata.extendInfo.autokey+'1.png'" ></up-image></view>
|
||||
<view class="member_bg"><up-image v-if="'member_bg' == vdata.extendInfo.autokey" :src="vdata.extendInfo.value"></up-image></view>
|
||||
<view class="shopinfo_bg"><up-image v-if="'shopinfo_bg' == vdata.extendInfo.autokey" :src="vdata.extendInfo.value"></up-image></view>
|
||||
<view class="shopinfo_bg_f" v-if="'shopinfo_bg' == vdata.extendInfo.autokey"></view>
|
||||
<view class="bg"><up-image v-if="vdata.extendInfo.autokey" :src="'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/cashier_admin_app_shopSet/'+vdata.extendInfo.autokey+'.png'" ></up-image></view>
|
||||
<view class="index_bg"><up-image v-if="'index_bg' == vdata.extendInfo.autoKey" :src="vdata.extendInfo.value"></up-image></view>
|
||||
<view class="my_bg"><up-image v-if="'my_bg' == vdata.extendInfo.autoKey" :src="vdata.extendInfo.value"></up-image></view>
|
||||
<view class="bg"><up-image v-if="'member_bg' == vdata.extendInfo.autoKey" :src="'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/cashier_admin_app_shopSet/'+vdata.extendInfo.autoKey+'.png'" ></up-image></view>
|
||||
<view class="member_bg"><up-image v-if="'member_bg' == vdata.extendInfo.autoKey" :src="vdata.extendInfo.value"></up-image></view>
|
||||
<view class="shopinfo_bg"><up-image v-if="'shopinfo_bg' == vdata.extendInfo.autoKey" :src="vdata.extendInfo.value"></up-image></view>
|
||||
<view class="shopinfo_bg_f" v-if="'shopinfo_bg' == vdata.extendInfo.autoKey"></view>
|
||||
<view class="bg"><up-image v-if="vdata.extendInfo.autoKey" :src="'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/cashier_admin_app_shopSet/'+vdata.extendInfo.autoKey+'.png'" ></up-image></view>
|
||||
</view>
|
||||
<view class="extend_img">
|
||||
<view class="extend_title">{{vdata.extendInfo.title}}背景图片</view>
|
||||
<view class="extend_title">{{vdata.extendInfo.name}}背景图片</view>
|
||||
<view class="fileUp">
|
||||
<up-image :src="vdata.extendInfo.value"></up-image>
|
||||
<view class="file" @tap="chooseAndUploadAvatar('extendUp')"></view>
|
||||
|
|
@ -113,16 +113,10 @@
|
|||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
// import { getShopInfo , editShopInfo, getShopExtend, editShopExtend } from '@/http/yskApi/shop.js'
|
||||
import storageManage from '@/commons/utils/storageManage.js'
|
||||
import go from '@/commons/utils/go.js'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import { $uploadFile } from '@/http/yskApi/file.js'
|
||||
import { uploadFile } from '@/api/index.js'
|
||||
import { getShopInfo, editShopInfo } from '@/api/shop.js'
|
||||
import { forIn } from 'lodash';
|
||||
import { getShopInfo, editShopInfo, getShopExtend, editShopExtend } from '@/api/shop.js'
|
||||
|
||||
const phone = ref(null)
|
||||
const vdata = reactive({
|
||||
shopInfo: {
|
||||
status: 2,
|
||||
|
|
@ -141,12 +135,10 @@ const vdata = reactive({
|
|||
label: "",
|
||||
type: "",
|
||||
inputValue: "",
|
||||
inputType: "text",
|
||||
maxLength: '999',
|
||||
|
||||
})
|
||||
onMounted(() => {
|
||||
// shopExtend();
|
||||
shopExtend();
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
|
|
@ -184,7 +176,6 @@ const shopInfo = () => {
|
|||
vdata.takeout = true
|
||||
}
|
||||
vdata.shopInfo = res;
|
||||
console.log(vdata.shopInfo)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -192,13 +183,11 @@ const shopInfo = () => {
|
|||
* 获取店铺图片
|
||||
*/
|
||||
let shopExtend = () => {
|
||||
getShopExtend({
|
||||
autokey: "index_bg",
|
||||
}).then((res) => {
|
||||
if ( res.content && res.content.length > 0 ) {
|
||||
vdata.extendList = res.content;
|
||||
getShopExtend().then((res) => {
|
||||
if ( res && res.length > 0 ) {
|
||||
vdata.extendList = res;
|
||||
vdata.extendIndex = 0;
|
||||
vdata.extendInfo = res.content[0];
|
||||
vdata.extendInfo = res[0];
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -207,7 +196,6 @@ let shopExtend = () => {
|
|||
* 付费模式修改
|
||||
*/
|
||||
let radioChange = (n) => {
|
||||
console.log('radioChange', n);
|
||||
let params = {
|
||||
id : vdata.shopInfo.id,
|
||||
registerType : n,
|
||||
|
|
@ -230,9 +218,10 @@ let updateShopInfo = (params,type) => {
|
|||
* 修改店铺图片
|
||||
*/
|
||||
let updateShopExtend = () => {
|
||||
editShopExtend(vdata.extendInfo).then((res) => {
|
||||
|
||||
})
|
||||
editShopExtend({
|
||||
autokey: vdata.extendInfo.autoKey,
|
||||
value: vdata.extendInfo.value,
|
||||
}).then((res) => {})
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -248,9 +237,7 @@ let chooseAndUploadAvatar = ( type ) => {
|
|||
sourceType: ['album', 'camera'], // 图片来源,相册或相机
|
||||
success: (res) => {
|
||||
let file = res.tempFiles[0];
|
||||
console.log(res)
|
||||
uploadFile(file).then(res => {
|
||||
console.log(res);
|
||||
if ( type == "coverImg") {
|
||||
vdata.shopInfo.coverImg = res;
|
||||
let params = {
|
||||
|
|
@ -265,7 +252,6 @@ let chooseAndUploadAvatar = ( type ) => {
|
|||
}
|
||||
|
||||
}).catch(res=>{
|
||||
console.log(res);
|
||||
if(res.errMsg){
|
||||
uni.showToast({
|
||||
title:'图片大小超出限制',
|
||||
|
|
@ -309,7 +295,6 @@ let switchChange = ( type ) => {
|
|||
let params = {
|
||||
id : vdata.shopInfo.id,
|
||||
}
|
||||
console.log(vdata.shopInfo)
|
||||
switch ( type ){
|
||||
case "address":
|
||||
params.lng = vdata.shopInfo.lng;
|
||||
|
|
@ -414,13 +399,14 @@ let showMap = () => {
|
|||
margin-top: 24rpx;
|
||||
.extendTab{
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
justify-content: flex-start;
|
||||
.extendTab_item{
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 4rpx;
|
||||
border: 2rpx solid #E5E5E5;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
.active{
|
||||
background: #318AFE;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,131 @@
|
|||
<template>
|
||||
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||
<template #desc>
|
||||
<view class="u-text-left u-p-l-30 u-p-r-30 u-p-t-30 ">
|
||||
<view class="u-m-t-32 u-flex ">
|
||||
<uni-easyinput type="number" v-model="form.pack_number" placeholder="打包数量"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-p-l-30 u-p-r-30 u-m-t-28 u-p-b-30">
|
||||
<view class="">
|
||||
<my-button @tap="confirm" shape="circle" fontWeight="700">确认</my-button>
|
||||
<view class="u-m-t-10">
|
||||
<my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, nextTick, ref } from 'vue';
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
|
||||
const $form = {
|
||||
pack_number: 1
|
||||
}
|
||||
const form = reactive({
|
||||
number: null,
|
||||
...$form
|
||||
})
|
||||
|
||||
function resetForm() {
|
||||
Object.assign(form, {
|
||||
...$form
|
||||
})
|
||||
}
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open(data) {
|
||||
console.log(data)
|
||||
form.number = data.number
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
function confirm() {
|
||||
const { pack_number } = form
|
||||
if( pack_number > form.number){
|
||||
uni.showToast({
|
||||
title: '打包数量不能大于菜品数量',
|
||||
icon: 'none'
|
||||
})
|
||||
return false;
|
||||
}
|
||||
emits('confirm', pack_number)
|
||||
close()
|
||||
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.lh34{
|
||||
line-height: 34rpx;
|
||||
}
|
||||
.tag {
|
||||
background-color: #fff;
|
||||
border: 1px solid #E5E5E5;
|
||||
line-height: inherit;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
padding: 6rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
|
||||
&.active {
|
||||
border-color: #E6F0FF;
|
||||
color: $my-main-color;
|
||||
}
|
||||
}
|
||||
|
||||
.hover-class {
|
||||
background-color: #E5E5E5;
|
||||
}
|
||||
|
||||
.discount {
|
||||
.u-absolute {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.bg1 {
|
||||
background: #F7F7FA;
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 0 80rpx;
|
||||
}
|
||||
|
||||
.border {
|
||||
border: 1px solid #E5E5E5;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
padding: 22rpx 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.placeholder-class {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -135,7 +135,7 @@
|
|||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-flex" v-if="item.is_pack" style="flex-shrink: 0;" >
|
||||
<view class="u-m-r-20 u-flex" v-if="item.pack_number>0" style="flex-shrink: 0;" >
|
||||
<uni-tag
|
||||
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
|
||||
size="small" text="打包" inverted type="success" />
|
||||
|
|
@ -149,7 +149,7 @@
|
|||
{{item.name}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-font-24 color-999 u-m-t-10">{{item.specSnap||' '}}</view>
|
||||
<view class="u-font-24 color-999 u-m-t-10">{{item.specInfo||' '}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="">
|
||||
|
|
@ -199,7 +199,7 @@
|
|||
</view>
|
||||
<view class="u-flex u-m-r-20 ">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="toggleGoodsItemKey(item,index,'is_pack')">{{item.is_pack?'取消打包':'打包'}}</button>
|
||||
@tap="showModel('packNumber',index,item)">{{item.pack_number>0?'取消打包':'打包'}}</button>
|
||||
</view>
|
||||
<view class="u-flex u-m-r-20 ">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
|
|
@ -262,7 +262,7 @@
|
|||
<view class="btn ">
|
||||
<my-button shape="circle" @click="createAnOrder">
|
||||
<view class="font-bold u-font-32">
|
||||
{{(pageData.shopInfo.registerType=='munchies'||pageData.eatTypes.active=='take-out')?'结算': '下单'}}
|
||||
{{(pageData.shopInfo.registerType=='before'||pageData.eatTypes.active=='take-out')?'结算': '下单'}}
|
||||
</view>
|
||||
</my-button>
|
||||
</view>
|
||||
|
|
@ -272,6 +272,7 @@
|
|||
@confirm="discountconfirm"></model-discount>
|
||||
<give-food title="赠菜" :ref="setModel" name="giveFood"></give-food>
|
||||
<one-remark @confirm="goodsOneRemarkConfirm" title="单品备注" :ref="setModel" name="remark"></one-remark>
|
||||
<pack-number @confirm="goodsOnePackNumberConfirm" title="打包" :ref="setModel" name="packNumber"></pack-number>
|
||||
<edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount>
|
||||
</view>
|
||||
|
||||
|
|
@ -284,6 +285,7 @@
|
|||
import { getSafeBottomHeight } from '@/commons/utils/safe-bottom.js'
|
||||
import modelDiscount from './components/discount'
|
||||
import giveFood from './components/give-food'
|
||||
import packNumber from './components/pack-number'
|
||||
import oneRemark from './components/remark'
|
||||
import editDiscount from '@/pagesCreateOrder/components/edit-discount.vue'
|
||||
import go from '@/commons/utils/go.js';
|
||||
|
|
@ -297,6 +299,7 @@
|
|||
import { getShopTableDetail } from '@/api/table.js'
|
||||
import { getProductList } from '@/api/product.js'
|
||||
import { createOrder } from '@/api/order.js'
|
||||
import { number } from 'uview-plus/libs/function/test';
|
||||
|
||||
const models = new Map();
|
||||
const modelData = reactive({
|
||||
|
|
@ -307,7 +310,9 @@
|
|||
masterId: '',
|
||||
tableId: ""
|
||||
})
|
||||
//用餐人数
|
||||
/**
|
||||
* 用餐人数
|
||||
*/
|
||||
const userNumbers = reactive({
|
||||
list: new Array(100).fill(1).map((v, index) => {
|
||||
// return index === 0 ? '无' : index + '人'
|
||||
|
|
@ -360,7 +365,6 @@
|
|||
getTbShopInfo()
|
||||
init()
|
||||
|
||||
// updateChoseCount()
|
||||
})
|
||||
let bottomHeight = ref(100)
|
||||
onReady(() => {
|
||||
|
|
@ -390,6 +394,26 @@
|
|||
totalAmount: 0,
|
||||
})
|
||||
|
||||
/**
|
||||
* 打包费
|
||||
*/
|
||||
const $packFee = computed(() => {
|
||||
return goods.list.reduce((prve, cur) => {
|
||||
return prve + (cur.packFee*parseFloat(cur.pack_number).toFixed(0))
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
|
||||
/**
|
||||
* 菜品数量
|
||||
*/
|
||||
const goodsNumber = computed(() => {
|
||||
const result = goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
return result
|
||||
})
|
||||
|
||||
|
||||
const isVip = computed(() => {
|
||||
console.log("pageData==",pageData)
|
||||
return pageData.shopInfo.isMemberPrice && pageData.user && pageData.user.id && pageData.user.isVip
|
||||
|
|
@ -405,17 +429,19 @@
|
|||
})
|
||||
|
||||
const goodsPrice = computed(() => {
|
||||
console.log("isVip.value===",isVip.value)
|
||||
console.log("isVip===",isVip.value)
|
||||
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
const lowMemberPrice = cur.lowMemberPrice ? cur.lowMemberPrice : cur.lowPrice
|
||||
const tPrice = (isVip.value ? lowMemberPrice : cur.lowPrice) * cur.number
|
||||
const tpackFee = cur.is_pack ? cur.packFee * 1 : 0
|
||||
const tpackFee = parseFloat(cur.pack_number).toFixed(0) > 0 ? cur.packFee*parseFloat(cur.pack_number).toFixed(0) : 0
|
||||
return prve + (cur.is_gift ? 0 : tPrice) + tpackFee
|
||||
}, 0)
|
||||
console.log("discount_sale_amount===",discount_sale_amount)
|
||||
return ((goodsTotalPrice - discount_sale_amount.value) || 0).toFixed(2)
|
||||
})
|
||||
|
||||
const allPrice = computed(() => {
|
||||
console.log("isVip===",goodsPrice.value)
|
||||
const n = goodsPrice.value * 1 + $seatFee.totalAmount
|
||||
return n.toFixed(2)
|
||||
})
|
||||
|
|
@ -433,10 +459,8 @@
|
|||
}, 0)
|
||||
return goodsTotalPrice - allPrice.value
|
||||
} else {
|
||||
console.log(discount_sale_amount.value, '优惠金额')
|
||||
return (discount_sale_amount.value)
|
||||
}
|
||||
console.log(discount_sale_amount.value, '优惠金额1')
|
||||
return (goodsTotalPrice + discount_sale_amount.value * 1).toFixed(2)
|
||||
})
|
||||
|
||||
|
|
@ -447,6 +471,13 @@
|
|||
websocketUtil.onMessage(data => {
|
||||
let msg = JSON.parse(data);
|
||||
let cartItem;
|
||||
if( msg.msg_id ){
|
||||
// console.log('Received data:', msg);
|
||||
websocketUtil.send(JSON.stringify({
|
||||
type: 'receipt',
|
||||
msg_id: msg.msg_id,
|
||||
}))
|
||||
}
|
||||
if( msg.status == 0 ){
|
||||
infoBox.showToast('添加失败')
|
||||
return false;
|
||||
|
|
@ -462,13 +493,7 @@
|
|||
break;
|
||||
|
||||
}
|
||||
if( msg.msg_id ){
|
||||
// console.log('Received data:', msg);
|
||||
websocketUtil.send(JSON.stringify({
|
||||
type: 'receipt',
|
||||
msg_id: msg.msg_id,
|
||||
}))
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -507,15 +532,10 @@
|
|||
operate_type:'init',
|
||||
table_code: pageData.table.tableCode,
|
||||
}))
|
||||
|
||||
// console.log(useType);
|
||||
// pageData.eatTypes.active = useType == 'take-out' ? useType : useType.replace(
|
||||
// /-after|-before/g, '');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取店铺信息
|
||||
*/
|
||||
|
|
@ -561,8 +581,8 @@
|
|||
*/
|
||||
async function changeUseType() {
|
||||
const { registerType } = pageData.shopInfo
|
||||
//munchies 先付 restaurant 后付
|
||||
const isPayAfter = registerType == "munchies" ? false : true;
|
||||
//before 先付 after 后付
|
||||
const isPayAfter = registerType == "before" ? false : true;
|
||||
let useType = "take-out";
|
||||
if (pageData.eatTypes.active == "take-out") {
|
||||
uni.setStorageSync("useType", "take-out");
|
||||
|
|
@ -605,7 +625,7 @@
|
|||
* 菜品赠送/等叫/打印修改
|
||||
* @param {Object} item
|
||||
*/
|
||||
async function toggleItem(item,key) {
|
||||
function toggleItem(item,key) {
|
||||
let par = {
|
||||
id: item.id,
|
||||
product_id: item.product_id ,
|
||||
|
|
@ -615,7 +635,24 @@
|
|||
updateCart(par)
|
||||
}
|
||||
|
||||
// 单品打折
|
||||
/**
|
||||
* 打包
|
||||
*/
|
||||
function toggleIsPack (item,key) {
|
||||
let par = {
|
||||
id: item.id,
|
||||
product_id: item.product_id ,
|
||||
sku_id: item.sku_id,
|
||||
pack_num: 0
|
||||
}
|
||||
par['pack_number'] = item['pack_number'] == 0 ? 1 : 0
|
||||
updateCart(par)
|
||||
}
|
||||
|
||||
/**
|
||||
* 单品打折
|
||||
* @param {Object} form
|
||||
*/
|
||||
async function discountconfirm(form) {
|
||||
if (form.discountMoney != '.') {
|
||||
let str = ''
|
||||
|
|
@ -640,6 +677,19 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打包
|
||||
*/
|
||||
function goodsOnePackNumberConfirm (e) {
|
||||
let par = {
|
||||
id: modelData.data.id,
|
||||
product_id: modelData.data.product_id ,
|
||||
sku_id: modelData.data.sku_id,
|
||||
pack_number: e
|
||||
}
|
||||
updateCart(par)
|
||||
}
|
||||
|
||||
/**
|
||||
* 单品备注确认
|
||||
* @param {Object} e
|
||||
|
|
@ -669,13 +719,31 @@
|
|||
* @param {Object} key
|
||||
* @param {Object} index
|
||||
*/
|
||||
function showModel(key, index) {
|
||||
function showModel(key, index, item) {
|
||||
modelData.data = goods.list[index]
|
||||
modelData.selIndex = index
|
||||
const model = models.get(key)
|
||||
|
||||
if( key == 'packNumber'){
|
||||
if( item.pack_number > 0 ){
|
||||
let par = {
|
||||
id: modelData.data.id,
|
||||
product_id: modelData.data.product_id ,
|
||||
sku_id: modelData.data.sku_id,
|
||||
pack_number: 0
|
||||
}
|
||||
updateCart(par)
|
||||
return false;
|
||||
}
|
||||
model && model.open({
|
||||
remark: modelData.data.note || ''
|
||||
number: item.number
|
||||
})
|
||||
|
||||
} else {
|
||||
model && model.open({
|
||||
packNumber: modelData.data.remark || ''
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function formatPrice(n) {
|
||||
|
|
@ -688,10 +756,9 @@
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//更新就餐人数
|
||||
/**
|
||||
* 更新就餐人数
|
||||
*/
|
||||
async function updateChoseCount() {
|
||||
const maxCapacity = pageData.table.id ? (pageData.table.maxCapacity || 0) : 100
|
||||
if (pageData.table.id && userNumbers.defaultCateIndex * 1 + 1 > maxCapacity) {
|
||||
|
|
@ -703,17 +770,21 @@
|
|||
}
|
||||
if (!pageData.shopInfo.isTableFee && pageData.table.id) {
|
||||
//不免餐位费
|
||||
const res = await Api.$choseCount({
|
||||
masterId: option.masterId,
|
||||
tableId: pageData.table.id || '',
|
||||
num: userNumbers.defaultCateIndex * 1 + 1,
|
||||
})
|
||||
Object.assign($seatFee, res)
|
||||
userNumbers.defaultCateIndex = res.totalNumber - 1
|
||||
|
||||
let seatFee = {
|
||||
totalNumber: userNumbers.defaultCateIndex * 1 + 1,
|
||||
totalAmount: (userNumbers.defaultCateIndex * 1 + 1) * pageData.shopInfo.tableFee,
|
||||
}
|
||||
Object.assign($seatFee, seatFee)
|
||||
userNumbers.defaultCateIndex = $seatFee.totalNumber - 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择就餐人数
|
||||
* @param {Object} e
|
||||
*/
|
||||
function userNumberChange(e) {
|
||||
console.log(e);
|
||||
userNumbers.defaultCateIndex = e.detail.value
|
||||
|
|
@ -721,20 +792,7 @@
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* 打包费
|
||||
*/
|
||||
const $packFee = computed(() => {
|
||||
return goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.packFee
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
const goodsNumber = computed(() => {
|
||||
const result = goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
return result
|
||||
})
|
||||
|
||||
|
||||
function chooseUser() {
|
||||
go.to('PAGES_CHOOSE_USER')
|
||||
|
|
@ -771,41 +829,40 @@
|
|||
* 创建订单
|
||||
*/
|
||||
async function createAnOrder() {
|
||||
if (!pageData.shopInfo.isTableFee) {
|
||||
//不免餐位费
|
||||
await Api.$choseCount({
|
||||
masterId: option.masterId,
|
||||
tableId: pageData.table.id || "",
|
||||
num: userNumbers.defaultCateIndex + 1,
|
||||
})
|
||||
}
|
||||
if (pageData.shopInfo.registerType == 'munchies' || pageData.eatTypes.active == 'take-out') {
|
||||
|
||||
if (pageData.shopInfo.registerType == 'before' || pageData.eatTypes.active == 'take-out') {
|
||||
const canJiesuan = await hasPermission('允许收款')
|
||||
if (!canJiesuan) {
|
||||
return
|
||||
}
|
||||
}
|
||||
// updateChoseCount()
|
||||
let originAmount = allPrice.value
|
||||
|
||||
console.log(originAmount)
|
||||
let vipPrice = isVip.value ? 1 : 0
|
||||
let par = {
|
||||
shopId: pageData.shopInfo.id, //店铺Id
|
||||
userId: pageData.user.id, //用户Id
|
||||
userId: pageData.user.userId, //用户Id
|
||||
tableCode: pageData.table.tableCode, //台桌编码
|
||||
dineMode: pageData.eatTypes.active, //用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
|
||||
remark: pageData.form.note, //备注
|
||||
seatNum: 0, //用餐人数
|
||||
packFee: 0, //打包费
|
||||
originAmount: originAmount, //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
seatNum: userNumbers.defaultCateIndex * 1 + 1, //用餐人数
|
||||
packFee: $packFee.value, //打包费
|
||||
originAmount: goodsPrice.value, //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
placeNum: 0, //当前订单下单次数
|
||||
waitCall: 0, //是否等叫 0 否 1 等叫
|
||||
vipPrice: pageData.shopInfo.isMemberPrice, //是否使用会员价
|
||||
vipPrice: vipPrice, //是否使用会员价
|
||||
}
|
||||
console.log(userNumbers.defaultCateIndex * 1 + 1)
|
||||
console.log(pageData.shopInfo.registerType)
|
||||
const res = await createOrder(par)
|
||||
uni.$emit('update:createOrderIndex')
|
||||
|
||||
if (pageData.shopInfo.registerType == 'munchies' || pageData.eatTypes.active == 'take-out') {
|
||||
websocketUtil.send(JSON.stringify({
|
||||
type:'onboc',
|
||||
account: uni.getStorageSync("iToken").loginId,
|
||||
shop_id: uni.getStorageSync("shopInfo").id,
|
||||
operate_type:'cleanup',
|
||||
table_code: pageData.table.tableCode,
|
||||
}))
|
||||
if (pageData.shopInfo.registerType == 'before' || pageData.eatTypes.active == 'take-out') {
|
||||
//先付
|
||||
return go.to('PAGES_ORDER_PAY', {
|
||||
orderId: res.id,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
v-for="(item,index) in data" :key="index">
|
||||
<view class="">
|
||||
<view class="u-line-1">{{item.name}}</view>
|
||||
<view class="u-m-t-10 u-font-24 color-666 u-line-1">{{item.specSnap||''}}</view>
|
||||
<view class="u-m-t-10 u-font-24 color-666 u-line-1">{{item.specInfo||''}}</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class="font-bold red u-m-r-32">¥{{formatPrice(item.lowPrice*item.number) }}</view>
|
||||
|
|
@ -129,7 +129,7 @@
|
|||
console.log(modal);
|
||||
}
|
||||
|
||||
|
||||
console.log(props.data);
|
||||
|
||||
const edmits = defineEmits(['clear', 'updateNumber'])
|
||||
|
||||
|
|
@ -149,7 +149,6 @@
|
|||
}
|
||||
|
||||
function toConfimOrder() {
|
||||
console.log(props.table);
|
||||
if (props.data.length <= 0) {
|
||||
return infoBox.showToast('还没有选择商品')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@
|
|||
})
|
||||
|
||||
const goods = computed(() => {
|
||||
console.log(props.skuMap[selSku.value])
|
||||
return props.skuMap[selSku.value]
|
||||
})
|
||||
watch(() => goods.value, (newval) => {
|
||||
|
|
|
|||
|
|
@ -113,32 +113,12 @@
|
|||
|
||||
</template>
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow,
|
||||
onPageScroll,
|
||||
onPullDownRefresh
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref,
|
||||
nextTick,
|
||||
watch,
|
||||
getCurrentInstance,
|
||||
onUnmounted,
|
||||
onBeforeUnmount,
|
||||
} from 'vue';
|
||||
import { onLoad, onReady, onShow } from '@dcloudio/uni-app';
|
||||
import { computed, reactive, ref, nextTick, watch, getCurrentInstance, onUnmounted, onBeforeUnmount } from 'vue';
|
||||
|
||||
|
||||
|
||||
import _ from 'lodash';
|
||||
import * as Api from '@/http/yskApi/Instead.js'
|
||||
import {
|
||||
$table,
|
||||
$choseTable,
|
||||
$returnTableDetail
|
||||
} from '@/http/yskApi/table.js'
|
||||
import {
|
||||
$tbShopCategory
|
||||
|
|
@ -231,10 +211,7 @@
|
|||
type: ''
|
||||
}
|
||||
|
||||
|
||||
const websocket = ref(null);
|
||||
onLoad((opt) => {
|
||||
// console.log(opt)
|
||||
option = opt
|
||||
Object.assign(data.table, opt)
|
||||
if (opt.useType) {
|
||||
|
|
@ -246,12 +223,6 @@
|
|||
if (JSON.stringify(opt) == '{}') {
|
||||
isCreateOrderToDetail.value = true
|
||||
}
|
||||
// if (!opt.tableId) {
|
||||
// infoBox.showErrorToast('暂不支持不选择桌台下载,请从桌台点餐')
|
||||
// return setTimeout(() => {
|
||||
// go.back()
|
||||
// }, 1500)
|
||||
// }
|
||||
init()
|
||||
})
|
||||
watch(() => data.table.id, (newval, oldval) => {
|
||||
|
|
@ -272,16 +243,11 @@
|
|||
getMenuItemTop()
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
if (websocket.value) {
|
||||
// websocket.value.destroy();
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
// 组件卸载时清理WebSocket
|
||||
onUnmounted(() => {
|
||||
if (websocket.value) {
|
||||
websocket.value.destroy();
|
||||
}
|
||||
|
||||
});
|
||||
let $originGoods = []
|
||||
let $category = []
|
||||
|
|
@ -298,43 +264,26 @@
|
|||
await getTableInfo()
|
||||
|
||||
// 获取分类数据
|
||||
const categoryRes = await categoryPage({ page: 1, size: 300 })
|
||||
const category = categoryRes.records;
|
||||
$category = category
|
||||
let categoryRes = await categoryPage({ page: 1, size: 300 })
|
||||
$category = categoryRes.records
|
||||
// 获取商品数据
|
||||
const goodsRes = await getGoods()
|
||||
const goods = goodsRes.records.filter((v) => {
|
||||
let isShow = true;
|
||||
if (v.type !== "sku") {
|
||||
if (v.type != "sku") {
|
||||
isShow = v.skuList.length >= 1;
|
||||
}
|
||||
return isShow;
|
||||
});
|
||||
$originGoods = goods
|
||||
$originGoods = goods;
|
||||
|
||||
if (option.type == 'add') {
|
||||
cars.length = 0
|
||||
setTabBar(category, goods, [])
|
||||
setTabBar($category, goods, [])
|
||||
return
|
||||
}
|
||||
if (!data.table.id) {
|
||||
//无桌台
|
||||
// const cartRes = await getCart()
|
||||
// cars.length = 0
|
||||
// const cartArr = getNowCart(cartRes.records)
|
||||
// for (let i in cartArr) {
|
||||
// cars.push(cartArr[i])
|
||||
// }
|
||||
// setTabBar(category, goods, cars)
|
||||
// return
|
||||
}
|
||||
|
||||
// const cartRes = await getCart()
|
||||
// cars.length = 0
|
||||
// const cartArr = getNowCart(cartRes.records)
|
||||
// for (let i in cartArr) {
|
||||
// cars.push(cartArr[i])
|
||||
// }
|
||||
|
||||
setTabBar(category, goods, cars)
|
||||
setTabBar($category, goods, cars)
|
||||
initCart()
|
||||
}
|
||||
|
||||
|
|
@ -345,7 +294,7 @@
|
|||
websocketUtil.onMessage(res => {
|
||||
let msg = JSON.parse(res);
|
||||
let cartItem;
|
||||
|
||||
console.log(msg)
|
||||
if( msg.msg_id ){
|
||||
// console.log('Received data:', msg);
|
||||
websocketUtil.send(JSON.stringify({
|
||||
|
|
@ -362,22 +311,32 @@
|
|||
cars.length = 0
|
||||
msg.data.map(item=>{
|
||||
cartItem = getNowCart(item,$originGoods)
|
||||
cars.push(cartItem)
|
||||
cartControls(cartItem,'add')
|
||||
})
|
||||
break;
|
||||
case 'onboc_add':
|
||||
console.log("onboc_add")
|
||||
case 'add':
|
||||
cartItem = getNowCart(msg.data,$originGoods)
|
||||
cars.push(cartItem)
|
||||
cartControls(cartItem,'add')
|
||||
break;
|
||||
case 'onboc_edit':
|
||||
case 'edit':
|
||||
cartItem = getNowCart(msg.data,$originGoods)
|
||||
cartControls(cartItem,'edit')
|
||||
break;
|
||||
case 'onboc_del':
|
||||
case 'del':
|
||||
cartItem = getNowCart(msg.data,$originGoods)
|
||||
cartControls(cartItem,'del')
|
||||
break;
|
||||
case 'onboc_cleanup':
|
||||
case 'cleanup':
|
||||
cars.length = 0
|
||||
for (let i in data.tabbar) {
|
||||
for (let k in data.tabbar[i].foods) {
|
||||
data.tabbar[i].foods[k].chooseNumber = 0
|
||||
}
|
||||
}
|
||||
console.log(data.tabbar)
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
@ -385,6 +344,63 @@
|
|||
});
|
||||
|
||||
|
||||
/**
|
||||
* 初始化购物车
|
||||
*/
|
||||
function initCart () {
|
||||
let params = {
|
||||
...data.socketData,
|
||||
operate_type:'init',
|
||||
table_code: data.table.tableCode,
|
||||
}
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车添加菜品
|
||||
*/
|
||||
function editCart (par,operate_type) {
|
||||
console.log('购物车添加菜品',par)
|
||||
let params = {
|
||||
...data.socketData,
|
||||
operate_type: operate_type,
|
||||
table_code: data.table.tableCode,
|
||||
product_id: '',
|
||||
sku_id: '', //
|
||||
number: 1, //数量
|
||||
is_temporary: 0, //是否是临时菜
|
||||
}
|
||||
Object.assign(params, par)
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除购物车菜品
|
||||
*/
|
||||
function delCart (id) {
|
||||
let params = {
|
||||
...data.socketData,
|
||||
id: id,
|
||||
operate_type:'del',
|
||||
table_code: data.table.tableCode,
|
||||
}
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除购物车
|
||||
*/
|
||||
function cleaCart () {
|
||||
let params = {
|
||||
...data.socketData,
|
||||
operate_type:'cleanup',
|
||||
table_code: data.table.tableCode,
|
||||
}
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
*/
|
||||
|
|
@ -463,62 +479,6 @@
|
|||
data.table = item
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化购物车
|
||||
*/
|
||||
function initCart () {
|
||||
let params = {
|
||||
...data.socketData,
|
||||
operate_type:'init',
|
||||
table_code: data.table.tableCode,
|
||||
}
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车添加菜品
|
||||
*/
|
||||
function editCart (par,operate_type) {
|
||||
console.log('购物车添加菜品',par)
|
||||
let params = {
|
||||
...data.socketData,
|
||||
operate_type: operate_type,
|
||||
table_code: data.table.tableCode,
|
||||
product_id: '',
|
||||
sku_id: '', //
|
||||
number: 1, //数量
|
||||
is_temporary: 0, //是否是临时菜
|
||||
}
|
||||
Object.assign(params, par)
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除购物车菜品
|
||||
*/
|
||||
function delCart (id) {
|
||||
let params = {
|
||||
...data.socketData,
|
||||
id: id,
|
||||
operate_type:'del',
|
||||
table_code: data.table.tableCode,
|
||||
}
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除购物车
|
||||
*/
|
||||
function cleaCart () {
|
||||
let params = {
|
||||
...data.socketData,
|
||||
operate_type:'cleanup',
|
||||
table_code: data.table.tableCode,
|
||||
}
|
||||
websocketUtil.send(JSON.stringify(params))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 菜品操作
|
||||
* @param {Object} foodsindex
|
||||
|
|
@ -533,49 +493,41 @@
|
|||
chooseTable()
|
||||
})
|
||||
}
|
||||
const $goods = data.tabbar[index].foods[foodsindex]
|
||||
let $goods = data.tabbar[index].foods[foodsindex]
|
||||
if ($goods.type !== 'sku') {
|
||||
//单规格
|
||||
console.log($goods)
|
||||
const goodsInCarIndex = cars.findIndex((carsGoods) => {
|
||||
let goodsInCarIndex = cars.findIndex((carsGoods) => {
|
||||
return carsGoods.sku_id == $goods.skuList[0].id && carsGoods.product_id == $goods.id;
|
||||
});
|
||||
const product_id = $goods.id
|
||||
const sku_id = $goods.skuList[0].id
|
||||
let product_id = $goods.id
|
||||
let sku_id = $goods.skuList[0].id
|
||||
let suitNum = $goods.skuList[0].suitNum || 1
|
||||
if (goodsInCarIndex !== -1) {
|
||||
//更新
|
||||
const carGoods = cars[goodsInCarIndex]
|
||||
const cartId = carGoods.id
|
||||
// const step = isAdd ? 1 : -1
|
||||
// $sku = !product_id ? { suitNum: 1 } : $goods.skuList.find(v => v.id == sku_id)
|
||||
let num = isAdd ? carGoods.number + 1 : + carGoods.number - 1
|
||||
let cartItem = cars[goodsInCarIndex]
|
||||
let number = isAdd ? cartItem.number + 1 : + cartItem.number - 1
|
||||
if( !isAdd ){
|
||||
if (num === 0 || num < suitNum) {
|
||||
if (number === 0 || number < suitNum) {
|
||||
//移除
|
||||
cars.splice(goodsInCarIndex, 1)
|
||||
$goods.chooseNumber = 0
|
||||
setSearchGoods(searchGoodsIndex, 0)
|
||||
delCart(cartId)
|
||||
delCart(cartItem.id)
|
||||
}
|
||||
}
|
||||
|
||||
// 不影响之前的代码 称重num单独处理
|
||||
// 不影响之前的代码 称重number单独处理
|
||||
if ($goods.type == 'weigh' && showCurrentInput) {
|
||||
num = carGoods.number * 1 + Number(showCurrentInput)
|
||||
number = cartItem.number * 1 + Number(showCurrentInput)
|
||||
}
|
||||
|
||||
editCart({
|
||||
id: cartId,
|
||||
number: num,
|
||||
id: cartItem.id,
|
||||
number: number,
|
||||
product_id: product_id,
|
||||
sku_id: sku_id,
|
||||
},'edit')
|
||||
carGoods.number = num
|
||||
$goods.chooseNumber = num
|
||||
setSearchGoods(searchGoodsIndex, num)
|
||||
setSearchGoods(searchGoodsIndex, number)
|
||||
} else {
|
||||
console.log(suitNum)
|
||||
// 不影响之前的代码 称重suit单独处理
|
||||
if ($goods.type == 'weigh' && showCurrentInput) {
|
||||
suitNum = showCurrentInput
|
||||
|
|
@ -587,10 +539,8 @@
|
|||
number: suitNum,
|
||||
product_id: product_id,
|
||||
sku_id: sku_id,
|
||||
discount_sale_amount: $goods.lowPrice
|
||||
},'add')
|
||||
infoBox.showToast('添加成功')
|
||||
$goods.chooseNumber = Number(suitNum)
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
@ -598,6 +548,86 @@
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* socket通知购物车商品数量修改处理
|
||||
*/
|
||||
function cartControls (cartItem,type) {
|
||||
let cartIndex = 0;
|
||||
let product_id = cartItem.product_id
|
||||
let sku_id = cartItem.sku_id
|
||||
let $goods;
|
||||
cars.map((item,index)=>{
|
||||
if(item.id == cartItem.id) {
|
||||
cartIndex = index;
|
||||
product_id = item.product_id
|
||||
sku_id = item.sku_id
|
||||
}
|
||||
})
|
||||
|
||||
data.tabbar.map(tabbarItem=>{
|
||||
if(tabbarItem.foods.find(v => v.id == product_id)){
|
||||
$goods = !product_id ? undefined : tabbarItem.foods.find(v => v.id == product_id)
|
||||
}
|
||||
})
|
||||
|
||||
let $sku;
|
||||
if( $goods.type != 'package'){
|
||||
//临时菜没有skuList
|
||||
$sku = !product_id ? { suitNum: 1 } : $goods.skuList.find(v => v.id == sku_id)
|
||||
} else {
|
||||
$sku = !product_id ? { suitNum: 1 } : $goods.skuList.find(v => v.id == sku_id)
|
||||
}
|
||||
if( type == 'del' ) {
|
||||
cars.splice(cartIndex, 1)
|
||||
$goods.chooseNumber = 0
|
||||
return;
|
||||
}
|
||||
if( type == 'add' ){
|
||||
cars.push(cartItem)
|
||||
$goods.chooseNumber = cartItem.number
|
||||
}
|
||||
if( type == 'edit' ){
|
||||
cars[cartIndex].number = cartItem.number
|
||||
if ($goods) {
|
||||
$goods.chooseNumber = cartItem.number
|
||||
}
|
||||
}
|
||||
|
||||
console.log(cars)
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车商品数量改变处理
|
||||
* @param {Object} e
|
||||
*/
|
||||
async function carsNumberChange(e) {
|
||||
console.log("carsNumberChange===",e)
|
||||
let $sku;
|
||||
let $goods;
|
||||
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)
|
||||
}
|
||||
})
|
||||
if( $goods.type != 'package'){
|
||||
//临时菜没有skuList
|
||||
$sku = !e.goods.product_id ? { suitNum: 1 } : $goods.skuList.find(v => v.id == e.goods.sku_id)
|
||||
} else {
|
||||
$sku = !e.goods.product_id ? { suitNum: 1 } : $goods.skuList.find(v => v.id == e.goods.sku_id)
|
||||
}
|
||||
if (e.num === 0 || e.num < $sku.suitNum) {
|
||||
//移除
|
||||
delCart(e.goods.id)
|
||||
return
|
||||
}
|
||||
editCart({
|
||||
number: e.num,
|
||||
id: e.goods.id,
|
||||
product_id: e.goods.product_id,
|
||||
sku_id: e.goods.sku_id
|
||||
},'edit')
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加套餐
|
||||
* @param {Object} d
|
||||
|
|
@ -610,7 +640,6 @@
|
|||
product_id: item.id,
|
||||
sku_id: item.skuList[0].id,
|
||||
pro_group_info: JSON.stringify(d),
|
||||
discount_sale_amount: item.lowPrice
|
||||
},'add')
|
||||
}
|
||||
|
||||
|
|
@ -655,17 +684,16 @@
|
|||
/**
|
||||
* 多规格选择
|
||||
* @param {Object} skuList
|
||||
* @param {Object} specSnap
|
||||
*/
|
||||
function returnSelGoodsSkuList(selectSpecInfo) {
|
||||
let specSnap = []
|
||||
let specInfo = []
|
||||
for (var key in selectSpecInfo) {
|
||||
specSnap.push({
|
||||
specInfo.push({
|
||||
name: key,
|
||||
value: selectSpecInfo[key]
|
||||
})
|
||||
}
|
||||
let result = specSnap.map((v, index) => {
|
||||
let result = specInfo.map((v, index) => {
|
||||
return {
|
||||
...v,
|
||||
valueArr: v.value,
|
||||
|
|
@ -686,40 +714,33 @@
|
|||
* @param {Object} sku
|
||||
* @param {Object} num
|
||||
*/
|
||||
async function guigeConfirm(sku, num) {
|
||||
const goods = guigeModelData.chooseGoods.item
|
||||
const skuId = sku.id
|
||||
const productId = goods.id
|
||||
const res = findGoodsInCar(goods, skuId)
|
||||
async function guigeConfirm(sku, suitNum) {
|
||||
console.log(sku)
|
||||
let goods = guigeModelData.chooseGoods.item
|
||||
let sku_id = sku.id
|
||||
let product_id = goods.id
|
||||
let res = findGoodsInCar(goods, sku_id)
|
||||
if (res) {
|
||||
//更新
|
||||
const {
|
||||
index
|
||||
} = res
|
||||
const carGoods = cars[index]
|
||||
const cartId = carGoods.id
|
||||
const newNumber = carGoods.number * 1 + num
|
||||
const {
|
||||
number
|
||||
} = await updateCartGoods({
|
||||
num: newNumber,
|
||||
cartId,
|
||||
productId,
|
||||
skuId
|
||||
})
|
||||
carGoods.number = number
|
||||
let { index } = res
|
||||
let carGoods = cars[index]
|
||||
let cartId = carGoods.id
|
||||
let newNumber = carGoods.number * 1 + suitNum
|
||||
|
||||
editCart({
|
||||
id: cartId,
|
||||
number: newNumber,
|
||||
product_id: product_id,
|
||||
sku_id: sku_id,
|
||||
},'add')
|
||||
} else {
|
||||
//添加
|
||||
const cartGoods = await addCart({
|
||||
num,
|
||||
productId,
|
||||
skuId
|
||||
})
|
||||
editCart({
|
||||
number: suitNum,
|
||||
product_id: product_id,
|
||||
sku_id: sku_id,
|
||||
},'add')
|
||||
infoBox.showToast('添加成功')
|
||||
cars.push({
|
||||
...cartGoods,
|
||||
specSnap: sku.specSnap
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -742,24 +763,17 @@
|
|||
|
||||
|
||||
//多规格商品弹窗时,找到默认可以下单的规格商品
|
||||
function findGoods(skuList = [], goodsListMap = {}, specList) {
|
||||
const skuMapNumber = skuList.reduce((prve, cur) => {
|
||||
function findGoods(selectSpecInfo = [], goodsListMap = {}, skuList) {
|
||||
let skuMapNumber = selectSpecInfo.reduce((prve, cur) => {
|
||||
for (let i in cur.valueArr) {
|
||||
prve[cur.valueArr[i]] = i;
|
||||
}
|
||||
return prve;
|
||||
}, {});
|
||||
const canBudyGoods = specList
|
||||
.filter((v) => util.isCanBuy(v, guigeModelData.chooseGoods.item))
|
||||
.sort((a, b) => {
|
||||
const aNumber = a.specSnap.split(",").reduce((prve, cur) => {
|
||||
return prve + skuMapNumber[cur];
|
||||
}, 0);
|
||||
const bNumber = b.specSnap.split(",").reduce((prve, cur) => {
|
||||
return prve + skuMapNumber[cur];
|
||||
}, 0);
|
||||
return aNumber - bNumber;
|
||||
});
|
||||
console.log("selectSpecInfo",selectSpecInfo)
|
||||
console.log("skuMapNumber",guigeModelData.chooseGoods.item)
|
||||
let canBudyGoods = skuList.filter((v) => util.isCanBuy(v, guigeModelData.chooseGoods.item))
|
||||
console.log("canBudyGoods",canBudyGoods)
|
||||
return canBudyGoods[0];
|
||||
}
|
||||
|
||||
|
|
@ -768,17 +782,16 @@
|
|||
* @param {Object} goods
|
||||
* @param {Object} selectSpecInfo
|
||||
* @param {Object} skuMap
|
||||
* @param {Object} specList
|
||||
* @param {Object} skuList
|
||||
*/
|
||||
function setSkugoodsDefaultInit(goods, selectSpecInfo, skuMap, specList) {
|
||||
function setSkugoodsDefaultInit(goods, selectSpecInfo, skuMap, skuList) {
|
||||
guigeModelData.chooseGoods.item = goods
|
||||
guigeModelData.chooseGoods.skus = selectSpecInfo
|
||||
guigeModelData.chooseGoods.skuMap = skuMap
|
||||
const skuGoods = findGoods(selectSpecInfo, skuMap, specList);
|
||||
const skuGoods = findGoods(selectSpecInfo, skuMap, skuList);
|
||||
if (skuGoods) {
|
||||
// this.skuGoods.data = skuGoods;
|
||||
// this.skuGoods.number = skuGoods.suit || 1;
|
||||
skuGoods.specSnap.split(",").map((v, index) => {
|
||||
|
||||
skuGoods.specInfo.split(",").map((v, index) => {
|
||||
guigeModelData.chooseGoods.skus[index].sel = v;
|
||||
});
|
||||
}
|
||||
|
|
@ -791,7 +804,7 @@
|
|||
const skuList = guigeModelData.chooseGoods.skus
|
||||
const skuMap = guigeModelData.chooseGoods.skuMap
|
||||
guigeModelData.chooseGoods.skus[skusIndex].sel = skdName
|
||||
const specSnap = guigeModelData.chooseGoods.skus.reduce((prve, cur) => {
|
||||
const specInfo = guigeModelData.chooseGoods.skus.reduce((prve, cur) => {
|
||||
prve.push(cur.sel)
|
||||
return prve
|
||||
}, []).join()
|
||||
|
|
@ -809,13 +822,12 @@
|
|||
return prve;
|
||||
}, []);
|
||||
|
||||
console.log(selArr);
|
||||
let selArrAllGroup = util.generateCombinations(selArr, selArr.length - 1);
|
||||
console.log(selArrAllGroup);
|
||||
const matchArr = [];
|
||||
for (let key in skuMap) {
|
||||
const goods = skuMap[key];
|
||||
const keyArr = key.split(",");
|
||||
let goods = skuMap[key];
|
||||
console.log(key)
|
||||
let keyArr = key.split(",");
|
||||
for (let spe of selArrAllGroup) {
|
||||
if (util.arrayContainsAll(keyArr, spe)) {
|
||||
matchArr.push(goods);
|
||||
|
|
@ -823,6 +835,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
console.log(matchArr);
|
||||
//全部规格都已下架
|
||||
if (!matchArr.length) {
|
||||
for (let k in skuList) {
|
||||
|
|
@ -833,11 +846,11 @@
|
|||
return;
|
||||
}
|
||||
const includeSkuMap = matchArr.reduce((prve, cur) => {
|
||||
const speArr = cur.specSnap.split(",");
|
||||
const speArr = cur.specInfo.split(",");
|
||||
for (let i of speArr) {
|
||||
if (!prve.hasOwnProperty("i")) {
|
||||
prve[i] = matchArr
|
||||
.filter((v) => v.specSnap.match(i))
|
||||
.filter((v) => v.specInfo.match(i))
|
||||
.every((v) => {
|
||||
return !util.isCanBuy(v, guigeModelData.chooseGoods.item)
|
||||
});
|
||||
|
|
@ -855,52 +868,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车商品数量改变
|
||||
* @param {Object} e
|
||||
*/
|
||||
async function carsNumberChange(e) {
|
||||
const { num, index, goods } = e
|
||||
const { product_id, categoryId, sku_id } = goods
|
||||
const cartId = goods.id
|
||||
//临时菜没有对应商品数据
|
||||
let $goods;
|
||||
data.tabbar.map(tabbarItem=>{
|
||||
if(tabbarItem.foods.find(v => v.id == product_id)){
|
||||
$goods = !product_id ? undefined : tabbarItem.foods.find(v => v.id == product_id)
|
||||
}
|
||||
})
|
||||
let $sku;
|
||||
if( $goods.type != 'package'){
|
||||
//临时菜没有skuList
|
||||
$sku = !product_id ? { suitNum: 1 } : $goods.skuList.find(v => v.id == sku_id)
|
||||
} else {
|
||||
$sku = !product_id ? { suitNum: 1 } : $goods.skuList.find(v => v.id == sku_id)
|
||||
}
|
||||
|
||||
console.log(num)
|
||||
console.log($sku.suitNum)
|
||||
if (num === 0 || num < $sku.suitNum) {
|
||||
//移除
|
||||
delCart(cartId)
|
||||
cars.splice(index, 1)
|
||||
$goods.chooseNumber = 0
|
||||
return
|
||||
}
|
||||
editCart({
|
||||
number: num,
|
||||
id: cartId,
|
||||
product_id: product_id,
|
||||
sku_id: sku_id
|
||||
},'edit')
|
||||
cars[index].number = num
|
||||
if ($goods) {
|
||||
$goods.chooseNumber = num
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1292,12 +1259,8 @@
|
|||
|
||||
function watchUpdate() {
|
||||
uni.$off('update:createOrderIndex')
|
||||
uni.$off('get:table')
|
||||
uni.$off('add:cashCai')
|
||||
uni.$on('update:createOrderIndex', () => {
|
||||
// data.table = {
|
||||
// tableId: ""
|
||||
// }
|
||||
cars.length = 0
|
||||
console.log('update:createOrderIndex');
|
||||
init()
|
||||
|
|
@ -1309,20 +1272,7 @@
|
|||
$originGoods.push(data)
|
||||
|
||||
})
|
||||
uni.$on('get:table', () => {
|
||||
console.log('get:table');
|
||||
if (data.table.id) {
|
||||
$table.get({
|
||||
qrcode: data.table.id
|
||||
}).then(res => {
|
||||
if (res.content[0] && res.content[0].status != 'idle') {
|
||||
data.table = {
|
||||
tableId: ''
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//根据店铺信息返回是否是后付款
|
||||
export function $trturnPayAfter(shop) {
|
||||
//munchies 先付 restaurant 后付
|
||||
const payAfter = shop.registerType == "munchies" ? false : true;
|
||||
//before 先付 after 后付
|
||||
const payAfter = shop.registerType == "before" ? false : true;
|
||||
return payAfter
|
||||
}
|
||||
//根据店铺信息返回就餐类型
|
||||
|
|
@ -19,12 +19,12 @@ export function $returnUseType(shop, useType) {
|
|||
}
|
||||
//判断商品是否可以下单
|
||||
export function isCanBuy(skuGoods,goods) {
|
||||
if(goods.typeEnum=='normal'){
|
||||
if(goods.type!='sku'){
|
||||
//单规格
|
||||
return goods.isGrounding&&goods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true);
|
||||
return goods.isSale&&goods.isSoldStock==0&&(goods.isStock?goods.stockNumber>0:true);
|
||||
}else{
|
||||
//多规格
|
||||
return goods.isGrounding&&goods.isPauseSale==0&&skuGoods.isGrounding&&skuGoods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true);
|
||||
return goods.isSale&&goods.isSoldStock==0&&skuGoods.isGrounding&&skuGoods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ function arrayContainsAll(arr1, arr2) {
|
|||
//n项 n-1项组合,生成全部结果
|
||||
function generateCombinations(arr, k) {
|
||||
let result = [];
|
||||
|
||||
console.log("current.length === k",arr)
|
||||
function helper(index, current) {
|
||||
if (current.length === k) {
|
||||
result.push(current.slice()); // 使用slice()来避免直接修改原始数组
|
||||
|
|
@ -53,6 +53,7 @@ function generateCombinations(arr, k) {
|
|||
helper(i + 1, current); // 递归调用,索引增加以避免重复选择相同的元素
|
||||
current.pop(); // 回溯,移除当前元素以便尝试其他组合
|
||||
}
|
||||
console.log(current)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,13 @@ export function getNowCart(carItem,goodsList) {
|
|||
if( carItem.is_temporary != 1 ){
|
||||
goodsList.map(goodsItem => {
|
||||
if(carItem.product_id == goodsItem.id){
|
||||
carItem.lowPrice = goodsItem.lowPrice
|
||||
carItem.lowMemberPrice = goodsItem.lowMemberPrice
|
||||
goodsItem.skuList.map(item=>{
|
||||
if(carItem.sku_id == item.id){
|
||||
carItem.lowPrice = item.salePrice
|
||||
carItem.lowMemberPrice = item.memberPrice
|
||||
carItem.specInfo = item.specInfo
|
||||
}
|
||||
})
|
||||
carItem.name = goodsItem.name
|
||||
carItem.coverImg = goodsItem.coverImg
|
||||
carItem.packFee = goodsItem.packFee
|
||||
|
|
|
|||
|
|
@ -1,548 +0,0 @@
|
|||
<template>
|
||||
<view class="default-box-padding bg-fff border-r-24 u-m-t-32" v-if="data.length">
|
||||
<view class=" font-bold u-p-b-32 border-bottom u-m-b-24" v-if="orderInfo.tableName">
|
||||
<text class="">桌号:</text>
|
||||
<text class="">{{orderInfo.tableName||""}}</text>
|
||||
</view>
|
||||
<view class=" color-999 border-bottom u-p-b-24">
|
||||
<text>共</text>
|
||||
<text class="color-333 "> {{goodsNumber}}</text>
|
||||
<text>份菜品</text>
|
||||
</view>
|
||||
<view class="u-m-b-20 " v-for="(order,orderIndex) in data" :key="orderIndex">
|
||||
<view class="u-p-t-24"> 第{{ order.placeNum }}次下单
|
||||
</view>
|
||||
<view class="u-m-t-24 list">
|
||||
<view class="item u-m-b-32" v-for="(item,index) in order.info" :key="index">
|
||||
<view class="u-flex u-col-top">
|
||||
<view class="u-flex">
|
||||
<image class="img" :src="item.coverImg||item.productImg" mode=""></image>
|
||||
</view>
|
||||
<view class="u-p-l-32 u-flex-1">
|
||||
<view class="u-flex u-row-between u-col-top">
|
||||
|
||||
<view class="">
|
||||
<view class="u-flex">
|
||||
<view class="tui" v-if="isTui(item)">
|
||||
{{item.status=='refunding'?'退款中':'已退'}}
|
||||
</view>
|
||||
<view
|
||||
:class="{'line-th':item.status=='return'||item.status=='refund'||item.status=='refunding'}">
|
||||
{{item.name||item.productName}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-8">
|
||||
<view class="u-m-r-20 u-flex " v-if="item.gift">
|
||||
<uni-tag text="赠送"
|
||||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-flex " v-if="item.userCouponId">
|
||||
<uni-tag :text=" productCouponDikou(item)"
|
||||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-flex" v-if="item.pack">
|
||||
<uni-tag
|
||||
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
|
||||
size="small" text="打包" inverted type="success" />
|
||||
</view>
|
||||
<view class="u-m-r-20 u-font-24 u-flex" v-if="item.returnAmount">
|
||||
<view class="color-666">退款金额:</view>
|
||||
<view class="color-999 u-m-l-6">{{item.returnAmount}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="color-999 u-font-24 u-m-t-8">{{item.productSkuName||''}}</view>
|
||||
|
||||
|
||||
<view class="u-m-t-12 color-666 u-font-24" v-if="item.note">
|
||||
备注:{{item.note}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-text-right u-m-t-28">
|
||||
<template v-if="isTui(item)">
|
||||
<view>¥0.00</view>
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}
|
||||
</view>
|
||||
</template>
|
||||
<template v-else-if="isGift(item)||item.userCouponId">
|
||||
<view>¥0.00</view>
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<template v-if="returnCanTuiMoney(item)*1!=returnTotalMoney(item)*1">
|
||||
<view>¥{{returnCanTuiMoney(item)}}</view>
|
||||
<view class=" color-666 line-th">
|
||||
¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view>¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
<!-- <template
|
||||
v-if="user.isVip&&item.isMember&&returnVipMoney(item)>0&&returnVipMoney(item)!=returnTotalMoney(item)">
|
||||
<view>¥{{returnVipMoney(item)}}</view>
|
||||
<view class=" color-666 line-th">
|
||||
¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view>¥{{returnTotalMoney(item)}}</view>
|
||||
</template> -->
|
||||
</template>
|
||||
<view class="u-m-t-22 color-999 u-font-24">X{{item.number||item.num}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<template v-if="canTuicai(orderInfo,item)">
|
||||
<view class="u-flex u-row-right gap-20 u-m-t-24">
|
||||
<!-- <my-button :height="60" color="#333" plain type="cancel" shape="circle">更多操作</my-button> -->
|
||||
<my-button :width="128" :height="48" plain shape="circle" @tap="tuicai(item,index)"><text
|
||||
class="no-wrap">退菜</text></my-button>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="canTuiKuan(orderInfo,item)">
|
||||
<view class="u-flex u-row-right gap-20 u-m-t-20">
|
||||
<my-button :width="128" :height="48" plain shape="circle" @tap="tuikuan(item,index)"><text
|
||||
class="no-wrap">{{item.userCouponId?'退券':'退款' }}</text> </my-button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="bg-gray u-p-20 u-m-t-20" v-if="orderInfo.remark">
|
||||
<view>备注</view>
|
||||
<view class="u-m-t-10">{{orderInfo.remark}}</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<view class="u-m-t-32">
|
||||
<view class="u-flex u-row-between border-top u-p-t-32">
|
||||
<view>
|
||||
<template v-if="orderInfo.status=='unpaid'">
|
||||
<view class="tag no-pay">
|
||||
未支付
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="orderInfo.status=='refund'">
|
||||
<view class="tag refund">
|
||||
退款成功
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
<view class="u-flex">
|
||||
<view class="u-flex u-m-r-24" v-if="youhuiAllPrice>0">
|
||||
<view class="color-red u-m-r-6 ">
|
||||
已优惠¥{{youhuiAllPrice}}
|
||||
</view>
|
||||
<up-icon name="info-circle" color="#999" :size="14" @click="youhuiDetailShow"></up-icon>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text>小计¥</text>
|
||||
<text class="font-bold u-font-32">{{allPrice}}</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<template v-if="orderInfo.refundAmount">
|
||||
<view class="u-flex u-row-between u-m-t-32">
|
||||
<view>退款金额</view>
|
||||
<view class="color-999">
|
||||
<text class="">{{(orderInfo.refundAmount).toFixed(2)}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-32">
|
||||
<view>退款原因</view>
|
||||
<view class="color-999">
|
||||
<text class="">{{orderInfo.refundRemark||''}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-32 u-p-b-24 border-bottom">
|
||||
<view></view>
|
||||
<view class="">
|
||||
<text class="">退款成功</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
<view></view>
|
||||
<view>
|
||||
<text>总计¥</text>
|
||||
<text class="font-bold u-font-32">{{to2(allPrice*1+seatFeePrice*1+packFee*1) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-20" v-if="orderInfo.status=='closed'">
|
||||
<view></view>
|
||||
<view>
|
||||
<text>实付¥</text>
|
||||
<text class="font-bold u-font-32">{{to2(orderInfo.amount) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-flex u-row-between u-m-t-20">
|
||||
<view></view>
|
||||
<view>
|
||||
<text>原价¥</text>
|
||||
<text class="font-bold u-font-32">{{to2(orderInfo.originAmount||0) }}</text>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="u-m-t-24">
|
||||
<my-button @tap="printOrder" type="cancel" :color="color.ColorMain">重新打印</my-button>
|
||||
</view>
|
||||
</view>
|
||||
<up-popup :round="10" :show="pop.youhui" mode="center" closeOnClickOverlay @close="youhuiDetailHide">
|
||||
<view class="u-p-30" style="width: 80vw;">
|
||||
<view class="font-bold u-text-center">优惠详情</view>
|
||||
<view class="u-m-t-32">
|
||||
<view class="u-flex u-row-between u-m-b-18" v-if="vipDiscountPrice*1>0">
|
||||
<view>会员优惠</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text>{{vipDiscountPrice}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-b-18" v-if="discountAmount">
|
||||
<view>打折</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text>{{to2(discountAmount) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between " v-if="orderInfo.fullCouponDiscountAmount*1>0">
|
||||
<view>满减券抵扣</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text>{{to2(orderInfo.fullCouponDiscountAmount) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-18" v-if="productCouponDiscountAmount*1>0">
|
||||
<view>商品券抵扣</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text> {{productCouponDiscountAmount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-flex u-row-between u-m-t-18"
|
||||
v-if="orderInfo.productCouponDiscountAmount||productCoupPrice*1>0">
|
||||
<view>商品券抵扣</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text> {{to2(orderInfo.productCouponDiscountAmount||productCoupPrice) }}</text>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="u-flex u-row-between u-m-t-18" v-if="orderInfo.pointsDiscountAmount">
|
||||
<view>积分抵扣</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text>{{to2(orderInfo.pointsDiscountAmount) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
reactive
|
||||
} from 'vue';
|
||||
import color from '@/commons/color.js'
|
||||
import {
|
||||
hasPermission
|
||||
} from '@/commons/utils/hasPermission.js'
|
||||
import {
|
||||
isTui,
|
||||
isTuiCai,
|
||||
isGift,
|
||||
canTuiKuan,
|
||||
canTuicai,
|
||||
numSum
|
||||
} from '@/commons/utils/goodsUtil.js'
|
||||
const pop = reactive({
|
||||
youhui: false
|
||||
})
|
||||
|
||||
function youhuiDetailShow() {
|
||||
pop.youhui = true
|
||||
}
|
||||
|
||||
function productCouponDikou(item) {
|
||||
return '商品券抵扣¥' + returnProductCoupPrice(item)
|
||||
}
|
||||
|
||||
function youhuiDetailHide() {
|
||||
pop.youhui = false
|
||||
}
|
||||
const props = defineProps({
|
||||
orderInfo: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
seatFee: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
user: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
id: '',
|
||||
isVip: false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function returnProductCoupPrice(item) {
|
||||
if (!item.isMember) {
|
||||
return item.price * item.num
|
||||
}
|
||||
const price = item.memberPrice ? item.memberPrice : item.price
|
||||
return price * item.num
|
||||
}
|
||||
const productCouponDiscountAmount = computed(() => {
|
||||
// if(props.orderInfo.productCouponDiscountAmount){
|
||||
// return orderInfo.productCouponDiscountAmount.toFixed(2)
|
||||
// }
|
||||
if (!props.data.length) {
|
||||
return 0
|
||||
}
|
||||
const n = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.userCouponId).reduce((a, b) => {
|
||||
return a + returnProductCoupPrice(b)
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
console.log(n);
|
||||
return n.toFixed(2)
|
||||
})
|
||||
const emits = defineEmits(['tuicai', 'tuikuan', 'printOrder'])
|
||||
|
||||
function returnVipMoney(item) {
|
||||
if (!item.memberPrice || !props.user.isVip) {
|
||||
return 0
|
||||
}
|
||||
return (item.memberPrice * item.num).toFixed(2)
|
||||
}
|
||||
|
||||
function returnTotalMoney(item) {
|
||||
return (item.price * item.num).toFixed(2)
|
||||
}
|
||||
|
||||
const canTuiKuanPrice = computed(() => {
|
||||
return props.data.reduce((prve,cur)=>{
|
||||
// const curTotal=cur.info.filter(v=>!v.userCouponId).reduce((a,b)=>{
|
||||
// return a+b.priceAmount*1
|
||||
// },0)
|
||||
const curTotal=cur.info.filter(v=>canTuiKuan(props.orderInfo,v)&&!v.userCouponId).reduce((a,b)=>{
|
||||
return a+b.priceAmount*1
|
||||
},0)
|
||||
return prve+curTotal
|
||||
},0)
|
||||
})
|
||||
function returnCanTuiMoney(item) {
|
||||
console.log(canTuiKuanPrice.value);
|
||||
if(props.orderInfo.status=='unpaid'){
|
||||
return returnTotalMoney(item)
|
||||
}else{
|
||||
return (item.priceAmount/(canTuiKuanPrice.value+seatFeePrice.value*1)*props.orderInfo.amount).toFixed(2)
|
||||
}
|
||||
}
|
||||
|
||||
function to2(n) {
|
||||
if (!n) {
|
||||
return 0
|
||||
}
|
||||
return n.toFixed(2)
|
||||
}
|
||||
|
||||
function tuicai(item, index) {
|
||||
emits('tuicai', item, index)
|
||||
}
|
||||
|
||||
function tuikuan(item, index) {
|
||||
hasPermission('允许退款').then(res => {
|
||||
if (res) {
|
||||
emits('tuikuan', {...item,priceAmount:returnCanTuiMoney(item)}, index)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function printOrder() {
|
||||
emits('printOrder')
|
||||
}
|
||||
|
||||
|
||||
const seatFeePrice = computed(() => {
|
||||
if (!props.seatFee.priceAmount) {
|
||||
return 0
|
||||
}
|
||||
const n = props.seatFee.priceAmount * (isTui(props.seatFee) ? 0 : 1)
|
||||
return n.toFixed(2)
|
||||
})
|
||||
const discountAmount = computed(() => {
|
||||
if (props.orderInfo.discountAmount) {
|
||||
return props.orderInfo.discountAmount
|
||||
}
|
||||
console.log(props.orderInfo.originAmount * (1 - props.orderInfo.discountRatio));
|
||||
return (props.orderInfo.originAmount * (1 - props.orderInfo.discountRatio))
|
||||
})
|
||||
const goodsOriginAllPrice = computed(() => {
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.reduce((a,
|
||||
b) => {
|
||||
return a + (b.num * b.price)
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
|
||||
const freePrice = computed(() => {
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.gift == true || isGift(v)).reduce((a,
|
||||
b) => {
|
||||
const price = (b.isMember && b.memberPrice) ? b.memberPrice : b.price
|
||||
return a + (b.num * price)
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
const vipDiscountPrice = computed(() => {
|
||||
if (!props.user.isVip) {
|
||||
return 0
|
||||
}
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.gift != true && v.status !== "return" && (v.isMember &&
|
||||
v.memberPrice) && (v.memberPrice != v.price)).reduce((
|
||||
a,
|
||||
b) => {
|
||||
return a + (b.num * (b.price - b.memberPrice))
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
const productCoupPrice = computed(() => {
|
||||
if (props.orderInfo.status == 'closed') {
|
||||
return props.orderInfo.productCouponDiscountAmount
|
||||
}
|
||||
const goodsPrice = props.data.reduce((a, b) => {
|
||||
const curTotal = b.info.filter(v => v.gift != true && v.userCouponId).reduce((prve,
|
||||
cur) => {
|
||||
const isVip = props.user.isVip && cur.isMember
|
||||
const memberPrice = cur.memberPrice ? cur.memberPrice : cur.price
|
||||
const price = isVip ? memberPrice : cur.price
|
||||
const curTotal = price * cur.num
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return a + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
const youhuiAllPrice = computed(() => {
|
||||
return (freePrice.value * 1 + vipDiscountPrice.value * 1 + props.orderInfo.fullCouponDiscountAmount + props
|
||||
.orderInfo.pointsDiscountAmount + (props.orderInfo.status == 'unpaid' ? productCoupPrice.value :
|
||||
productCouponDiscountAmount.value) * 1 + (props.orderInfo.discountAmount ||
|
||||
0)).toFixed(2)
|
||||
|
||||
})
|
||||
const packFee = computed(() => {
|
||||
//不是退菜只要有打包费的都计算,包括赠送
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.status !== "return").reduce((a,
|
||||
b) => {
|
||||
return a + b.packAmount
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
|
||||
})
|
||||
const allPrice = computed(() => {
|
||||
const n = goodsOriginAllPrice.value - youhuiAllPrice.value
|
||||
return (n < 0 ? 0 : n).toFixed(2)
|
||||
|
||||
// if (props.orderInfo.status == 'unpaid') {
|
||||
// const n = goodsOriginAllPrice.value - youhuiAllPrice.value
|
||||
// return (n < 0 ? 0 : n).toFixed(2)
|
||||
// }
|
||||
// return props.orderInfo.amount
|
||||
})
|
||||
|
||||
const goodsNumber = computed(() => {
|
||||
let result = 0
|
||||
result = props.data.reduce((a, b) => {
|
||||
const bTotal = b.info.reduce((prve, cur) => {
|
||||
return prve + (cur.number || cur.num) * 1;
|
||||
}, 0);
|
||||
return a + bTotal
|
||||
}, 0)
|
||||
return result
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.img {
|
||||
width: 152rpx;
|
||||
height: 152rpx;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.border-top {
|
||||
border-color: #F6F6F6;
|
||||
}
|
||||
|
||||
.border-r-24 {
|
||||
border-radius: 24rpx;
|
||||
}
|
||||
|
||||
.border-bottom {
|
||||
// border-color: rgb(240, 240, 240);
|
||||
border-color: #F6F6F6;
|
||||
}
|
||||
|
||||
.line-th {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.tag {
|
||||
padding: 4rpx 8rpx 2rpx 10rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 24rpx;
|
||||
|
||||
&.no-pay {
|
||||
background-color: rgb(170, 170, 170);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&.refund {
|
||||
background-color: #FCE7E7;
|
||||
padding: 8rpx 20rpx 6rpx 22rpx;
|
||||
color: #EB4F4F;
|
||||
}
|
||||
}
|
||||
|
||||
.tui {
|
||||
background-color: rgb(239, 239, 239);
|
||||
border-radius: 4rpx;
|
||||
margin-right: 6rpx;
|
||||
color: #666;
|
||||
padding: 0 4rpx;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -17,8 +17,7 @@
|
|||
<text>份菜品</text>
|
||||
</view>
|
||||
<view class="u-m-b-20 " v-for="(order,orderIndex) in data" :key="orderIndex">
|
||||
<view class="u-p-t-24"> 第{{ order.placeNum }}次下单
|
||||
</view>
|
||||
<view class="u-p-t-24"> 第{{ order.placeNum }}次下单 </view>
|
||||
<view class="u-m-t-24 list">
|
||||
<view class="item u-m-b-32" v-for="(item,index) in order.info" :key="index">
|
||||
<view class="u-flex u-col-top">
|
||||
|
|
@ -39,7 +38,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-8">
|
||||
<view class="u-m-r-20 u-flex " v-if="item.gift">
|
||||
<view class="u-m-r-20 u-flex " v-if="item.payAmount<=0">
|
||||
<uni-tag text="赠送"
|
||||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
|
|
@ -49,7 +48,7 @@
|
|||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-flex" v-if="item.pack">
|
||||
<view class="u-m-r-20 u-flex" v-if="item.packNumber > 0">
|
||||
<uni-tag
|
||||
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
|
||||
size="small" text="打包" inverted type="success" />
|
||||
|
|
@ -62,8 +61,8 @@
|
|||
<view class="color-999 u-font-24 u-m-t-8">{{item.productSkuName||''}}</view>
|
||||
|
||||
|
||||
<view class="u-m-t-12 color-666 u-font-24" v-if="item.note">
|
||||
备注:{{item.note}}
|
||||
<view class="u-m-t-12 color-666 u-font-24" v-if="item.remark">
|
||||
备注:{{item.remark}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-text-right u-m-t-28">
|
||||
|
|
@ -86,15 +85,7 @@
|
|||
<template v-else>
|
||||
<view>¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
<!-- <template
|
||||
v-if="user.isVip&&item.isMember&&returnVipMoney(item)>0&&returnVipMoney(item)!=returnTotalMoney(item)">
|
||||
<view>¥{{returnVipMoney(item)}}</view>
|
||||
<view class=" color-666 line-th">
|
||||
¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view>¥{{returnTotalMoney(item)}}</view>
|
||||
</template> -->
|
||||
|
||||
</template>
|
||||
<view class="u-m-t-22 color-999 u-font-24">X{{item.number||item.num}}</view>
|
||||
</view>
|
||||
|
|
@ -117,10 +108,6 @@
|
|||
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="bg-gray u-p-20 u-m-t-20" v-if="orderInfo.remark">
|
||||
<view>备注</view>
|
||||
<view class="u-m-t-10">{{orderInfo.remark}}</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<view class="u-m-t-32">
|
||||
|
|
@ -143,7 +130,6 @@
|
|||
<view class="color-red u-m-r-6 ">
|
||||
已优惠¥{{youhuiAllPrice}}
|
||||
</view>
|
||||
<!-- <up-icon name="info-circle" color="#999" :size="14" @click="youhuiDetailShow"></up-icon> -->
|
||||
</view>
|
||||
<view>
|
||||
<text>小计¥</text>
|
||||
|
|
@ -178,13 +164,13 @@
|
|||
<template v-if="orderInfo.status=='unpaid'">
|
||||
<view>
|
||||
<text>总计¥</text>
|
||||
<text class="font-bold u-font-32">{{orderInfo.amount }}</text>
|
||||
<text class="font-bold u-font-32">{{orderInfo.orderAmount }}</text>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view>
|
||||
<text>总计¥</text>
|
||||
<text class="font-bold u-font-32">{{orderInfo.amount}}</text>
|
||||
<text class="font-bold u-font-32">{{orderInfo.payAmount}}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -226,14 +212,6 @@
|
|||
<text> {{productCouponDiscountAmount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-flex u-row-between u-m-t-18"
|
||||
v-if="orderInfo.productCouponDiscountAmount||productCoupPrice*1>0">
|
||||
<view>商品券抵扣</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text> {{to2(orderInfo.productCouponDiscountAmount||productCoupPrice) }}</text>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="u-flex u-row-between u-m-t-18" v-if="orderInfo.pointsDiscountAmount">
|
||||
<view>积分抵扣</view>
|
||||
<view class="color-red">
|
||||
|
|
@ -303,7 +281,45 @@
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 转桌/并桌
|
||||
*/
|
||||
function rotatingTables() {
|
||||
let arr = []
|
||||
props.data.forEach(ele => {
|
||||
ele.info.forEach(res => {
|
||||
// 头像 coverImg
|
||||
res.coverImg = res.productImg
|
||||
// 名字 name
|
||||
res.name = res.productName
|
||||
// 金额 salePrice
|
||||
res.salePrice = res.price
|
||||
// 数量 number
|
||||
res.number = res.num
|
||||
res.masterId = props.orderInfo.masterId
|
||||
res.useType = props.orderInfo.useType
|
||||
res.tableId = props.orderInfo.tableId
|
||||
arr.push(res)
|
||||
})
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: '/pagesCreateOrder/confirm-order/rotatingTables?item=' + JSON.stringify(arr) + '&tableId=' + props
|
||||
.orderInfo.tableId
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 计算菜品数量
|
||||
*/
|
||||
const goodsNumber = computed(() => {
|
||||
let result = 0
|
||||
result = props.data.reduce((a, b) => {
|
||||
const bTotal = b.info.reduce((prve, cur) => {
|
||||
return prve + (cur.number || cur.num) * 1;
|
||||
}, 0);
|
||||
return a + bTotal
|
||||
}, 0)
|
||||
return result
|
||||
})
|
||||
function returnProductCoupPrice(item) {
|
||||
if (!item.isMember) {
|
||||
return item.price * item.num
|
||||
|
|
@ -337,17 +353,14 @@
|
|||
}
|
||||
|
||||
function returnTotalMoney(item) {
|
||||
return (item.price * item.num).toFixed(2)
|
||||
return (item.payAmount * item.num).toFixed(2)
|
||||
}
|
||||
|
||||
const canTuiKuanPrice = computed(() => {
|
||||
const goodsTotal = props.data.reduce((prve, cur) => {
|
||||
// const curTotal=cur.info.filter(v=>!v.userCouponId).reduce((a,b)=>{
|
||||
// return a+b.priceAmount*1
|
||||
// },0)
|
||||
const curTotal = cur.info.filter(v => !isTui(v) && !v.userCouponId)
|
||||
.reduce((a, b) => {
|
||||
return a + b.priceAmount * 1
|
||||
return a + b.payAmount * 1
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
|
|
@ -357,12 +370,9 @@
|
|||
})
|
||||
const TuiKuanPrice = computed(() => {
|
||||
return props.data.reduce((prve, cur) => {
|
||||
// const curTotal=cur.info.filter(v=>!v.userCouponId).reduce((a,b)=>{
|
||||
// return a+b.priceAmount*1
|
||||
// },0)
|
||||
const curTotal = cur.info.filter(v => isTui(v) && !v.userCouponId)
|
||||
.reduce((a, b) => {
|
||||
return a + b.priceAmount * 1
|
||||
return a + b.payAmount * 1
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
|
|
@ -371,29 +381,27 @@
|
|||
return props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => !isTui(v) && !v.userCouponId)
|
||||
.reduce((a, b) => {
|
||||
return a + b.priceAmount * 1
|
||||
return a + b.payAmount * 1
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
})
|
||||
const cantuiSeatFee = computed(() => {
|
||||
let seatFee = props.orderInfo.seatInfo ? (props.orderInfo.seatInfo.priceAmount) : 0
|
||||
let seatFee = props.orderInfo.seatInfo ? (props.orderInfo.seatInfo.seatAmount) : 0
|
||||
const bili = Math.floor((seatFee / canTuiKuanPrice.value) * 100) / 100
|
||||
seatFee = Math.floor((props.orderInfo.amount - props.orderInfo.refundAmount) * bili * 100) / 100
|
||||
return seatFee
|
||||
})
|
||||
|
||||
function returnCanTuiMoney(item) {
|
||||
return props.orderInfo.status == 'unpaid' ? item.priceAmount : item.priceAmount
|
||||
return props.orderInfo.status == 'unpaid' ? item.payAmount : item.payAmount
|
||||
if (props.orderInfo.status == 'unpaid') {
|
||||
return returnTotalMoney(item)
|
||||
} else {
|
||||
if (props.orderInfo.pointsDiscountAmount > 0 || props.orderInfo.fullCouponDiscountAmount > 0) {
|
||||
return item.canReturnAmount
|
||||
// const bili=Math.floor((item.priceAmount/canTuiKuanPrice.value )*100)/100
|
||||
// return Math.floor((allPrice.value)*bili*100)/100
|
||||
} else {
|
||||
return item.priceAmount
|
||||
return item.payAmount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -414,7 +422,7 @@
|
|||
if (res) {
|
||||
emits('tuikuan', {
|
||||
...item,
|
||||
priceAmount: item.priceAmount
|
||||
payAmount: item.payAmount
|
||||
}, index)
|
||||
}
|
||||
})
|
||||
|
|
@ -426,10 +434,10 @@
|
|||
|
||||
|
||||
const seatFeePrice = computed(() => {
|
||||
if (!props.seatFee.priceAmount) {
|
||||
if (!props.seatFee.seatAmount) {
|
||||
return 0
|
||||
}
|
||||
const n = props.seatFee.priceAmount * (isTui(props.seatFee) ? 0 : 1)
|
||||
const n = props.seatFee.seatAmount * (isTui(props.seatFee) ? 0 : 1)
|
||||
return n.toFixed(2)
|
||||
})
|
||||
const discountAmount = computed(() => {
|
||||
|
|
@ -528,8 +536,8 @@
|
|||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.reduce((a,
|
||||
b) => {
|
||||
return a + (b.status == 'unpaid' ? b.priceAmount : b.status == 'return' ? 0 : b
|
||||
.priceAmount * 1)
|
||||
return a + (b.status == 'unpaid' ? b.payAmount : b.status == 'return' ? 0 : b
|
||||
.payAmount * 1)
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
|
|
@ -539,47 +547,15 @@
|
|||
const n = goodsOriginAllPrice.value - youhuiAllPrice.value
|
||||
return (n < 0 ? 0 : n).toFixed(2)
|
||||
}
|
||||
const returnAmount = props.orderInfo.seatInfo && props.orderInfo.seatInfo.returnAmount ? props.orderInfo
|
||||
.seatInfo.returnAmount : 0
|
||||
const returnAmount = props.orderInfo.seatInfo && props.orderInfo.seatInfo.seatAmount ? props.orderInfo
|
||||
.seatInfo.seatAmount : 0
|
||||
const canReturnAmount = props.orderInfo.seatInfo && props.orderInfo.seatInfo.canReturnAmount ? props
|
||||
.orderInfo.seatInfo.canReturnAmount : 0
|
||||
const total = props.orderInfo.amount - (returnAmount ? returnAmount : canReturnAmount)
|
||||
const total = props.orderInfo.amount - (seatAmount ? seatAmount : canReturnAmount)
|
||||
return (total <= 0 ? 0 : total).toFixed(2)
|
||||
})
|
||||
|
||||
function rotatingTables() {
|
||||
let arr = []
|
||||
props.data.forEach(ele => {
|
||||
ele.info.forEach(res => {
|
||||
// 头像 coverImg
|
||||
res.coverImg = res.productImg
|
||||
// 名字 name
|
||||
res.name = res.productName
|
||||
// 金额 salePrice
|
||||
res.salePrice = res.price
|
||||
// 数量 number
|
||||
res.number = res.num
|
||||
res.masterId = props.orderInfo.masterId
|
||||
res.useType = props.orderInfo.useType
|
||||
res.tableId = props.orderInfo.tableId
|
||||
arr.push(res)
|
||||
})
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: '/pagesCreateOrder/confirm-order/rotatingTables?item=' + JSON.stringify(arr) + '&tableId=' + props
|
||||
.orderInfo.tableId
|
||||
})
|
||||
}
|
||||
const goodsNumber = computed(() => {
|
||||
let result = 0
|
||||
result = props.data.reduce((a, b) => {
|
||||
const bTotal = b.info.reduce((prve, cur) => {
|
||||
return prve + (cur.number || cur.num) * 1;
|
||||
}, 0);
|
||||
return a + bTotal
|
||||
}, 0)
|
||||
return result
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-24">
|
||||
<view>订单类型</view>
|
||||
<view>{{returnUseType(data.useType)}}</view>
|
||||
<view>{{returnUseType(data.dineMode)}}</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-24">
|
||||
<view>桌位号</view>
|
||||
|
|
@ -20,14 +20,9 @@
|
|||
<view>支付方式</view>
|
||||
<view>{{data.payType||''}}</view>
|
||||
</view>
|
||||
<!-- <view class="u-flex u-row-between u-m-t-24">
|
||||
<view>预约时间</view>
|
||||
<view></view>
|
||||
</view> -->
|
||||
<view class="u-flex u-row-between u-m-t-24">
|
||||
<view>下单时间</view>
|
||||
<view><up-text v-if="data.createdAt" mode="date" format="yyyy-mm-dd hh:MM:ss"
|
||||
:text="data.createdAt"></up-text></view>
|
||||
<view><up-text v-if="data.createTime" mode="date" format="yyyy-mm-dd hh:MM:ss" :text="data.createTime"></up-text></view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-24">
|
||||
<view>订单编号</view>
|
||||
|
|
@ -38,16 +33,13 @@
|
|||
<up-icon name="/static/copy.svg" :size="16"></up-icon>
|
||||
</up-copy>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-24 u-col-top">
|
||||
<view class="no-wrap">商家备注</view>
|
||||
<view class="u-p-l-32 " style="max-width: 522rpx; word-wrap: break-word;">
|
||||
{{data.remark}}
|
||||
</view>
|
||||
<!-- <my-button plain shape="circle" :width="160" :height="60">编辑</my-button> -->
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
|
@ -80,7 +72,7 @@
|
|||
if (!useType) {
|
||||
return ''
|
||||
}
|
||||
return useType == "takeout" ? '自取' : '堂食';
|
||||
return useType == "take-out" ? '自取' : '堂食';
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<view class="u-flex u-row-between u-m-t-20 border-bottom u-p-b-20">
|
||||
<view class="u-flex">
|
||||
<up-avatar :size="30" :src="user.headImg"></up-avatar>
|
||||
<view class="color-666 u-m-l-30">{{user.telephone||'未绑定手机号'}}</view>
|
||||
<view class="color-666 u-m-l-30">{{user.phone||'未绑定手机号'}}</view>
|
||||
</view>
|
||||
<view>
|
||||
<my-button @click="toOrder" :height="60" plain shape="circle">他的订单</my-button>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,11 @@
|
|||
<template>
|
||||
<view class="min-page bg-gray u-font-28 u-p-30">
|
||||
<user-vue :orderInfo="orderDetail.info" :user="user"></user-vue>
|
||||
<!-- <view class="default-box-padding bg-fff border-r-12 u-m-t-32">
|
||||
<text class="">桌位号:</text>
|
||||
<text class="">{{orderDetail.info.tableName}}</text>
|
||||
</view> -->
|
||||
|
||||
<goods-list @printOrder="onPrintOrder" @tuikuan="onTuikuan" :orderInfo="orderDetail.info"
|
||||
:user="user"
|
||||
:data="orderDetail.goodsList" :seatFee="orderDetail.seatFee" @tuicai="onTuiCai"></goods-list>
|
||||
<!-- <template v-if="orderDetail.seatFee.totalNumber&&orderDetail.seatFee.totalAmount"> -->
|
||||
|
||||
<!-- <view class="default-box-padding bg-fff border-r-12 u-m-t-20 u-flex u-row-between" v-if="orderDetail.info.discountAmount>0">
|
||||
<view>服务员改价</view>
|
||||
<view class="color-red">-¥{{orderDetail.info.discountAmount}}</view>
|
||||
</view> -->
|
||||
<template v-if="true">
|
||||
<extra-vue @tuicai="onSeatFeeTuicai" @tuikuan="onSeatFeeTuiKuan" :orderInfo="orderDetail.info"
|
||||
:data="orderDetail.seatFee"></extra-vue>
|
||||
|
|
@ -64,21 +56,73 @@
|
|||
import go from '@/commons/utils/go.js'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import {hasPermission} from '@/commons/utils/hasPermission.js'
|
||||
import {
|
||||
onLoad,
|
||||
onShow,
|
||||
onHide
|
||||
} from '@dcloudio/uni-app';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import {
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
import OrderDetail from './page.js'
|
||||
import { getHistoryOrder } from '@/api/order.js'
|
||||
import { shopStaffDetail } from '@/api/staff.js'
|
||||
import { shopUserDetail } from '@/api/shopUser.js'
|
||||
|
||||
|
||||
const tuicai = reactive({
|
||||
show: false,
|
||||
isSeatFee: false,
|
||||
selGoods: {}
|
||||
})
|
||||
const orderDetail = reactive({
|
||||
goodsList: [],
|
||||
info: {},
|
||||
seatFee: {
|
||||
totalAmount: 0
|
||||
}
|
||||
})
|
||||
const options = reactive({})
|
||||
// 监听选择用户事件
|
||||
let user = ref({
|
||||
headImg:'',
|
||||
telephone:'',
|
||||
amount:'0.00',
|
||||
accountPoints:'0.00'
|
||||
})
|
||||
onLoad((opt) => {
|
||||
Object.assign(options, opt)
|
||||
console.log(options);
|
||||
})
|
||||
onShow(() => {
|
||||
watchEmit()
|
||||
watchChooseuser()
|
||||
getOrderDetail()
|
||||
})
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
*/
|
||||
async function getOrderDetail () {
|
||||
let res = await getHistoryOrder({orderId: options.id})
|
||||
console.log(res)
|
||||
if(res.userId){
|
||||
shopUserDetail({id:res.userId}).then(res=>{
|
||||
if(res){
|
||||
user.value = res
|
||||
}
|
||||
})
|
||||
}
|
||||
orderDetail.seatFee = {
|
||||
seatNum: res.seatNum,
|
||||
seatAmount: res.seatAmount,
|
||||
}
|
||||
orderDetail.goodsList = Object.entries(res.detailMap).map(([key, value]) => ({
|
||||
info: value,
|
||||
placeNum: key
|
||||
}))
|
||||
console.log(orderDetail.goodsList);
|
||||
orderDetail.info = res
|
||||
}
|
||||
|
||||
function onSeatFeeTuicai(seatFee) {
|
||||
seatFee={...seatFee,num:seatFee.num,productName:seatFee.productName}
|
||||
|
|
@ -223,7 +267,7 @@
|
|||
name: options.name || orderDetail.info.tableName,
|
||||
masterId:orderDetail.info.masterId,
|
||||
type: 'add',
|
||||
vipUserId:orderDetail.memberId?orderDetail.memberId:''
|
||||
vipUserId:orderDetail.userId?orderDetail.userId:''
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -232,7 +276,7 @@
|
|||
if(!canJieZhang){
|
||||
return
|
||||
}
|
||||
const memberId=orderDetail.info.memberId||''
|
||||
const userId=orderDetail.info.userId||''
|
||||
clearEmit()
|
||||
go.to('PAGES_ORDER_PAY', {
|
||||
tableId: options.tableId|| orderDetail.info.tableId,
|
||||
|
|
@ -240,79 +284,10 @@
|
|||
masterId: options.masterId,
|
||||
orderId: orderDetail.info.id,
|
||||
discount: 1,
|
||||
memberId
|
||||
userId
|
||||
})
|
||||
}
|
||||
|
||||
const orderDetail = reactive({
|
||||
goodsList: [],
|
||||
info: {},
|
||||
seatFee: {
|
||||
totalAmount: 0
|
||||
}
|
||||
})
|
||||
const options = reactive({})
|
||||
async function init() {
|
||||
const res = await orderApi.tbOrderInfoDetail(options.id)
|
||||
if(res.memberId){
|
||||
queryAllShopUser({id:res.memberId}).then(res=>{
|
||||
if(res.content[0]){
|
||||
user.value=res.content[0]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
if (res.detailList.length) {
|
||||
uni.setStorageSync('useType', res.detailList[0].useType)
|
||||
}
|
||||
const masterId = res.masterId
|
||||
options.masterId = res.masterId
|
||||
// if (res.status == 'unpaid') {
|
||||
if (false) {
|
||||
const {
|
||||
records,
|
||||
seatFee
|
||||
} = await Api.getCart({
|
||||
masterId,
|
||||
tableId: res.tableId,
|
||||
page: 1,
|
||||
size: 200
|
||||
})
|
||||
orderDetail.goodsList = records
|
||||
orderDetail.seatFee = seatFee ? seatFee : orderDetail.seatFee
|
||||
} else {
|
||||
const goodsMap = {}
|
||||
for (let i in res.detailList) {
|
||||
const goods = res.detailList[i]
|
||||
if (goods.productName != '客座费') {
|
||||
if (goodsMap.hasOwnProperty(goods.placeNum)) {
|
||||
goodsMap[goods.placeNum].push(goods)
|
||||
} else {
|
||||
goodsMap[goods.placeNum] = [goods]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
console.log(res.seatInfo);
|
||||
orderDetail.seatFee = res.seatInfo|| {
|
||||
// name: '客座费',
|
||||
// number: res.seatCount,
|
||||
// num: res.seatCount,
|
||||
// totalNumber: res.seatCount,
|
||||
// priceAmount: res.seatAmount,
|
||||
// status:'',
|
||||
totalNumber:0,
|
||||
}
|
||||
orderDetail.goodsList = Object.entries(goodsMap).map(([key, value]) => ({
|
||||
info: value,
|
||||
placeNum: key
|
||||
}))
|
||||
console.log(orderDetail.goodsList);
|
||||
}
|
||||
console.log(res,'debug121')
|
||||
orderDetail.info = res
|
||||
}
|
||||
|
||||
function watchEmit() {
|
||||
uni.$off('orderDetail:update')
|
||||
|
|
@ -322,13 +297,7 @@
|
|||
})
|
||||
}
|
||||
|
||||
// 监听选择用户事件
|
||||
let user = ref({
|
||||
headImg:'',
|
||||
telephone:'',
|
||||
amount:'0.00',
|
||||
accountPoints:'0.00'
|
||||
})
|
||||
|
||||
//更新选择用户
|
||||
async function setUser(par) {
|
||||
const submitPar = {
|
||||
|
|
@ -359,15 +328,7 @@
|
|||
})
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
watchEmit()
|
||||
watchChooseuser()
|
||||
init()
|
||||
})
|
||||
onLoad((opt) => {
|
||||
Object.assign(options, opt)
|
||||
console.log(options);
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@
|
|||
<view class="u-m-t-26">
|
||||
<view class="u-flex u-col-bottom u-font-24 color-999">
|
||||
<up-avatar :size="33"></up-avatar>
|
||||
<view class="u-m-l-16">{{formatTime(data.createdAt)}}</view>
|
||||
<view class="u-m-l-16">{{formatTime(data.createTime)}}</view>
|
||||
</view>
|
||||
<view class="u-m-t-32">
|
||||
<view class="u-font-32">{{goosZhonglei}}种商品,共{{goodsNumber}}件</view>
|
||||
<view class="border-bottom u-p-b-32">
|
||||
<view class="" v-for="(item,index) in data.detailList" :key="index">
|
||||
<view class="" v-for="(item,index) in data.goods" :key="index">
|
||||
<view class="u-flex u-row-between u-col-top u-m-t-32" v-if="item.productId!=-999">
|
||||
<view>
|
||||
<view class=""> {{item.productName}}</view>
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else-if="item.isMember&&data.memberId&&item.memberPrice&&item.memberPrice!=item.price">
|
||||
<template v-else-if="item.isMember&&data.userId&&item.memberPrice&&item.memberPrice!=item.price">
|
||||
<view class="u-text-right u-relative" :style="computedPriceStyle()">
|
||||
<text class="line-th">¥{{goodsPriceAmount(item)}}</text>
|
||||
<view class="u-absolute" style="bottom: 100%;right: 0;">
|
||||
|
|
@ -141,7 +141,7 @@
|
|||
productName: '客座费',
|
||||
priceAmount: 0
|
||||
},
|
||||
detailList: []
|
||||
goods: []
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -168,7 +168,7 @@
|
|||
return (price * item.num).toFixed(2)
|
||||
}
|
||||
// const packeFee=computed(()=>{
|
||||
// return props.data.detailList.reduce((prve,cur)=>{
|
||||
// return props.data.goods.reduce((prve,cur)=>{
|
||||
// return prve+cur.packAmount
|
||||
// },0).toFixed(2)
|
||||
// })
|
||||
|
|
@ -182,8 +182,8 @@
|
|||
// })
|
||||
|
||||
function goodsMapInit() {
|
||||
for (let i in props.data.detailList) {
|
||||
const goods = props.data.detailList[i]
|
||||
for (let i in props.data.goods) {
|
||||
const goods = props.data.goods[i]
|
||||
if ($goodsMap.hasOwnProperty(goods.productId)) {
|
||||
$goodsMap[goods.productId] += goods.num * 1
|
||||
goodsNumber.value += goods.num * 1
|
||||
|
|
@ -195,7 +195,7 @@
|
|||
}
|
||||
}
|
||||
goodsMapInit()
|
||||
watch(() => props.data.detailList.length, (newval) => {
|
||||
watch(() => props.data.goods.length, (newval) => {
|
||||
goodsNumber.value = 0
|
||||
goodsMapInit()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@
|
|||
list: [],
|
||||
total: 0,
|
||||
query: {
|
||||
platformType: "admin-app",
|
||||
orderNo: "",
|
||||
platformType: "APP",
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
startTime: today.start,
|
||||
|
|
@ -140,9 +140,6 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,17 +1,17 @@
|
|||
<template>
|
||||
<view class="u-p-l-30 u-p-r-30 u-p-t-30 u-font-28 ">
|
||||
<up-sticky offset-top="0">
|
||||
<my-tabs v-model="myQuan.types.sel" :list="myQuan.types.list"></my-tabs>
|
||||
<my-tabs v-model="pageData.types.sel" :list="pageData.types.list"></my-tabs>
|
||||
</up-sticky>
|
||||
<view class="u-m-t-32">
|
||||
<template v-if="myQuan.types.sel==0">
|
||||
<template v-if="pageData.types.sel==0">
|
||||
<view class="" @click="changeFullReductionCouponSel(item)"
|
||||
v-for="(item,index) in myQuan.res.fullReductionCoupon" :class="{filtergray:!item.use}" :key="index">
|
||||
v-for="(item,index) in pageData.fullReductionCoupon" :class="{filtergray:!item.use}" :key="index">
|
||||
<view class="quan u-row-between u-flex u-col-center u-m-b-32 border-r-10 ">
|
||||
<view class="no-use" v-if="!item.use">
|
||||
<image class="img" src="/pagesOrder/static/image/no-use.svg" mode=""></image>
|
||||
</view>
|
||||
<view class="sel u-abso" v-if="item.id==myQuan.fullReductionCouponSel.id ">
|
||||
<view class="sel u-abso" v-if="item.id == pageData.fullReductionCouponSel.id ">
|
||||
<up-icon name="checkbox-mark" color="#fff"></up-icon>
|
||||
</view>
|
||||
<view class="u-p-t-32 u-p-b-32 u-p-l-24 u-p-r-24 left">
|
||||
|
|
@ -41,13 +41,13 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<template v-if="myQuan.res.fullReductionCoupon.length<=0&&myQuan.hasAjax">
|
||||
<template v-if="pageData.fullReductionCoupon.length <= 0 && pageData.hasAjax">
|
||||
<my-img-empty tips="暂无可用优惠券"></my-img-empty>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<template v-if="myQuan.types.sel==1">
|
||||
<view class="" @click="changeProductCoupon(item)" v-for="(item,index) in myQuan.res.productCoupon"
|
||||
<template v-if="pageData.types.sel==1">
|
||||
<view class="" @click="changeProductCoupon(item)" v-for="(item,index) in pageData.productCoupon"
|
||||
:class="{filtergray:!item.use}" :key="index">
|
||||
<view class="quan goods u-row-between u-flex u-col-center u-m-b-32 border-r-10 u-relative">
|
||||
<view class="no-use" v-if="!item.use">
|
||||
|
|
@ -74,9 +74,6 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="right u-flex u-flex-col u-col-bottom u-row-center">
|
||||
<!-- <view class="u-flex u-row-center w-full">
|
||||
<view class="color-red font-bold u-m-b-24 ">¥{{item.discountAmount}}</view>
|
||||
</view> -->
|
||||
<view class="u-flex ">
|
||||
<view class="use-btn" @click.stop="toEmitChooseQuan(item)">去使用</view>
|
||||
</view>
|
||||
|
|
@ -84,7 +81,7 @@
|
|||
</view>
|
||||
|
||||
</view>
|
||||
<template v-if="myQuan.res.productCoupon.length<=0&&myQuan.hasAjax">
|
||||
<template v-if="pageData.productCoupon.length <= 0 && pageData.hasAjax">
|
||||
<my-img-empty tips="暂无可用优惠券"></my-img-empty>
|
||||
</template>
|
||||
</template>
|
||||
|
|
@ -133,31 +130,13 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
watch,
|
||||
computed,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import { onLoad, onReady } from '@dcloudio/uni-app'
|
||||
import { ref, reactive, watch, computed, onMounted } from 'vue';
|
||||
import color from '@/commons/color.js'
|
||||
import dayjs from 'dayjs';
|
||||
import {
|
||||
getSafeBottomHeight
|
||||
} from '@/commons/utils/safe-bottom.js'
|
||||
import { getSafeBottomHeight } from '@/commons/utils/safe-bottom.js'
|
||||
import go from '@/commons/utils/go.js'
|
||||
import {
|
||||
onLoad,
|
||||
onReady
|
||||
} from '@dcloudio/uni-app'
|
||||
import * as orderApi from '@/http/yskApi/order.js'
|
||||
import {
|
||||
$activateByOrderId
|
||||
} from '@/http/yskApi/Instead.js'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import {
|
||||
queryAllShopUser
|
||||
} from '@/http/yskApi/shop-user.js'
|
||||
import {
|
||||
returnNewGoodsList,
|
||||
returnCoupCanUse,
|
||||
|
|
@ -165,6 +144,10 @@
|
|||
returnProductCoupon,
|
||||
returnCanUseFullReductionCoupon
|
||||
} from '../quan_util.js'
|
||||
import { getHistoryOrder } from '@/api/order.js'
|
||||
import { shopUserDetail } from '@/api/shopUser.js'
|
||||
import { getCouponList } from '@/api/coupon.js'
|
||||
|
||||
|
||||
const modal = reactive({
|
||||
title: '提示',
|
||||
|
|
@ -176,20 +159,116 @@
|
|||
data: ''
|
||||
})
|
||||
|
||||
const option = reactive({
|
||||
orderId: '',
|
||||
userId: '',
|
||||
orderPrice: 0
|
||||
})
|
||||
const pageData = reactive({
|
||||
order: null,
|
||||
user: null,
|
||||
types: {
|
||||
list: ['满减券(单选)', '商品券(多选)'],
|
||||
sel: 0
|
||||
},
|
||||
fullReductionCouponSel: {
|
||||
id: ''
|
||||
},
|
||||
fullReductionCoupon: [],
|
||||
productCoupon: [],
|
||||
hasAjax: false
|
||||
})
|
||||
let canDikouGoodsArr = []
|
||||
let safebottomHeight = ref(0)
|
||||
|
||||
onLoad((opt) => {
|
||||
Object.assign(option, opt)
|
||||
getQuan()
|
||||
})
|
||||
watch(() => pageData.types.sel, (newval) => {
|
||||
if (newval == 0) {
|
||||
pageData.fullReductionCoupon = returnCanUseFullReductionCoupon(pageData.fullReductionCoupon, payPrice.value,
|
||||
pageData.fullReductionCouponSel)
|
||||
}
|
||||
if (newval == 1) {
|
||||
|
||||
}
|
||||
})
|
||||
onReady(() => {
|
||||
getSafeBottomHeight('bottom', 0).then(height => {
|
||||
safebottomHeight.value = height
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* 抵扣金额
|
||||
*/
|
||||
const discountAmount = computed(() => {
|
||||
const goodsQuan = pageData.productCoupon.filter(v => v.checked)
|
||||
const fullReductionCoupon = pageData.fullReductionCouponSel.id ? [pageData.fullReductionCouponSel] : []
|
||||
let coupArr = [...fullReductionCoupon, ...goodsQuan]
|
||||
return returnCouponAllPrice(coupArr, canDikouGoodsArr, pageData.user)
|
||||
})
|
||||
const payPrice = computed(() => {
|
||||
const pay = option.orderPrice - discountAmount.value
|
||||
return (pay < 0 ? 0 : pay).toFixed(2)
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取优惠券
|
||||
*/
|
||||
async function getQuan() {
|
||||
shopUserDetail({ id: option.userId }).then(res=>{
|
||||
pageData.user = res
|
||||
})
|
||||
pageData.order = await getHistoryOrder({orderId:option.orderId})
|
||||
|
||||
console.log(pageData.order);
|
||||
const res = await getCouponList()
|
||||
let fullReductionCoupon = res.filter(v => v.type == 1)
|
||||
let productCoupon = res.filter(v => v.type == 2)
|
||||
|
||||
canDikouGoodsArr = returnNewGoodsList(pageData.order.detailMap || [])
|
||||
fullReductionCoupon = fullReductionCoupon.map((v) => {
|
||||
if(option.orderPrice<=0){
|
||||
return {...v,use:false}
|
||||
}else{
|
||||
return{
|
||||
...v,
|
||||
use:v.use && option.orderPrice * 1 >= v
|
||||
.fullAmount * 1
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
productCoupon = productCoupon.map(v => {
|
||||
const calcCoup = returnProductCoupon(v, pageData.order.detailMap, pageData.user)
|
||||
return {
|
||||
...calcCoup,
|
||||
checked: false,
|
||||
use:option.orderPrice<=0?false:v.use
|
||||
}
|
||||
}).filter((v) => v.use);
|
||||
pageData.fullReductionCoupon = fullReductionCoupon
|
||||
pageData.productCoupon = productCoupon
|
||||
console.log(pageData)
|
||||
pageData.hasAjax = true;
|
||||
}
|
||||
|
||||
function confirmModelCancel() {
|
||||
setModalShow('clear', false, '')
|
||||
}
|
||||
|
||||
async function confirmModelConfirm() {
|
||||
if (modal.key == 'clear') {
|
||||
myQuan.fullReductionCouponSel = {
|
||||
pageData.fullReductionCouponSel = {
|
||||
id: ''
|
||||
}
|
||||
const item = modal.data
|
||||
item.checked = !item.checked
|
||||
const CheckedArr = myQuan.res.productCoupon.filter(v => v.checked)
|
||||
const noCheckedArr = myQuan.res.productCoupon.filter(v => !v.checked)
|
||||
const CheckedArr = pageData.productCoupon.filter(v => v.checked)
|
||||
const noCheckedArr = pageData.productCoupon.filter(v => !v.checked)
|
||||
noCheckedArr.map(v => {
|
||||
console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr));
|
||||
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)
|
||||
})
|
||||
setModalShow('clear', false, '')
|
||||
|
|
@ -207,36 +286,20 @@
|
|||
function back() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
let order = ref({
|
||||
|
||||
})
|
||||
let canDikouGoodsArr = []
|
||||
const myQuan = reactive({
|
||||
fullReductionCouponSel: {
|
||||
id: ''
|
||||
},
|
||||
res: {
|
||||
fullReductionCoupon: [],
|
||||
productCoupon: []
|
||||
},
|
||||
types: {
|
||||
list: ['满减券(单选)', '商品券(多选)'],
|
||||
sel: 0
|
||||
},
|
||||
list: [],
|
||||
sel: -1,
|
||||
hasAjax: false
|
||||
})
|
||||
|
||||
/**
|
||||
* 商品券选择
|
||||
* @param {Object} item
|
||||
*/
|
||||
function changeProductCoupon(item) {
|
||||
if (!item.use) {
|
||||
return
|
||||
}
|
||||
if (myQuan.fullReductionCouponSel.id && !item.checked) {
|
||||
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
|
||||
const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : []
|
||||
if (pageData.fullReductionCouponSel.id && !item.checked) {
|
||||
const goodsQuan = pageData.productCoupon.filter(v => v.checked)
|
||||
const fullReductionCoupon = pageData.fullReductionCouponSel.id ? [pageData.fullReductionCouponSel] : []
|
||||
let coupArr = [...goodsQuan, item]
|
||||
const payPrice = option.orderPrice - returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
|
||||
const payPrice = option.orderPrice - returnCouponAllPrice(coupArr, canDikouGoodsArr, pageData.user)
|
||||
if (payPrice<=0) {
|
||||
modal.content = '选择该商品券后支付金额将为0,继续选择将取消选择的满减券'
|
||||
modal.cancelText = '取消'
|
||||
|
|
@ -244,7 +307,7 @@
|
|||
setModalShow('clear', true, item)
|
||||
return
|
||||
}
|
||||
if (myQuan.fullReductionCouponSel.fullAmount > payPrice) {
|
||||
if (pageData.fullReductionCouponSel.fullAmount > payPrice) {
|
||||
modal.content = '选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券'
|
||||
modal.cancelText = '取消'
|
||||
modal.confirmText = '继续选择'
|
||||
|
|
@ -254,142 +317,65 @@
|
|||
}
|
||||
|
||||
item.checked = !item.checked
|
||||
const CheckedArr = myQuan.res.productCoupon.filter(v => v.checked)
|
||||
const CheckedArr = pageData.productCoupon.filter(v => v.checked)
|
||||
if (CheckedArr.length <= 0) {
|
||||
return myQuan.res.productCoupon.map(v => {
|
||||
return pageData.productCoupon.map(v => {
|
||||
v.use = true
|
||||
})
|
||||
}
|
||||
const noCheckedArr = myQuan.res.productCoupon.filter(v => !v.checked)
|
||||
const noCheckedArr = pageData.productCoupon.filter(v => !v.checked)
|
||||
noCheckedArr.map(v => {
|
||||
console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr));
|
||||
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 优惠券选择
|
||||
* @param {Object} item
|
||||
*/
|
||||
function changeFullReductionCouponSel(item) {
|
||||
if (!item.use) {
|
||||
return
|
||||
// return
|
||||
}
|
||||
console.log(item);
|
||||
if (item.id == myQuan.fullReductionCouponSel.id) {
|
||||
myQuan.fullReductionCouponSel = {
|
||||
if (item.id == pageData.fullReductionCouponSel.id) {
|
||||
pageData.fullReductionCouponSel = {
|
||||
id: ''
|
||||
}
|
||||
} else {
|
||||
myQuan.fullReductionCouponSel = item
|
||||
pageData.fullReductionCouponSel = item
|
||||
}
|
||||
myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value, myQuan
|
||||
pageData.fullReductionCoupon = returnCanUseFullReductionCoupon(pageData.fullReductionCoupon, payPrice.value, pageData
|
||||
.fullReductionCouponSel)
|
||||
}
|
||||
|
||||
function formatStr(str) {
|
||||
return str.replaceAll('"', '')
|
||||
// return str.replaceAll('"', '')
|
||||
}
|
||||
|
||||
function toUse(item) {
|
||||
|
||||
}
|
||||
let user = reactive({
|
||||
isVip: false
|
||||
})
|
||||
|
||||
let $fullReductionCoupon = []
|
||||
let $productCoupon = []
|
||||
async function getQuan() {
|
||||
order.value = await orderApi.tbOrderInfoDetail(option.orderId)
|
||||
if (order.value.memberId) {
|
||||
const userRes = await queryAllShopUser({
|
||||
id: order.value.memberId
|
||||
})
|
||||
if (userRes.content[0]) {
|
||||
user.value = userRes.content[0]
|
||||
}
|
||||
}
|
||||
|
||||
console.log(order.value);
|
||||
const res = await $activateByOrderId({
|
||||
orderId: option.orderId,
|
||||
memberId: option.memberId
|
||||
})
|
||||
canDikouGoodsArr = returnNewGoodsList(order.value.detailList || [])
|
||||
res.fullReductionCoupon = res.fullReductionCoupon.map((v) => {
|
||||
if(option.orderPrice<=0){
|
||||
return {...v,use:false}
|
||||
}else{
|
||||
return{
|
||||
...v,
|
||||
use:v.use && option.orderPrice * 1 >= v
|
||||
.fullAmount * 1
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
res.productCoupon = res.productCoupon.map(v => {
|
||||
const calcCoup = returnProductCoupon(v, canDikouGoodsArr, user.value)
|
||||
return {
|
||||
...calcCoup,
|
||||
checked: false,
|
||||
use:option.orderPrice<=0?false:v.use
|
||||
}
|
||||
}).filter((v) => v.use);
|
||||
$fullReductionCoupon = res.fullReductionCoupon
|
||||
$productCoupon = res.productCoupon
|
||||
myQuan.res = res
|
||||
myQuan.hasAjax = true;
|
||||
}
|
||||
const option = reactive({
|
||||
orderId: '',
|
||||
memberId: '',
|
||||
orderPrice: 0
|
||||
})
|
||||
|
||||
/**
|
||||
* 优惠券选择确认
|
||||
* @param {Object} item
|
||||
*/
|
||||
function toEmitChooseQuan(item) {
|
||||
let arr = []
|
||||
if (item) {
|
||||
arr = [item]
|
||||
} else {
|
||||
if (myQuan.fullReductionCouponSel.id) {
|
||||
arr.push(myQuan.fullReductionCouponSel)
|
||||
if (pageData.fullReductionCouponSel.id) {
|
||||
arr.push(pageData.fullReductionCouponSel)
|
||||
}
|
||||
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
|
||||
const goodsQuan = pageData.productCoupon.filter(v => v.checked)
|
||||
arr.push(...goodsQuan)
|
||||
}
|
||||
uni.$emit('choose-quan', arr)
|
||||
back()
|
||||
}
|
||||
const discountAmount = computed(() => {
|
||||
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
|
||||
const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : []
|
||||
let coupArr = [...fullReductionCoupon, ...goodsQuan]
|
||||
return returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
|
||||
})
|
||||
const payPrice = computed(() => {
|
||||
const pay = option.orderPrice - discountAmount.value
|
||||
return (pay < 0 ? 0 : pay).toFixed(2)
|
||||
})
|
||||
watch(() => myQuan.types.sel, (newval) => {
|
||||
if (newval == 0) {
|
||||
myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value,
|
||||
myQuan.fullReductionCouponSel)
|
||||
}
|
||||
if (newval == 1) {
|
||||
|
||||
}
|
||||
})
|
||||
onLoad((opt) => {
|
||||
Object.assign(option, opt)
|
||||
getQuan()
|
||||
})
|
||||
let safebottomHeight = ref(0)
|
||||
onReady(() => {
|
||||
getSafeBottomHeight('bottom', 0).then(height => {
|
||||
console.log(height);
|
||||
safebottomHeight.value = height
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
export function isTui(item) {
|
||||
console.log("isTui",item.status);
|
||||
return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
|
||||
}
|
||||
//是否使用会员价
|
||||
|
|
@ -19,8 +20,11 @@ export function returnProductCouponPrice(coup, goodsArr, vipUser) {
|
|||
}
|
||||
//返回新的商品列表,过滤掉退菜的,退单的商品
|
||||
export function returnNewGoodsList(arr) {
|
||||
let goodsMap = {}
|
||||
return arr.filter(v => !isTui(v))
|
||||
let goods_list = []
|
||||
Object.values(arr).forEach(item=>{
|
||||
goods_list = [...goods_list,...item]
|
||||
})
|
||||
return goods_list.filter(v => !isTui(v))
|
||||
}
|
||||
//根据当前购物车商品以及数量,已选券对应商品数量,判断该商品券是否可用
|
||||
export function returnCoupCanUse(goodsArr = [], coup, selCoupArr = []) {
|
||||
|
|
@ -128,11 +132,15 @@ export function returnProCoupStartIndex(coupArr,index){
|
|||
}
|
||||
//返回商品数量从0到n每一个对应的价格对照表
|
||||
export function returnGoodsPayPriceMap(goodsArr){
|
||||
return goodsArr.reduce((prve,cur)=>{
|
||||
let goods_arr = []
|
||||
Object.values(goodsArr).forEach(item=>{
|
||||
goods_arr = [...goods_arr,...item]
|
||||
})
|
||||
return goods_arr.reduce((prve,cur)=>{
|
||||
if(!prve.hasOwnProperty(cur.productId)){
|
||||
prve[cur.productId]=[]
|
||||
}
|
||||
const arr=new Array(cur.num).fill(cur).map(v=>{
|
||||
let arr=new Array(cur.num).fill(cur).map(v=>{
|
||||
return {
|
||||
memberPrice:v.memberPrice?v.memberPrice:v.price,
|
||||
price:v.price
|
||||
|
|
@ -141,6 +149,7 @@ export function returnGoodsPayPriceMap(goodsArr){
|
|||
prve[cur.productId].push(...arr)
|
||||
return prve
|
||||
},{})
|
||||
|
||||
}
|
||||
//计算商品券总优惠价格
|
||||
export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||
|
|
@ -155,6 +164,7 @@ export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
|
|||
let coupMap={}
|
||||
for(let i in coupArr){
|
||||
const coup=coupArr[i]
|
||||
console.log(coup)
|
||||
if(coupMap.hasOwnProperty(coup.proId)){
|
||||
coupMap[coup.proId].push(coup)
|
||||
}else{
|
||||
|
|
@ -178,15 +188,15 @@ export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
|
|||
return aPrice-bPrice
|
||||
})
|
||||
goodsPayPriceMap[coup.proId]=goodsMap[coup.proId].reduce((prve,cur)=>{
|
||||
const arr=new Array(cur.num).fill(cur.payPrice)
|
||||
const arr=new Array(cur.number).fill(cur.payPrice)
|
||||
console.log(arr);
|
||||
prve.push(...arr)
|
||||
return prve
|
||||
},[])
|
||||
}
|
||||
const proCoupStartIndex=returnProCoupStartIndex(arr,i)
|
||||
console.log(proCoupStartIndex);
|
||||
const coupNum=Math.min(goodsPayPriceMap[coup.proId].length,coup.num)
|
||||
console.log(coup);
|
||||
const coupNum = Math.min(goodsPayPriceMap[coup.proId].length,coup.number)
|
||||
console.log(coupNum);
|
||||
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coupNum)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ module.exports = {
|
|||
// },
|
||||
devServer: {
|
||||
proxy: {
|
||||
'/server3': {
|
||||
target: 'http://101.37.12.135:8080', // 目标服务器地址
|
||||
'/account': {
|
||||
target: 'https://tapi.cashier.sxczgkj.cn', // 目标服务器地址
|
||||
changeOrigin: true, // 是否改变源地址
|
||||
rewrite: '/' // 重写路径
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue