初始上传

This commit is contained in:
2026-04-04 17:27:12 +08:00
parent 4d80d28eb4
commit b7e11774ee
11191 changed files with 1588469 additions and 0 deletions

View File

@@ -0,0 +1,157 @@
<template>
<base-page>
<view class="uni-flex uni-row page-height">
<view class="common-wrap left-wrap">
<view class="cashregister-header-box">
<view class="order-time">
<view class="title">消费时间</view>
<uni-datetime-picker v-model="buyCardOrderData.create_time" type="datetime" :clearIcon="false" />
</view>
<view class="header" v-if="globalMemberInfo">
<view class="headimg" @click="showMember">
<image class="header-image" :src="globalMemberInfo.headimg ? $util.img(globalMemberInfo.headimg) : $util.img(defaultImg.head)" @error="globalMemberInfo.headimg = defaultImg.head"/>
<view v-if="globalMemberInfo.member_level" class="member-nameplate">
{{ globalMemberInfo.member_level_name }}
</view>
</view>
<view class="head-info" @click="showMember">
<view class="head-info-top">
<view class="name">
<block v-if="globalMemberInfo.mobile">
<view class="mobile">{{ globalMemberInfo.mobile }}</view>
<view class="text">
<text></text>
<text class="nickname">{{globalMemberInfo.nickname }}</text>
<text></text>
</view>
</block>
<text v-else>{{ globalMemberInfo.nickname }}</text>
</view>
</view>
<view class="head-info-bottom point">积分{{ globalMemberInfo.point }}</view>
<view class="head-info-bottom balance">余额{{ (parseFloat(globalMemberInfo.balance_money) + parseFloat(globalMemberInfo.balance)) | moneyFormat}}</view>
</view>
<button class="switch primary-btn member-open" @click="openMember()">更换会员</button>
<button class="switch primary-btn replace-member" @click="replaceMember()">散客</button>
</view>
<view class="header" v-else>
<view class="headimg">
<image class="header-image" :src="$util.img(defaultImg.head)" />
</view>
<view class="head-info">
<view class="name">散客</view>
</view>
<button class="switch primary-btn" @click="openMember()">查询会员</button>
</view>
</view>
<view class="content">
<!-- <view class="title">
<view>结算清单<text>{{ buyCardOrderData.goods_num }}</text></view>
<view class="clear" @click="clearGoods">
<text class="iconfont iconqingchushujuku"></text>
<text>清空</text>
</view>
</view> -->
<view class="content-list common-scrollbar">
<block v-if="buyCardOrderData.goods_list.length && Object.keys(buyCardGoodsData).length">
<view class="content-item" v-for="(item, index) in buyCardOrderData.goods_list" :key="index">
<view class="item-img">
<image :src="$util.img(item.goods_image.split(',')[0], { size: 'small' })" mode="widthFix"/>
</view>
<view class="uni-flex flex-1 info-wrap">
<view class="info-top">
<view class="uni-flex justify-between items-center">
<view class="item-name">{{ item.sku_name }}</view>
<view class="item-del" @click="deleteGoods(item)">
<text class="iconfont iconshanchu"></text>
<text>删除</text>
</view>
</view>
<view class="item-spe" v-if="item.spec_name" arrow-down>{{ item.spec_name }}</view>
</view>
<view class="info-bottom flex justify-between items-center">
<view class="item-price">{{ item.price | moneyFormat }}</view>
<view class="item-num">
<view class="num-dec" @click="dec(item)">-</view>
<view class="num">{{ buyCardGoodsData['sku_' + item.sku_id].num }}</view>
<view class="num-inc" @click="inc(item)">+</view>
</view>
</view>
</view>
</view>
</block>
<block v-else>
<view class="empty">
<image src="@/static/cashier/cart_empty.png" mode="widthFix"/>
<view class="tips">点击右侧商品选择商品进行结账</view>
</view>
</block>
</view>
</view>
<view class="bottom">
<view class="bottom-info">
<view class="bottom-left">合计 <text>{{ buyCardOrderData.goods_num }}</text> </view>
<text class="pay-money">{{ buyCardOrderData.pay_money | moneyFormat }}</text>
</view>
<view class="bottom-btn">
<button class="primary-btn btn-right" :disabled="buyCardOrderData.goods_num == 0" @click="pay('')">结账</button>
</view>
</view>
<view class="pay-shade" v-show="type == 'pay'"></view>
</view>
<view class="uni-flex uni-row" style="flex: 1;">
<view class="list-wrap flex-1">
<!-- 卡项商品 -->
<view class="content" v-show="type == 'goods'">
<ns-card :type="buyCardOrderData.card_type" ref="card"/>
</view>
<view class="content" v-show="type == 'pay'">
<ns-payment ref="payment" storeRoute="buycard" @cancel="cancelPayment" @success="paySuccess" :outTradeNo="outTradeNo"/>
</view>
</view>
</view>
</view>
<ns-select-member ref="selectMember"/>
<!-- 会员详情弹出框 -->
<ns-member-detail-popup ref="memberDetailPopup" />
</base-page>
</template>
<script>
import buycard from './public/js/buycard.js';
import nsSelectMember from '@/components/ns-select-member/ns-select-member.vue';
export default {
components: {
nsSelectMember
},
mixins: [buycard]
};
</script>
<style lang="scss" scoped>
@import './public/css/index.scss';
</style>
<style>
.cashregister-header-box>>>.uni-select-lay-select {
padding-right: 0.1rem !important;
}
.cashregister-header-box>>>.uni-select-lay-icon {
display: none !important;
}
.cashregister-header-box>>>.uni-select-lay-input-close {
display: none !important;
}
</style>

View File

@@ -0,0 +1,326 @@
.common-wrap.right-wrap{
background-color: transparent;
}
.left-wrap {
position: relative;
width: 4rem;
display: flex;
flex-direction: column;
margin-right: 0.2rem;
border-radius: 0.04rem;
.pay-shade {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: rgba($color: #fff, $alpha: 0.6);
z-index: 10;
}
.content {
color: #303133;
flex: 1;
height: 0;
display: flex;
flex-direction: column;
.title {
font-size: 0.14rem;
padding: 0.1rem 0.25rem;
justify-content: space-between;
display: flex;
}
.clear {
display: flex;
align-items: center;
text {
&:nth-child(1) {
font-size: 0.18rem;
}
&:nth-child(2) {
margin-left: 0.03rem;
font-size: 0.14rem;
}
}
}
.content-list {
margin-top: 0.1rem;
flex: 1;
height: 0;
overflow-y: scroll;
padding: 0 0.2rem;
.content-item {
position: relative;
display: flex;
align-items: start;
flex-wrap: wrap;
justify-content: space-between;
border-bottom: 0.01rem solid #e6e6e6;
padding-top: 0.08rem;
padding-bottom: 0.08rem;
&.focus,
&:focus {
outline: none;
}
.flex {
display: flex;
align-items: center;
}
.info-wrap {
margin-left: 0.1rem;
flex-wrap: wrap;
min-height: 0.6rem;
}
.item-img {
width: 0.6rem;
height: 0.6rem;
display: flex;
align-items: center;
image {
width: 100%;
}
}
.item-name {
font-size: 0.14rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 2.04rem;
height: 0.20rem;
font-weight: 500;
color: #222222;
line-height: 0.20rem;
}
.item-del {
cursor: pointer;
font-size: 0.14rem;
display: flex;
align-items: center;
&:hover {
color: $primary-color;
}
.iconfont.iconshanchu {
font-size: 0.2rem;
}
}
.item-spe {
font-size: 0.12rem;
margin-top: 0.04rem;
width: 2.04rem;
height: 0.17rem;
font-weight: 500;
color: #808695;
line-height: 0.17rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.info-top {
width: 100%;
}
.info-bottom {
width: 100%;
align-self: flex-end;
}
.item-price {
flex: 1;
}
.item-subtotal {
flex: 1;
display: flex;
align-items: end;
.unit {
font-size: 0.12rem;
}
}
.item-num {
display: flex;
flex: 1;
justify-content: flex-end;
align-items: center;
margin-left: 0.1rem;
.num {
// min-width: 0.82rem;
// text-align: right;
}
.num-dec {
width: 0.25rem;
height: 0.25rem;
background: #e6e6e6;
border: 0.01rem solid #e6e6e6;
border-radius: 30%;
text-align: center;
line-height: 0.23rem;
font-size: 0.25rem;
margin-right: 0.1rem;
cursor: pointer;
transition: 0.3s;
}
.num-inc {
width: 0.25rem;
height: 0.25rem;
background: $primary-color;
border: 0.01rem solid #e6e6e6;
border-radius: 30%;
text-align: center;
line-height: 0.23rem;
font-size: 0.25rem;
margin-left: 0.1rem;
cursor: pointer;
transition: 0.3s;
color: #fff;
}
}
.weight {
flex: 1;
justify-content: end;
}
.item-total-price {
font-size: 0.14rem;
margin-left: 0.1rem;
color: #fe2278;
}
.card-deduction {
width: 100%;
font-size: 0.12rem;
margin-top: 0.05rem;
color: #999;
}
}
}
.empty {
text-align: center;
image {
width: 60%;
margin-top: 0.4rem;
}
.tips {
color: #999;
margin-top: 0.15rem;
}
}
}
.bottom {
width: 100%;
padding: 0.2rem 0.2rem 0.24rem 0.2rem;
box-sizing: border-box;
background-color: #ffffff;
.bottom-info {
display: flex;
align-items: center;
justify-content: space-between;
color: #303133;
font-weight: 500;
height: 0.27rem;
line-height: 0.27rem;
margin-bottom: 0.12rem;
.bottom-left {
font-size: 0.14rem;
color: #303133;
text{
display: inline-block;
margin: 0 .05rem;
}
.money {
color: #fe2278;
}
}
.pay-money {
font-size: 0.27rem;
height: 0.27rem;
font-weight: 600;
font-family: AlibabaPuHuiTiM;
color: $primary-color;
line-height: 0.22rem;
}
}
.bottom-btn {
display: flex;
align-items: center;
margin-top: 0.2rem;
justify-content: flex-end;
.btn-right {
width: 1.4rem;
height: 0.4rem;
line-height: 0.4rem;
border: 0 !important;
margin: 0;
}
}
}
}
.list-wrap {
border-radius: 0.02rem;
height: 100%;
border-left: 0;
box-sizing: border-box;
flex:1;
.content {
height: 100%;
}
.comp-btn {
width: 80%;
margin-top: 0.2rem;
}
.header {
height: 0.66rem;
line-height: 0.66rem;
text-align: left;
color: #303133;
font-size: 0.14rem;
}
.body {
padding: 0.3rem;
}
}
.page-height {
height: 100%;
}
.common-wrap {
height: 100%;
}

View File

@@ -0,0 +1,346 @@
import {cardCalculate, cardCreate} from '@/api/order_create.js'
import {mapGetters} from 'vuex';
export default {
data() {
return {
type: 'goods',
isRepeat: false,
outTradeNo: ''
};
},
computed: {
...mapGetters(['buyCardGoodsData', 'buyCardOrderData', 'buyCardActive', 'memberSearchWayConfig'])
},
watch: {
globalMemberInfo: function (nVal) {
this.calculation();
},
buyCardGoodsData: {
// 每个属性值发生变化就会调用这个函数
handler(newVal, oldVal) {
this.calculation();
},
// 深度监听 属性的变化
deep: true
}
},
onLoad(option) {
uni.hideTabBar();
this.$store.commit('buycard/setOrderData', {
card_type: option.type || 'oncecard'
});
if (this.globalMemberInfo) this.type = 'goods';
},
onShow() {
this.$store.commit('buycard/setOrderData', {
create_time: this.$util.timeFormat(parseInt(new Date().getTime() / 1000))
});
if (this.$refs.card) this.$refs.card.init();
this.calculation();
this.addKeyDownEvent();
// 添加组件的键盘监听事件
if (this.$refs.payment) this.$refs.payment.addKeyDownEvent();
},
onHide() {
this.removeKeyDownEvent();
// 移除组件的键盘监听事件
this.$refs.payment.removeKeyDownEvent();
},
methods: {
switchStoreAfter() {
if (this.$refs.card) this.$refs.card.init();
this.calculation();
},
openMember() {
if (this.$refs.selectMember) {
this.$store.commit('buycard/setActive', 'ShowMember');
this.$refs.selectMember.open(() => {
this.$store.commit('buycard/setActive', 'ShowMemberAfter');
});
}
},
showMember() {
this.$store.commit('buycard/setActive', 'ShowMember');
if (!this.globalMemberInfo) {
if (this.$refs.selectMember) this.$refs.selectMember.open(() => {
this.$store.commit('buycard/setActive', 'ShowMemberAfter');
});
} else {
// 打开会员信息弹出框
this.$store.commit('buycard/setActive', 'ShowMemberAfter');
this.$refs.memberDetailPopup.open();
}
},
/**
* 切换散客
*/
replaceMember() {
this.$store.commit('app/setGlobalMemberInfo', null);
this.type = 'goods';
},
calculation() {
if (!Object.keys(this.buyCardGoodsData).length) return;
let sku_array = [];
Object.keys(this.buyCardGoodsData).forEach(key => {
let item = this.buyCardGoodsData[key];
sku_array.push({
sku_id: item.sku_id,
num: item.num
});
});
let data = {
sku_array: JSON.stringify(sku_array),
create_time: this.buyCardOrderData.create_time
};
if (this.globalMemberInfo) data.member_id = this.globalMemberInfo.member_id;
cardCalculate(data).then(res => {
if (res.code == 0) {
this.$store.commit('buycard/setOrderData', res.data);
} else {
this.$util.showToast({
title: res.message
});
}
})
},
inc(data) {
let _buyCardGoodsData = this.$util.deepClone(this.buyCardGoodsData);
if (data.goods_type != '') {
_buyCardGoodsData['sku_' + data.sku_id].num += 1;
} else {
if (data.num < data.stock) _buyCardGoodsData['sku_' + data.sku_id].num += 1;
}
this.$store.commit('buycard/setGoodsData', _buyCardGoodsData);
},
dec(data) {
if (data.num > 1) {
let _buyCardGoodsData = this.$util.deepClone(this.buyCardGoodsData);
_buyCardGoodsData['sku_' + data.sku_id].num -= 1;
this.$store.commit('buycard/setGoodsData', _buyCardGoodsData);
}
},
deleteGoods(data) {
let _buyCardGoodsData = this.$util.deepClone(this.buyCardGoodsData);
delete _buyCardGoodsData['sku_' + data.sku_id];
this.$store.commit('buycard/setGoodsData', _buyCardGoodsData);
if (!Object.keys(_buyCardGoodsData).length) {
this.$store.commit('buycard/setOrderData', {
goods_list: [],
goods_num: 0,
pay_money: 0
});
}
},
clearGoods() {
this.$store.commit('buycard/setGoodsData', {});
this.$store.commit('buycard/setOrderData', {
goods_list: [],
goods_num: 0,
pay_money: 0
});
},
pay(type = '', callback) {
if (!this.globalMemberInfo) {
if (this.$refs.selectMember) {
this.$store.commit('buycard/setActive', 'ShowMember');
this.$refs.selectMember.open(() => {
this.$store.commit('buycard/setActive', 'ShowMemberAfter');
});
setTimeout(() => {
this.$refs.selectMember.inputFocus = true;
}, 200);
}
return false;
}
if (!Object.keys(this.buyCardGoodsData).length || this.isRepeat) return;
this.isRepeat = true;
if (this.outTradeNo) {
this.type = 'pay';
if (type) this.$refs.payment.type = type;
return;
}
this.$store.commit('buycard/setActive', 'OrderCreate'); // 记录页面活跃值:创建订单
let sku_array = [];
Object.keys(this.buyCardGoodsData).forEach(key => {
let item = this.buyCardGoodsData[key];
sku_array.push({
sku_id: item.sku_id,
num: item.num
});
});
let data = {
sku_array: JSON.stringify(sku_array),
remark: this.buyCardOrderData.remark,
create_time: this.buyCardOrderData.create_time,
order_key: this.buyCardOrderData.order_key
};
if (this.globalMemberInfo) data.member_id = this.globalMemberInfo.member_id;
cardCreate(data).then(res => {
this.isRepeat = false;
if (res.code == 0) {
this.outTradeNo = res.data.out_trade_no;
this.type = 'pay';
if (type) this.$refs.payment.type = type;
setTimeout(() => {
if (callback) callback();
}, 100)
} else {
this.$util.showToast({
title: res.message
});
}
});
},
cancelPayment() {
this.outTradeNo = '';
this.type = 'goods';
},
paySuccess() {
this.type = 'goods';
this.isRepeat = false;
this.$store.commit('buycard/setActive', '');
this.wholeOrderCancel();
this.$refs.card.onceCardData.page = 0;
this.$refs.card.onceCardData.total = 1;
this.$refs.card.timeCardData.page = 0;
this.$refs.card.timeCardData.total = 1;
this.$refs.card.commonCardData.page = 0;
this.$refs.card.commonCardData.total = 1;
this.$refs.card.getOnceCard();
this.$refs.card.getTimeCard();
this.$refs.card.getCommonCard();
},
/**
* 整单取消
*/
wholeOrderCancel() {
if (Object.keys(this.buyCardGoodsData).length) {
// 清除商品数据
this.$store.commit('buycard/setGoodsData', {});
let orderId = this.billingOrderData && (this.billingOrderData.order_id ? this.billingOrderData.order_id : 0) || 0
// 清除订单数据
this.$store.commit('buycard/setOrderData', {
goods_num: 0,
pay_money: 0,
goods_list: [],
remark: '',
create_time: this.$util.timeFormat(parseInt(new Date().getTime() / 1000)),
order_id: orderId
});
this.outTradeNo = '';
}
},
toGoods() {
this.type = 'goods';
},
/**
* 添加键盘监听事件
*/
addKeyDownEvent() {
// #ifdef H5
// 绑定监听事件
window.addEventListener("keydown", this.listenerKeyDown, true);
// 监听F1~F12BACKSPACE
window.POS_HOTKEY_CALLBACK = (control, code) => {
this.posHotKeyCallback(code);
};
// #endif
},
/**
* 移除键盘监听事件
*/
removeKeyDownEvent() {
// #ifdef H5
window.removeEventListener("keydown", this.listenerKeyDown, true);
delete window.POS_HOTKEY_CALLBACK;
// #endif
},
listenerKeyDown(e) {
var code = e.code;
// console.log('KeyDown', this.type, code, this.buyCardActive, e);
if (this.type != 'pay' && code == 'KeyM') {
// 选择会员键盘快捷键【M】
this.openMember();
} else if(this.buyCardActive == 'ShowMember' && this.memberSearchWayConfig.way == 'list'){
// 按照会员列表进行搜索
if (code == 'Enter' || code == 'NumpadEnter') {
if(this.$refs.selectMember.searchFinish && this.$refs.selectMember.memberId){
this.$refs.selectMember.getMemberInfo(this.$refs.selectMember.memberId);
}
}
} else if (this.buyCardActive == 'ShowMemberAfter') {
// 活跃窗口:设置会员后
if (code == 'Enter' || code == 'NumpadEnter') {
this.pay('');
}
} else if (this.buyCardOrderData.goods_num && this.buyCardActive == 'SelectGoodsAfter') {
// 选择卡项商品后
if (code == 'Enter' || code == 'NumpadEnter') {
this.pay('');
}
}
},
/**
* 监听键盘事件回调
* @param {Object} code
*/
posHotKeyCallback(code) {
if (code == 'F2') {
// 选择卡项
if (this.type != 'pay') {
this.toGoods();
this.$store.commit('buycard/setActive', 'SelectGoodsAfter');
}
} else if (code == 'F3') {
// 选择会员
if (this.type != 'pay') {
this.showMember();
}
} else if (code == 'BACKSPACE') {
// 退格键
if (this.buyCardActive == 'OrderCreate') {
if (this.$refs.payment) {
if (this.$refs.payment.active == 'openMoneyPopup') {
this.$refs.payment.deleteCode();
}
}
}
} else {
// 触发左侧菜单按键回调
this.menuTriggerKeyCodeCallBack(code);
}
}
}
}