first
This commit is contained in:
commit
89db955ec1
|
|
@ -0,0 +1,8 @@
|
||||||
|
unpackage/cache
|
||||||
|
unpackage/dist
|
||||||
|
unpackage/res
|
||||||
|
unpackage/resources
|
||||||
|
node_modules/
|
||||||
|
/node_modules/
|
||||||
|
" "
|
||||||
|
" "
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
// launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
|
||||||
|
// launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
|
||||||
|
"version" : "0.0",
|
||||||
|
"configurations" : [
|
||||||
|
{
|
||||||
|
"app-plus" : {
|
||||||
|
"launchtype" : "local"
|
||||||
|
},
|
||||||
|
"default" : {
|
||||||
|
"launchtype" : "local"
|
||||||
|
},
|
||||||
|
"mp-weixin" : {
|
||||||
|
"launchtype" : "local"
|
||||||
|
},
|
||||||
|
"type" : "uniCloud"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"playground" : "custom",
|
||||||
|
"type" : "uni-app:app-android"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,166 @@
|
||||||
|
<!--
|
||||||
|
|
||||||
|
App.vue本身不是页面,这里不能编写视图元素,也就是没有<template>
|
||||||
|
-->
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
reactive
|
||||||
|
} from 'vue';
|
||||||
|
import appConfig from '@/config/appConfig.js';
|
||||||
|
import {
|
||||||
|
onLaunch,onHide
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
|
import { getFindBySource } from '@/http/yskApi/version.js'
|
||||||
|
onHide(()=>{
|
||||||
|
|
||||||
|
})
|
||||||
|
onLaunch(() => {
|
||||||
|
uni.hideTabBar()
|
||||||
|
//#ifdef APP-PLUS
|
||||||
|
//获取当前系统版本信息
|
||||||
|
plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
|
||||||
|
//请求后台接口 解析数据 对比版本
|
||||||
|
console.log("widgetInfo==",widgetInfo)
|
||||||
|
getFindBySource({source:'点餐宝'}).then(res => {
|
||||||
|
console.log('res');
|
||||||
|
if (res.url && widgetInfo.version < res.version) {
|
||||||
|
let downloadLink = res.url;
|
||||||
|
console.log(downloadLink)
|
||||||
|
let ready = false;
|
||||||
|
// 校验是否强制升级
|
||||||
|
if (res.isUp == 1) {
|
||||||
|
uni.showModal({
|
||||||
|
showCancel: false,
|
||||||
|
title: '发现新版本',
|
||||||
|
confirmText: '立即更新',
|
||||||
|
content: res.message,
|
||||||
|
success: res => {
|
||||||
|
if (res.confirm) {
|
||||||
|
uni.showLoading({title:'下载中...'});
|
||||||
|
if (uni.getSystemInfoSync().platform ==
|
||||||
|
'android') {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.downloadFile({
|
||||||
|
url: downloadLink,
|
||||||
|
success: downloadResult => {
|
||||||
|
uni.hideLoading()
|
||||||
|
if (downloadResult.statusCode === 200) {
|
||||||
|
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => {
|
||||||
|
entry.getParent(_oldFile=>{
|
||||||
|
entry.moveTo(_oldFile,'.apk',newFilePath=>{
|
||||||
|
console.log('newFilePath',newFilePath.fullPath)
|
||||||
|
plus.runtime
|
||||||
|
.install(newFilePath.fullPath, { force: false },
|
||||||
|
d => {
|
||||||
|
console
|
||||||
|
.log(
|
||||||
|
'install success...'
|
||||||
|
);
|
||||||
|
plus.runtime
|
||||||
|
.restart();
|
||||||
|
},
|
||||||
|
e => {
|
||||||
|
console.log(e)
|
||||||
|
console
|
||||||
|
.error(
|
||||||
|
'install fail...'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (uni.getSystemInfoSync().platform ==
|
||||||
|
'ios') {
|
||||||
|
plus.runtime.openURL(downloadLink, function(
|
||||||
|
res) {});
|
||||||
|
}
|
||||||
|
} else if (res.cancel) {
|
||||||
|
console.log('取消');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
uni.showModal({
|
||||||
|
title: '发现新版本',
|
||||||
|
confirmText: '立即更新',
|
||||||
|
cancelText: '下次更新',
|
||||||
|
content: res.message,
|
||||||
|
success: res => {
|
||||||
|
if (res.confirm) {
|
||||||
|
uni.showLoading({title:'下载中...'});
|
||||||
|
if (uni.getSystemInfoSync().platform ==
|
||||||
|
'android') {
|
||||||
|
uni.downloadFile({
|
||||||
|
url: downloadLink,
|
||||||
|
success: downloadResult => {
|
||||||
|
if (downloadResult
|
||||||
|
.statusCode ===
|
||||||
|
200) {
|
||||||
|
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => {
|
||||||
|
entry.getParent(_oldFile=>{
|
||||||
|
entry.moveTo(_oldFile,'.apk',newFilePath=>{
|
||||||
|
console.log('newFilePath',newFilePath.fullPath)
|
||||||
|
plus.runtime
|
||||||
|
.install(newFilePath.fullPath, { force: false },
|
||||||
|
d => {
|
||||||
|
console
|
||||||
|
.log(
|
||||||
|
'install success...'
|
||||||
|
);
|
||||||
|
plus.runtime
|
||||||
|
.restart();
|
||||||
|
},
|
||||||
|
e => {
|
||||||
|
console.log(e)
|
||||||
|
console
|
||||||
|
.error(
|
||||||
|
'install fail...'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (uni.getSystemInfoSync().platform ==
|
||||||
|
'ios') {
|
||||||
|
plus.runtime.openURL(downloadLink, function(
|
||||||
|
res) {});
|
||||||
|
}
|
||||||
|
} else if (res.cancel) {
|
||||||
|
uni.hideLoading()
|
||||||
|
console.log('取消');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).catch((res)=>{
|
||||||
|
console.log(res)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style lang="scss">
|
||||||
|
/** 每个页面公共css */
|
||||||
|
@import '@/commons/style/common.scss';
|
||||||
|
@import '@/commons/style/ipad.scss';
|
||||||
|
|
||||||
|
/** uni 组件样式覆盖 */
|
||||||
|
@import '@/commons/style/uni-overwrite.scss';
|
||||||
|
|
||||||
|
@import "uview-plus/index.scss";
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"version" : "1",
|
||||||
|
"prompt" : "template",
|
||||||
|
"title" : "服务协议和隐私政策",
|
||||||
|
"message" : " 请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/> 你可阅读<a href=\"static/service.html\">《服务协议》</a>和<a href=\"static/privacy.html\">《隐私政策》</a>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。",
|
||||||
|
"buttonAccept" : "同意并接受",
|
||||||
|
"buttonRefuse" : "暂不同意",
|
||||||
|
"second" : {
|
||||||
|
"title" : "确认提示",
|
||||||
|
"message" : " 进入应用前,你需先同意<a href=\"static/service.html\">《服务协议》</a>和<a href=\"static/privacy.html\">《隐私政策》</a>,否则将退出应用。",
|
||||||
|
"buttonAccept" : "同意并继续",
|
||||||
|
"buttonRefuse" : "退出应用"
|
||||||
|
},
|
||||||
|
"styles" : {
|
||||||
|
"backgroundColor" : "#FFFFFF",
|
||||||
|
"borderRadius" : "5px",
|
||||||
|
"title" : {
|
||||||
|
"color" : "#262626"
|
||||||
|
},
|
||||||
|
"buttonAccept" : {
|
||||||
|
"color" : "#3981FF"
|
||||||
|
},
|
||||||
|
"buttonRefuse" : {
|
||||||
|
"color" : "#A6A6A6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
let statusHeight=44
|
||||||
|
// #ifdef H5
|
||||||
|
statusHeight=0
|
||||||
|
// #endif
|
||||||
|
// #ifndef H5
|
||||||
|
statusHeight=22
|
||||||
|
// #endif
|
||||||
|
export const customNavHeight=statusHeight
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,48 @@
|
||||||
|
import {
|
||||||
|
reactive, ref
|
||||||
|
} from 'vue';
|
||||||
|
function isSameType(a, b) {
|
||||||
|
return a instanceof b === true || b instanceof a === true;
|
||||||
|
}
|
||||||
|
class LIST{
|
||||||
|
constructor(data) {
|
||||||
|
this.data=reactive({
|
||||||
|
page:0,
|
||||||
|
totalPage:0,
|
||||||
|
total:0,
|
||||||
|
list:[],
|
||||||
|
hasAjax:false,
|
||||||
|
status:'',//loading fail success
|
||||||
|
query:{
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Object.assign(this.data, data)
|
||||||
|
}
|
||||||
|
add(item){
|
||||||
|
this.data.list.push(item)
|
||||||
|
}
|
||||||
|
del(index){
|
||||||
|
this.data.list.splice(index,1)
|
||||||
|
}
|
||||||
|
update(index,item){
|
||||||
|
this.data.list[index]=item
|
||||||
|
}
|
||||||
|
get(index){
|
||||||
|
return this.data.list[index]
|
||||||
|
}
|
||||||
|
getVal(key){
|
||||||
|
return this.data[key]
|
||||||
|
}
|
||||||
|
setQuery(key,val){
|
||||||
|
this.data.query[key]=val
|
||||||
|
}
|
||||||
|
setVal(key,val){
|
||||||
|
this.data[key]=val
|
||||||
|
if(key=='page'){
|
||||||
|
this.data['page']=val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LIST
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
export const ColorMain= '#318AFE';
|
||||||
|
export const ColorRed= '#F02C45';
|
||||||
|
|
||||||
|
|
||||||
|
export default{
|
||||||
|
ColorMain,ColorRed
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
export const $types = [{
|
||||||
|
title: "计量商品",
|
||||||
|
desc: '单价购买',
|
||||||
|
value: 'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "多规格",
|
||||||
|
desc: '多种不同规格',
|
||||||
|
value: 'sku'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "套餐组合",
|
||||||
|
desc: '选择多种组合',
|
||||||
|
value: 'group'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "称重商品",
|
||||||
|
desc: '按重量售卖',
|
||||||
|
value: 'weight'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "时价商品",
|
||||||
|
desc: '收银端可更改价格',
|
||||||
|
value: 'currentPrice'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// 商品默认sku
|
||||||
|
export const $defaultSku = {
|
||||||
|
salePrice: '',
|
||||||
|
memberPrice: '',
|
||||||
|
costPrice: '',
|
||||||
|
originPrice: '',
|
||||||
|
// stockNumber: '',
|
||||||
|
firstShared: '',
|
||||||
|
suit: 1,
|
||||||
|
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 库存记录筛选类型
|
||||||
|
export const $invoicingType = [{
|
||||||
|
text: '全部',
|
||||||
|
value: ''
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '供应商入库',
|
||||||
|
value: 'purveyor'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '供应商退货',
|
||||||
|
value: 'reject'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '其他入库',
|
||||||
|
value: 'purchase'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '其他出库',
|
||||||
|
value: 'other-out'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// 页面常用数据
|
||||||
|
export const $pageData = {
|
||||||
|
query: {
|
||||||
|
page: 0,
|
||||||
|
size: 10
|
||||||
|
},
|
||||||
|
totalElements: 0,
|
||||||
|
list: [],
|
||||||
|
hasAjax: false,
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
export default {
|
||||||
|
status: [
|
||||||
|
{
|
||||||
|
key: 'unpaid',
|
||||||
|
label: '待支付'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'unsend',
|
||||||
|
label: '待发货'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'closed',
|
||||||
|
label: '订单完成'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'send',
|
||||||
|
label: '已发'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'refunding',
|
||||||
|
label: '申请退单'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'refund',
|
||||||
|
label: '退单'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'cancelled',
|
||||||
|
label: '取消订单'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'merge',
|
||||||
|
label: '合台'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'pending',
|
||||||
|
label: '挂单'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'activate',
|
||||||
|
label: '激活'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'paying',
|
||||||
|
label: '支付中'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
sendType: [
|
||||||
|
{
|
||||||
|
key: 'post',
|
||||||
|
label: '快递'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'takeaway',
|
||||||
|
label: '外卖'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'takeself',
|
||||||
|
label: '自提'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'table',
|
||||||
|
label: '堂食'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
orderType: [
|
||||||
|
{
|
||||||
|
key: 'cash',
|
||||||
|
label: '收银'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'miniapp',
|
||||||
|
label: '小程序'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'offline',
|
||||||
|
label: '线下'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'return',
|
||||||
|
label: '退单'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
该文件夹内放置: 项目自建资源, 比如 公共样式文件, 和 工具包等文件。
|
||||||
|
|
||||||
|
|
||||||
|
目录结构:
|
||||||
|
commons
|
||||||
|
style
|
||||||
|
utils
|
||||||
|
|
||||||
|
知识点: 样式文件不应该放置到 static文件夹内(css、less/scss 等资源不要放在 static 目录下,建议这些公用的资源放在自建的 common 目录下。), 详见:
|
||||||
|
https://uniapp.dcloud.net.cn/tutorial/project.html
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,406 @@
|
||||||
|
.u-relative,
|
||||||
|
.u-rela {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-absolute,
|
||||||
|
.u-abso {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
.u-fixed,.u-fix{
|
||||||
|
position: fixed;
|
||||||
|
}
|
||||||
|
.left-top{
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
.u-overflow-hide{
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvue不能用标签命名样式,不能放在微信组件中,否则微信开发工具会报警告,无法使用标签名当做选择器
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
image {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在weex,也即nvue中,所有元素默认为border-box
|
||||||
|
view,
|
||||||
|
text {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
|
.u-font-xs {
|
||||||
|
font-size: 22rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-font-sm {
|
||||||
|
font-size: 26rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-font-md {
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-font-lg {
|
||||||
|
font-size: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-font-xl {
|
||||||
|
font-size: 34rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-flex {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-flex-wrap {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-flex-nowrap {
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-col-center {
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-col-top {
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-col-bottom {
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-row-center {
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-row-left {
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-row-right {
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-row-between {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-row-around {
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-text-left {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-text-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-text-right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-flex-col {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex!important;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction: column!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义flex等分
|
||||||
|
@for $i from 0 through 12 {
|
||||||
|
.u-flex-#{$i} {
|
||||||
|
flex: $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义字体(px)单位,小于20都为px单位字体
|
||||||
|
@for $i from 9 to 20 {
|
||||||
|
.u-font-#{$i} {
|
||||||
|
font-size: $i + px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义字体(rpx)单位,大于或等于20的都为rpx单位字体
|
||||||
|
@for $i from 20 through 40 {
|
||||||
|
.u-font-#{$i} {
|
||||||
|
font-size: $i + rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义内外边距,历遍1-80
|
||||||
|
@for $i from 0 through 80 {
|
||||||
|
// 只要双数和能被5除尽的数
|
||||||
|
@if $i % 2 == 0 or $i % 5 == 0 {
|
||||||
|
// 得出:u-margin-30或者u-m-30
|
||||||
|
.u-margin-#{$i}, .u-m-#{$i} {
|
||||||
|
margin: $i + rpx!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 得出:u-padding-30或者u-p-30
|
||||||
|
.u-padding-#{$i}, .u-p-#{$i} {
|
||||||
|
padding: $i + rpx!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
@each $short, $long in l left, t top, r right, b bottom {
|
||||||
|
// 缩写版,结果如: u-m-l-30
|
||||||
|
// 定义外边距
|
||||||
|
.u-m-#{$short}-#{$i} {
|
||||||
|
margin-#{$long}: $i + rpx!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义内边距
|
||||||
|
.u-p-#{$short}-#{$i} {
|
||||||
|
padding-#{$long}: $i + rpx!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 完整版,结果如:u-margin-left-30
|
||||||
|
// 定义外边距
|
||||||
|
.u-margin-#{$long}-#{$i} {
|
||||||
|
margin-#{$long}: $i + rpx!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义内边距
|
||||||
|
.u-padding-#{$long}-#{$i} {
|
||||||
|
padding-#{$long}: $i + rpx!important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置nvue的默认关于flex的样式
|
||||||
|
.u-reset-nvue {
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* start--文本行数限制--start */
|
||||||
|
.u-line-1 {
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-line-2 {
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-line-3 {
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-line-4 {
|
||||||
|
-webkit-line-clamp: 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-line-5 {
|
||||||
|
-webkit-line-clamp: 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-line-2, .u-line-3, .u-line-4, .u-line-5 {
|
||||||
|
overflow: hidden;
|
||||||
|
word-break: break-all;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box; // 弹性伸缩盒
|
||||||
|
-webkit-box-orient: vertical; // 设置伸缩盒子元素排列方式
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end--文本行数限制--end */
|
||||||
|
|
||||||
|
|
||||||
|
/* start--不同颜色文字--start */
|
||||||
|
.color-333{
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.color-666{
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
.color-999{
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
.color-red{
|
||||||
|
color: $my-red-color;
|
||||||
|
}
|
||||||
|
.color-main{
|
||||||
|
color:$my-main-color
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end--不同颜色文字--end */
|
||||||
|
|
||||||
|
|
||||||
|
.tranistion{
|
||||||
|
transition: all .3s ease-in-out;
|
||||||
|
}
|
||||||
|
.tranistion-1{
|
||||||
|
transition: all .1s ease-in-out;
|
||||||
|
}
|
||||||
|
.tranistion-2{
|
||||||
|
transition: all .2s ease-in-out;
|
||||||
|
}
|
||||||
|
.font-bold{
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* start--不同颜色背景--start */
|
||||||
|
.my-bg-main{
|
||||||
|
background-color:$my-main-color
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end--不同颜色背景--end */
|
||||||
|
|
||||||
|
.safe-page{
|
||||||
|
padding-bottom: 60rpx!important;
|
||||||
|
}
|
||||||
|
::v-deep .uni-switch-input.uni-switch-input-checked{
|
||||||
|
border-color: $my-main-color;
|
||||||
|
background-color: $my-main-color;
|
||||||
|
}
|
||||||
|
.min-page{
|
||||||
|
/* #ifdef H5 */
|
||||||
|
min-height: calc(100vh - 44px);
|
||||||
|
/* #endif */
|
||||||
|
/* #ifndef H5 */
|
||||||
|
min-height: 100vh;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
.w-full{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.gap-20{
|
||||||
|
gap: 20rpx;
|
||||||
|
}
|
||||||
|
.color-000{
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
.color-fff{
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.bg-fff{
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
.bg-gray{
|
||||||
|
background-color: #F9F9F9;
|
||||||
|
}
|
||||||
|
.overflow-hide{
|
||||||
|
/* #ifdef H5 */
|
||||||
|
height: calc(100vh - 44px);
|
||||||
|
/* #endif */
|
||||||
|
/* #ifndef H5 */
|
||||||
|
height: 100vh;
|
||||||
|
/* #endif */
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.no-wrap{
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.border-r-12{
|
||||||
|
border-radius: 12rpx;
|
||||||
|
}
|
||||||
|
.border-r-18{
|
||||||
|
border-radius: 18rpx;
|
||||||
|
}
|
||||||
|
.border-top{
|
||||||
|
border-top: 1px solid #E5E5E5;
|
||||||
|
}
|
||||||
|
.border-bottom{
|
||||||
|
border-bottom: 1px solid #E5E5E5;
|
||||||
|
}
|
||||||
|
.scale7{
|
||||||
|
transform: scale(0.7);
|
||||||
|
}
|
||||||
|
.page-gray {
|
||||||
|
min-height: calc(100vh);
|
||||||
|
/* #ifdef H5 */
|
||||||
|
min-height: calc(100vh - var(--window-top));
|
||||||
|
/* #endif */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: #F9F9F9;
|
||||||
|
}
|
||||||
|
.box-shadow{
|
||||||
|
box-shadow: 0 0 5px #eee;
|
||||||
|
}
|
||||||
|
.safe-bottom{
|
||||||
|
padding-bottom: env(safe-area-inset-bottom);
|
||||||
|
/* #ifdef H5 */
|
||||||
|
padding-bottom: 28rpx;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
.position-all{
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
.fixed-top{
|
||||||
|
position: fixed;
|
||||||
|
/* #ifdef H5 */
|
||||||
|
top: 44px;
|
||||||
|
/* #endif */
|
||||||
|
/* #ifndef H5 */
|
||||||
|
top: 0;
|
||||||
|
/* #endif */
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
.lh30 {
|
||||||
|
line-height: 30px;
|
||||||
|
}
|
||||||
|
.default-box-padding{
|
||||||
|
padding: 32rpx 28rpx;
|
||||||
|
}
|
||||||
|
.icon-arrow-down-fill {
|
||||||
|
width: 16rpx;
|
||||||
|
height: 10rpx;
|
||||||
|
}
|
||||||
|
.zIndex-999{
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
|
.icon-default-size{
|
||||||
|
width: 28rpx;
|
||||||
|
height: 28rpx;
|
||||||
|
}
|
||||||
|
::v-deep.uni-easyinput__placeholder-class{
|
||||||
|
font-size: 28rpx!important;
|
||||||
|
}
|
||||||
|
.filter-gray{
|
||||||
|
filter: grayscale(1);
|
||||||
|
}
|
||||||
|
// .u-font-20{
|
||||||
|
// font-size: 10px;
|
||||||
|
// }
|
||||||
|
// .u-font-24{
|
||||||
|
// font-size: 12px;
|
||||||
|
// }
|
||||||
|
// .u-font-28{
|
||||||
|
// font-size: 14px;
|
||||||
|
// }
|
||||||
|
// .u-font-32{
|
||||||
|
// font-size: 16px;
|
||||||
|
// }
|
||||||
|
.line-th{
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
//覆盖u-view-plus 颜色
|
||||||
|
.u-primary-light {
|
||||||
|
color: $my-main-color;
|
||||||
|
}
|
||||||
|
::v-deep .u-border{
|
||||||
|
border-width: 1px!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .u-m-t-16 .u-textarea{
|
||||||
|
border-width: 1px!important;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,230 @@
|
||||||
|
/**
|
||||||
|
* 系统级别: 全局样式
|
||||||
|
*
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2022/11/22 07:29
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** 已整理 **/
|
||||||
|
|
||||||
|
|
||||||
|
// 通用 列表页样式
|
||||||
|
.page-wrapper {
|
||||||
|
min-height: calc(100vh - 70rpx); /** 最小高度 **/
|
||||||
|
padding-bottom: 70rpx; /** 安全距离(防止home条遮挡文字) **/
|
||||||
|
background-color: $v-color-bgrey; /** 全局背景灰 **/
|
||||||
|
}
|
||||||
|
|
||||||
|
// 底部 固定的按钮, 比如: 创建门店, 创建员工等按钮。
|
||||||
|
.list-footer{
|
||||||
|
height: 100rpx;
|
||||||
|
background: transparent;
|
||||||
|
.button-wrapper {
|
||||||
|
border-top: 1rpx solid rgba(0,0,0, 0.07);
|
||||||
|
background-color: rgba(252, 252, 252, 0.85);
|
||||||
|
backdrop-filter: blur(20rpx);
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
padding: 30rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** 详情页 覆写:list-item */
|
||||||
|
.list-item-by-detail {
|
||||||
|
padding: 60rpx 60rpx 10rpx 60rpx !important;
|
||||||
|
background-color: transparent !important; /** 背景透明 **/
|
||||||
|
.list-title{
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
.list-subtitle{
|
||||||
|
color: rgba(251,252,253,0.7) !important;
|
||||||
|
}
|
||||||
|
.list-info {
|
||||||
|
image {
|
||||||
|
margin-right: 0 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**列表条目渲染, 比如: 头像、 主标题, **/
|
||||||
|
.list-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 40rpx;
|
||||||
|
height: 170rpx;
|
||||||
|
background-color: #FFF; /** 背景 白色 **/
|
||||||
|
image {
|
||||||
|
flex-shrink: 0;
|
||||||
|
flex-grow: 0;
|
||||||
|
width: 100rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
margin-right: 30rpx;
|
||||||
|
}
|
||||||
|
.list-info {
|
||||||
|
flex: 1;
|
||||||
|
.list-title {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
height: 40rpx;
|
||||||
|
color: rgba(77,77,77,1);
|
||||||
|
.list-name {
|
||||||
|
width: auto;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.list-subtitle {
|
||||||
|
color: rgba(153, 153, 153, 1);
|
||||||
|
margin-top: 25rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
width: 430rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** 状态小圆点 **/
|
||||||
|
.state-dot {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
&::after {
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
width: 20rpx;
|
||||||
|
height: 20rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 状态小圆点 **/
|
||||||
|
.state-dot-enable {
|
||||||
|
&::after {
|
||||||
|
background-color: #168FFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 状态小圆点 **/
|
||||||
|
.state-dot-disable {
|
||||||
|
&::after {
|
||||||
|
background-color: #D9D9D9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 状态小圆点 **/
|
||||||
|
.state-dot-error {
|
||||||
|
&::after {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述预览图, 参考: app详情
|
||||||
|
* 第一个最后一个距离上下 40rpx, 中间间距20rpx
|
||||||
|
*/
|
||||||
|
.desc-view {
|
||||||
|
.desc-view-item {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 20rpx 40rpx;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
color: #808080;
|
||||||
|
}
|
||||||
|
.desc {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 已整理 **/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//容器内部元素上下左右居中
|
||||||
|
.flex-center {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
// 触摸反馈样式
|
||||||
|
.touch-hover {
|
||||||
|
background-color: #f7f8fa !important ;
|
||||||
|
}
|
||||||
|
.touch-button {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
/* 单行文本超出省略号 */
|
||||||
|
.single-text-beyond {
|
||||||
|
overflow: hidden; /*超出部分隐藏*/
|
||||||
|
white-space: nowrap; /*禁止换行*/
|
||||||
|
text-overflow: ellipsis; /*省略号*/
|
||||||
|
}
|
||||||
|
// 按钮背景样式
|
||||||
|
.footer-button-style {
|
||||||
|
border-top: 1rpx solid #fcfcfc;
|
||||||
|
background-color: rgba(252, 252, 252, 0.85);
|
||||||
|
backdrop-filter: blur(20rpx);
|
||||||
|
}
|
||||||
|
// 搜素框 提示语样式
|
||||||
|
.input-placeholder {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: rgba(0, 0, 0, 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 表单分割线
|
||||||
|
.line {
|
||||||
|
height: 20rpx;
|
||||||
|
background-color: $v-color-bgrey;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* jeepay-btn 通用btn样式。
|
||||||
|
* 用法: <button class='jeepay-btn' hover-class="hover-button" @tap="loginFunc">登录</button>
|
||||||
|
*/
|
||||||
|
.jeepay-btn {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 110rpx;
|
||||||
|
font-size: 33rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
color: $J-color-tff;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
background: linear-gradient(270deg, rgba(35,143,252,1) 0%, rgba(26,102,255,1) 100%);
|
||||||
|
box-shadow: 0 20rpx 60rpx -20rpx rgba(0,84,210,0.5);
|
||||||
|
&.hover-button {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 输入框icon **/
|
||||||
|
.input-icon{
|
||||||
|
width: 36rpx;
|
||||||
|
height: 36rpx;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
.login-wrapper{
|
||||||
|
.login-bottom{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
::v-deep .uni-easyinput__content-input{
|
||||||
|
height: initial;
|
||||||
|
}
|
||||||
|
::v-deep .uni-forms-item{
|
||||||
|
min-height: initial;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,181 @@
|
||||||
|
/**
|
||||||
|
* 系统级别:覆写 uni样式
|
||||||
|
*
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2022/11/22 07:29
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* 去除开关右侧边距 */
|
||||||
|
.uni-switch-input {
|
||||||
|
margin-right: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .uni-navbar {
|
||||||
|
position: relative;
|
||||||
|
z-index: 10;
|
||||||
|
} */
|
||||||
|
.uni-popup{
|
||||||
|
z-index: 998 !important;
|
||||||
|
}
|
||||||
|
// 表单组件样式 覆写
|
||||||
|
.uni-forms-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 120rpx;
|
||||||
|
background-color: $J-bg-ff;
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
.uni-forms-item ::v-deep .uni-forms-item__label {
|
||||||
|
font-size: 32rpx !important;
|
||||||
|
font-weight: 400;
|
||||||
|
text-indent: 40rpx;
|
||||||
|
color: #4d4d4d;
|
||||||
|
height: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
// uni-form-item 表单校验, 如果校验不通过, 显示的文字占位, 并且添加下边距。
|
||||||
|
.uni-forms-item__error.msg--active{
|
||||||
|
position: relative !important;
|
||||||
|
margin-bottom: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.is-input-error-border .uni-easyinput__placeholder-class{
|
||||||
|
color: #f56c6c !important
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 去掉按钮边框
|
||||||
|
button:after {
|
||||||
|
border: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去点导航栏组件center&right
|
||||||
|
::v-deep.uni-navbar__header {
|
||||||
|
.uni-navbar__header-container,
|
||||||
|
.uni-navbar__header-btns-right {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改 uuni-easyinput
|
||||||
|
// form 外层必须包裹一个 view class="jeepay-form"
|
||||||
|
.jeepay-form {
|
||||||
|
.uni-easyinput {
|
||||||
|
.uni-easyinput__content {
|
||||||
|
border: 2px solid transparent !important;
|
||||||
|
height: 110rpx;
|
||||||
|
padding: 0 30rpx;
|
||||||
|
margin-bottom: 50rpx;
|
||||||
|
box-sizing: border-box !important;
|
||||||
|
border-radius: 20rpx !important;
|
||||||
|
background-color: rgba(247, 247, 247, 1) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-easyinput__content-input {
|
||||||
|
color: rgba(0, 0, 0, 1);
|
||||||
|
font-size: 32rpx !important;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-foucs {
|
||||||
|
border: 2px solid #1d79fd !important;
|
||||||
|
background-color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-input-placeholder
|
||||||
|
/* #ifdef MP-WEIXIN */
|
||||||
|
,.uni-easyinput__placeholder-class
|
||||||
|
/* #endif */ {
|
||||||
|
font-size: 32rpx !important;
|
||||||
|
color: #B3B3B3 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.jeepay-edit-form .uni-easyinput__content-input {
|
||||||
|
padding-left: 0 !important;
|
||||||
|
.uni-input-placeholder {
|
||||||
|
font-size: 32rpx !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置新密码覆盖form默认样式
|
||||||
|
.new-password {
|
||||||
|
.uni-forms-item.is-direction-left {
|
||||||
|
padding: 0 40rpx;
|
||||||
|
.uni-forms-item__label {
|
||||||
|
width: 190rpx !important;
|
||||||
|
font-size: 32rpx !important;
|
||||||
|
font-weight: 400;
|
||||||
|
white-space: nowrap;
|
||||||
|
color: rgba(102, 102, 102, 1);
|
||||||
|
text-indent: 0 !important;
|
||||||
|
}
|
||||||
|
.uni-easyinput__placeholder-class {
|
||||||
|
font-size: 32rpx !important;
|
||||||
|
font-weight: 400 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索栏覆盖默认样式
|
||||||
|
/* #ifdef MP-WEIXIN */
|
||||||
|
.input-main {
|
||||||
|
button {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: rgba(29,121,253,1);
|
||||||
|
background: rgba(255,255,255,1);
|
||||||
|
}
|
||||||
|
.uni-easyinput {
|
||||||
|
.uni-easyinput__content {
|
||||||
|
background-color: $J-bg-f5 !important;
|
||||||
|
border-radius: $J-b-r12;
|
||||||
|
.uni-easyinput__content-input {
|
||||||
|
padding-left: 0 !important;
|
||||||
|
.uni-input-input {
|
||||||
|
border-radius: $J-b-r12 !important;
|
||||||
|
overflow: hidden !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.uni-input-placeholder {
|
||||||
|
font-size: 27rpx;
|
||||||
|
}
|
||||||
|
.uni-icons {
|
||||||
|
color: rgba(230,230,230,1) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
|
// 搜索栏覆盖默认样式
|
||||||
|
/* #ifdef MP-WEIXIN */
|
||||||
|
button[is="components/Button/Button"] {
|
||||||
|
padding: 0;
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
|
// 修改时间选择器按钮颜色
|
||||||
|
.xp-button--confirm {
|
||||||
|
background: $jeepay-bg-primary;
|
||||||
|
}
|
||||||
|
.xp-button--cancel {
|
||||||
|
color: rgba(0, 0, 0, 0.5) !important;
|
||||||
|
}
|
||||||
|
// label 样式
|
||||||
|
.f-label{
|
||||||
|
width: 280rpx;
|
||||||
|
align-self: start;
|
||||||
|
padding-top: 40rpx;
|
||||||
|
font-size: 32rpx ;
|
||||||
|
font-weight: 400;
|
||||||
|
text-indent: 40rpx;
|
||||||
|
color: #4d4d4d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
* 系统级别: 自定义变量
|
||||||
|
*
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2022/11/22 07:29
|
||||||
|
*/
|
||||||
|
|
||||||
|
// $v : 表示: variables简写。 uni的默认都有特殊开头, 一般不会重复。
|
||||||
|
$v-color-t21: #217dfe;
|
||||||
|
|
||||||
|
// 全局通用: 背景灰 background grey
|
||||||
|
$v-color-bgrey: #F7F7F7;
|
||||||
|
|
||||||
|
// 背景色
|
||||||
|
$J-bg-f7: #f7f7f7; //页面背景色
|
||||||
|
$J-bg-ff: #fff;
|
||||||
|
$J-bg-f5: #f5f5f5; //输入框背景色
|
||||||
|
|
||||||
|
// 文字颜色
|
||||||
|
$J-color-t80: #808080; //常用于 未选中文字颜色
|
||||||
|
$J-color-t21: #217dfe; //卡片文字选中 统计报表
|
||||||
|
$J-color-tff: #fff;
|
||||||
|
$J-color-tSff: rgba(255, 255, 255, 0.7);
|
||||||
|
$J-color-t29: #2980fd; //选中 文字颜色 搜索
|
||||||
|
$J-color-ta6: #a6a6a6;
|
||||||
|
$J-color-t4d: #4d4d4d; //标题颜色
|
||||||
|
$J-color-t99: #999;
|
||||||
|
$J-color-t8c: #8c8c8c; // 卡片列表 标题文字颜色
|
||||||
|
//圆角相关变量
|
||||||
|
$J-b-r32: 32rpx;
|
||||||
|
$J-b-r12: 12rpx;
|
||||||
|
$J-b-r10: 10rpx;
|
||||||
|
$v-b-r20: 20rpx;
|
||||||
|
|
||||||
|
// 文字大小
|
||||||
|
$J-f-size30: 30rpx;
|
||||||
|
|
||||||
|
// 常用边框颜色
|
||||||
|
$v-b-color-ed: #ededed;
|
||||||
|
|
||||||
|
//common.scss 分包页面以及组件里所用的颜色
|
||||||
|
$my-main-color:#318AFE;
|
||||||
|
$my-red-color:#F02C45;
|
||||||
|
|
||||||
|
//my-components
|
||||||
|
$u-main-color: #303133;
|
||||||
|
$u-content-color: #606266;
|
||||||
|
$u-tips-color: #909193;
|
||||||
|
$u-light-color: #c0c4cc;
|
||||||
|
$u-border-color: #dadbde;
|
||||||
|
$u-bg-color: #f3f4f6;
|
||||||
|
$u-disabled-color: #c8c9cc;
|
||||||
|
|
||||||
|
$u-primary: #3c9cff;
|
||||||
|
$u-primary-dark: #398ade;
|
||||||
|
$u-primary-disabled: #9acafc;
|
||||||
|
$u-primary-light: #ecf5ff;
|
||||||
|
|
||||||
|
$u-warning: #f9ae3d;
|
||||||
|
$u-warning-dark: #f1a532;
|
||||||
|
$u-warning-disabled: #f9d39b;
|
||||||
|
$u-warning-light: #fdf6ec;
|
||||||
|
|
||||||
|
$u-success: #5ac725;
|
||||||
|
$u-success-dark: #53c21d;
|
||||||
|
$u-success-disabled: #a9e08f;
|
||||||
|
$u-success-light: #f5fff0;
|
||||||
|
|
||||||
|
$u-error: #f56c6c;
|
||||||
|
$u-error-dark: #e45656;
|
||||||
|
$u-error-disabled: #f7b2b2;
|
||||||
|
$u-error-light: #fef0f0;
|
||||||
|
|
||||||
|
$u-info: #909399;
|
||||||
|
$u-info-dark: #767a82;
|
||||||
|
$u-info-disabled: #c4c6c9;
|
||||||
|
$u-info-light: #f4f4f5;
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
export const $status = {
|
||||||
|
pending: {
|
||||||
|
label: "挂单中",
|
||||||
|
type: "#E6A23C",
|
||||||
|
},
|
||||||
|
using: {
|
||||||
|
label: "开台中",
|
||||||
|
type: "#fa5555",
|
||||||
|
},
|
||||||
|
paying: {
|
||||||
|
label: "结算中",
|
||||||
|
type: "#E6A23C",
|
||||||
|
},
|
||||||
|
idle: {
|
||||||
|
label: "空闲",
|
||||||
|
type: "#3F9EFF",
|
||||||
|
},
|
||||||
|
subscribe: {
|
||||||
|
label: "预定",
|
||||||
|
type: "rgb(34, 191, 100)",
|
||||||
|
},
|
||||||
|
closed: {
|
||||||
|
label: "关台",
|
||||||
|
type: "rgb(221,221,221)",
|
||||||
|
},
|
||||||
|
// opening: {
|
||||||
|
// label: "开台中",
|
||||||
|
// type: "#67C23A",
|
||||||
|
// },
|
||||||
|
cleaning: {
|
||||||
|
label: "待清台",
|
||||||
|
type: "#FAAD14",
|
||||||
|
},
|
||||||
|
unbind: {
|
||||||
|
label: "未绑定",
|
||||||
|
type: "rgb(221,221,221)",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
* 统一工具类 (all utils x ) aux ( 谐音 ) [ window 无法创建此命名的文件 放弃。 = = ]
|
||||||
|
* 统一使用: all Kit 简称 ak.
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeepay.vip
|
||||||
|
* @date 2022/12/12 18:38
|
||||||
|
*/
|
||||||
|
|
||||||
|
import go from './go.js'
|
||||||
|
import emit from './emit.js'
|
||||||
|
import ent from './ent.js'
|
||||||
|
import cal from './cal.js'
|
||||||
|
import dataKit from './dataKit.js'
|
||||||
|
import timer from './timer.js'
|
||||||
|
import infoBox from './infoBox.js'
|
||||||
|
|
||||||
|
const ak = {
|
||||||
|
go: go,
|
||||||
|
emit: emit,
|
||||||
|
ent: ent,
|
||||||
|
cal: cal,
|
||||||
|
timer: timer,
|
||||||
|
infoBox: infoBox,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ak
|
||||||
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**
|
||||||
|
* 数字, 计算相关函数
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeepay.vip
|
||||||
|
* @date 2022/11/22 10:38
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保留小数n位,不进行四舍五入
|
||||||
|
* num你传递过来的数字,
|
||||||
|
* decimal你保留的几位,默认保留小数后两位
|
||||||
|
*/
|
||||||
|
const formatDecimal = function(num, decimal = 2) {
|
||||||
|
num = num.toString()
|
||||||
|
const index = num.indexOf('.')
|
||||||
|
if (index !== -1) {
|
||||||
|
num = num.substring(0, decimal + index + 1)
|
||||||
|
} else {
|
||||||
|
num = num.substring(0)
|
||||||
|
}
|
||||||
|
//截取后保留两位小数
|
||||||
|
return parseFloat(num).toFixed(decimal)
|
||||||
|
}
|
||||||
|
|
||||||
|
const model = {
|
||||||
|
// 分转元
|
||||||
|
// amount - 金额 parseFloat - 是否转换为数字格式, 默认String
|
||||||
|
cert2Dollar(amount, needParseFloat = false) {
|
||||||
|
if (needParseFloat) { // parseFlot
|
||||||
|
return formatDecimal(amount / 100)
|
||||||
|
}
|
||||||
|
return formatDecimal(amount / 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
/**
|
||||||
|
* 数据 工具类
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeepay.vip
|
||||||
|
* @date 2022/11/30 14:18
|
||||||
|
*/
|
||||||
|
|
||||||
|
const model = {
|
||||||
|
|
||||||
|
// 递归遍历树状结构数据 matchFunc 匹配结果, true表示匹配成功, 否则继续匹配。
|
||||||
|
// pnode 可不传入
|
||||||
|
// 返回结构: [当前数据, 上级数据 ]
|
||||||
|
recursionTreeData: (treeData, matchFunc, childrenName = 'children', pnode = null ) => {
|
||||||
|
|
||||||
|
for (let i = 0; i < treeData.length; i++) {
|
||||||
|
|
||||||
|
const item = treeData[i]
|
||||||
|
|
||||||
|
// 匹配成功
|
||||||
|
if(matchFunc(item)){
|
||||||
|
return [item, pnode]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item[childrenName] && item[childrenName].length > 0) {
|
||||||
|
let res = model.recursionTreeData(item[childrenName], matchFunc, childrenName, item)
|
||||||
|
if(res){
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
||||||
|
|
@ -0,0 +1,164 @@
|
||||||
|
/**
|
||||||
|
* datamap , 数据字典, 存放常用的配置常量信息。 如订单类型的判断, 用户类型的判断。
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeepay.vip
|
||||||
|
* @date 2022/11/28 16:16
|
||||||
|
*/
|
||||||
|
|
||||||
|
const payOrderStateMap = {
|
||||||
|
0: {
|
||||||
|
text: '订单生成',
|
||||||
|
color: '#2980FD'
|
||||||
|
},
|
||||||
|
1: {
|
||||||
|
text: '支付中',
|
||||||
|
color: '#FFAA33'
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
text: '支付成功',
|
||||||
|
color: '#09BB07'
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
text: '支付失败',
|
||||||
|
color: '#CB2972'
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
text: '已撤销',
|
||||||
|
color: '#808080'
|
||||||
|
},
|
||||||
|
5: {
|
||||||
|
text: '已退款',
|
||||||
|
color: '#FF5B4C'
|
||||||
|
},
|
||||||
|
6: {
|
||||||
|
text: '订单关闭',
|
||||||
|
color: '#D9D9D9'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
// 订单 图片 和背景颜色
|
||||||
|
const payOrderImageMap = {
|
||||||
|
WECHAT: {
|
||||||
|
title: '微信',
|
||||||
|
imgUrl: '/static/orderImg/wechat.svg', //微信支付
|
||||||
|
bgColor: '#09BB07',
|
||||||
|
},
|
||||||
|
ALIPAY: {
|
||||||
|
title: '支付宝',
|
||||||
|
imgUrl: '/static/orderImg/zfb.svg', //支付宝支付
|
||||||
|
bgColor: '#458FFF',
|
||||||
|
},
|
||||||
|
YSFPAY: {
|
||||||
|
title: '云闪付',
|
||||||
|
imgUrl: '/static/orderImg/ysf.svg', // 云闪付支付
|
||||||
|
bgColor: '#FF5B4C',
|
||||||
|
},
|
||||||
|
UNIONPAY: {
|
||||||
|
title: '银联',
|
||||||
|
imgUrl: '/static/orderImg/union-pay.svg', //银联支付
|
||||||
|
bgColor: '#0D131A',
|
||||||
|
},
|
||||||
|
OTHER: {
|
||||||
|
title: '其他',
|
||||||
|
imgUrl: '/static/orderImg/default-pay.svg', //其他支付
|
||||||
|
bgColor: '#5F36C4',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1-超级管理员 2-普通用户 3-拓展员, 11-店长, 12-店员
|
||||||
|
const userTypeMap = {
|
||||||
|
1: {
|
||||||
|
text: '超管',
|
||||||
|
bgColor: 'linear-gradient(270deg, rgba(35,161,252,1) 0%, rgba(26,102,255,1) 100%)',
|
||||||
|
type: 'blue'
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
text: '普通用户',
|
||||||
|
bgColor: 'linear-gradient(270deg, rgba(35,161,252,1) 0%, rgba(26,102,255,1) 100%)'
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
text: '拓展员',
|
||||||
|
bgColor: 'linear-gradient(270deg, rgba(35,161,252,1) 0%, rgba(26,102,255,1) 100%)'
|
||||||
|
},
|
||||||
|
11: {
|
||||||
|
text: '店长',
|
||||||
|
bgColor: 'linear-gradient(270deg, rgba(220,61,138,1) 0%, rgba(187,23,92,1) 100%)',
|
||||||
|
type: 'purple'
|
||||||
|
},
|
||||||
|
12: {
|
||||||
|
text: '店员',
|
||||||
|
bgColor: ' linear-gradient(270deg, rgba(61,220,68,1) 0%, rgba(23,187,118,1) 100%)',
|
||||||
|
type: 'green'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
// 设备厂商
|
||||||
|
const devProvider = {
|
||||||
|
zgwl: '智谷物联',
|
||||||
|
bsj: '博实结',
|
||||||
|
fe: '飞鹅',
|
||||||
|
ps: '品生',
|
||||||
|
clj: '财来聚',
|
||||||
|
wsy: '微收银',
|
||||||
|
xjl: '小精灵',
|
||||||
|
lmspay: '立码收',
|
||||||
|
lkls: '拉卡拉',
|
||||||
|
zw: '智网'
|
||||||
|
}
|
||||||
|
|
||||||
|
const rechargeStateMap = {
|
||||||
|
0: {
|
||||||
|
text: '初始化',
|
||||||
|
color: '#2980FD'
|
||||||
|
},
|
||||||
|
1: {
|
||||||
|
text: '充值中',
|
||||||
|
color: '#FFAA33'
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
text: '充值成功',
|
||||||
|
color: '#09BB07'
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
text: '充值失败',
|
||||||
|
color: '#CB2972'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const model = {
|
||||||
|
// 订单状态文本和color
|
||||||
|
payOrderState: (state) => {
|
||||||
|
// 避免循环判断,影响性能。
|
||||||
|
if (payOrderStateMap[state]) {
|
||||||
|
return payOrderStateMap[state]
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
text: '未知',
|
||||||
|
color: '#D9D9D9'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 订单图片 和图片背景颜色
|
||||||
|
payOrderImage: (state) => {
|
||||||
|
// 取值 找到 返回当前值 未找到返回空对象
|
||||||
|
return payOrderImageMap[state] || {}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 用户类型的判断
|
||||||
|
userType: (userTypeVal) => {
|
||||||
|
return userTypeMap[userTypeVal] || {}
|
||||||
|
},
|
||||||
|
// 查找设备厂商 找到就返回 找不到据返回空
|
||||||
|
provider: (state) => {
|
||||||
|
return devProvider[state] || '未知'
|
||||||
|
},
|
||||||
|
|
||||||
|
// 会员充值订单图片 和图片背景颜色
|
||||||
|
rechargeRecordImage: (state) => {
|
||||||
|
// 取值 找到 返回当前值 未找到返回空对象
|
||||||
|
return rechargeStateMap[state] || {}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
// 获取今天的开始和结束时间
|
||||||
|
export function getTodayTimestamps() {
|
||||||
|
const start = dayjs().startOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
const end = dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
return { start, end ,label:'今日'};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取昨天的开始和结束时间
|
||||||
|
export function getYesterdayTimestamps() {
|
||||||
|
const start = dayjs().subtract(1, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
const end = dayjs().subtract(1, 'day').endOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
return { start, end ,label:'昨日'};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取本周的开始和结束时间
|
||||||
|
export function getThisWeekTimestamps() {
|
||||||
|
const start = dayjs().startOf('week').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
const end = dayjs().endOf('week').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
return { start, end,label:'本周' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取本月的开始和结束时间
|
||||||
|
export function getThisMonthTimestamps() {
|
||||||
|
const start = dayjs().startOf('month').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
const end = dayjs().endOf('month').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
return { start, end ,label:'本月'};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,138 @@
|
||||||
|
/**
|
||||||
|
* 页面通讯工具类(uni.emit)的封装
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2022/11/24 15:54
|
||||||
|
*/
|
||||||
|
|
||||||
|
const model = {
|
||||||
|
|
||||||
|
// 定义监听器的名字, 应该是一个页面一个, 不可两个页面公共一个, 否则会导致: 一个页面onUnload 移除时影响另一个页面的正常接收。
|
||||||
|
// 业务页面 监听, onUnload应该移除掉。
|
||||||
|
|
||||||
|
// 通用搜索页
|
||||||
|
ENAME_REF_SEARCH_PAGE : 'ENAME_REF_SEARCH_PAGE',
|
||||||
|
|
||||||
|
// 应用列表页的刷新
|
||||||
|
ENAME_REF_TABLE_MCH_APP : 'ENAME_REF_TABLE_MCH_APP',
|
||||||
|
// 应用详情
|
||||||
|
ENAME_REF_TABLE_MCH_APP_DETAILS : 'ENAME_REF_TABLE_MCH_APP_DETAILS',
|
||||||
|
|
||||||
|
// 调起扫一扫
|
||||||
|
ENAME_E_PAY_SCAN : 'ENAME_E_PAY_SCAN',
|
||||||
|
// 重置 金额
|
||||||
|
ENAME_RESET_PAY_AMOUNT: 'ENAME_RESET_PAY_AMOUNT',
|
||||||
|
// 更新支付订单信息
|
||||||
|
ENAME_REF_PAY_ORDER : 'ENAME_REF_PAY_ORDER',
|
||||||
|
|
||||||
|
// 更新 门店列表
|
||||||
|
ENAME_REF_STORE_LIST : 'ENAME_REF_STORE_LIST',
|
||||||
|
|
||||||
|
// 更新 门店详情
|
||||||
|
ENAME_REF_STORE_DETAIL : 'ENAME_REF_STORE_DETAIL',
|
||||||
|
|
||||||
|
// 更新 员工列表
|
||||||
|
ENAME_REF_SYS_USER_LIST : 'ENAME_REF_SYS_USER_LIST',
|
||||||
|
|
||||||
|
// 更新 员工详情
|
||||||
|
ENAME_REF_SYS_USER_DETAIL : 'ENAME_REF_SYS_USER_DETAIL',
|
||||||
|
|
||||||
|
// 更新 通道列表
|
||||||
|
ENAME_REF_PAY_PASSAGE_LIST : 'ENAME_REF_PAY_PASSAGE_LIST',
|
||||||
|
|
||||||
|
// 更新 辅助终端信息
|
||||||
|
ENAME_REF_TERMINAL_LIST : 'ENAME_REF_TERMINAL_LIST',
|
||||||
|
|
||||||
|
// 更新 辅助终端 详情页
|
||||||
|
ENAME_REF_TERMINAL_DETAIL : 'ENAME_REF_TERMINAL_DETAIL',
|
||||||
|
|
||||||
|
// 更新 智能pos 信息
|
||||||
|
ENAME_REF_AUTOPOS_LIST : 'ENAME_REF_AUTOPOS_LIST',
|
||||||
|
|
||||||
|
// 更新 智能pos 详情页
|
||||||
|
ENAME_REF_AUTOPOS_DETAIL : 'ENAME_REF_AUTOPOS_DETAIL',
|
||||||
|
|
||||||
|
// 更新 扫码pos 信息
|
||||||
|
ENAME_REF_SCANPOS_LIST : 'ENAME_REF_SCANPOS_LIST',
|
||||||
|
|
||||||
|
// 更新 扫码pos 详情页
|
||||||
|
ENAME_REF_SCANPOS_DETAIL : 'ENAME_REF_SCANPOS_DETAIL',
|
||||||
|
// 码牌列表
|
||||||
|
ENAME_REF_QRC_LIST : 'ENAME_REF_QRC_LIST',
|
||||||
|
|
||||||
|
// 码牌详情
|
||||||
|
ENAME_REF_QRC_DETAIL : 'ENAME_REF_QRC_DETAIL',
|
||||||
|
// 更新 打印机 信息
|
||||||
|
ENAME_REF_PRINTER_LIST : 'ENAME_REF_PRINTER_LIST',
|
||||||
|
|
||||||
|
// 更新 打印机 详情页
|
||||||
|
ENAME_REF_PRINTER_DETAIL : 'ENAME_REF_PRINTER_DETAIL',
|
||||||
|
|
||||||
|
// 云喇叭列表
|
||||||
|
ENAME_REF_SPEAKER_LIST : 'ENAME_REF_SPEAKER_LIST',
|
||||||
|
|
||||||
|
// 云喇叭详情
|
||||||
|
ENAME_REF_SPEAKER_DETAIL : 'ENAME_REF_SPEAKER_DETAIL',
|
||||||
|
|
||||||
|
|
||||||
|
// 进件列表
|
||||||
|
ENAME_REF_APPLYMENT_LIST : 'ENAME_REF_APPLYMENT_LIST',
|
||||||
|
|
||||||
|
// 刷脸设备列表
|
||||||
|
ENAME_REF_FACE_LIST : 'ENAME_REF_FACE_LIST',
|
||||||
|
// 刷脸设备详情
|
||||||
|
ENAME_REF_FACE_DETAIL : 'ENAME_REF_FACE_DETAIL',
|
||||||
|
|
||||||
|
// 刷脸广告列表
|
||||||
|
ENAME_REF_AD_LIST : 'ENAME_REF_AD_LIST',
|
||||||
|
|
||||||
|
// 刷脸广告 详情
|
||||||
|
ENAME_REF_AD_DETAILS : 'ENAME_REF_AD_DETAILS',
|
||||||
|
|
||||||
|
// 更新 会员列表
|
||||||
|
ENAME_REF_MEMBER_LIST : 'ENAME_REF_MEMBER_LIST',
|
||||||
|
|
||||||
|
// 更新 会员详情
|
||||||
|
ENAME_REF_MEMBER_DETAIL : 'ENAME_REF_MEMBER_DETAIL',
|
||||||
|
|
||||||
|
// 更新 会员账户流水列表
|
||||||
|
ENAME_REF_MEMBER_ACCOUNT_HISTORY_LIST : 'ENAME_REF_MEMBER_ACCOUNT_HISTORY_LIST',
|
||||||
|
|
||||||
|
// 更新 会员账户流水详情
|
||||||
|
ENAME_REF_MEMBER_ACCOUNT_HISTORY_DETAIL : 'ENAME_REF_MEMBER_ACCOUNT_HISTORY_DETAIL',
|
||||||
|
|
||||||
|
// 更新 会员充值记录列表
|
||||||
|
ENAME_REF_MEMBER_RECHARGE_RECORD_LIST : 'ENAME_REF_MEMBER_RECHARGE_RECORD_LIST',
|
||||||
|
|
||||||
|
// 更新 会员充值记录详情
|
||||||
|
ENAME_REF_MEMBER_RECHARGE_RECORD_DETAIL : 'ENAME_REF_MEMBER_RECHARGE_RECORD_DETAIL',
|
||||||
|
|
||||||
|
// 更新 充值规则列表
|
||||||
|
ENAME_REF_RECHARGE_RULE_LIST : 'ENAME_REF_RECHARGE_RULE_LIST',
|
||||||
|
|
||||||
|
// 刷新页面的 发射事件 , 更新页面 && 更新搜索页面
|
||||||
|
refPageAndSearchEmit: (refEmitEventName, data = {} ) => {
|
||||||
|
model.pageEmit(refEmitEventName, data)
|
||||||
|
model.pageEmit(model.ENAME_REF_SEARCH_PAGE, data)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 自定义
|
||||||
|
pageEmit: (refEmitEventName, data) => {
|
||||||
|
uni.$emit(refEmitEventName, data )
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 废弃该函数。 ( 因为: 页面只监听一次, 使用该函数则无法再次监听, 需要再每个页面写入: uni.$on 保证正常接收。 )
|
||||||
|
// 监听页面刷新函数
|
||||||
|
on: (refEmitEventName) => {
|
||||||
|
return new Promise( (resolve) => {
|
||||||
|
uni.$on(refEmitEventName, function(data){
|
||||||
|
resolve( data )
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
/**
|
||||||
|
* 加解密工具包
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeepay.vip
|
||||||
|
* @date 2021/5/16 17:35
|
||||||
|
*/
|
||||||
|
import { SM4 } from 'gm-crypto'
|
||||||
|
import appConfig from '@/config/appConfig.js'
|
||||||
|
|
||||||
|
let HEX_KEY = null
|
||||||
|
|
||||||
|
// 字符串转16进制
|
||||||
|
function str2hex(str) {
|
||||||
|
var val = ''
|
||||||
|
for (var i = 0; i < str.length; i++) {
|
||||||
|
if (val == '')
|
||||||
|
val = str.charCodeAt(i).toString(16)
|
||||||
|
else
|
||||||
|
val += str.charCodeAt(i).toString(16)
|
||||||
|
}
|
||||||
|
val += ''
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取hex秘钥
|
||||||
|
function getHexKey(){
|
||||||
|
|
||||||
|
if(!HEX_KEY){
|
||||||
|
|
||||||
|
HEX_KEY = str2hex(appConfig.encryptKey)
|
||||||
|
|
||||||
|
}
|
||||||
|
return HEX_KEY
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 解密 (http响应数据, 做通用处理)
|
||||||
|
export function sm4DecryptByResData(data){
|
||||||
|
|
||||||
|
if(!data){
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
let res = SM4.decrypt(data, getHexKey(), {
|
||||||
|
inputEncoding: 'base64',
|
||||||
|
outputEncoding: 'utf8'
|
||||||
|
})
|
||||||
|
|
||||||
|
if(!res){
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
return JSON.parse(res)['originData']
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加密 (http响应数据, 做通用处理)
|
||||||
|
export function sm4EncryptByReqData(data){
|
||||||
|
|
||||||
|
if(!data){
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加密处理
|
||||||
|
let encryptData = SM4.encrypt(JSON.stringify(data), getHexKey(), {
|
||||||
|
inputEncoding: 'utf8',
|
||||||
|
outputEncoding: 'base64'
|
||||||
|
})
|
||||||
|
|
||||||
|
return {encryptData : encryptData}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**
|
||||||
|
* 权限判断
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2022/11/22 14:29
|
||||||
|
*/
|
||||||
|
import storageManage from '@/commons/utils/storageManage.js'
|
||||||
|
const model = {
|
||||||
|
|
||||||
|
// 判断是否包含该权限
|
||||||
|
has(entId){
|
||||||
|
let userInfo = storageManage.userInfo()
|
||||||
|
if(userInfo && userInfo.entIdList && userInfo.entIdList.indexOf(entId) >= 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
/**
|
||||||
|
* form 验证 工具类
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeepay.vip
|
||||||
|
* @date 2022/11/25 10:58
|
||||||
|
*/
|
||||||
|
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
|
||||||
|
const model = {
|
||||||
|
|
||||||
|
|
||||||
|
// 正则表达式
|
||||||
|
regexp: {
|
||||||
|
|
||||||
|
// 手机号验证规则
|
||||||
|
mobile: /^1\d{10}$/,
|
||||||
|
|
||||||
|
// 登录用户名: 字母开头 6 -18位。
|
||||||
|
loginUsername: /^[a-zA-Z][a-zA-Z0-9]{5,17}$/,
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// 验证规则:
|
||||||
|
rules: {
|
||||||
|
|
||||||
|
// showText 为空, 说明是 input的placeHoloder 直接飘红,
|
||||||
|
// showText 有值: 在文本框下方提示。
|
||||||
|
// 只有input 才有这种特殊判断。
|
||||||
|
requiredInput: (showText, type = 'string') => {
|
||||||
|
return {format: type, required: true, errorMessage: showText ? ('请输入' + showText) : ' ' }
|
||||||
|
},
|
||||||
|
|
||||||
|
requiredSelect: (showText, type = 'string') => {
|
||||||
|
return {format: type, required: true, errorMessage: '请选择' + showText }
|
||||||
|
},
|
||||||
|
|
||||||
|
requiredUpload: (showText, type = 'string') => {
|
||||||
|
return {format: type, required: true, errorMessage: '请上传' + showText }
|
||||||
|
},
|
||||||
|
|
||||||
|
// 正则验证 , 请注意: 该规则需要在required后面, 此处不可包含required
|
||||||
|
patternRule: (showText, p) => {
|
||||||
|
return {pattern: p, errorMessage: '请输入正确的' + showText }
|
||||||
|
},
|
||||||
|
|
||||||
|
requiredInputShowToast: (showText, type = 'string') => {
|
||||||
|
return {format: type, required: true, errorMessage:' ', toastErrorMessage: '请输入' + showText }
|
||||||
|
},
|
||||||
|
|
||||||
|
requiredSelectShowToast: (showText, type = 'string') => {
|
||||||
|
return {format: type, required: true, errorMessage:' ', toastErrorMessage: '请选择' + showText }
|
||||||
|
},
|
||||||
|
|
||||||
|
requiredUploadShowToast: (showText, type = 'string') => {
|
||||||
|
return {format: type, required: true, errorMessage:' ', toastErrorMessage: '请上传' + showText }
|
||||||
|
},
|
||||||
|
|
||||||
|
patternRuleShowToast: (showText, p) => {
|
||||||
|
return {pattern: p, errorMessage:' ', toastErrorMessage: '请输入正确的' + showText }
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// 支持 提示信息
|
||||||
|
// 类型如下:
|
||||||
|
// {
|
||||||
|
// required: true,
|
||||||
|
// toastErrorMessage: "请输入去去去去群",
|
||||||
|
// errorMessage: ' ', // 不会显示在下部, 需要空格占位
|
||||||
|
// }
|
||||||
|
validate: (form) => {
|
||||||
|
|
||||||
|
return form.validate().catch(e => {
|
||||||
|
|
||||||
|
if(!e || e.length <= 0){
|
||||||
|
return Promise.reject()
|
||||||
|
}
|
||||||
|
|
||||||
|
for(let i = 0; i < e.length; i++){
|
||||||
|
let k = e[i].key
|
||||||
|
let rules = form.rules[k].rules
|
||||||
|
for(let j = 0; j < rules.length; j++){
|
||||||
|
if(rules[j].toastErrorMessage && rules[j].required){
|
||||||
|
infoBox.showToast(rules[j].toastErrorMessage) // 仅提示一次即可
|
||||||
|
return Promise.reject(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Promise.reject(e)
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
* 格式化价格函数,将价格限定在指定的最小值和最大值范围内,并保留两位小数。
|
||||||
|
*
|
||||||
|
* @param {number} price - 需要格式化的价格。
|
||||||
|
* @param {number} min - 价格的最小值。
|
||||||
|
* @param {number} max - 价格的最大值,默认为100000000。
|
||||||
|
* @param {Boolean} returnIsArea - 是否返回值符合范围区间,默认为false。
|
||||||
|
* @returns {number} - 返回格式化后的价格,如果超出范围则返回最小值或最大值。
|
||||||
|
*/
|
||||||
|
export const formatPrice = (price,min=-Infinity, max = 100000000,returnIsArea=false,isRerturnNullString=false) => {
|
||||||
|
|
||||||
|
if(price === undefined || price === null||price===''){
|
||||||
|
return isRerturnNullString?'':0
|
||||||
|
}
|
||||||
|
// 将价格转换为浮点数并保留两位小数
|
||||||
|
const newval = parseFloat((Math.floor(price * 100) / 100).toFixed(2))
|
||||||
|
// 如果价格大于最大值,返回最大值
|
||||||
|
if (newval > max) {
|
||||||
|
return returnIsArea?{value:max,error:true}:max
|
||||||
|
}
|
||||||
|
// 如果价格小于最小值,返回最小值
|
||||||
|
if (newval < min) {
|
||||||
|
return returnIsArea?{value:min,error:true}:min
|
||||||
|
}
|
||||||
|
// 如果价格小于最小值,返回最小值
|
||||||
|
if (newval < min) {
|
||||||
|
return min
|
||||||
|
}
|
||||||
|
// 返回格式化后的价格
|
||||||
|
return newval
|
||||||
|
}
|
||||||
|
export function returnReverseVal(val, isReturnString = true) {
|
||||||
|
const isBol = typeof val === "boolean";
|
||||||
|
const isString = typeof val === "string";
|
||||||
|
let reverseNewval = "";
|
||||||
|
if (isBol) {
|
||||||
|
reverseNewval = !val;
|
||||||
|
}
|
||||||
|
if (isString) {
|
||||||
|
reverseNewval = val === "true" ? "false" : "true";
|
||||||
|
}
|
||||||
|
return reverseNewval;
|
||||||
|
}
|
||||||
|
export function returnBoolean(val) {
|
||||||
|
const isBol = typeof val === "boolean";
|
||||||
|
const isString = typeof val === "string";
|
||||||
|
let newval = "";
|
||||||
|
if (isBol) {
|
||||||
|
newval = val;
|
||||||
|
}
|
||||||
|
if (isString) {
|
||||||
|
newval = val === "true" ? true : false;
|
||||||
|
}
|
||||||
|
return newval;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
function getDayArea(date = new Date(), type) {
|
||||||
|
const now = date
|
||||||
|
if (type === 'start') {
|
||||||
|
const startOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||||
|
return startOfDay
|
||||||
|
}
|
||||||
|
if (type === 'end') {
|
||||||
|
const endOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
||||||
|
return endOfDay;
|
||||||
|
}
|
||||||
|
return `${startOfDay}-${endOfDay}`
|
||||||
|
}
|
||||||
|
function getMonthArea(date = new Date(), type) {
|
||||||
|
let now = date
|
||||||
|
let currentMonthStart = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||||
|
let currentMonthEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0 , 23, 59, 59, 999);
|
||||||
|
if (type === 'start') {
|
||||||
|
return currentMonthStart
|
||||||
|
}
|
||||||
|
if (type === 'end') {
|
||||||
|
return currentMonthEnd;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
start: currentMonthStart,
|
||||||
|
end: currentMonthEnd
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
getDayArea, getMonthArea
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
/**
|
||||||
|
* 获取url链接参数
|
||||||
|
* @param {Object} url
|
||||||
|
* @param {Object} name
|
||||||
|
*/
|
||||||
|
export function getQueryString(url, name) {
|
||||||
|
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
|
||||||
|
var r = url.substr(1).match(reg)
|
||||||
|
if (r != null) {
|
||||||
|
return r[2]
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
/**
|
||||||
|
* 页面跳转工具类
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2022/11/14 17:12
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 引入 pages用于解析 pageId 变量 , 注意 需要在 pages.json 定义pageId 参数。
|
||||||
|
// 使用方法: go.to(""), 优点: 扩展分包可任意路径,业务调用不再传入固定URL, 传入的是pageId变量。
|
||||||
|
import pagesJSON from '@/pages.json'
|
||||||
|
import emit from './emit.js'
|
||||||
|
|
||||||
|
// 获取到全部的页面路径 和 ID
|
||||||
|
const ALL_PAGES = { }
|
||||||
|
|
||||||
|
// 添加到 ALL_PAGES
|
||||||
|
function addPages(pagesRoot){
|
||||||
|
let rootUrl = pagesRoot.root ? `/${pagesRoot.root}/` : '/'
|
||||||
|
pagesRoot.pages.forEach(r => {
|
||||||
|
if(r.pageId){
|
||||||
|
ALL_PAGES[r.pageId] = rootUrl + r.path
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 添加 主目录
|
||||||
|
addPages(pagesJSON)
|
||||||
|
|
||||||
|
// 2. 添加分包文件 目录
|
||||||
|
if(pagesJSON.subPackages){
|
||||||
|
pagesJSON.subPackages.forEach(r => addPages(r))
|
||||||
|
}
|
||||||
|
|
||||||
|
const model = {
|
||||||
|
|
||||||
|
// 跳转类型
|
||||||
|
GO_TYPE_TO: 'navigateTo',
|
||||||
|
GO_TYPE_REDIRECT: 'redirect',
|
||||||
|
GO_TYPE_RELAUNCH: 'reLaunch',
|
||||||
|
GO_TYPE_SWITCHTAB: 'switchTab',
|
||||||
|
|
||||||
|
|
||||||
|
// 对象转换url参数
|
||||||
|
object2param: (obj) => {
|
||||||
|
|
||||||
|
if(!obj || Object.keys(obj).length <= 0){
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = "?"
|
||||||
|
Object.keys(obj).forEach(k => {
|
||||||
|
|
||||||
|
let val = obj[k]
|
||||||
|
// H5需要转码, 其他平台不需要
|
||||||
|
// #ifdef H5
|
||||||
|
val = encodeURIComponent(val)
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
result += `${k}=${val}&`
|
||||||
|
})
|
||||||
|
return result.substr(0, (result.length - 1));
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// uni.navigateTo函数的封装: 保留当前页面,跳转到应用内的某个页面,使用uni.navigateBack可以返回到原页面。
|
||||||
|
// 参数: pagesIdOrUrl(路径或者pageId), 页面参数, 扩展参数
|
||||||
|
to: (pagesIdOrUrl, params = {}, type = model.GO_TYPE_TO, extObject = {}) => {
|
||||||
|
|
||||||
|
// 使用ID作为标识
|
||||||
|
if(pagesIdOrUrl.indexOf('PAGES_') == 0){
|
||||||
|
pagesIdOrUrl = ALL_PAGES[pagesIdOrUrl]
|
||||||
|
}
|
||||||
|
pagesIdOrUrl += model.object2param(params)
|
||||||
|
if(type == model.GO_TYPE_TO){
|
||||||
|
uni.navigateTo(Object.assign({ url: pagesIdOrUrl }, extObject))
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type == model.GO_TYPE_REDIRECT){
|
||||||
|
uni.redirectTo(Object.assign({ url: pagesIdOrUrl }, extObject))
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type == model.GO_TYPE_RELAUNCH){
|
||||||
|
uni.reLaunch(Object.assign({ url: pagesIdOrUrl }, extObject))
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type == model.GO_TYPE_SWITCHTAB){
|
||||||
|
uni.switchTab(Object.assign({ url: pagesIdOrUrl }, extObject))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 跳转到通用搜索页面
|
||||||
|
toSearchPage: (pageType, extObject = {}) => {
|
||||||
|
model.to("PAGES_LIST_SEARCH", Object.assign({type: pageType}, extObject))
|
||||||
|
},
|
||||||
|
|
||||||
|
// delta 返回到第几页, refEmitEventName: 触发全局更新函数 (更新 list and search )
|
||||||
|
back: (delta = 1, refEmitEventName) => {
|
||||||
|
|
||||||
|
if(refEmitEventName){
|
||||||
|
emit.refPageAndSearchEmit(refEmitEventName)
|
||||||
|
}
|
||||||
|
uni.navigateBack(delta)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
export function canComputedPackFee(v) {
|
||||||
|
return v.pack && v.status != 'return' && v.status != 'refund' && v.status != 'refunding'
|
||||||
|
}
|
||||||
|
export function returnCanComputedGoodsArr(arr) {
|
||||||
|
return arr.filter(v => canComputedPackFee(v))
|
||||||
|
}
|
||||||
|
export function returnPackFee(arr) {
|
||||||
|
return arr.reduce((prve, cur) => {
|
||||||
|
return prve + cur.packAmount
|
||||||
|
}, 0).toFixed(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canTuicai(orderInfo, item) {
|
||||||
|
if (orderInfo.status == 'unpaid' && orderInfo.isPostpaid !== null && orderInfo.isPostpaid == 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return orderInfo.status == 'unpaid' && orderInfo.useType != 'dine-in-before' && item.status != 'return'
|
||||||
|
}
|
||||||
|
export function canTuiKuan(orderInfo, item) {
|
||||||
|
return orderInfo.status == 'closed' && item.status != 'return' && item.status != 'refund' && item.status !=
|
||||||
|
'refunding'
|
||||||
|
}
|
||||||
|
export function isTuiCai(item) {
|
||||||
|
return item.status == 'return'
|
||||||
|
}
|
||||||
|
export function isTui(item) {
|
||||||
|
return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
|
||||||
|
}
|
||||||
|
export function isGift(item) {
|
||||||
|
return !isTui(item) && item.gift
|
||||||
|
}
|
||||||
|
export function numSum(arr) {
|
||||||
|
const sum = arr.reduce((a, b) => {
|
||||||
|
return a + b * 100
|
||||||
|
}, 0)
|
||||||
|
return (sum / 100).toFixed(2)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,163 @@
|
||||||
|
import {
|
||||||
|
$hasPermission
|
||||||
|
} from '@/http/yskApi/shop.js'
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
|
||||||
|
const $PermissionObj = {
|
||||||
|
data: [{
|
||||||
|
key: 'yun_xu_cha_kan_jing_ying_shu_ju',
|
||||||
|
text: '允许查看经营数据'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'yun_xu_cha_kan_suo_you_jiao_ban_ji_lu',
|
||||||
|
text: '允许查看所有交班记录'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
default: [{
|
||||||
|
key: 'yun_xu_xia_dan',
|
||||||
|
text: '允许下单'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'yun_xu_shou_kuan',
|
||||||
|
text: '允许收款'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'yun_xu_tui_kuan',
|
||||||
|
text: '允许退款'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'yun_xu_jiao_ban',
|
||||||
|
text: '允许交班'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
goods: [{
|
||||||
|
key: 'yun_xu_xiu_gai_shang_pin',
|
||||||
|
text: '允许修改商品'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'yun_xu_shang_xia_jia_shang_pin',
|
||||||
|
text: '允许上下架商品'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'yun_xu_xiu_gai_fen_lei',
|
||||||
|
text: '允许修改分类'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'yun_xu_xiu_gai_fen_zu',
|
||||||
|
text: '允许修改分组'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
discount:[
|
||||||
|
{
|
||||||
|
key: 'yun_xu_da_zhe',
|
||||||
|
text: '允许打折'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
vip:[
|
||||||
|
{
|
||||||
|
text: '允许管理会员信息',
|
||||||
|
key: 'yun_xu_guan_li_hui_yuan_xin_xi'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'yun_xu_xiu_gai_hui_yuan_yu_e',
|
||||||
|
text: '允许修改会员余额'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
stock:[
|
||||||
|
{
|
||||||
|
text: '允许提交报损',
|
||||||
|
key: 'yun_xu_ti_jiao_bao_sun'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '允许沽清',
|
||||||
|
key: 'yun_xu_gu_qing'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '允许售罄商品',
|
||||||
|
key: 'yun_xu_shou_qing_shang_pin'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text:'允许修改商品库存',
|
||||||
|
key:'yun_xu_xiu_gai_shang_pin_ku_cun'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '允许耗材入库',
|
||||||
|
key: 'yun_xu_hao_cai_ru_ku'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '允许耗材出库',
|
||||||
|
key: 'yun_xu_hao_cai_chu_ku'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '允许耗材盘点',
|
||||||
|
key: 'yun_xu_hao_cai_pan_dian'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
function isChinese(str) {
|
||||||
|
for (var i = 0; i < str.length; i++) {
|
||||||
|
if (str.charCodeAt(i) >= 0x4E00 && str.charCodeAt(i) <= 0x9FFF) {
|
||||||
|
return true; // 是中文
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false; // 不是中文,全是英文或其他
|
||||||
|
}
|
||||||
|
|
||||||
|
function isObjectButNotArray(value) {
|
||||||
|
return typeof value === 'object' && Array.isArray(value) === false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findPermissionObj(str) {
|
||||||
|
for (let i in $PermissionObj) {
|
||||||
|
const obj = $PermissionObj[i].find(v => v.key == str || v.text == str)
|
||||||
|
if (obj) {
|
||||||
|
return obj
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.error('未找到相关权限配置,请检查权限配置文件commons/utils/hasPermission.js文件进行修改或增加')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnFormatParams(params) {
|
||||||
|
if (typeof params === 'string') {
|
||||||
|
return findPermissionObj(params)
|
||||||
|
} else {
|
||||||
|
if (isObjectButNotArray(params)) {
|
||||||
|
const obj=findPermissionObj(params.key || params.text)
|
||||||
|
return {...params,...obj}
|
||||||
|
} else {
|
||||||
|
console.error('参数只能是字符串或者对象,不能是数组')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否有某权限
|
||||||
|
* @param {Object|String} params
|
||||||
|
*/
|
||||||
|
export async function hasPermission(params) {
|
||||||
|
//如果是商户默认拥有全部权限
|
||||||
|
const loginType=uni.getStorageSync('loginType')
|
||||||
|
if(loginType=='merchant'){
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
params = returnFormatParams(params)
|
||||||
|
if (!params) {
|
||||||
|
return infoBox.showToast('未找到相关权限,请检查代码或在权限配置文件commons/utils/hasPermission.js文件进行修改或增加')
|
||||||
|
}
|
||||||
|
const option = Object.assign({
|
||||||
|
tips: true,
|
||||||
|
key: '',
|
||||||
|
text: ''
|
||||||
|
}, params)
|
||||||
|
const res = await $hasPermission({
|
||||||
|
code: params.key
|
||||||
|
})
|
||||||
|
if (!res && option.tips) {
|
||||||
|
infoBox.showToast('您没有' + params.text + '权限!')
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
/**
|
||||||
|
* 提示信息公共文件
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2022/11/14 15:29
|
||||||
|
*/
|
||||||
|
|
||||||
|
const model = {
|
||||||
|
|
||||||
|
// uni.showToast的封装
|
||||||
|
// 参数: 标题、 显示时长(单位: 秒), 扩展参数
|
||||||
|
// 返回: promise对象, 当提示消失后调用 resolve()
|
||||||
|
showToast: (title, duration = 1.5, extObject) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.showToast(Object.assign({ title: title, icon: 'none', mask: false, duration: (duration * 1000) }, extObject))
|
||||||
|
setTimeout(resolve, (duration * 1000));
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// success类型的提示
|
||||||
|
showSuccessToast: (title, duration) => {
|
||||||
|
return model.showToast(title, duration, {icon: 'success'})
|
||||||
|
},
|
||||||
|
|
||||||
|
// error类型的提示
|
||||||
|
showErrorToast: (title, duration) => {
|
||||||
|
return model.showToast(title, duration, {icon: 'error'})
|
||||||
|
},
|
||||||
|
|
||||||
|
showLoading: (title = '请稍后' ) => {
|
||||||
|
return uni.showLoading({ title: title, mask: true })
|
||||||
|
},
|
||||||
|
|
||||||
|
hideLoading: () => {
|
||||||
|
return uni.hideLoading()
|
||||||
|
},
|
||||||
|
|
||||||
|
// 返回 Promise 点击确定和取消
|
||||||
|
// APP安卓原生提示(比较丑), APP 不推荐使用该函数 。
|
||||||
|
showModal: (title, confirmText = '确定', cancalText = '取消', extObject) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.showModal( Object.assign({
|
||||||
|
title: title,
|
||||||
|
confirmText: confirmText,
|
||||||
|
showCancel: cancalText ? true : false,
|
||||||
|
cancelText: cancalText,
|
||||||
|
success: function(r) {
|
||||||
|
if (r.confirm) {
|
||||||
|
resolve()
|
||||||
|
}else if (r.cancel) {
|
||||||
|
reject()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, extObject ));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
export function prveImg(arr, current) {
|
||||||
|
uni.previewImage({
|
||||||
|
urls: arr,current,
|
||||||
|
longPressActions: {
|
||||||
|
itemList: ['发送给朋友', '保存图片', '收藏'],
|
||||||
|
success: function(data) {
|
||||||
|
console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
|
||||||
|
},
|
||||||
|
fail: function(err) {
|
||||||
|
console.log(err.errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
import { $getBaiduToken } from '@/http/apiManager.js';
|
||||||
|
const audioTeam = [];
|
||||||
|
let audioStartSwitch = false;
|
||||||
|
const getAudioUrl = 'https://tsn.baidu.com/text2audio';
|
||||||
|
|
||||||
|
export default function openVoice(objs) { // 传入需转为语音的文本内容
|
||||||
|
let lineUp = false;
|
||||||
|
let returnAudio = false;
|
||||||
|
if (typeof(objs) !== 'string') {
|
||||||
|
if (objs && objs.lineUp === true) {
|
||||||
|
lineUp = true;
|
||||||
|
}
|
||||||
|
if (objs && objs.returnAudio === true) {
|
||||||
|
returnAudio = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(returnAudio) {
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
openVoiceFc(objs, returnAudio).then(res=>{
|
||||||
|
resolve(res);
|
||||||
|
}).catch(err=>{
|
||||||
|
reject(err)
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!audioStartSwitch || lineUp) {
|
||||||
|
audioStartSwitch = true;
|
||||||
|
openVoiceFc(objs);
|
||||||
|
} else {
|
||||||
|
audioTeam.push(objs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openVoiceFc(objs, returnAudio) {
|
||||||
|
if(returnAudio) {
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
$getBaiduToken().then(({bizData}) => {
|
||||||
|
if (bizData) {
|
||||||
|
resolve(tts(objs, bizData, returnAudio));
|
||||||
|
} else {
|
||||||
|
reject('获取语音tok接口为空');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
$getBaiduToken().then(({bizData}) => {
|
||||||
|
if (bizData) {
|
||||||
|
tts(objs, bizData);
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function tts(objs, tok, returnAudio) {
|
||||||
|
if(typeof(objs)=='string')
|
||||||
|
objs = {voiceSet: {tex: objs}};
|
||||||
|
const data = {
|
||||||
|
tok,
|
||||||
|
cuid: tok,
|
||||||
|
ctp: 1,
|
||||||
|
lan: 'zh',
|
||||||
|
...objs.voiceSet
|
||||||
|
}
|
||||||
|
if(returnAudio)
|
||||||
|
return btts( data, objs.audioSet, objs.audioCallback, objs.lineUp, returnAudio);
|
||||||
|
btts( data, objs.audioSet, objs.audioCallback, objs.lineUp, returnAudio);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setAudioSet(options, audio) {
|
||||||
|
if (options) {
|
||||||
|
audio.volume = options.volume || 1;
|
||||||
|
audio.startTime = options.startTime || 0;
|
||||||
|
audio.loop = options.loop || false;
|
||||||
|
audio.obeyMuteSwitch = options.obeyMuteSwitch && typeof(options.obeyMuteSwitch) == 'boolean' ? options.obeyMuteSwitch :
|
||||||
|
true; //支持微信小程序、百度小程序、头条小程序
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function btts(param, options, audioCallback, lineUp, returnAudio) {
|
||||||
|
let audio = uni.createInnerAudioContext();
|
||||||
|
setAudioSet(options, audio);
|
||||||
|
// 序列化参数列表
|
||||||
|
let fd = [];
|
||||||
|
for (let k in param) {
|
||||||
|
fd.push(k + '=' + encodeURIComponent(encodeURIComponent(param[k])));
|
||||||
|
}
|
||||||
|
audio.src = `${getAudioUrl}?${fd.join('&')}`;
|
||||||
|
|
||||||
|
if(returnAudio) {
|
||||||
|
audio.onEnded(() => {
|
||||||
|
audio.destroy(); //销毁音频实例
|
||||||
|
audio = null;
|
||||||
|
})
|
||||||
|
audio.onError((e)=>{
|
||||||
|
if (audioCallback && audioCallback.onError && typeof(audioCallback.onError) == 'function') audioCallback.onError(e);
|
||||||
|
audio.destroy(); //销毁音频实例
|
||||||
|
audio = null;
|
||||||
|
})
|
||||||
|
return audio;
|
||||||
|
}
|
||||||
|
audio.onPlay(() => {
|
||||||
|
if (audioCallback && audioCallback.onPlay && typeof(audioCallback.onPlay) == 'function') audioCallback.onPlay();
|
||||||
|
})
|
||||||
|
audio.onPause(()=>{
|
||||||
|
if (audioCallback && audioCallback.onPause && typeof(audioCallback.onPause) == 'function') audioCallback.onPause();
|
||||||
|
})
|
||||||
|
audio.onWaiting(()=>{
|
||||||
|
if (audioCallback && audioCallback.onWaiting && typeof(audioCallback.onWaiting) == 'function') audioCallback.onWaiting();
|
||||||
|
})
|
||||||
|
audio.onStop(()=>{
|
||||||
|
if (audioCallback && audioCallback.onStop && typeof(audioCallback.onStop) == 'function') audioCallback.onStop();
|
||||||
|
})
|
||||||
|
audio.onTimeUpdate(()=>{
|
||||||
|
if (audioCallback && audioCallback.onTimeUpdate && typeof(audioCallback.onTimeUpdate) == 'function') audioCallback.onTimeUpdate();
|
||||||
|
})
|
||||||
|
audio.onSeeking(()=>{
|
||||||
|
if (audioCallback && audioCallback.onSeeking && typeof(audioCallback.onSeeking) == 'function') audioCallback.onSeeking();
|
||||||
|
})
|
||||||
|
audio.onSeeked(()=>{
|
||||||
|
if (audioCallback && audioCallback.onSeeked && typeof(audioCallback.onSeeked) == 'function') audioCallback.onSeeked();
|
||||||
|
})
|
||||||
|
audio.onEnded(() => {
|
||||||
|
audio.destroy(); //销毁音频实例
|
||||||
|
audio = null;
|
||||||
|
if (audioCallback && audioCallback.onEnded && typeof(audioCallback.onEnded) == 'function') audioCallback.onEnded();
|
||||||
|
if (lineUp !== false) {
|
||||||
|
if (audioTeam.length > 0) {
|
||||||
|
openVoiceFc(audioTeam[0]);
|
||||||
|
audioTeam.splice(0, 1);
|
||||||
|
} else {
|
||||||
|
audioStartSwitch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
audio.onError((e)=>{
|
||||||
|
if (audioCallback && audioCallback.onError && typeof(audioCallback.onError) == 'function') audioCallback.onError(e);
|
||||||
|
audio.destroy(); //销毁音频实例
|
||||||
|
audio = null;
|
||||||
|
})
|
||||||
|
audio.play();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
import storageManage from '@/commons/utils/storageManage.js'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import baiduyy from './QS-baiduyy.js'; // 百度语音合成
|
||||||
|
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
import wxTextToSpeach from './wxTextToSpeach.js'; // 微信小程序插件语音合成
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
|
const model = {
|
||||||
|
// 监听推送通知
|
||||||
|
addPushMsgEventListener: function(){
|
||||||
|
|
||||||
|
console.log("监听推送")
|
||||||
|
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
// unipush1.0监听消息
|
||||||
|
if(plus && plus.push) {
|
||||||
|
plus.push.addEventListener('receive', model.handlePush)
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
// unipush2.0监听消息
|
||||||
|
model.uniPushListener2()
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// uniPush2.0 接收推送消息
|
||||||
|
uniPushListener2: function() {
|
||||||
|
uni.onPushMessage((res) => {
|
||||||
|
console.log("uniPush2.0 收到推送消息:", res.data) //监听推送消息
|
||||||
|
model.handlePush(res.data)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 语音播报
|
||||||
|
handlePush: function(message) {
|
||||||
|
|
||||||
|
// 没有token信息
|
||||||
|
if(!storageManage.token()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 信息不存在
|
||||||
|
if(!message || !message.content) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const content = JSON.parse(message.content)
|
||||||
|
console.log("消息内容:", content)
|
||||||
|
|
||||||
|
// 支付成功
|
||||||
|
if (content && content.type == 'paySuccess') {
|
||||||
|
// 在过期时间之内, 则调起语音播报。
|
||||||
|
if( dayjs(content.expiredTime).isAfter(dayjs()) ){
|
||||||
|
console.log('执行消息播报');
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
wxTextToSpeach(content.msg)
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifndef MP-WEIXIN
|
||||||
|
baiduyy(content.msg)
|
||||||
|
// #endif
|
||||||
|
uni.vibrateLong({});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
import {
|
||||||
|
$pushInfoRegister
|
||||||
|
} from '@/http/apiManager.js'
|
||||||
|
import storageManage from '@/commons/utils/storageManage.js'
|
||||||
|
// 默认导出 方法 注册 push连接
|
||||||
|
export default async function() {
|
||||||
|
let cid1 = undefined // unipush1.0 客户端CID
|
||||||
|
let cid2 = undefined // unipush2.0 客户端CID
|
||||||
|
let orgCid = undefined // 原始cid如果获取的cid和新的cid不相同赋值原始cid后端会根据原始cid更新
|
||||||
|
let cidType = undefined //传递类型 是 app 还是 微信
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
cidType = 'app_plus'
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
cidType = 'mp_weixin'
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
if (!plus) {
|
||||||
|
cid1 = plus.push.getClientInfo().clientid
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
const data = await uni.getPushClientId()
|
||||||
|
console.log('客户端推送标识:', data.cid)
|
||||||
|
cid2 = data.cid
|
||||||
|
// 如果不存 cid 本地存储 写入 cid
|
||||||
|
if (!storageManage.uniPush2Cid()) {
|
||||||
|
storageManage.uniPush2Cid(data.cid)
|
||||||
|
} else if (cid2 !== storageManage.uniPush2Cid()) { // 否则进行 cid 对比 判断 是否相等 不相等 赋值 orgCid
|
||||||
|
orgCid = storageManage.uniPush2Cid() //赋值原始cid
|
||||||
|
storageManage.uniPush2Cid(data.cid) //重新写入 cid
|
||||||
|
}
|
||||||
|
if (cid1) {
|
||||||
|
pushInfoRegister(cid1)
|
||||||
|
} else {
|
||||||
|
pushInfoRegister(cid1, cid2, orgCid, cidType)
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushInfoRegister(cid1 = '', cid2 = '', org = '', cidType = '') {
|
||||||
|
$pushInfoRegister({
|
||||||
|
cid1,
|
||||||
|
cid2,
|
||||||
|
orgCid: org,
|
||||||
|
cidType
|
||||||
|
}).then(res => {
|
||||||
|
orgCid = '' //重置 数据
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
import { $mchConfig } from "@/http/apiManager"
|
||||||
|
import storageManage from '@/commons/utils/storageManage.js'
|
||||||
|
let num = 0 //计算错误此时 超过5次错误 不在出触发
|
||||||
|
const plugin = requirePlugin("WechatSI")
|
||||||
|
const pushMsgArr = [] //维护一个消息队列
|
||||||
|
let backgroundAudioManager = undefined //获取背景音频实例
|
||||||
|
let audioMp3 = ''
|
||||||
|
console.log('执行创建 语音播报逻辑');
|
||||||
|
// 获取配置项 判断是否 开启 小程序 语音推送
|
||||||
|
export function getPushStatus () {
|
||||||
|
if (!storageManage.token()) return //未登录 不播放
|
||||||
|
$mchConfig('orderConfig').then(({ bizData = [] }) => {
|
||||||
|
const weChat = bizData.find(v => v.configKey == "weChatVoice")
|
||||||
|
if (weChat && weChat?.configVal == 1) {
|
||||||
|
createBgMusice()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// getPushStatus()
|
||||||
|
// 创建 背景音乐
|
||||||
|
function createBgMusice (file) {
|
||||||
|
backgroundAudioManager = wx.getBackgroundAudioManager()
|
||||||
|
backgroundAudioManager.title = '订单通知'
|
||||||
|
if (!audioMp3) {
|
||||||
|
createFile()
|
||||||
|
} else {
|
||||||
|
backgroundAudioManager.src = audioMp3
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听 音频播放失败事件
|
||||||
|
backgroundAudioManager.onError(function (res) {
|
||||||
|
console.log('音频播放失败', res, num);
|
||||||
|
if (num >= 5) return
|
||||||
|
createFile()
|
||||||
|
num++
|
||||||
|
})
|
||||||
|
// 监听 音频播放结束事件
|
||||||
|
onBgMusiceEnd()
|
||||||
|
}
|
||||||
|
// 监听bei背景音乐播放状态
|
||||||
|
export function onBgMusiceEnd () {
|
||||||
|
backgroundAudioManager.onEnded(() => {
|
||||||
|
if (pushMsgArr.length > 0) return broadcast(pushMsgArr.pop()) //如果有消息 则继续播放
|
||||||
|
backgroundAudioManager.src = audioMp3 //否则播放默认背景音乐
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function startOrEndMusice (flag) {
|
||||||
|
if (!flag && !!backgroundAudioManager) return backgroundAudioManager.stop() //关闭背景音乐 地址指向空即可
|
||||||
|
if (!backgroundAudioManager) return createBgMusice() // 如果一开始是关闭状态 则创建背景音乐实例
|
||||||
|
backgroundAudioManager.src = audioMp3 // 否则重新赋值背景音地址即可
|
||||||
|
}
|
||||||
|
export default function (message) {
|
||||||
|
if (!backgroundAudioManager) return
|
||||||
|
pushMsgArr.unshift(message) //将消息添加到消息队列头部 背景音乐播放结束后 会对消息队列 进行校验 如果消息队列有消息 会进行播放 否则继续循环背景音乐
|
||||||
|
}
|
||||||
|
// 播放订单
|
||||||
|
function broadcast (msg) {
|
||||||
|
plugin.textToSpeech({
|
||||||
|
lang: "zh_CN",
|
||||||
|
tts: true,
|
||||||
|
content: msg,
|
||||||
|
success: function (res) {
|
||||||
|
backgroundAudioManager.src = res.filename;
|
||||||
|
onBgMusiceEnd()
|
||||||
|
},
|
||||||
|
fail: function (res) {
|
||||||
|
console.log("fail tts", res)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建文件
|
||||||
|
export function createFile (file) {
|
||||||
|
const fs = wx.getFileSystemManager()
|
||||||
|
fs.copyFile({
|
||||||
|
srcPath: `static/noiseless.mp3`,
|
||||||
|
destPath: `${wx.env.USER_DATA_PATH}/noiseless.mp3`,
|
||||||
|
success (res) {
|
||||||
|
console.log(res, `${wx.env.USER_DATA_PATH}/noiseless.mp3`)
|
||||||
|
audioMp3 = `${wx.env.USER_DATA_PATH}/noiseless.mp3`
|
||||||
|
backgroundAudioManager.src = audioMp3
|
||||||
|
},
|
||||||
|
fail (res) {
|
||||||
|
console.error(res)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
创建 云空间 上传云函数 云函数 url化 运营平台 配置云函数地址
|
||||||
|
|
||||||
|
打包时 勾选云push 2.0 push1.0 仅支持 app 推送
|
||||||
|
|
||||||
|
注意配置 百度语音相关参数
|
||||||
|
|
||||||
|
使用push2.0 请将 static\noiseless.mp3 文件 配置到运营平台 系统 配置 通知配置 push2.0 uniPush语音播报音频文件(小程序播报必填) 下
|
||||||
|
|
||||||
|
注意:扩展库依赖3张opendb表:opendb-tempdata,opendb-device,uni-id-device。公测版uniCloud,执行扩展库会自动创建。如果你使用的是uniCloud正式版需要自己创建这3张表。
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,7 @@
|
||||||
|
export const objToArrary = (obj,keyNewName) => {
|
||||||
|
return Object.entries(obj).map(([key, value]) => ({
|
||||||
|
key,
|
||||||
|
[keyNewName]:key,
|
||||||
|
...value,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
|
||||||
|
|
||||||
|
// 密钥对生成 http://web.chacuo.net/netrsakeypair
|
||||||
|
|
||||||
|
const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' +
|
||||||
|
'2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ=='
|
||||||
|
|
||||||
|
// 加密
|
||||||
|
export function encrypt(txt) {
|
||||||
|
const encryptor = new JSEncrypt()
|
||||||
|
encryptor.setPublicKey(publicKey) // 设置公钥
|
||||||
|
return encryptor.encrypt(txt) // 对需要加密的数据进行加密
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
import {
|
||||||
|
getCurrentInstance,
|
||||||
|
} from 'vue';
|
||||||
|
export async function getElRect(elClass, instance,option) {
|
||||||
|
instance = instance ? instance : getCurrentInstance();
|
||||||
|
const query = uni.createSelectorQuery().in(instance.proxy);
|
||||||
|
try{
|
||||||
|
const res= await getEle(query,elClass,option)
|
||||||
|
return res
|
||||||
|
}catch(e){
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function getEle(query,elClass,option){
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
query.select('.' + elClass).fields({
|
||||||
|
size: true,
|
||||||
|
...option
|
||||||
|
}, res => {
|
||||||
|
// 如果节点尚未生成,res值为null,循环调用执行
|
||||||
|
if (!res) {
|
||||||
|
return setTimeout(() => {
|
||||||
|
getEle(query,elClass,option);
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
|
resolve(res);
|
||||||
|
}).exec();
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getSafeBottomHeight(className, height = 16) {
|
||||||
|
const bottomEle = await getElRect(className)
|
||||||
|
return bottomEle.height + height
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
// 保存图片
|
||||||
|
export function saveHeadImgFile(base64, quality) {
|
||||||
|
const bitmap = new plus.nativeObj.Bitmap("test");
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// 从本地加载Bitmap图片
|
||||||
|
bitmap.loadBase64Data(base64, function() {
|
||||||
|
const url = "_doc/" + getTimeStamps() + ".png"; // url为时间戳命名方式
|
||||||
|
|
||||||
|
bitmap.save(url, {
|
||||||
|
overwrite: true, // 是否覆盖
|
||||||
|
quality: quality // 图片清晰度
|
||||||
|
}, (i) => {
|
||||||
|
console.log(url)
|
||||||
|
uni.saveImageToPhotosAlbum({
|
||||||
|
filePath: url,
|
||||||
|
success: function() {
|
||||||
|
resolve({
|
||||||
|
code: 0,
|
||||||
|
msg: '保存成功',
|
||||||
|
filePath: url
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fail:function(){
|
||||||
|
msg:'保存失败'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, (e) => {
|
||||||
|
reject('保存图片失败:' + JSON.stringify(e));
|
||||||
|
});
|
||||||
|
}, (e) => {
|
||||||
|
reject('加载图片失败:' + JSON.stringify(e));
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTimeStamps (){
|
||||||
|
return (new Date()).valueOf()
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,290 @@
|
||||||
|
/**
|
||||||
|
* 存储管理对象
|
||||||
|
* 目标:将现有系统的所有需要存储的数据,统一管理
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2022/04/13 07:18
|
||||||
|
*/
|
||||||
|
|
||||||
|
import appConfig from "@/config/appConfig.js"
|
||||||
|
|
||||||
|
// 应用级(vue级别)缓存, 当存在时则读取此值, 否则读取storage中的值。( vue线程内的缓存,不必要每次读取应用数据,影响性能)
|
||||||
|
const appCache = {
|
||||||
|
tokenVal: null, // token取值
|
||||||
|
currentUser: null, // 当前商户信息
|
||||||
|
}
|
||||||
|
|
||||||
|
const model = {
|
||||||
|
|
||||||
|
setLogin(res){
|
||||||
|
const user=res.user.user
|
||||||
|
uni.setStorageSync('logoutHandle',false)
|
||||||
|
uni.setStorageSync('shopId', res.shopId)
|
||||||
|
uni.setStorageSync('shopName',res.shopName)
|
||||||
|
uni.setStorageSync('logo',res.logo)
|
||||||
|
uni.setStorageSync('loginType',res.loginType)
|
||||||
|
uni.setStorageSync('shopUserId',user.id)
|
||||||
|
if(res.loginType=='staff'){
|
||||||
|
uni.setStorageSync('merchantName',user.createBy||user.updateBy)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 退出清空所有的缓存数据。 (不包含 环境相关)
|
||||||
|
cleanByLogout: () => {
|
||||||
|
// 1. 清空app级别缓存。
|
||||||
|
Object.keys(appCache).forEach(k => appCache[k] = null)
|
||||||
|
const merchantName=uni.getStorageSync('merchantName')
|
||||||
|
const MerchantId=uni.getStorageSync('MerchantId')
|
||||||
|
let envName = model.env() // 获取到当前的环境变量
|
||||||
|
uni.clearStorageSync() // 清除所有的缓存信息
|
||||||
|
uni.setStorageSync('merchantName',merchantName)
|
||||||
|
uni.setStorageSync('MerchantId',MerchantId)
|
||||||
|
model.env(envName) // 重置env
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取和放置token
|
||||||
|
token: (val, isDelete = false) => {
|
||||||
|
if (isDelete) {
|
||||||
|
appCache.tokenVal = ""
|
||||||
|
return uni.removeStorageSync(appConfig.tokenKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val) {
|
||||||
|
// 有值,为放置
|
||||||
|
appCache.tokenVal = val
|
||||||
|
uni.setStorageSync(appConfig.tokenKey, val)
|
||||||
|
} else {
|
||||||
|
// 否则为获取
|
||||||
|
|
||||||
|
if (!appCache.tokenVal) {
|
||||||
|
//缓存取不到,获取应用本地信息
|
||||||
|
appCache.tokenVal = uni.getStorageSync(appConfig.tokenKey)
|
||||||
|
}
|
||||||
|
return appCache.tokenVal
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 获取和放置shopId
|
||||||
|
shopId: (val, isDelete = false) => {
|
||||||
|
if (isDelete) {
|
||||||
|
appCache.shopId = ""
|
||||||
|
return uni.removeStorageSync('shopId')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val) {
|
||||||
|
// 有值,为放置
|
||||||
|
appCache.shopId = val
|
||||||
|
uni.setStorageSync('shopId', val)
|
||||||
|
} else {
|
||||||
|
// 否则为获取
|
||||||
|
|
||||||
|
if (!appCache.shopId) {
|
||||||
|
//缓存取不到,获取应用本地信息
|
||||||
|
appCache.shopId = uni.getStorageSync('shopId')
|
||||||
|
}
|
||||||
|
return appCache.shopId
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 获取和放置店铺员工id
|
||||||
|
shopUserId: (val, isDelete = false) => {
|
||||||
|
if (isDelete) {
|
||||||
|
appCache.shopUserId = ""
|
||||||
|
return uni.removeStorageSync('shopUserId')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val) {
|
||||||
|
// 有值,为放置
|
||||||
|
appCache.shopUserId = val
|
||||||
|
uni.setStorageSync('shopUserId', val)
|
||||||
|
} else {
|
||||||
|
// 否则为获取
|
||||||
|
|
||||||
|
if (!appCache.shopUserId) {
|
||||||
|
//缓存取不到,获取应用本地信息
|
||||||
|
appCache.shopUserId = uni.getStorageSync('shopUserId')
|
||||||
|
}
|
||||||
|
return appCache.shopUserId
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 获取和放置useType就餐类型
|
||||||
|
useType: (val, isDelete = false) => {
|
||||||
|
if (isDelete) {
|
||||||
|
appCache.useType = ""
|
||||||
|
return uni.removeStorageSync('useType')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val) {
|
||||||
|
// 有值,为放置
|
||||||
|
appCache.useType = val
|
||||||
|
uni.setStorageSync('useType', val)
|
||||||
|
} else {
|
||||||
|
// 否则为获取
|
||||||
|
|
||||||
|
if (!appCache.useType) {
|
||||||
|
//缓存取不到,获取应用本地信息
|
||||||
|
appCache.useType = uni.getStorageSync('useType')
|
||||||
|
}
|
||||||
|
return appCache.useType
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 缓存代客下单商品
|
||||||
|
cacheGoods: (val, isDelete = false) => {
|
||||||
|
if (isDelete) {
|
||||||
|
appCache.cacheGoods = ""
|
||||||
|
return uni.removeStorageSync('cacheGoods')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val) {
|
||||||
|
// 有值,为放置
|
||||||
|
appCache.cacheGoods = val
|
||||||
|
uni.setStorageSync('cacheGoods', val)
|
||||||
|
} else {
|
||||||
|
// 否则为获取
|
||||||
|
|
||||||
|
if (!appCache.cacheGoods) {
|
||||||
|
//缓存取不到,获取应用本地信息
|
||||||
|
appCache.cacheGoods = uni.getStorageSync('cacheGoods')
|
||||||
|
}
|
||||||
|
return appCache.cacheGoods
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 缓存代客下单商品节点信息缓存
|
||||||
|
cacheGoodsNode: (val, isDelete = false) => {
|
||||||
|
if (isDelete) {
|
||||||
|
appCache.cacheGoodsNode = ""
|
||||||
|
return uni.removeStorageSync('cacheGoodsNode')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val) {
|
||||||
|
// 有值,为放置
|
||||||
|
appCache.cacheGoodsNode = val
|
||||||
|
uni.setStorageSync('cacheGoodsNode', val)
|
||||||
|
} else {
|
||||||
|
// 否则为获取
|
||||||
|
|
||||||
|
if (!appCache.cacheGoodsNode) {
|
||||||
|
//缓存取不到,获取应用本地信息
|
||||||
|
appCache.cacheGoodsNode = uni.getStorageSync('cacheGoodsNode')
|
||||||
|
}
|
||||||
|
return appCache.cacheGoodsNode
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 已经登录的用户记录
|
||||||
|
loggedInUser: (addUserName = null, removeUserName = null) => {
|
||||||
|
let key = "loggedInUserList"
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
if (removeUserName) {
|
||||||
|
let nameList = uni.getStorageSync(key) || []
|
||||||
|
if (nameList.length <= 0) {
|
||||||
|
//不存在数据
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
let hasUserIndex = nameList.indexOf(removeUserName)
|
||||||
|
if (hasUserIndex >= 0) {
|
||||||
|
nameList.splice(hasUserIndex, 1) //删除
|
||||||
|
uni.setStorageSync(key, nameList)
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 有新插入的记录
|
||||||
|
if (addUserName) {
|
||||||
|
let nameList = uni.getStorageSync(key) || []
|
||||||
|
|
||||||
|
let hasUser = false
|
||||||
|
for (let i = 0; i < nameList.length; i++) {
|
||||||
|
if (nameList[i] == addUserName) {
|
||||||
|
hasUser = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 包含记录
|
||||||
|
if (hasUser) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 最多存储 5 个
|
||||||
|
if (nameList.length >= 5) {
|
||||||
|
nameList.splice(0, 1) //删除第一个
|
||||||
|
}
|
||||||
|
nameList.push(addUserName)
|
||||||
|
uni.setStorageSync(key, nameList)
|
||||||
|
|
||||||
|
//获取
|
||||||
|
} else {
|
||||||
|
return uni.getStorageSync(key) || [] //默认空数组
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 用户信息
|
||||||
|
userInfo: (currentUserInfo) => {
|
||||||
|
if (currentUserInfo) {
|
||||||
|
// 仅保存基础数据
|
||||||
|
let saveUser = {
|
||||||
|
|
||||||
|
sysUserId: currentUserInfo.sysUserId, // 用户ID
|
||||||
|
realname: currentUserInfo.realname, // 用户姓名
|
||||||
|
avatarUrl: currentUserInfo.avatarUrl, // 头像
|
||||||
|
telphone: currentUserInfo.telphone, // 手机号
|
||||||
|
userType: currentUserInfo.userType, // 用户类型
|
||||||
|
|
||||||
|
mchNo: currentUserInfo.userNo, // 商户No
|
||||||
|
mchShortName: currentUserInfo.shortName, // 商户简称
|
||||||
|
mchType: currentUserInfo.mchType, // 商户类型
|
||||||
|
mchLevel: currentUserInfo.mchLevel, // 商户级别
|
||||||
|
isHasMemberEnt:currentUserInfo.isHasMemberEnt,// 是否购买会员模块
|
||||||
|
entIdList: currentUserInfo.entIdList, // 权限集合List
|
||||||
|
|
||||||
|
}
|
||||||
|
uni.setStorageSync("currentUserInfo", saveUser) // 改变存储
|
||||||
|
appCache.currentUser = null
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!appCache.currentUser){ // 获取缓存数据
|
||||||
|
appCache.currentUser = uni.getStorageSync("currentUserInfo")
|
||||||
|
}
|
||||||
|
|
||||||
|
return appCache.currentUser
|
||||||
|
},
|
||||||
|
|
||||||
|
// 项目环境变量:(测试、 生产的切换)
|
||||||
|
env: (envMode) => {
|
||||||
|
if (envMode) {
|
||||||
|
uni.setStorageSync(appConfig.storeEnvEnumKey, envMode) // 改变存储
|
||||||
|
}
|
||||||
|
return uni.getStorageSync(appConfig.storeEnvEnumKey)
|
||||||
|
},
|
||||||
|
|
||||||
|
// push 状态是否开启
|
||||||
|
pushIsOpen: (pushFlag) => {
|
||||||
|
if (pushFlag) {
|
||||||
|
uni.setStorageSync('pushFlag', pushFlag) // 改变存储
|
||||||
|
}
|
||||||
|
return uni.getStorageSync('pushFlag')
|
||||||
|
},
|
||||||
|
// 网站信息
|
||||||
|
siteInfos: (siteInfos) => {
|
||||||
|
if (siteInfos) {
|
||||||
|
uni.setStorageSync("siteInfos", siteInfos) // 改变存储
|
||||||
|
}
|
||||||
|
return uni.getStorageSync("siteInfos")
|
||||||
|
},
|
||||||
|
|
||||||
|
// unipush2 cid
|
||||||
|
uniPush2Cid: (uniPush2Cid) => {
|
||||||
|
if (uniPush2Cid) {
|
||||||
|
uni.setStorageSync("uniPush2Cid", uniPush2Cid) // 改变存储
|
||||||
|
}
|
||||||
|
return uni.getStorageSync("uniPush2Cid")
|
||||||
|
},
|
||||||
|
uploadImgSize: (uploadImgSize) => {
|
||||||
|
if (uploadImgSize) {
|
||||||
|
uni.setStorageSync("uploadImgSize", uploadImgSize) // 存储 上传 图片大小限制
|
||||||
|
}
|
||||||
|
return uni.getStorageSync("uploadImgSize")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import dayjs from 'dayjs' //时间格式库
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
// 时间校验 用于筛选 开始 时间不能大于结束 开始结束时间必选 时间 返回值 true 和 false
|
||||||
|
export const startAndEndTime = (start, end) => {
|
||||||
|
if (!start || !end) {
|
||||||
|
infoBox.showToast('请选择开始或结束时间')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (dayjs(start).isAfter(end)) {
|
||||||
|
infoBox.showToast('开始时间不能大于结束时间')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
/**
|
||||||
|
* 任务执行器
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeepay.vip
|
||||||
|
* @date 2022/11/15 16:30
|
||||||
|
*/
|
||||||
|
const model = {
|
||||||
|
|
||||||
|
|
||||||
|
// 任务启动工具, 每 xxs调用一次, 知道多次x次为止。
|
||||||
|
// 注意: 启动后将立马调用一次, 而不是1s后再调用。
|
||||||
|
|
||||||
|
// 参数:
|
||||||
|
// allCount: 全部的次数 (支持promise 并不一定是 秒)
|
||||||
|
// stepSecond : 步伐(单位: 秒)
|
||||||
|
// callbackFunc 回调函数, 支持返回 boolean 或者 promise ,
|
||||||
|
// 注意: boolean类型: true 进入下一次循环, false: 停止任务。
|
||||||
|
// promise类型: then 进入下一次循环, catch: 停止任务。
|
||||||
|
startTimeoutTask: (stepSecond, allCount, callbackFunc) => {
|
||||||
|
|
||||||
|
// 不存在回调函数
|
||||||
|
if(!callbackFunc){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let callbackResult = callbackFunc(allCount)
|
||||||
|
|
||||||
|
// 明确返回false, 说明不再循环
|
||||||
|
if(callbackResult === false){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不包含剩余次数了。
|
||||||
|
if(allCount <= 0){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// promise
|
||||||
|
if(typeof callbackResult == 'object'){
|
||||||
|
|
||||||
|
callbackResult.then(() => {
|
||||||
|
setTimeout(() => model.startTimeoutTask(stepSecond, --allCount, callbackFunc), (stepSecond * 1000) )
|
||||||
|
})
|
||||||
|
|
||||||
|
}else{ // 其他boolean类型, 或返回不明确, 继续下一次任务。
|
||||||
|
|
||||||
|
setTimeout(() => model.startTimeoutTask(stepSecond, --allCount, callbackFunc), (stepSecond * 1000) )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
/**
|
||||||
|
* 统一扫码, 支持登录、 码牌绑定、 打印机、 等
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeepay.vip
|
||||||
|
* @date 2022/11/22 10:38
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { $parseQrCodeUrl } from '@/http/apiManager.js'
|
||||||
|
|
||||||
|
const model = {
|
||||||
|
|
||||||
|
// 扫码结果类型
|
||||||
|
QR_TYPE_LOGIN: 'QR_TYPE_LOGIN', // 登录
|
||||||
|
QR_TYPE_QRC: 'QR_TYPE_QRC', // 码牌
|
||||||
|
QR_TYPE_PRINTER: 'QR_TYPE_PRINTER', // 打印机
|
||||||
|
QR_TYPE_OTHER: 'QR_TYPE_OTHER', // 其他
|
||||||
|
|
||||||
|
|
||||||
|
returnFunc: (type, bizValue, originQrVal) => {
|
||||||
|
return { type: type, bizValue: bizValue, originQrVal: originQrVal}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 解析 码牌
|
||||||
|
parseQrc: (originQrVal) => {
|
||||||
|
return $parseQrCodeUrl(originQrVal).then( ({bizData}) => {
|
||||||
|
return model.returnFunc(model.QR_TYPE_QRC, bizData, originQrVal)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// 返回 类型 和 扫码的值
|
||||||
|
// 参数: 是否解析qrc , 默认不解析
|
||||||
|
scan: (isParseQRC = false) => {
|
||||||
|
|
||||||
|
return uni.scanCode().then(({ result }) => {
|
||||||
|
|
||||||
|
// 登录类型
|
||||||
|
if(result.startsWith("JEEPAY_LOGIN_QR_")){
|
||||||
|
return model.returnFunc(model.QR_TYPE_LOGIN, result.substring(16), result)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(isParseQRC){
|
||||||
|
return model.parseQrc(result).then( (res) => {
|
||||||
|
return res;
|
||||||
|
}).catch(() => {
|
||||||
|
return model.returnFunc(model.QR_TYPE_OTHER, result, result)
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
|
||||||
|
return model.returnFunc(model.QR_TYPE_OTHER, result, result)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default model
|
||||||
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
export default {
|
||||||
|
get(key) {
|
||||||
|
return uni.getStorageSync(key)
|
||||||
|
},
|
||||||
|
set(key, value) {
|
||||||
|
uni.setStorageSync(key, value)
|
||||||
|
},
|
||||||
|
del(key) {
|
||||||
|
uni.removeStorageSync(key)
|
||||||
|
},
|
||||||
|
clear() {
|
||||||
|
uni.clearStorageSync()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
import { $versionDetection } from '@/http/apiManager.js';
|
||||||
|
import appConfig from '@/config/appConfig.js'
|
||||||
|
|
||||||
|
// app更新
|
||||||
|
function appPlusUpdate(sign){
|
||||||
|
|
||||||
|
// 获取版本号
|
||||||
|
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
|
||||||
|
|
||||||
|
// 调起接口查询
|
||||||
|
$versionDetection({versionNumber: inf.versionCode})
|
||||||
|
.then(({ bizData }) => {
|
||||||
|
|
||||||
|
//返回data为空或者版本号一致
|
||||||
|
if (!bizData || Object.keys(bizData).length == 0 || !bizData.versionSerialNumber || bizData.versionSerialNumber == inf.versionCode) {
|
||||||
|
if(sign === 'checked') {
|
||||||
|
uni.showToast({
|
||||||
|
title: '已是最新版本'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 是否强制更新
|
||||||
|
let isForceUpdate = bizData.forceUpdate == 1
|
||||||
|
uni.showModal({
|
||||||
|
title: '发现新版本:' + bizData.versionName,
|
||||||
|
showCancel: !isForceUpdate ,
|
||||||
|
content: bizData.versionDesc,
|
||||||
|
confirmText: '立即更新',
|
||||||
|
confirmColor: '#108EE9',
|
||||||
|
success: function(r) {
|
||||||
|
if (r.confirm) {
|
||||||
|
downLoad(bizData.downloadUrl);
|
||||||
|
}else{
|
||||||
|
// 强制更新也需要更新
|
||||||
|
if(isForceUpdate){
|
||||||
|
downLoad(bizData.downloadUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//下载更新包
|
||||||
|
function downLoad(url) {
|
||||||
|
|
||||||
|
if (!url) {
|
||||||
|
uni.showToast({icon: 'none',title: '下载地址错误'});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 下载文件
|
||||||
|
uni.showLoading({title: '更新中'});
|
||||||
|
uni.downloadFile({
|
||||||
|
url: url,
|
||||||
|
success: res => {
|
||||||
|
uni.hideLoading();
|
||||||
|
if (res.statusCode === 200) {
|
||||||
|
uni.showToast({title: '下载成功'});
|
||||||
|
plus.runtime.install(res.tempFilePath);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: res => {
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获取当前版本 & 检查
|
||||||
|
export function getCurrentVersionPromise() {
|
||||||
|
let isApp = false
|
||||||
|
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
isApp = true
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
if(!isApp){
|
||||||
|
return Promise.reject()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取版本号
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
|
||||||
|
resolve(inf)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前版本 & 检查
|
||||||
|
export function checkCurrVersion(sign) {
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
switch(uni.getSystemInfoSync().platform){
|
||||||
|
case 'android':
|
||||||
|
appPlusUpdate(sign) //仅安卓更新
|
||||||
|
break;
|
||||||
|
case 'ios':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//同步取出ext.json对象
|
||||||
|
export function getExtStoreId(){
|
||||||
|
try{
|
||||||
|
const extConfig = uni.getExtConfigSync()
|
||||||
|
if(extConfig.domain){
|
||||||
|
appConfig.env.JEEPAY_BASE_URL = extConfig.domain
|
||||||
|
}
|
||||||
|
// uni.showToast({title: JSON.stringify(extConfig),icon:"none",duration:3000});
|
||||||
|
console.log(extConfig,'extJson对象');
|
||||||
|
return extConfig;
|
||||||
|
}catch(err){
|
||||||
|
console.log(err,'getExtStoreId__error')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export const $weeks=['周一','周二','周三','周四','周五','周六','周日'];
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
<!--
|
||||||
|
组件功能: 对button的封装
|
||||||
|
@author terrfly
|
||||||
|
@site https://www.jeequan.com
|
||||||
|
@date 2022/12/05 14:39
|
||||||
|
-->
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<button class="jeepay-btn" hover-class="jeepay-hover-button">
|
||||||
|
<slot />
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.jeepay-btn {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 110rpx;
|
||||||
|
font-size: 33rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
color: $J-color-tff;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
background: $jeepay-bg-primary;
|
||||||
|
box-shadow: 0 20rpx 60rpx -20rpx rgba(0,84,210,0.5);
|
||||||
|
&.jeepay-hover-button {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,208 @@
|
||||||
|
<template>
|
||||||
|
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||||
|
<template #desc>
|
||||||
|
<view class="u-text-left u-p-30 color-666">
|
||||||
|
<view class="u-m-t-32 u-flex ">
|
||||||
|
<view>应付金额</view>
|
||||||
|
<view class="u-m-l-32">
|
||||||
|
{{form.price}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-t-40 u-flex ">
|
||||||
|
<view>实收金额</view>
|
||||||
|
<view class="u-m-l-32 border u-p-l-10 u-p-r-10 u-flex-1">
|
||||||
|
<uni-easyinput type="number" @input="currentPriceInput" @change="currentPriceChange" paddingNone :inputBorder="false"
|
||||||
|
v-model="form.currentPrice"
|
||||||
|
placeholder="输入实际金额"></uni-easyinput>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-t-54 u-flex ">
|
||||||
|
<view>优惠折扣</view>
|
||||||
|
<view class="u-m-l-32 u-flex-1 u-flex border u-p-l-10 u-p-r-10">
|
||||||
|
<view class="u-flex-1">
|
||||||
|
<uni-easyinput type="number" @input="discountInput" @change="discountChange" paddingNone :inputBorder="false"
|
||||||
|
v-model="form.discount"
|
||||||
|
placeholder="输入折扣"></uni-easyinput>
|
||||||
|
</view>
|
||||||
|
<view class="u-font-32 color-333">%</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<template #btn>
|
||||||
|
<view class="u-p-30">
|
||||||
|
<view class="u-m-t-10">
|
||||||
|
<my-button @tap="confirm" shape="circle" fontWeight="700" >修改</my-button>
|
||||||
|
<view class="">
|
||||||
|
<my-button @tap="close" type="cancel" bgColor="#fff" >取消</my-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</my-model>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
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
|
||||||
|
},
|
||||||
|
price: {
|
||||||
|
type: [Number,String],
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
function currentPriceInput(newval){
|
||||||
|
form.discount=(newval*100/form.price).toFixed()
|
||||||
|
}
|
||||||
|
function discountInput(newval){
|
||||||
|
form.currentPrice=(form.price*newval/100).toFixed(2)
|
||||||
|
}
|
||||||
|
function currentPriceChange(newval){
|
||||||
|
if(newval<0){
|
||||||
|
form.currentPrice=0
|
||||||
|
form.discount=100
|
||||||
|
return infoBox.showToast('实收金额不能小于0')
|
||||||
|
}
|
||||||
|
if(newval>props.price){
|
||||||
|
form.currentPrice=props.price
|
||||||
|
form.discount=0
|
||||||
|
return infoBox.showToast('实收金额不能大于应付金额')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function discountChange(newval){
|
||||||
|
if(newval<0){
|
||||||
|
form.currentPrice=props.price
|
||||||
|
form.discount=0
|
||||||
|
return infoBox.showToast('优惠折扣不能小于0')
|
||||||
|
}
|
||||||
|
if(newval>100){
|
||||||
|
form.discount=100
|
||||||
|
form.currentPrice=0
|
||||||
|
return infoBox.showToast('优惠折扣不能大于100')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const $form = {
|
||||||
|
price:props.price,
|
||||||
|
currentPrice: props.price,
|
||||||
|
discount: 100
|
||||||
|
}
|
||||||
|
const form = reactive({
|
||||||
|
...$form
|
||||||
|
})
|
||||||
|
watch(()=>props.price,(newval)=>{
|
||||||
|
console.log(newval);
|
||||||
|
form.price=newval
|
||||||
|
form.currentPrice=newval
|
||||||
|
})
|
||||||
|
function resetForm() {
|
||||||
|
Object.assign(form, {
|
||||||
|
...$form
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const model = ref(null)
|
||||||
|
|
||||||
|
function open() {
|
||||||
|
model.value.open()
|
||||||
|
form.price=props.price
|
||||||
|
form.currentPrice=props.price
|
||||||
|
form.discount=props.discount
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
model.value.close()
|
||||||
|
}
|
||||||
|
const emits = defineEmits(['confirm'])
|
||||||
|
|
||||||
|
function confirm() {
|
||||||
|
console.log(form);
|
||||||
|
emits('confirm',{...form,currentPrice:Number(form.currentPrice).toFixed(2)})
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
defineExpose({
|
||||||
|
open,
|
||||||
|
close
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.border{
|
||||||
|
border-radius: 8rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
border-color: #999;
|
||||||
|
}
|
||||||
|
.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>
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
<template>
|
||||||
|
<view class="action-sheet" @tap="close" v-if="show">
|
||||||
|
<view class="box">
|
||||||
|
<slot name="title">
|
||||||
|
</slot>
|
||||||
|
<view class="item" @tap.stop="itemClick(index)" v-for="(item,index) in props.list" :key="index">
|
||||||
|
<button class="bg-fff btn" hover-class="btn-hover-class" :class="{'color-main':active==index}">{{item}}</button>
|
||||||
|
</view>
|
||||||
|
<view class="bock-gary"></view>
|
||||||
|
<view class="cancel-btn" @tap="close">
|
||||||
|
<button>取消</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
const props=defineProps({
|
||||||
|
//那个按钮文字高亮
|
||||||
|
active:{
|
||||||
|
type:Number,
|
||||||
|
default:-1
|
||||||
|
},
|
||||||
|
autoClose:{
|
||||||
|
type:Boolean,
|
||||||
|
default:true
|
||||||
|
},
|
||||||
|
title:{
|
||||||
|
type:String,
|
||||||
|
default:''
|
||||||
|
},
|
||||||
|
list:{
|
||||||
|
type:Array,
|
||||||
|
default:['编辑','删除']
|
||||||
|
},
|
||||||
|
show:{
|
||||||
|
type:Boolean,
|
||||||
|
default:false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const emits=defineEmits(['itemClick','close'])
|
||||||
|
let show=ref(false)
|
||||||
|
function open(){
|
||||||
|
show.value=true
|
||||||
|
}
|
||||||
|
function close(){
|
||||||
|
show.value=false
|
||||||
|
emits('close')
|
||||||
|
}
|
||||||
|
function itemClick(index){
|
||||||
|
if(props.autoClose){
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
emits('itemClick',index)
|
||||||
|
}
|
||||||
|
defineExpose({
|
||||||
|
open,close
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
$bg:rgb(240, 240, 240);
|
||||||
|
.action-sheet{
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
top: 0;
|
||||||
|
background-color: rgba(51,51,51,.5);
|
||||||
|
z-index: 999;
|
||||||
|
.box{
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
border-radius: 20rpx 20rpx 0rpx 0rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #fff;
|
||||||
|
/* #ifndef H5 */
|
||||||
|
padding-bottom: calc(24rpx + constant(safe-area-inset-bottom));
|
||||||
|
padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
|
.item{
|
||||||
|
text-align: center;
|
||||||
|
font-size: 32rpx;
|
||||||
|
border-bottom: 1px solid $bg;
|
||||||
|
.btn{
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bock-gary{
|
||||||
|
background-color: $bg;
|
||||||
|
height: 20rpx;
|
||||||
|
}
|
||||||
|
.cancel-btn{
|
||||||
|
text-align: center;
|
||||||
|
font-size: 32rpx;
|
||||||
|
}
|
||||||
|
.btn-hover-class{
|
||||||
|
background-color: rgb(222, 222, 222);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,158 @@
|
||||||
|
<template>
|
||||||
|
<view class="">
|
||||||
|
<button class="btn" hover-class="btn-hover-class"
|
||||||
|
@tap="tap"
|
||||||
|
@click="click"
|
||||||
|
:disabled="disabled"
|
||||||
|
:style="computeStyle()"
|
||||||
|
:class="[returnShape,returnType,returnShadow,returnDisabled]"
|
||||||
|
>
|
||||||
|
<view class="u-flex u-row-center u-col-center auto-center">
|
||||||
|
<slot></slot>
|
||||||
|
</view>
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed } from 'vue';
|
||||||
|
const props=defineProps({
|
||||||
|
disabled:{
|
||||||
|
type:Boolean,
|
||||||
|
default:false
|
||||||
|
},
|
||||||
|
plain:{
|
||||||
|
type:Boolean,
|
||||||
|
default:false
|
||||||
|
},
|
||||||
|
borderRadius:{
|
||||||
|
type:String,
|
||||||
|
default:''
|
||||||
|
},
|
||||||
|
bgColor:{
|
||||||
|
type:String,
|
||||||
|
default:''
|
||||||
|
},
|
||||||
|
color:{
|
||||||
|
type:String
|
||||||
|
},
|
||||||
|
shape:{
|
||||||
|
//circle square
|
||||||
|
type:String,
|
||||||
|
default:'square'
|
||||||
|
},
|
||||||
|
type:{
|
||||||
|
type:String,
|
||||||
|
default:'primary'
|
||||||
|
},
|
||||||
|
width:{
|
||||||
|
type:[String,Number],
|
||||||
|
default:''
|
||||||
|
},
|
||||||
|
height:{
|
||||||
|
type:[String,Number],
|
||||||
|
default:'80'
|
||||||
|
},
|
||||||
|
fontSize:{
|
||||||
|
type:[String,Number],
|
||||||
|
default:'28'
|
||||||
|
},
|
||||||
|
fontWeight:{
|
||||||
|
type:[String,Number],
|
||||||
|
default:'500'
|
||||||
|
},
|
||||||
|
showShadow:{
|
||||||
|
type:Boolean,
|
||||||
|
default:false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const emits=defineEmits(['click','tap'])
|
||||||
|
function tap(){
|
||||||
|
emits('tap')
|
||||||
|
}
|
||||||
|
function click(){
|
||||||
|
emits('click')
|
||||||
|
}
|
||||||
|
const shapeClassList={circle:'circle',square:'square'}
|
||||||
|
const typeClassList={primary:'primary',default:'default',cancel:'cancel'}
|
||||||
|
const returnShape= computed(()=>{
|
||||||
|
return shapeClassList[props.shape]
|
||||||
|
})
|
||||||
|
const returnShadow=computed(()=>{
|
||||||
|
return props.showShadow?'shadow':''
|
||||||
|
})
|
||||||
|
const returnDisabled=computed(()=>{
|
||||||
|
return props.disabled?'disabled':''
|
||||||
|
})
|
||||||
|
const returnType=computed(()=>{
|
||||||
|
if(props.plain){
|
||||||
|
return 'plain-'+typeClassList[props.type]+' '+' plain'
|
||||||
|
}
|
||||||
|
return typeClassList[props.type]
|
||||||
|
})
|
||||||
|
function computeStyle(){
|
||||||
|
return `
|
||||||
|
line-height:${props.height}rpx;
|
||||||
|
${props.width>=0?('width:'+props.width+'rpx;'):''}
|
||||||
|
${props.plain?('background-color:transparent;'):''}
|
||||||
|
font-size:${props.fontSize}rpx;
|
||||||
|
font-weight:${props.fontWeight};
|
||||||
|
${props.color?('color:'+props.color+';'):''}
|
||||||
|
${props.bgColor?('background-color:'+props.bgColor+';'):''}
|
||||||
|
${props.bgColor?('border-color:'+props.bgColor+';'):''}
|
||||||
|
${props.borderRadius?('border-radius:'+props.borderRadius+';'):''}
|
||||||
|
`
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.auto-center{
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
.shadow{
|
||||||
|
// box-shadow: 0 0 10px #aaa;
|
||||||
|
box-shadow: 0 20rpx 60rpx -20rpx rgba(0,84,210,0.5);
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
font-size: 28rpx;
|
||||||
|
border:1px solid transparent ;
|
||||||
|
&.disabled{
|
||||||
|
color: #bbb!important;
|
||||||
|
border-color: #eee!important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.plain{
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
.plain-primary{
|
||||||
|
color: $my-main-color;
|
||||||
|
border-color: $my-main-color;
|
||||||
|
}
|
||||||
|
.plain-default{
|
||||||
|
color: #999;
|
||||||
|
border-color: #999;
|
||||||
|
}
|
||||||
|
.plain-cancel{
|
||||||
|
color: #999;
|
||||||
|
border-color: #999;
|
||||||
|
}
|
||||||
|
.primary{
|
||||||
|
background-color: $my-main-color;
|
||||||
|
color: #fff;
|
||||||
|
border-color: $my-main-color;
|
||||||
|
}
|
||||||
|
.default{
|
||||||
|
background-color: transparent;
|
||||||
|
color: #999;
|
||||||
|
border-color: #999;
|
||||||
|
}
|
||||||
|
.circle{
|
||||||
|
border-radius: 200rpx;
|
||||||
|
}
|
||||||
|
.square{
|
||||||
|
border-radius: 12rpx;
|
||||||
|
}
|
||||||
|
.btn-hover-class {
|
||||||
|
opacity: .6;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,601 @@
|
||||||
|
<template>
|
||||||
|
<view class="mask" v-if="show" @tap="close">
|
||||||
|
<view class="box" @tap.stop="nullFunction">
|
||||||
|
<view class="u-flex u-relative u-row-center u-p-30 top" v-if="props.isArea">
|
||||||
|
<view class="font-bold u-font-32">{{props.title}}</view>
|
||||||
|
<view class="close" @tap="close">
|
||||||
|
<uni-icons type="closeempty" size="24"></uni-icons>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
<view class="u-p-30 u-flex u-flex-wrap gap-20 fastTime" v-if="props.isArea">
|
||||||
|
<view class="item" v-for="(item,index) in fastTime" :key="index" @tap="changeTime(item.key)">
|
||||||
|
{{item.title}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<picker-view :immediate-change="true" @pickend="pickend" :value="value" @change="bindChange"
|
||||||
|
class="picker-view">
|
||||||
|
<template v-if="props.mode==='all'||props.mode==='date'">
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in years" :key="index">{{item}}年</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in months" :key="index">{{item}}月</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in days" :key="index">{{item}}日</view>
|
||||||
|
</picker-view-column>
|
||||||
|
</template>
|
||||||
|
<template v-if="props.mode==='all'||props.mode==='time'">
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in hours" :key="index">{{item}}时</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in minutes" :key="index">{{item}}分</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in seconds" :key="index">{{item}}秒</view>
|
||||||
|
</picker-view-column>
|
||||||
|
</template>
|
||||||
|
</picker-view>
|
||||||
|
<template v-if="props.isArea">
|
||||||
|
<view class="u-text-center color-999">至</view>
|
||||||
|
<picker-view :immediate-change="true" :value="value1" @pickend="pickend1" @change="bindChange1"
|
||||||
|
class="picker-view">
|
||||||
|
<template v-if="props.mode==='all'||props.mode==='date'">
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in years" :key="index">{{item}}年</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in months" :key="index">{{item}}月</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in days1" :key="index">{{item}}日</view>
|
||||||
|
</picker-view-column>
|
||||||
|
</template>
|
||||||
|
<template v-if="props.mode==='all'||props.mode==='time'">
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in hours" :key="index">{{item}}时</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in minutes" :key="index">{{item}}分</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="item" v-for="(item,index) in seconds" :key="index">{{item}}秒</view>
|
||||||
|
</picker-view-column>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</picker-view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 占位 -->
|
||||||
|
<view style="height: 80px;"></view>
|
||||||
|
<template v-if="props.isArea">
|
||||||
|
<view class="fixed_b" >
|
||||||
|
<my-button shape="circle" @tap="confirm">确定</my-button>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<view class="fixed_b u-flex u-row-center">
|
||||||
|
<view class="u-m-r-16">
|
||||||
|
<my-button type="cancel" @tap="close" width="240">
|
||||||
|
<view class="color-999">取消</view>
|
||||||
|
</my-button>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-l-16">
|
||||||
|
<my-button @tap="confirm" width="240">确定</my-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import myButton from "@/components/my-components/my-button.vue"
|
||||||
|
import {
|
||||||
|
reactive,
|
||||||
|
nextTick,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
const props = defineProps({
|
||||||
|
selTime:{
|
||||||
|
type: [String,Number],
|
||||||
|
},
|
||||||
|
defaultIndex: {
|
||||||
|
type: Array,
|
||||||
|
default: () => {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
defaultTime: {
|
||||||
|
type: Array,
|
||||||
|
default: () => {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: '筛选日期时间'
|
||||||
|
},
|
||||||
|
isArea: {
|
||||||
|
//是否选中范围时间
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
mode: {
|
||||||
|
//all date time
|
||||||
|
type: String,
|
||||||
|
default: 'time'
|
||||||
|
},
|
||||||
|
yearsLen:{
|
||||||
|
type: Number,
|
||||||
|
default:30
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const $nowDate = new Date()
|
||||||
|
const nowDate = {
|
||||||
|
year: $nowDate.getFullYear(),
|
||||||
|
month: $nowDate.getMonth() + 1,
|
||||||
|
day: $nowDate.getDate(),
|
||||||
|
hours: $nowDate.getHours(),
|
||||||
|
minutes: $nowDate.getMinutes(),
|
||||||
|
seconds: $nowDate.getSeconds()
|
||||||
|
}
|
||||||
|
const yearsLen = props.yearsLen
|
||||||
|
|
||||||
|
function returnYears() {
|
||||||
|
if(props.isArea){
|
||||||
|
return new Array(yearsLen).fill(1).map((v, index) => {
|
||||||
|
return nowDate.year - index
|
||||||
|
}).reverse()
|
||||||
|
}else{
|
||||||
|
return new Array(yearsLen).fill(1).map((v, index) => {
|
||||||
|
return nowDate.year-Math.floor(yearsLen/2) + index
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const years = returnYears()
|
||||||
|
|
||||||
|
const months = new Array(12).fill(1).map((v, index) => {
|
||||||
|
return index + 1
|
||||||
|
})
|
||||||
|
const days = ref(new Array(getMonthArea($nowDate, 'end').getDate()).fill(1).map((v, index) => {
|
||||||
|
return index + 1
|
||||||
|
}))
|
||||||
|
const days1 = ref(new Array(getMonthArea($nowDate, 'end').getDate()).fill(1).map((v, index) => {
|
||||||
|
return index + 1
|
||||||
|
}))
|
||||||
|
const hours = new Array(24).fill(1).map((v, index) => {
|
||||||
|
return index
|
||||||
|
})
|
||||||
|
const minutes = new Array(60).fill(1).map((v, index) => {
|
||||||
|
return index
|
||||||
|
})
|
||||||
|
const seconds = new Array(60).fill(1).map((v, index) => {
|
||||||
|
return index
|
||||||
|
})
|
||||||
|
const fastTime = reactive([{
|
||||||
|
title: '今日',
|
||||||
|
key: 'now'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '昨日',
|
||||||
|
key: 'prve'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '本月',
|
||||||
|
key: 'nowMonth'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '上月',
|
||||||
|
key: 'prveMonth'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function setPrveDay() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function setNowMoneth() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function setprveMoneth() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setDay(start, end) {
|
||||||
|
value.value = [
|
||||||
|
start.year,
|
||||||
|
start.month,
|
||||||
|
start.day,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
]
|
||||||
|
value1.value = [
|
||||||
|
end.year,
|
||||||
|
end.month,
|
||||||
|
end.day,
|
||||||
|
23,
|
||||||
|
59,
|
||||||
|
59,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeTime(key) {
|
||||||
|
const yearIndex = years.findIndex(v => v == nowDate.year)
|
||||||
|
const prveyearIndex = years.findIndex(v => v == nowDate.year) - 1
|
||||||
|
const nowMonthIndex = nowDate.month - 1
|
||||||
|
const nowDayIndex = nowDate.day - 1
|
||||||
|
const dataMap = {
|
||||||
|
now: function() {
|
||||||
|
return {
|
||||||
|
start: {
|
||||||
|
year: yearIndex,
|
||||||
|
month: nowMonthIndex,
|
||||||
|
day: nowDayIndex
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
year: yearIndex,
|
||||||
|
month: nowMonthIndex,
|
||||||
|
day: nowDayIndex
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
prve: function() {
|
||||||
|
const oneDay = 1000 * 60 * 60 * 24
|
||||||
|
const date = new Date(new Date(nowDate.year, nowDate.month, nowDate.day, 0, 0, 0).getTime() -
|
||||||
|
oneDay)
|
||||||
|
return {
|
||||||
|
start: {
|
||||||
|
year: years.findIndex(v => v == date.getFullYear()),
|
||||||
|
month: date.getMonth() - 1 < 0 ? 11 : date.getMonth() - 1,
|
||||||
|
day: date.getDate() - 1
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
year: years.findIndex(v => v == date.getFullYear()),
|
||||||
|
month: date.getMonth() - 1 < 0 ? 11 : date.getMonth() - 1,
|
||||||
|
day: date.getDate() - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
nowMonth: function() {
|
||||||
|
return {
|
||||||
|
start: {
|
||||||
|
year: yearIndex,
|
||||||
|
month: nowMonthIndex,
|
||||||
|
day: 0
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
year: yearIndex,
|
||||||
|
month: nowMonthIndex,
|
||||||
|
day: new Date(nowDate.year, nowDate.month, 0).getDate() - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
prveMonth: function() {
|
||||||
|
const oneDay = 1000 * 60 * 60 * 24
|
||||||
|
const date = new Date(new Date(nowDate.year, nowDate.month - 1, 0, 0, 0).getTime() - oneDay)
|
||||||
|
console.log(date.getMonth());
|
||||||
|
return {
|
||||||
|
start: {
|
||||||
|
year: years.findIndex(v => v == date.getFullYear()),
|
||||||
|
month: date.getMonth(),
|
||||||
|
day: 0
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
year: years.findIndex(v => v == date.getFullYear()),
|
||||||
|
month: date.getMonth(),
|
||||||
|
day: date.getDate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const data = dataMap[key]()
|
||||||
|
setDay(data.start, data.end)
|
||||||
|
changeDays(false, value.value)
|
||||||
|
changeDays(true, value1.value)
|
||||||
|
|
||||||
|
console.log(value1.value);
|
||||||
|
const start = returnDateString(value.value)
|
||||||
|
const end = returnDateString(value1.value)
|
||||||
|
|
||||||
|
emits('confirm', {
|
||||||
|
text: `${start}——${end}`,
|
||||||
|
start,
|
||||||
|
end
|
||||||
|
})
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
let value = ref([])
|
||||||
|
let value1 = ref([])
|
||||||
|
initValue()
|
||||||
|
|
||||||
|
|
||||||
|
function returnFindIndex(arr) {
|
||||||
|
const yearIndex = years.findIndex(v => v == arr[0])
|
||||||
|
const monthIndex = arr[1]
|
||||||
|
const dayIndex = arr[2] - 1
|
||||||
|
const hIndex = arr[3]
|
||||||
|
const mIndex = arr[4]
|
||||||
|
const sIndex = arr[5]
|
||||||
|
return [
|
||||||
|
yearIndex, monthIndex, dayIndex, hIndex, mIndex, sIndex
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
function initValue() {
|
||||||
|
if (props.defaultTime.length && !props.isArea) {
|
||||||
|
value.value = returnFindIndex(props.defaultTime)
|
||||||
|
} else {
|
||||||
|
const yearIndex = years.findIndex(v => v == nowDate.year)
|
||||||
|
value.value = [
|
||||||
|
yearIndex,
|
||||||
|
nowDate.month - 1,
|
||||||
|
nowDate.day - 1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
]
|
||||||
|
value1.value = [
|
||||||
|
yearIndex,
|
||||||
|
nowDate.month - 1,
|
||||||
|
nowDate.day - 1,
|
||||||
|
23,
|
||||||
|
59,
|
||||||
|
59,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let show = ref(false)
|
||||||
|
const emits = defineEmits('close', 'open', 'confirm')
|
||||||
|
|
||||||
|
function toggle() {
|
||||||
|
show.value = !show.value
|
||||||
|
if (show.value) {
|
||||||
|
open()
|
||||||
|
} else {
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
show.value = false
|
||||||
|
// emits('close', false)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function open() {
|
||||||
|
if(typeof props.selTime==='number'){
|
||||||
|
const d=new Date(props.selTime)
|
||||||
|
value.value[0]=years.findIndex(v=>v===d.getFullYear())
|
||||||
|
value.value[1]=months.findIndex(v=>v===d.getMonth())+1
|
||||||
|
value.value[2]=days.value.findIndex(v=>v===d.getDate())
|
||||||
|
}
|
||||||
|
show.value = true
|
||||||
|
// emits('open', true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnDateString(arr, isObj) {
|
||||||
|
const year = years[arr[0]]
|
||||||
|
const month = arr[1] + 1
|
||||||
|
const day = arr[2] + 1
|
||||||
|
const hour = ('0' + arr[3]).slice(-2)
|
||||||
|
const min = ('0' + arr[4]).slice(-2)
|
||||||
|
const sen = ('0' + arr[5]).slice(-2)
|
||||||
|
if (isObj) {
|
||||||
|
return new Date(year, month, day, hour, min, sen)
|
||||||
|
}
|
||||||
|
return `${year}-${month}-${day} ${hour}:${min}:${sen}`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function confirm(e) {
|
||||||
|
const start = returnDateString(value.value)
|
||||||
|
console.log(start);
|
||||||
|
const end = returnDateString(value1.value)
|
||||||
|
if (!props.isArea) {
|
||||||
|
emits('confirm', start)
|
||||||
|
} else {
|
||||||
|
emits('confirm', {
|
||||||
|
text: `${start}——${end}`,
|
||||||
|
start,
|
||||||
|
end
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnMonthStart(arr) {
|
||||||
|
return new Date(years[arr[0]], months[arr[1]] - 1, 1).getDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnMonthEnd(arr) {
|
||||||
|
return new Date(years[arr[0]], months[arr[1]], 0).getDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
//防抖
|
||||||
|
function debounce(fn, wait) {
|
||||||
|
let timeout = null;
|
||||||
|
return function() {
|
||||||
|
let context = this;
|
||||||
|
let args = arguments;
|
||||||
|
if (timeout) clearTimeout(timeout);
|
||||||
|
let callNow = !timeout;
|
||||||
|
timeout = setTimeout(() => {
|
||||||
|
timeout = null;
|
||||||
|
}, wait);
|
||||||
|
if (callNow) fn.apply(context, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} isDays1 //是否是结束时间选择
|
||||||
|
* @param {Object} arr
|
||||||
|
*/
|
||||||
|
function changeDays(isDays1, arr) {
|
||||||
|
const end = returnMonthEnd(arr)
|
||||||
|
if (end) {
|
||||||
|
if (isDays1) {
|
||||||
|
days1.value = new Array(end).fill(1).map((v,
|
||||||
|
index) => {
|
||||||
|
return index + 1
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
days.value = new Array(end).fill(1).map((v,
|
||||||
|
index) => {
|
||||||
|
return index + 1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function bindChange(e) {
|
||||||
|
const startTotal = returnDateString(e.detail.value, true).getTime()
|
||||||
|
const endTotal = returnDateString(value1.value, true).getTime()
|
||||||
|
value.value = e.detail.value
|
||||||
|
setTimeout(()=>{
|
||||||
|
if (props.isArea) {
|
||||||
|
value.value = startTotal > endTotal ? value1.value : e.detail.value
|
||||||
|
}
|
||||||
|
debounce(changeDays(false, value.value), 100)
|
||||||
|
},10)
|
||||||
|
// nextTick(() => {
|
||||||
|
// if (props.isArea) {
|
||||||
|
// value.value = startTotal > endTotal ? value1.value : e.detail.value
|
||||||
|
// }
|
||||||
|
// console.log(value.value);
|
||||||
|
// debounce(changeDays(false, value.value), 100)
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindChange1(e) {
|
||||||
|
const startTotal = returnDateString(value.value, true).getTime()
|
||||||
|
const endTotal = returnDateString(e.detail.value, true).getTime()
|
||||||
|
value1.value = e.detail.value
|
||||||
|
nextTick(() => {
|
||||||
|
value1.value = endTotal < startTotal ? value.value : e.detail.value
|
||||||
|
debounce(changeDays(true, value1.value), 100)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDayDate(date = new Date(), type) {
|
||||||
|
const now = date
|
||||||
|
if (type === 'start') {
|
||||||
|
const startOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||||
|
return startOfDay
|
||||||
|
}
|
||||||
|
if (type === 'end') {
|
||||||
|
const endOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
||||||
|
return endOfDay;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMonthArea(date = new Date(), type) {
|
||||||
|
let now = date
|
||||||
|
let currentMonthStart = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||||
|
let currentMonthEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
||||||
|
if (type === 'start') {
|
||||||
|
return currentMonthStart
|
||||||
|
}
|
||||||
|
if (type === 'end') {
|
||||||
|
return currentMonthEnd;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
start: currentMonthStart,
|
||||||
|
end: currentMonthEnd
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function nullFunction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickend(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickend1(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
defineExpose({
|
||||||
|
close,
|
||||||
|
open,
|
||||||
|
confirm,
|
||||||
|
toggle
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.fastTime {
|
||||||
|
.item {
|
||||||
|
background-color: rgb(247, 247, 247);
|
||||||
|
padding: 6rpx 40rpx;
|
||||||
|
border-radius: 6rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top {
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
right: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mask {
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
top: 0;
|
||||||
|
z-index: 999;
|
||||||
|
background-color: rgba(51, 51, 51, .5);
|
||||||
|
|
||||||
|
.item {
|
||||||
|
line-height: 34px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box {
|
||||||
|
position: absolute;
|
||||||
|
background-color: #fff;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
border-radius: 16rpx 16rpx 0 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed_b {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
padding: 30rpx;
|
||||||
|
z-index: 100;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.picker-view {
|
||||||
|
width: 750rpx;
|
||||||
|
height: 300rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
<template>
|
||||||
|
<view class="u-flex u-row-center">
|
||||||
|
<view class="empty color-999 u-font-28 u-m-t-60 u-text-center">{{text}}</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
const props= defineProps({
|
||||||
|
text:{
|
||||||
|
type:String,
|
||||||
|
default:'暂无记录'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.empty{
|
||||||
|
position: relative;
|
||||||
|
padding: 0 16rpx;
|
||||||
|
&:before,&::after{
|
||||||
|
position: absolute;
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
top: 50%;
|
||||||
|
height: 1px;
|
||||||
|
background-color: #E5E5E5;
|
||||||
|
border-radius: 1px;
|
||||||
|
width: 94rpx;
|
||||||
|
}
|
||||||
|
&:before{
|
||||||
|
right: 100%;
|
||||||
|
}
|
||||||
|
&::after{
|
||||||
|
left: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
<template>
|
||||||
|
<view class="icon"
|
||||||
|
:class="[computedClass]"
|
||||||
|
></view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed } from 'vue';
|
||||||
|
const props=defineProps({
|
||||||
|
type:{
|
||||||
|
type:String
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const classMap={
|
||||||
|
add:'icon-add',
|
||||||
|
reduce:'icon-reduce'
|
||||||
|
}
|
||||||
|
const computedClass=computed(()=>{
|
||||||
|
return classMap[props.type]
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
$icon-size: 34rpx;
|
||||||
|
$icon-line-width: 20rpx;
|
||||||
|
$icon-line-height: 4rpx;
|
||||||
|
.icon {
|
||||||
|
width: $icon-size;
|
||||||
|
height: $icon-size;
|
||||||
|
position: relative;
|
||||||
|
border-radius: 50%;
|
||||||
|
|
||||||
|
&:before,
|
||||||
|
&::after {
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
content: '';
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-add {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
width: $icon-line-height;
|
||||||
|
height: $icon-line-width;
|
||||||
|
top: calc(($icon-size /2) - ($icon-line-width / 2));
|
||||||
|
left: calc(($icon-size /2) - ($icon-line-height / 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
width: $icon-line-width;
|
||||||
|
height: 4rpx;
|
||||||
|
top: calc(($icon-size /2) - ($icon-line-height / 2));
|
||||||
|
left: calc(($icon-size /2) - ($icon-line-width / 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-reduce {
|
||||||
|
background-color: $my-red-color;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
width: $icon-line-width;
|
||||||
|
height: $icon-line-height;
|
||||||
|
top: calc(($icon-size /2) - ($icon-line-height / 2));
|
||||||
|
left: calc(($icon-size /2) - ($icon-line-width / 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<template>
|
||||||
|
<view class="u-flex u-flex-col u-row-center u-col-center w-full">
|
||||||
|
<slot>
|
||||||
|
<image :src="img" mode="" class="img"></image>
|
||||||
|
<view class="tips">{{tips}}</view>
|
||||||
|
</slot>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
const props= defineProps({
|
||||||
|
tips:{
|
||||||
|
type:String,
|
||||||
|
default:'暂无数据'
|
||||||
|
},
|
||||||
|
img:{
|
||||||
|
type:String,
|
||||||
|
default:'/static/icon-empty.svg'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.img{
|
||||||
|
width: 326rpx;
|
||||||
|
height: 336rpx;
|
||||||
|
}
|
||||||
|
.tips{
|
||||||
|
margin-top: 74rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,326 @@
|
||||||
|
<template>
|
||||||
|
<up-popup :show="show" @close="close" closeOnClickOverlay @open="open" mode="center" :round="16">
|
||||||
|
<view class="login-wrapper">
|
||||||
|
<view class="login-bottom jeepay-form">
|
||||||
|
<view class="u-flex u-flex-row u-row-right u-m-t-10">
|
||||||
|
<up-icon name="close-circle-fill" size="20" color="#999" @click="close"></up-icon>
|
||||||
|
</view>
|
||||||
|
<up-form errorType="toast" :model="vdata.formData" :rules="rules" ref="loginFormRef">
|
||||||
|
<view class="">
|
||||||
|
<up-tabs :list="accountType.list" keyName="label" @change="accountTypeChange"></up-tabs>
|
||||||
|
</view>
|
||||||
|
<template v-if="accountType.sel==1">
|
||||||
|
<up-form-item prop="merchantName">
|
||||||
|
<up--input v-model="vdata.formData.merchantName" placeholder="请输入商户号">
|
||||||
|
</up--input>
|
||||||
|
</up-form-item>
|
||||||
|
</template>
|
||||||
|
<up-form-item prop="username">
|
||||||
|
<up--input v-model="vdata.formData.username" placeholder="请输入登录名/手机号"></up--input>
|
||||||
|
</up-form-item>
|
||||||
|
<up-form-item prop="pwd">
|
||||||
|
<up--input v-model="vdata.formData.pwd" type="password" placeholder="请输入登录密码"></up--input>
|
||||||
|
</up-form-item>
|
||||||
|
<up-form-item prop="code">
|
||||||
|
<up--input v-model="vdata.formData.code" placeholder="请输入验证码">
|
||||||
|
</up--input>
|
||||||
|
<image :src="vdata.formData.img" class=" " style="width: 100px; height: 40px;margin-left: 5px;"
|
||||||
|
@click="getCode" mode="">
|
||||||
|
</image>
|
||||||
|
</up-form-item>
|
||||||
|
<view class="u-m-t-10">
|
||||||
|
<up-button shape="circle" @click="loginFunc" type="primary" text="登录"></up-button>
|
||||||
|
</view>
|
||||||
|
</up-form>
|
||||||
|
<!-- <uni-forms ref="loginFormRef" label-width="0" :model="vdata.formData" :rules="rules">
|
||||||
|
<view class="u-p-b-30">
|
||||||
|
<my-tabs size="large" @change="accountTypeChange" v-model="accountType.sel" :list="accountType.list"
|
||||||
|
textKey="label"></my-tabs>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<template v-if="accountType.sel==1">
|
||||||
|
<uni-forms-item name="merchantName">
|
||||||
|
<uni-easyinput class='jeepay-easyinput' placeholder="请输入商户号"
|
||||||
|
v-model="vdata.formData.merchantName" :clearable="false">
|
||||||
|
<template #prefixIcon>
|
||||||
|
<image src="@/static/login/icon-user.svg" class="input-icon" />
|
||||||
|
</template>
|
||||||
|
</uni-easyinput>
|
||||||
|
</uni-forms-item>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<uni-forms-item name="username">
|
||||||
|
<uni-easyinput class='jeepay-easyinput' placeholder="请输入登录名/手机号"
|
||||||
|
v-model="vdata.formData.username" :clearable="false">
|
||||||
|
<template #prefixIcon>
|
||||||
|
<image src="@/static/login/icon-user.svg" class="input-icon" />
|
||||||
|
</template>
|
||||||
|
</uni-easyinput>
|
||||||
|
</uni-forms-item>
|
||||||
|
|
||||||
|
<uni-forms-item name="pwd">
|
||||||
|
<uni-easyinput class='jeepay-easyinput' :type="vdata.isShowPwd ? 'text' : 'password'"
|
||||||
|
v-model="vdata.formData.pwd" :clearable="false" placeholder="请输入登录密码">
|
||||||
|
<template #prefixIcon>
|
||||||
|
<image src="@/static/login/icon-pw.svg" class="input-icon" />
|
||||||
|
</template>
|
||||||
|
<template #suffixIcon>
|
||||||
|
<view class='show-tips' @tap="vdata.isShowPwd = !vdata.isShowPwd ">
|
||||||
|
{{ vdata.isShowPwd ? '隐藏' : '显示' }}
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</uni-easyinput>
|
||||||
|
</uni-forms-item>
|
||||||
|
|
||||||
|
<uni-forms-item name="code">
|
||||||
|
<view style="display: flex;" class="u-flex u-flex-y-center u-flex-row">
|
||||||
|
<uni-easyinput class='jeepay-easyinput' :maxlength="6" placeholder="请输入验证码"
|
||||||
|
v-model="vdata.formData.code" :clearable="false">
|
||||||
|
<template #prefixIcon>
|
||||||
|
<image src="@/static/login/icon-sms-code.svg" class="input-icon" />
|
||||||
|
</template>
|
||||||
|
</uni-easyinput>
|
||||||
|
<image :src="vdata.formData.img" class=" u-m-b-50"
|
||||||
|
style="width: 200rpx; height: 80rpx;margin-left: 10rpx;" @click="getCode" mode="">
|
||||||
|
</image>
|
||||||
|
</view>
|
||||||
|
</uni-forms-item>
|
||||||
|
</view>
|
||||||
|
<up-button @click="loginFunc" type="primary" text="登录"></up-button>
|
||||||
|
</uni-forms> -->
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</up-popup>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
encrypt
|
||||||
|
} from '@/commons/utils/rsaEncrypt.js'
|
||||||
|
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
reactive,
|
||||||
|
onMounted,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
import storageManage from '@/commons/utils/storageManage.js'
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js';
|
||||||
|
import go from '@/commons/utils/go.js'
|
||||||
|
import timer from '@/commons/utils/timer.js'
|
||||||
|
import formUtil from '@/commons/utils/formUtil.js'
|
||||||
|
import {
|
||||||
|
login,
|
||||||
|
getCodeImg
|
||||||
|
} from '@/http/yskApi/login.js';
|
||||||
|
let show = ref(false)
|
||||||
|
const emits = defineEmits(['update:modelValue', 'loginSuccess'])
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
watch(() => props.modelValue, (newval) => {
|
||||||
|
show.value = newval
|
||||||
|
})
|
||||||
|
watch(() => show.value, (newval) => {
|
||||||
|
if(newval){
|
||||||
|
getCode()
|
||||||
|
}
|
||||||
|
emits('update:modelValue', newval)
|
||||||
|
})
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
show.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function open() {
|
||||||
|
show.value = true
|
||||||
|
}
|
||||||
|
const accountType = reactive({
|
||||||
|
list: [{
|
||||||
|
label: '商户',
|
||||||
|
value: 'merchant'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '员工',
|
||||||
|
value: 'staff'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
sel: 0
|
||||||
|
})
|
||||||
|
|
||||||
|
function accountTypeChange(e) {
|
||||||
|
console.log(e);
|
||||||
|
accountType.sel = e.index
|
||||||
|
}
|
||||||
|
const loginFormRef = ref()
|
||||||
|
const envChangeTipsRef = ref()
|
||||||
|
const refAgr = ref()
|
||||||
|
const rules = {
|
||||||
|
merchantName: [{
|
||||||
|
required: true,
|
||||||
|
message: '请输入商户号',
|
||||||
|
trigger: ['blur', 'change'],
|
||||||
|
}],
|
||||||
|
username: [{
|
||||||
|
required: true,
|
||||||
|
message: '请输入员工账号,登录名/手机号',
|
||||||
|
trigger: ['blur', 'change'],
|
||||||
|
}],
|
||||||
|
pwd: [{
|
||||||
|
required: true,
|
||||||
|
message: '请输入密码',
|
||||||
|
trigger: ['blur', 'change'],
|
||||||
|
}],
|
||||||
|
code: [{
|
||||||
|
required: true,
|
||||||
|
message: '请输入验证码',
|
||||||
|
trigger: ['blur', 'change'],
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
const vdata = reactive({
|
||||||
|
isShowPwd: false, // 是否显示密码
|
||||||
|
loginType: 'pwd', // 类型切换: pwd or sms
|
||||||
|
isShowSafetyCode: false, // 是否显示安全码输入框
|
||||||
|
allowSendMsgFlag: true, // 是否可发送短信验证码
|
||||||
|
sendMsgText: '发送验证码',
|
||||||
|
isSelectedAgreement: false, // 勾选隐私协议
|
||||||
|
siteInfos: storageManage.siteInfos() || {},
|
||||||
|
formData: {
|
||||||
|
username: '', // 账密登录: 用户名
|
||||||
|
pwd: '', // 账密登录: 密码
|
||||||
|
rememberMe: false,
|
||||||
|
code: '',
|
||||||
|
uuid: '',
|
||||||
|
merchantName: '',
|
||||||
|
loginType: 'merchant'
|
||||||
|
},
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const getCode = () => {
|
||||||
|
getCodeImg().then(res => {
|
||||||
|
vdata.formData.img = res.img
|
||||||
|
vdata.formData.uuid = res.uuid
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
getCode()
|
||||||
|
|
||||||
|
onMounted(() => {})
|
||||||
|
|
||||||
|
function loginFunc() {
|
||||||
|
// 表单验证
|
||||||
|
formUtil.validate(loginFormRef.value).then(() => {
|
||||||
|
let loginPromise = null;
|
||||||
|
loginPromise = login({
|
||||||
|
username: vdata.formData.username,
|
||||||
|
password: encrypt(vdata.formData.pwd),
|
||||||
|
rememberMe: false,
|
||||||
|
code: vdata.formData.code,
|
||||||
|
uuid: vdata.formData.uuid,
|
||||||
|
merchantName: vdata.formData.merchantName,
|
||||||
|
loginType: accountType.list[accountType.sel].value
|
||||||
|
})
|
||||||
|
|
||||||
|
if (loginPromise == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 请求后的操作
|
||||||
|
loginPromise.then(res => {
|
||||||
|
console.log(res);
|
||||||
|
// 登录成功
|
||||||
|
loginFinishFunc(res)
|
||||||
|
|
||||||
|
}).catch(e => {
|
||||||
|
getCode()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
watch(() => accountType.sel, (newval) => {
|
||||||
|
if (newval == 1) {
|
||||||
|
vdata.formData.merchantName = uni.getStorageSync('merchantName') || ''
|
||||||
|
} else {
|
||||||
|
vdata.formData.username = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 封装登录成功后的操作
|
||||||
|
async function loginFinishFunc(loginBizData) {
|
||||||
|
// 保存 token
|
||||||
|
storageManage.setLogin(loginBizData)
|
||||||
|
storageManage.token(loginBizData.token)
|
||||||
|
storageManage.shopId(loginBizData.shopId)
|
||||||
|
storageManage.shopUserId(loginBizData.user.user.id)
|
||||||
|
storageManage.userInfo(loginBizData)
|
||||||
|
emits('loginSuccess')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.input-icon {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .input-placeholder {
|
||||||
|
font-size: 14px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-wrapper {
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.login-bottom {
|
||||||
|
min-height: 368px;
|
||||||
|
padding: 0 20px 20px 20px;
|
||||||
|
min-width: 400px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
.show-tips {
|
||||||
|
color: rgba(88, 132, 204, 1);
|
||||||
|
font-weight: 400;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.register-box {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0 30rpx;
|
||||||
|
margin-top: 50rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
|
||||||
|
.register {
|
||||||
|
text:last-child {
|
||||||
|
color: #1D79FD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.forget {
|
||||||
|
color: #1D79FD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.swidth-login {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 212rpx;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
color: rgba(77, 77, 77, 1);
|
||||||
|
|
||||||
|
image {
|
||||||
|
width: 40rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
<template>
|
||||||
|
<view class="mask u-fixed tranistion position-all u-flex u-flex-col u-row-center u-col-center" v-if="show"
|
||||||
|
:style="computedStyle" @tap="maskClick">
|
||||||
|
<view class="w-full" @tap.stop="nullFunction">
|
||||||
|
<slot></slot>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
computed,
|
||||||
|
ref,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
const props = defineProps({
|
||||||
|
show:{
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
zIndex: {
|
||||||
|
type: [Number, String]
|
||||||
|
},
|
||||||
|
tapClose: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const emits = defineEmits(['close', 'toggle', 'open'])
|
||||||
|
watch(()=>props.show,(newval)=>{
|
||||||
|
show.value=newval
|
||||||
|
})
|
||||||
|
let show = ref(props.show)
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
show.value = false
|
||||||
|
emits('close')
|
||||||
|
}
|
||||||
|
|
||||||
|
function open() {
|
||||||
|
show.value = true
|
||||||
|
emits('open')
|
||||||
|
}
|
||||||
|
|
||||||
|
function nullFunction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggle() {
|
||||||
|
if (show.value) {
|
||||||
|
close()
|
||||||
|
} else {
|
||||||
|
open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function maskClick() {
|
||||||
|
if (props.tapClose) {
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const computedStyle = computed(() => {
|
||||||
|
return `
|
||||||
|
z-index:${props.zIndex};
|
||||||
|
`
|
||||||
|
})
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
close,
|
||||||
|
toggle,
|
||||||
|
open
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.mask {
|
||||||
|
background-color: rgba(51, 51, 51, .5);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,232 @@
|
||||||
|
<template>
|
||||||
|
<view class="model u-text-center" v-if="show" @tap="modelTap">
|
||||||
|
<div @tap.stop="" class="box u-font-32 tranistion" :class="[returnBoxClass]" :style="[computeBoxStyle,computeStyle()]" >
|
||||||
|
<view class="u-relative">
|
||||||
|
<view class=" color-333 font-bold">{{props.title||'提示'}}</view>
|
||||||
|
<template v-if="showIcon">
|
||||||
|
<slot name="icon">
|
||||||
|
<view class="close" @tap="close">
|
||||||
|
<uni-icons :size="iconSize" :color="iconColor" type="clear"></uni-icons>
|
||||||
|
</view>
|
||||||
|
</slot>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<slot name="desc">
|
||||||
|
<view class=" color-666 u-p-30">{{props.desc}}</view>
|
||||||
|
</slot>
|
||||||
|
<slot name="btn" v-if="showBtn">
|
||||||
|
<view class="btns u-flex">
|
||||||
|
<view class="cancel btn" @tap="cancel">{{props.cancelText}}</view>
|
||||||
|
<view class="confirm btn" @tap="confirm">{{props.confirmText}}</view>
|
||||||
|
</view>
|
||||||
|
</slot>
|
||||||
|
</div>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
computed,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
const emits = defineEmits(['cancel', 'confirm', 'close', 'open'])
|
||||||
|
|
||||||
|
|
||||||
|
function isNumber(value) {
|
||||||
|
return Number(value)==value && !isNaN(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
confirmClickClose:{
|
||||||
|
type:Boolean,
|
||||||
|
default:true
|
||||||
|
},
|
||||||
|
isClickMaskHide:{
|
||||||
|
type:Boolean,
|
||||||
|
default:true
|
||||||
|
},
|
||||||
|
iconSize:{
|
||||||
|
type: Number,
|
||||||
|
default: 26
|
||||||
|
},
|
||||||
|
iconColor:{
|
||||||
|
type: String,
|
||||||
|
default: '#999'
|
||||||
|
},
|
||||||
|
mode:{
|
||||||
|
//center bottom
|
||||||
|
type: String,
|
||||||
|
default: 'center'
|
||||||
|
},
|
||||||
|
//单位rpx
|
||||||
|
borderRadius:{
|
||||||
|
type:[String,Number],
|
||||||
|
default:36
|
||||||
|
},
|
||||||
|
showIcon:{
|
||||||
|
type:Boolean,
|
||||||
|
default:true
|
||||||
|
},
|
||||||
|
showBtn:{
|
||||||
|
type:Boolean,
|
||||||
|
default:true
|
||||||
|
},
|
||||||
|
cancelText: {
|
||||||
|
type: String,
|
||||||
|
default: '取消'
|
||||||
|
},
|
||||||
|
confirmText: {
|
||||||
|
type: String,
|
||||||
|
default: '确定'
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: '提示'
|
||||||
|
},
|
||||||
|
desc: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
width:{
|
||||||
|
type:[Number,String],
|
||||||
|
default:''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
function computeStyle(){
|
||||||
|
const width=props.width?props.width:''
|
||||||
|
const bottomBorderRadius=`${props.borderRadius}rpx ${props.borderRadius}rpx 0 0`
|
||||||
|
const centerBorderRadius=`${props.borderRadius}rpx`
|
||||||
|
const borderRadius=isNumber(props.borderRadius)?(props.mode==='bottom'?bottomBorderRadius:centerBorderRadius):props.borderRadius
|
||||||
|
return `
|
||||||
|
width:${width?width:''};
|
||||||
|
borderRadius:${borderRadius};
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
const computedClass=computed(()=>{
|
||||||
|
return show.value?'show':'none'
|
||||||
|
})
|
||||||
|
const returnBoxClass=computed(()=>{
|
||||||
|
if(props.mode==='center'){
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
return 'bottom-box'
|
||||||
|
})
|
||||||
|
const computeBoxStyle=computed(()=>{
|
||||||
|
if(props.mode==='center'){
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
function getComputeClass() {
|
||||||
|
|
||||||
|
}
|
||||||
|
let show = ref(false)
|
||||||
|
|
||||||
|
function open() {
|
||||||
|
show.value = true
|
||||||
|
emits('open')
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
show.value = false
|
||||||
|
emits('close')
|
||||||
|
}
|
||||||
|
function modelTap(){
|
||||||
|
if(props.isClickMaskHide){
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function cancel() {
|
||||||
|
show.value = false
|
||||||
|
emits('cancel')
|
||||||
|
emits('close')
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirm() {
|
||||||
|
emits('confirm')
|
||||||
|
if(props.confirmClickClose){
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
open,
|
||||||
|
close,
|
||||||
|
cancel,
|
||||||
|
confirm
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.show{
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
.none{
|
||||||
|
transform: scale(0);
|
||||||
|
}
|
||||||
|
.close {
|
||||||
|
position: absolute;
|
||||||
|
right: 30rpx;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
// background: #999999;
|
||||||
|
// border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.model {
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
top: 0;
|
||||||
|
background: rgba(51, 51, 51, 0.5);
|
||||||
|
z-index: 980;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 46rpx;
|
||||||
|
|
||||||
|
.box {
|
||||||
|
width: 100%;
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 36rpx 36rpx 36rpx 36rpx;
|
||||||
|
padding-top: 32rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
max-width: 50vw;
|
||||||
|
.btns {
|
||||||
|
border-top: 2rpx solid #E5E5E5;
|
||||||
|
|
||||||
|
.cancel {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm {
|
||||||
|
color: $my-main-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&>.btn {
|
||||||
|
padding: 30rpx;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bottom-box{
|
||||||
|
position: absolute;left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
padding-bottom: 100rpx;
|
||||||
|
border-radius: 36rpx 36rpx 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,150 @@
|
||||||
|
<template>
|
||||||
|
<view v-if="pagesData.length">
|
||||||
|
<view class="u-flex pagination u-row-center u-font-28">
|
||||||
|
<view class="prve btn" :class="{disabled:currentPage===1}" @tap="btnClick('')">上一页</view>
|
||||||
|
<view>
|
||||||
|
<picker @change="pageChange" :value="defaultPaageIndex" :range="pagesData">
|
||||||
|
<view class="u-flex current-page u-col-center btn">
|
||||||
|
<text class="page color-main font-bold">{{currentPage}}</text>
|
||||||
|
<!-- <text class="page color-main font-bold">{{currentPage}}/{{maxPage}}</text> -->
|
||||||
|
<view class="arrow-down"></view>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
<!-- <view class="u-flex current-page u-col-center btn">
|
||||||
|
|
||||||
|
<text class="page color-main font-bold">{{page}}</text>
|
||||||
|
<view class="arrow-down"></view>
|
||||||
|
</view> -->
|
||||||
|
<view class="next btn" :class="{disabled:currentPage===maxPage}" @tap="btnClick('add')">下一页</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
computed,
|
||||||
|
reactive,
|
||||||
|
ref,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
const props = defineProps({
|
||||||
|
size: {
|
||||||
|
type: Number,
|
||||||
|
default: 10
|
||||||
|
},
|
||||||
|
totalElements: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
type: Number,
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
|
pages: {
|
||||||
|
type: [Array, Number],
|
||||||
|
default: [1]
|
||||||
|
},
|
||||||
|
defaultPaageIndex: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const emits = defineEmits(['change','update:page'])
|
||||||
|
|
||||||
|
let currentPage = ref(props.page === 0 ? 1 : props.page)
|
||||||
|
|
||||||
|
function returnMaxPage() {
|
||||||
|
const result=Math.ceil(props.totalElements / props.size)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
let maxPage=ref(returnMaxPage())
|
||||||
|
const pagesData = computed(() => {
|
||||||
|
maxPage.value=returnMaxPage()
|
||||||
|
return new Array(returnMaxPage()).fill(1).map((v, index) => index + 1)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// const pagesData = ref( Array.isArray(props.pages) ? props.pages : new Array(props.pages).fill(1).map((v,index)=>index+1))
|
||||||
|
// const maxPage=ref( Array.isArray(props.pages)? (props.pages[props.pages.length - 1] +1): (props.pages+1))
|
||||||
|
let defaultPaageIndex = ref(props.defaultPaageIndex > 0 ? props.defaultPaageIndex : props.page - 1)
|
||||||
|
|
||||||
|
//设置页码值
|
||||||
|
function setCurrentPage(page) {
|
||||||
|
currentPage.value = page
|
||||||
|
}
|
||||||
|
|
||||||
|
function pageChange(e) {
|
||||||
|
setCurrentPage(e.detail.value * 1 + 1)
|
||||||
|
}
|
||||||
|
//看是否到达临界值来决定是否改变页码
|
||||||
|
function btnClick(isAdd) {
|
||||||
|
let newPage = currentPage.value * 1 + (isAdd == 'add' ? 1 : -1)
|
||||||
|
if (newPage <= 0) {
|
||||||
|
return infoBox.showToast('已经是第一页了')
|
||||||
|
}
|
||||||
|
if (newPage > maxPage.value) {
|
||||||
|
return infoBox.showToast('没有更多页了')
|
||||||
|
}
|
||||||
|
setCurrentPage(newPage)
|
||||||
|
}
|
||||||
|
watch(()=>props.page,(newval)=>{
|
||||||
|
currentPage.value =newval
|
||||||
|
})
|
||||||
|
watch(() => currentPage.value, (newval) => {
|
||||||
|
emits('change', newval)
|
||||||
|
emits('update:page', newval)
|
||||||
|
defaultPaageIndex.value = newval - 1
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.btn {
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 2px solid $my-main-color;
|
||||||
|
padding: 8rpx 46rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
gap: 30rpx;
|
||||||
|
|
||||||
|
.current-page {
|
||||||
|
position: relative;
|
||||||
|
padding-left: 18rpx;
|
||||||
|
|
||||||
|
.page {
|
||||||
|
margin-right: 74rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.prve,
|
||||||
|
.next {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prve,.next {
|
||||||
|
&.disabled {
|
||||||
|
// background-color: #ccc;
|
||||||
|
// border-color: #ccc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrow-down {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
right: 12rpx;
|
||||||
|
margin-top: 10rpx;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-top: 20rpx solid $my-main-color;
|
||||||
|
border-right: 20rpx solid transparent;
|
||||||
|
border-left: 20rpx solid transparent;
|
||||||
|
border-bottom: 20rpx solid transparent;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,344 @@
|
||||||
|
<template>
|
||||||
|
<view class="mask" v-if="show" @tap="close">
|
||||||
|
<view class="box" @tap.stop="nullFunction">
|
||||||
|
<view class="u-flex u-relative u-row-center u-p-30 top" v-if="props.showTitle">
|
||||||
|
<view class="font-bold u-font-32">{{props.title}}</view>
|
||||||
|
<view class="close" @tap="close">
|
||||||
|
<uni-icons type="closeempty" size="24"></uni-icons>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
<!-- <view class="u-p-30 u-flex u-flex-wrap gap-20 fastTime">
|
||||||
|
<view class="item" v-for="(item,index) in fastTime" :key="index" @tap="changeTime(item.key)">
|
||||||
|
{{item.title}}
|
||||||
|
</view>
|
||||||
|
</view> -->
|
||||||
|
<picker-view indicator-class="activeClass" :immediate-change="true" @pickend="pickend" :value="value"
|
||||||
|
@change="bindChange" class="picker-view">
|
||||||
|
<template v-if="list.length">
|
||||||
|
<picker-view-column v-for="(arr,index) in list" :key="index">
|
||||||
|
<view class="item" v-for="(item,itemIndex) in arr" :key="itemIndex">
|
||||||
|
{{props.rangeKey? item[props.rangeKey]:item }}
|
||||||
|
</view>
|
||||||
|
</picker-view-column>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- <template>
|
||||||
|
<picker-view-column v-if="props.list.length">
|
||||||
|
<view class="item" v-for="(item,index) in props.list" :key="index">
|
||||||
|
{{props.rangeKey? item[props.rangeKey]:item }}</view>
|
||||||
|
</picker-view-column>
|
||||||
|
</template> -->
|
||||||
|
</picker-view>
|
||||||
|
|
||||||
|
<!-- 站位 -->
|
||||||
|
<view style="height: 80px;"></view>
|
||||||
|
<view class="fixed_b u-flex u-row-between">
|
||||||
|
<my-button type="cancel" @tap="close" width="240">
|
||||||
|
<view class="color-999">取消</view>
|
||||||
|
</my-button>
|
||||||
|
<my-button @tap="confirm" width="240">确定</my-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import myButton from "@/components/my-components/my-button.vue"
|
||||||
|
import {
|
||||||
|
reactive,
|
||||||
|
nextTick,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
const props = defineProps({
|
||||||
|
autoClear: {
|
||||||
|
//是否自动清除选中
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
defaultIndex: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {
|
||||||
|
return [0]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showTitle: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
list: {
|
||||||
|
//[name:'',value:'',children:[]]
|
||||||
|
type: Object,
|
||||||
|
default: () => {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rangeKey: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: '筛选日期时间'
|
||||||
|
},
|
||||||
|
isLink: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
mode: {
|
||||||
|
//all date time
|
||||||
|
type: String,
|
||||||
|
default: 'all'
|
||||||
|
},
|
||||||
|
showSeconds:{
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function nullFunction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let list = ref([])
|
||||||
|
|
||||||
|
function isTowLvArr(arr) {
|
||||||
|
return arr.some(item => Array.isArray(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnNowArr(arr, indexArr) {
|
||||||
|
try{
|
||||||
|
if(!arr.length){
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
let lv = 0
|
||||||
|
let result = [arr[0]]
|
||||||
|
|
||||||
|
function returnItem(item, selIndex) {
|
||||||
|
if (item.hasOwnProperty('children') && Array.isArray(item['children'])) {
|
||||||
|
lv++
|
||||||
|
result.push(item['children'])
|
||||||
|
returnItem(item['children'][selIndex], indexArr[lv] || 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
returnItem(arr[0][indexArr[lv]], indexArr[lv])
|
||||||
|
return result
|
||||||
|
}catch(e){
|
||||||
|
console.error(`请绑定指定样式数据list:[{name:'',value:'',children:[
|
||||||
|
{name:'',value:''}
|
||||||
|
]}]`)
|
||||||
|
//TODO handle the exception
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setList() {
|
||||||
|
if (props.mode === 'time') {
|
||||||
|
const length=props.showSeconds?3:2
|
||||||
|
list.value = new Array(length).fill(1).map((v, index) => {
|
||||||
|
//时
|
||||||
|
if (index === 0) {
|
||||||
|
return new Array(24).fill(1).map((h, hIndex) => {
|
||||||
|
return ('0' + hIndex).slice(-2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//分
|
||||||
|
if (index === 1) {
|
||||||
|
return new Array(60).fill(1).map((m, hIndex) => {
|
||||||
|
return ('0' + hIndex).slice(-2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//秒
|
||||||
|
if (index === 2) {
|
||||||
|
return new Array(60).fill(1).map((s, hIndex) => {
|
||||||
|
return ('0' + hIndex).slice(-2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const propArr = isTowLvArr(props.list) ? props.list : [props.list]
|
||||||
|
const indexArr = props.defaultIndex
|
||||||
|
const computedArr = props.isLink ? returnNowArr(propArr, indexArr) : propArr
|
||||||
|
list.value = computedArr||[]
|
||||||
|
}
|
||||||
|
setList()
|
||||||
|
|
||||||
|
let value = ref(props.defaultIndex)
|
||||||
|
|
||||||
|
function resetValue() {
|
||||||
|
value.value = value.value.map(v => 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
function setValue() {
|
||||||
|
if(props.mode==='time'){
|
||||||
|
return value.value=props.defaultIndex
|
||||||
|
}
|
||||||
|
const arr = new Array(list.value.length).fill(0).map((v, index) => {
|
||||||
|
return props.defaultIndex[index] !== undefined ? props.defaultIndex[index] : v
|
||||||
|
})
|
||||||
|
|
||||||
|
value.value = props.defaultIndex.length === list.value.length ? props.defaultIndex : arr
|
||||||
|
}
|
||||||
|
setValue()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let show = ref(false)
|
||||||
|
const emits = defineEmits('close', 'open', 'confirm')
|
||||||
|
|
||||||
|
function toggle() {
|
||||||
|
show.value = !show.value
|
||||||
|
if (show.value) {
|
||||||
|
open()
|
||||||
|
} else {
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
show.value = false
|
||||||
|
if (props.autoClear) {
|
||||||
|
resetValue()
|
||||||
|
}
|
||||||
|
// emits('close', false)
|
||||||
|
}
|
||||||
|
|
||||||
|
function open() {
|
||||||
|
show.value = true
|
||||||
|
nextTick(()=>{
|
||||||
|
setValue()
|
||||||
|
})
|
||||||
|
// emits('open', true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getItem() {
|
||||||
|
let result = []
|
||||||
|
for (let i in value.value) {
|
||||||
|
result.push(list.value[i][value.value[i]])
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirm(e) {
|
||||||
|
const result = getItem()
|
||||||
|
emits('confirm', [...result])
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
|
||||||
|
//防抖
|
||||||
|
function debounce(fn, wait) {
|
||||||
|
let timeout = null;
|
||||||
|
return function() {
|
||||||
|
let context = this;
|
||||||
|
let args = arguments;
|
||||||
|
if (timeout) clearTimeout(timeout);
|
||||||
|
let callNow = !timeout;
|
||||||
|
timeout = setTimeout(() => {
|
||||||
|
timeout = null;
|
||||||
|
}, wait);
|
||||||
|
if (callNow) fn.apply(context, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function changeList() {
|
||||||
|
if (!props.isLink) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const computedArr = returnNowArr(list.value, value.value)
|
||||||
|
list.value = computedArr
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindChange(e) {
|
||||||
|
value.value = e.detail.value
|
||||||
|
debounce(changeList(), 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function pickend(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
close,
|
||||||
|
open,
|
||||||
|
confirm,
|
||||||
|
toggle,
|
||||||
|
resetValue
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.fastTime {
|
||||||
|
.item {
|
||||||
|
background-color: rgb(247, 247, 247);
|
||||||
|
padding: 6rpx 40rpx;
|
||||||
|
border-radius: 6rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top {
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
right: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mask {
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
top: 0;
|
||||||
|
z-index: 999;
|
||||||
|
background-color: rgba(51, 51, 51, .5);
|
||||||
|
|
||||||
|
.activeClass {
|
||||||
|
font-size: 32rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item {
|
||||||
|
line-height: 34px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box {
|
||||||
|
position: absolute;
|
||||||
|
background-color: #fff;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
border-radius: 16rpx 16rpx 0 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed_b {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
padding: 48rpx 120rpx;
|
||||||
|
padding-bottom: calc(env(safe-area-inset-bottom) + 48rpx);
|
||||||
|
z-index: 100;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.picker-view {
|
||||||
|
width: 750rpx;
|
||||||
|
height: 300rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
<template>
|
||||||
|
<view class="my-radio u-font-28 u-flex color-333" @tap.stop="changeVal">
|
||||||
|
<view class="circle u-flex u-row-center" :style="computedStyle()"
|
||||||
|
:class="{active:modelValue,square:shape==='square'}">
|
||||||
|
<uni-icons type="checkmarkempty" v-if="modelValue" :size="size-4" color="#fff"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-l-12">
|
||||||
|
<slot>{{text}}</slot>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
ref
|
||||||
|
} from 'vue'
|
||||||
|
import color from '@/commons/color.js'
|
||||||
|
const props = defineProps({
|
||||||
|
disabled: {
|
||||||
|
type: [Boolean],
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
borderColor: {
|
||||||
|
type: String,
|
||||||
|
default: '#bbb',
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
//单位px
|
||||||
|
type: Number,
|
||||||
|
default: 16,
|
||||||
|
},
|
||||||
|
// v-modal
|
||||||
|
modelValue: {
|
||||||
|
type: [Number, Boolean],
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
shape: {
|
||||||
|
//circle square
|
||||||
|
type: String,
|
||||||
|
default: 'circle',
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function computedStyle() {
|
||||||
|
return `
|
||||||
|
width:${props.size}px;
|
||||||
|
height:${props.size}px;
|
||||||
|
border-color:${props.borderColor};
|
||||||
|
border-color:${props.modelValue?color.ColorMain:props.borderColor};
|
||||||
|
`
|
||||||
|
}
|
||||||
|
const emits = defineEmits(['update:modelValue', 'change'])
|
||||||
|
|
||||||
|
function changeVal() {
|
||||||
|
if (props.disabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
emits('click')
|
||||||
|
let currentVal = props.modelValue
|
||||||
|
let type = typeof currentVal
|
||||||
|
if (type === 'number') {
|
||||||
|
currentVal = currentVal === 0 ? 1 : 0
|
||||||
|
}
|
||||||
|
if (type === 'boolean') {
|
||||||
|
currentVal = !currentVal
|
||||||
|
}
|
||||||
|
emits('update:modelValue', currentVal)
|
||||||
|
emits('change', currentVal)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.my-radio {
|
||||||
|
|
||||||
|
.circle {
|
||||||
|
background: #FFFFFF;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
border-color: $my-main-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
border: 1px solid #707070;
|
||||||
|
border-radius: 50%;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
&.square {
|
||||||
|
border-radius: 8rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,345 @@
|
||||||
|
<template>
|
||||||
|
<up-popup customStyle="overflow: hidden;" :show="show" round="20" mode="bottom" @close="close" @open="open">
|
||||||
|
<view class="reportDamage">
|
||||||
|
<view class="reportDamage_head">
|
||||||
|
<view class="reportDamage_title">{{title}}</view>
|
||||||
|
<up-icon name="close-circle-fill" color="#333" size="25" @tap="close"></up-icon>
|
||||||
|
</view>
|
||||||
|
<view class="reportDamage_content">
|
||||||
|
<view class="reportDamage_cell">
|
||||||
|
<view class="cell_lable">
|
||||||
|
<up-image v-if="type=='product'" class="thumbnail" radius="10" :show-loading="true" :src="item.coverImg"></up-image>
|
||||||
|
<view>{{item.conName}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="cell_value">
|
||||||
|
<up-icon name="minus-circle" color="#999" size="25" @tap="minus"></up-icon>
|
||||||
|
<view class="text">{{vdata.stockNumber}}</view>
|
||||||
|
<up-icon name="plus-circle-fill" color="#318AFE" size="25" @tap="plus"></up-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="reportDamage_cell">
|
||||||
|
<view class="cell_lable">商品单位</view>
|
||||||
|
<view class="cell_value"><view>{{item.conUnit}}</view> <up-icon name="arrow-right" color="#999999" size="15"></up-icon></view>
|
||||||
|
</view>
|
||||||
|
<view class="reportDamage_cell">
|
||||||
|
<view class="cell_lable">报损图片</view>
|
||||||
|
<view class="cell_value file">
|
||||||
|
|
||||||
|
<view class="file_img" v-for="(item,index) in vdata.imgUrlList">
|
||||||
|
<up-image class="file_img_item" :show-loading="true" :src="item"></up-image>
|
||||||
|
<view class="del" @tap="del(index)">
|
||||||
|
<up-icon name="trash" color="#fff" size="25" @tap="plus"></up-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="file" @tap="chooseAndUploadAvatar()">
|
||||||
|
<up-icon name="camera-fill" color="#E5E5E5" size="35"></up-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="reportDamage_footer">
|
||||||
|
<view class="reportDamage_btn" @tap="affirm">确认</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</up-popup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
computed,
|
||||||
|
ref,
|
||||||
|
reactive,
|
||||||
|
onMounted,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
import { $uploadFile } from '@/http/yskApi/file.js'
|
||||||
|
import { consumableBreakage , productBreakage} from '@/http/yskApi/breakage.js'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
show:{
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
type:{
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
title:{
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
item:{
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
|
|
||||||
|
})
|
||||||
|
const emits = defineEmits(['close','open',"affirm"])
|
||||||
|
const vdata = reactive({
|
||||||
|
stockNumber: 1,
|
||||||
|
imgUrlList: [],
|
||||||
|
})
|
||||||
|
let show = ref(props.show)
|
||||||
|
let type = ref(props.type)
|
||||||
|
let itemData = ref(props.item)
|
||||||
|
watch(()=>props.show,(newval)=>{
|
||||||
|
show.value=newval
|
||||||
|
})
|
||||||
|
onMounted(() => {
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
show.value = false;
|
||||||
|
vdata.imgUrlList = [];
|
||||||
|
vdata.stockNumber = 1;
|
||||||
|
emits('close')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开报损弹窗
|
||||||
|
*/
|
||||||
|
function open() {
|
||||||
|
show.value = true;
|
||||||
|
emits('open')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报损数量减少
|
||||||
|
*/
|
||||||
|
function minus() {
|
||||||
|
if ( vdata.stockNumber <= 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vdata.stockNumber--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报损数量增加
|
||||||
|
*/
|
||||||
|
function plus() {
|
||||||
|
vdata.stockNumber++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除报损图片
|
||||||
|
*/
|
||||||
|
function del ( index ) {
|
||||||
|
vdata.imgUrlList.splice(index,1)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传报损图片
|
||||||
|
*/
|
||||||
|
function chooseAndUploadAvatar () {
|
||||||
|
if ( vdata.imgUrlList.length >= 6 ) {
|
||||||
|
uni.showToast({
|
||||||
|
title:'最多只可以上传六张',
|
||||||
|
icon:'none'
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 选择图片
|
||||||
|
uni.chooseImage({
|
||||||
|
count: 1, // 默认为1,只选择一张图片
|
||||||
|
sizeType: ['original', 'compressed'], // 图片质量,原图或压缩
|
||||||
|
sourceType: ['album', 'camera'], // 图片来源,相册或相机
|
||||||
|
success: (res) => {
|
||||||
|
let file = res.tempFiles[0];
|
||||||
|
console.log(res)
|
||||||
|
$uploadFile(file).then(res => {
|
||||||
|
console.log(res);
|
||||||
|
vdata.imgUrlList.push(res.data[0])
|
||||||
|
|
||||||
|
}).catch(res=>{
|
||||||
|
console.log(res);
|
||||||
|
if(res.errMsg){
|
||||||
|
uni.showToast({
|
||||||
|
title:'图片大小超出限制',
|
||||||
|
icon:'error'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fail: chooseImageError => {
|
||||||
|
// 选择图片失败处理逻辑
|
||||||
|
console.log('choose image fail:', chooseImageError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认
|
||||||
|
*/
|
||||||
|
function affirm () {
|
||||||
|
// emits('affirm')
|
||||||
|
if (vdata.imgUrlList.length <= 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title:'请上传报损图片',
|
||||||
|
icon:'none'
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let params = {
|
||||||
|
coverImg: vdata.imgUrlList,
|
||||||
|
}
|
||||||
|
//商品报损
|
||||||
|
if ( type.value == 'consumable') {
|
||||||
|
params.consId = itemData.value.conIn;
|
||||||
|
params.amount = vdata.stockNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
consumableBreakage(params).then((res) => {
|
||||||
|
show.value = false;
|
||||||
|
vdata.imgUrlList = [];
|
||||||
|
vdata.stockNumber = 1;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
close,
|
||||||
|
open,
|
||||||
|
affirm
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.mask {
|
||||||
|
background-color: rgba(51, 51, 51, .5);
|
||||||
|
}
|
||||||
|
::v-deep .u-popup__content{
|
||||||
|
// background-color: transparent;
|
||||||
|
|
||||||
|
}
|
||||||
|
.reportDamage{
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
.reportDamage_head{
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 32rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: #F4F4F4;
|
||||||
|
.reportDamage_title{
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #333333;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.reportDamage_content{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background-color: #fff;
|
||||||
|
|
||||||
|
.reportDamage_cell{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 32rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #333333;
|
||||||
|
border-bottom: 2rpx solid #E5E5E5;
|
||||||
|
.cell_lable{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
.thumbnail{
|
||||||
|
width: 112rpx;
|
||||||
|
height: 112rpx;
|
||||||
|
margin-right: 24rpx;
|
||||||
|
}
|
||||||
|
::v-deep .u-image,.u-image__loading,.u-image__image{
|
||||||
|
width: 100%!important;
|
||||||
|
height: 100%!important;
|
||||||
|
}
|
||||||
|
::v-deep uni-image{
|
||||||
|
width: 112rpx!important;
|
||||||
|
height: 112rpx!important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.cell_value{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
.text{
|
||||||
|
margin-left: 20rpx;
|
||||||
|
margin-right: 20rpx;
|
||||||
|
}
|
||||||
|
.file{
|
||||||
|
padding: 30rpx;
|
||||||
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||||
|
border: 2rpx solid #E5E5E5;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
}
|
||||||
|
.file_img{
|
||||||
|
width: 120rpx;
|
||||||
|
height: 120rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
position: relative;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
.del{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background-color: rgba(0, 0, 0, 0.2);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.file_img_item{
|
||||||
|
width: 120rpx;
|
||||||
|
height: 120rpx;
|
||||||
|
|
||||||
|
}
|
||||||
|
::v-deep .u-image,.u-image__loading,.u-image__image{
|
||||||
|
width: 100%!important;
|
||||||
|
height: 100%!important;
|
||||||
|
}
|
||||||
|
::v-deep uni-image{
|
||||||
|
width: 120rpx!important;
|
||||||
|
height: 120rpx!important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.cell_value.file{
|
||||||
|
// flex-direction: row-reverse;
|
||||||
|
// justify-content: flex-start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.reportDamage_cell:last-child{
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.reportDamage_footer{
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 32rpx;
|
||||||
|
padding-bottom: 68rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.reportDamage_btn{
|
||||||
|
width: 100%;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
text-align: center;
|
||||||
|
background: #318AFE;
|
||||||
|
border-radius: 40rpx 40rpx 40rpx 40rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
<template>
|
||||||
|
<view class="search-box" :class="{'shape-circle':shape==='circle'}">
|
||||||
|
<view class="search-btn u-flex u-flex-1">
|
||||||
|
<image src="@/static/iconImg/icon-search.svg" class="icon-search" />
|
||||||
|
<view class="u-flex-1 u-p-l-24"><input v-model="search.keyword" @confirm="confirm" type="text"
|
||||||
|
placeholder-style="font-size:28rpx;" :placeholder="placeholder" /></view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
<view @tap.stop="clear" v-if="search.keyword">
|
||||||
|
<uni-icons type="clear" size="16" color="#999"></uni-icons>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
reactive
|
||||||
|
} from 'vue';
|
||||||
|
const props = defineProps({
|
||||||
|
placeholder: {
|
||||||
|
type:String,
|
||||||
|
default:'搜索'
|
||||||
|
},
|
||||||
|
shape:{
|
||||||
|
type:String,
|
||||||
|
default:''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const search = reactive({
|
||||||
|
keyword: "",
|
||||||
|
})
|
||||||
|
|
||||||
|
function clear() {
|
||||||
|
search.keyword = ''
|
||||||
|
}
|
||||||
|
const emits = defineEmits(['confirm'])
|
||||||
|
|
||||||
|
function confirm(e) {
|
||||||
|
emits('confirm', search.keyword)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.search-box {
|
||||||
|
background: #F9F9F9;
|
||||||
|
padding: 10rpx 30rpx 10rpx 30rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
display: flex;
|
||||||
|
box-sizing: border-box;
|
||||||
|
&.shape-circle{
|
||||||
|
border-radius: 100px;
|
||||||
|
}
|
||||||
|
.icon-search {
|
||||||
|
width: 26rpx;
|
||||||
|
height: 26rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<view class="u-flex u-p-b-28 item" :class="{'active':active==index}" v-for="(item,index) in list" :key="index">
|
||||||
|
<view class="left ">
|
||||||
|
<view class="circle"></view>
|
||||||
|
<view class="left-line" :class="{hide:index==list.length-1}"></view>
|
||||||
|
</view>
|
||||||
|
<view class="u-p-l-12 ">
|
||||||
|
<view class="u-font-20">{{formatTitle(item[titleKey]||'') }}</view>
|
||||||
|
<view class="u-font-24 u-m-t-2">{{item[contentKey]||''}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
const props = defineProps({
|
||||||
|
active: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
list: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
titleKey: {
|
||||||
|
type: String,
|
||||||
|
default: 'title'
|
||||||
|
},
|
||||||
|
contentKey: {
|
||||||
|
type: String,
|
||||||
|
default: 'content'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function formatTitle(time){
|
||||||
|
return dayjs(time).format('YYYY-M-D HH:MM:ss')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
$leftWidth: 12rpx;
|
||||||
|
$circleSize: 12rpx;
|
||||||
|
$lineWidth: 2rpx;
|
||||||
|
$circleLeft:0;
|
||||||
|
$lineLeft: calc($circleSize / 2 - $lineWidth / 2 );
|
||||||
|
|
||||||
|
.item {
|
||||||
|
color: #999;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.left {
|
||||||
|
height: 100%;
|
||||||
|
width: $leftWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
color: $my-main-color;
|
||||||
|
|
||||||
|
.circle {
|
||||||
|
background: $my-main-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-line {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.circle {
|
||||||
|
position: absolute;
|
||||||
|
top: 6rpx;
|
||||||
|
left: $circleLeft;
|
||||||
|
width: $circleSize;
|
||||||
|
height: $circleSize;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #999;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-line {
|
||||||
|
left: $lineLeft;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 4rpx;
|
||||||
|
top: calc($circleSize + 10rpx);
|
||||||
|
width: $lineWidth;
|
||||||
|
background-color: #999;
|
||||||
|
border-radius: $lineWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hide {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,163 @@
|
||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<view class="q-switch-box" :style="{
|
||||||
|
backgroundColor: modelValue ? activeBgColor : inActiveBgColor,
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
borderRadius: `calc(${height} / 2)`,
|
||||||
|
}" @click.stop="changeSwitch"
|
||||||
|
:class="{disabled:disabled&&openDisabledClass}"
|
||||||
|
>
|
||||||
|
<view v-show="!modelValue" class="before" :style="{
|
||||||
|
left: `calc(${margin} * 2)`,
|
||||||
|
}">
|
||||||
|
<slot name="left">{{ inShowText }}</slot>
|
||||||
|
</view>
|
||||||
|
<!-- 圆圈 -->
|
||||||
|
<view class="circle-inner" :style="{
|
||||||
|
margin: margin,
|
||||||
|
width: circleRadius,
|
||||||
|
height: circleRadius,
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
...switchAnimation,
|
||||||
|
}"></view>
|
||||||
|
<view v-show="modelValue" class="after" :style="{
|
||||||
|
right: `calc(${margin} * 2)`,
|
||||||
|
}">
|
||||||
|
<slot name="right">{{ showText }}</slot>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<!-- 自定义Switch:自定义左右内容 -->
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
computed,
|
||||||
|
ref
|
||||||
|
} from 'vue'
|
||||||
|
const props = defineProps({
|
||||||
|
disabled:{
|
||||||
|
type:Boolean,
|
||||||
|
default:false
|
||||||
|
},
|
||||||
|
openDisabledClass:{
|
||||||
|
type:Boolean,
|
||||||
|
default:true
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
type: String,
|
||||||
|
default: '40rpx',
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
type: String,
|
||||||
|
default: '78rpx',
|
||||||
|
},
|
||||||
|
margin: {
|
||||||
|
type: String,
|
||||||
|
default: '4rpx',
|
||||||
|
},
|
||||||
|
fontSize: {
|
||||||
|
type: String,
|
||||||
|
default: '32rpx',
|
||||||
|
},
|
||||||
|
// 激活背景色
|
||||||
|
activeBgColor: {
|
||||||
|
type: String,
|
||||||
|
default: '#318AFE',
|
||||||
|
},
|
||||||
|
// 未激活背景色
|
||||||
|
inActiveBgColor: {
|
||||||
|
type: String,
|
||||||
|
default: '#ECECEC',
|
||||||
|
},
|
||||||
|
// 激活文本
|
||||||
|
showText: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
// 未激活文本
|
||||||
|
inShowText: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
// v-modal
|
||||||
|
modelValue: {
|
||||||
|
type: [Boolean,Number],
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const emits = defineEmits(['update:modelValue', 'change','click'])
|
||||||
|
// 修改switch值
|
||||||
|
function changeSwitch() {
|
||||||
|
if(props.disabled){
|
||||||
|
emits('click')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let currentVal=props.modelValue
|
||||||
|
let type=typeof currentVal
|
||||||
|
if(type==='number'){
|
||||||
|
currentVal=currentVal===0?1:0
|
||||||
|
}
|
||||||
|
if(type==='boolean'){
|
||||||
|
currentVal=!currentVal
|
||||||
|
}
|
||||||
|
emits('update:modelValue', currentVal)
|
||||||
|
emits('change', currentVal)
|
||||||
|
}
|
||||||
|
// 圆圈半径
|
||||||
|
let circleRadius = computed(() => {
|
||||||
|
return `calc(((${props.height} / 2) - ${props.margin})* 2)`
|
||||||
|
})
|
||||||
|
// 动画效果
|
||||||
|
let switchAnimation = computed(() => {
|
||||||
|
let obj = {
|
||||||
|
transition: `transform 0.3s`,
|
||||||
|
transform: 'translateX(0)',
|
||||||
|
}
|
||||||
|
//激活
|
||||||
|
if (props.modelValue) {
|
||||||
|
let innerRadius = `((${props.height} / 2) - ${props.margin})` //圆圈半径
|
||||||
|
let moveValue =
|
||||||
|
`calc(${props.width} - ${props.margin} * 2 - (${innerRadius} * 2))` //偏移距离 总宽度 - 圆圈左右边距 - 圆圈宽度
|
||||||
|
// console.log('move-value', moveValue)
|
||||||
|
obj.transform = `translateX(${moveValue})`
|
||||||
|
} else {
|
||||||
|
// 未激活
|
||||||
|
obj.transform = 'translateX(0)'
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.q-switch-box {
|
||||||
|
display: flex;
|
||||||
|
background-color: #eaeaea;
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
&.disabled{
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
.circle-inner {
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.before {
|
||||||
|
position: absolute;
|
||||||
|
color: #bbbbbb;
|
||||||
|
font-size: 28rpx;
|
||||||
|
display: flex;
|
||||||
|
height: 100%;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.after {
|
||||||
|
position: absolute;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
display: flex;
|
||||||
|
height: 100%;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,144 @@
|
||||||
|
<template>
|
||||||
|
<view class="u-relative bg border-r-16">
|
||||||
|
|
||||||
|
<view class="u-flex tabs zhanwei u-relative">
|
||||||
|
<view class="active-block" :style="computedBlockStyle">
|
||||||
|
</view>
|
||||||
|
<view class="u-flex-1 u-text-center item" :class="[index===current?'':'active',size]" @tap="changeCurrent(index)"
|
||||||
|
v-for="(item,index) in props.list" :key="index">
|
||||||
|
{{textKey?item[textKey]:item}}
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
<view class="u-flex tabs u-absolute position-all">
|
||||||
|
|
||||||
|
<view class="u-flex-1 u-text-center item" :class="{active:index===current}" @tap="changeCurrent(index)"
|
||||||
|
v-for="(item,index) in props.list" :key="index">
|
||||||
|
{{textKey?item[textKey]:item}}
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
computed,
|
||||||
|
ref,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
const props = defineProps({
|
||||||
|
size:{
|
||||||
|
type: String,
|
||||||
|
default:''
|
||||||
|
},
|
||||||
|
padding: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
list: {
|
||||||
|
type: Array
|
||||||
|
},
|
||||||
|
textKey: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
defaultIndex: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
modelValue: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const emit = defineEmits(['change', 'update:modelValue'])
|
||||||
|
let current = ref(props.modelValue || props.defaultIndex || 0)
|
||||||
|
|
||||||
|
function changeCurrent(index) {
|
||||||
|
current.value = index
|
||||||
|
}
|
||||||
|
const computedBlockStyle = computed(() => {
|
||||||
|
const oneWidth = 100 / props.list.length
|
||||||
|
const left = current.value * oneWidth
|
||||||
|
return {
|
||||||
|
width: oneWidth + '%',
|
||||||
|
left: left + '%'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
watch(() => props.modelValue, (newval) => {
|
||||||
|
current.value = newval
|
||||||
|
})
|
||||||
|
watch(() => current.value, (newval) => {
|
||||||
|
emit('update:modelValue', newval)
|
||||||
|
emit('change', newval)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.zhanwei {
|
||||||
|
.item {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg {
|
||||||
|
background: #E6F0FF;
|
||||||
|
padding: 7rpx 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.border-r-16 {
|
||||||
|
border-radius: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.active-block {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
color: #fff;
|
||||||
|
top: 4rpx;
|
||||||
|
bottom: 4rpx;
|
||||||
|
left: 10rpx;
|
||||||
|
position: absolute;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
transition: all .2s ease-in-out;
|
||||||
|
overflow: hidden;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabs {
|
||||||
|
border-radius: 16rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #318AFE;
|
||||||
|
z-index: 2;
|
||||||
|
|
||||||
|
.active-block {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
color: #fff;
|
||||||
|
top: 4rpx;
|
||||||
|
bottom: 4rpx;
|
||||||
|
left: 0;
|
||||||
|
position: absolute;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
transition: all .2s ease-in-out;
|
||||||
|
overflow: hidden;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item {
|
||||||
|
padding: 9rpx 0;
|
||||||
|
transition: all .2s ease-in-out;
|
||||||
|
position: relative;
|
||||||
|
background-color: transparent;
|
||||||
|
z-index: 2;
|
||||||
|
&.large{
|
||||||
|
padding: 16rpx 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.item.active {
|
||||||
|
border-radius: 8rpx;
|
||||||
|
// background-color: $my-main-color;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<template>
|
||||||
|
<view></view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<template>
|
||||||
|
<myPickerview :list="list" :isLink="false" @confirm="confirm" ref="picker"></myPickerview>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
reactive,
|
||||||
|
ref
|
||||||
|
} from "vue";
|
||||||
|
import myPickerview from './my-pickerview'
|
||||||
|
const picker = ref(null)
|
||||||
|
function generateString(length, char) {
|
||||||
|
return char.repeat(length);
|
||||||
|
}
|
||||||
|
function createNumberArr(len) {
|
||||||
|
return new Array(len).fill(1).map((v, index) => {
|
||||||
|
return `${generateString(`${len}`.length-1,'0')}${index}`.slice(-2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const $HOURS =createNumberArr(24)
|
||||||
|
const $MINUTES = createNumberArr(60)
|
||||||
|
const list = reactive(
|
||||||
|
[
|
||||||
|
$HOURS,
|
||||||
|
[':'],
|
||||||
|
$MINUTES,
|
||||||
|
['至'],
|
||||||
|
$HOURS,
|
||||||
|
[':'],
|
||||||
|
$MINUTES
|
||||||
|
]
|
||||||
|
)
|
||||||
|
const emits=defineEmits(['confirm'])
|
||||||
|
|
||||||
|
function open() {
|
||||||
|
picker.value.open()
|
||||||
|
}
|
||||||
|
function confirm(e){
|
||||||
|
const val=e.join('').replace('至','-')
|
||||||
|
emits('confirm',val)
|
||||||
|
}
|
||||||
|
defineExpose({
|
||||||
|
open
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
<template>
|
||||||
|
<up-upload :fileList="images" @afterRead="afterRead" @delete="deletePic" :multiple="multiple" :width="width"
|
||||||
|
:height="height" :maxCount="maxCount"></up-upload>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
$uploadFile
|
||||||
|
} from '@/http/yskApi/file.js'
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: 60
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: 60
|
||||||
|
},
|
||||||
|
maxCount: {
|
||||||
|
type: [Number],
|
||||||
|
default: 10
|
||||||
|
},
|
||||||
|
multiple: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const emits = defineEmits(['update:modelValue'])
|
||||||
|
const images = ref(props.modelValue)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function uploadfile(par){
|
||||||
|
let file=null;
|
||||||
|
// #ifdef H5
|
||||||
|
file= par.file
|
||||||
|
// #endif
|
||||||
|
// #ifndef H5
|
||||||
|
file= par
|
||||||
|
// #endif
|
||||||
|
return $uploadFile(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
function afterRead(e) {
|
||||||
|
console.log(e);
|
||||||
|
if (Array.isArray(e.file)) {
|
||||||
|
for (let i in e.file) {
|
||||||
|
const file = e.file[i]
|
||||||
|
console.log(file);
|
||||||
|
uploadfile(file).then(res => {
|
||||||
|
console.log(res);
|
||||||
|
images.value.push({
|
||||||
|
url: e.file[i].url,
|
||||||
|
serveUrl: res.data[0]
|
||||||
|
})
|
||||||
|
}).catch(res => {
|
||||||
|
console.log(res);
|
||||||
|
if (res.errMsg) {
|
||||||
|
images.value.splice(i, 1)
|
||||||
|
uni.showToast({
|
||||||
|
title: '图片大小超出限制',
|
||||||
|
icon: 'error'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
const i=0
|
||||||
|
uploadfile(e.file).then(res => {
|
||||||
|
console.log(res);
|
||||||
|
images.value.push({
|
||||||
|
url: e.file.url,
|
||||||
|
serveUrl: res.data[0]
|
||||||
|
})
|
||||||
|
}).catch(res => {
|
||||||
|
console.log(res);
|
||||||
|
if (res.errMsg) {
|
||||||
|
images.value.splice(i, 1)
|
||||||
|
uni.showToast({
|
||||||
|
title: '图片大小超出限制',
|
||||||
|
icon: 'error'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function deletePic(e) {
|
||||||
|
const {
|
||||||
|
index
|
||||||
|
} = e
|
||||||
|
images.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => images.value, (newval) => {
|
||||||
|
emits('update:modelValue', newval)
|
||||||
|
})
|
||||||
|
watch(() => props.modelValue, (newval) => {
|
||||||
|
images.value = newval
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
<template>
|
||||||
|
<uni-file-picker v-model="imgList" file-mediatype="image" mode="grid" :limit="limit" @progress="FileUploadprogress"
|
||||||
|
:image-styles="imageStyles"
|
||||||
|
@delete="fileDelete" @success="FileUploadsuccess" @fail="FileUploadail" @select="FileUploadselect" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
$uploadFile
|
||||||
|
} from '@/http/yskApi/file.js'
|
||||||
|
import {
|
||||||
|
reactive,
|
||||||
|
ref,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
const props = defineProps({
|
||||||
|
images: {
|
||||||
|
type: [Array,String],
|
||||||
|
default: () => {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
limit: {
|
||||||
|
type: Number,
|
||||||
|
default: 10
|
||||||
|
},
|
||||||
|
imageStyles:{
|
||||||
|
type:Object,
|
||||||
|
default:()=>{
|
||||||
|
return {
|
||||||
|
border:{
|
||||||
|
radius:'12rpx'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const emits = defineEmits(['change'])
|
||||||
|
const arr=props.images===''?[]:typeof props.images==='string'? [{path:props.images,url:props.images}]:props.images
|
||||||
|
let imgList = ref(arr)
|
||||||
|
let flag=false
|
||||||
|
const stopWatcher = watch(() => props.images, (newval) => {
|
||||||
|
if(!flag){
|
||||||
|
imgList.value = (typeof newval==='string'&&newval!=='')?[{path:newval,url:newval}]:newval
|
||||||
|
flag=true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
watch(() => imgList.value.length, () => {
|
||||||
|
change()
|
||||||
|
})
|
||||||
|
//图片上传
|
||||||
|
function FileUploadprogress() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileUploadsuccess() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileUploadail() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileUploadselect(e) {
|
||||||
|
for (let i in e.tempFiles) {
|
||||||
|
const file = e.tempFiles[i]
|
||||||
|
$uploadFile(file).then(res => {
|
||||||
|
console.log(res);
|
||||||
|
imgList.value.push({
|
||||||
|
url: res.data[0],
|
||||||
|
path: file.path
|
||||||
|
})
|
||||||
|
}).catch(res=>{
|
||||||
|
console.log(res);
|
||||||
|
if(res.errMsg){
|
||||||
|
imgList.value.splice(i,1)
|
||||||
|
uni.showToast({
|
||||||
|
title:'图片大小超出限制',
|
||||||
|
icon:'error'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fileDelete(e) {
|
||||||
|
const index = imgList.value.findIndex(v => e.tempFilePath === v.path)
|
||||||
|
if (index != -1) {
|
||||||
|
imgList.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
console.log(imgList.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFileList() {
|
||||||
|
if (props.limit === 1) {
|
||||||
|
const item=imgList.value[0]
|
||||||
|
return item===undefined?'':typeof item === 'string' ? item : item.url
|
||||||
|
}
|
||||||
|
return imgList.value.map(v => {
|
||||||
|
const url = v.url
|
||||||
|
return typeof v === 'string' ? v : url
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function change() {
|
||||||
|
console.log(getFileList());
|
||||||
|
emits('change', getFileList())
|
||||||
|
}
|
||||||
|
defineExpose({
|
||||||
|
getFileList
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
const appConfig = {
|
||||||
|
|
||||||
|
// 项目名称
|
||||||
|
appName: '银收客',
|
||||||
|
|
||||||
|
// token取值key
|
||||||
|
tokenKey: 'iToken',
|
||||||
|
// tokenKey: 'satoken',
|
||||||
|
|
||||||
|
// 环境变量相关
|
||||||
|
env: {},
|
||||||
|
|
||||||
|
// 环境变量常量
|
||||||
|
ENV_ENUM: {
|
||||||
|
DEVELOPMENT: 'development', // 本地调试地址
|
||||||
|
TEST: 'test', // 测试地址
|
||||||
|
DEMO: 'demo', // 演示环境
|
||||||
|
PRODUCTION: 'production' // 生产环境
|
||||||
|
},
|
||||||
|
|
||||||
|
storeEnvEnumKey: 'currentEnvEnum', // 本地存储的envkey的值
|
||||||
|
|
||||||
|
encryptKey: '1234567890123456' // http数据加解密的key
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default appConfig;
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
/**
|
||||||
|
* ENV 的封装
|
||||||
|
* 由于uniapp 无法设置.env等打包属性,实现线上,线下多版本配置属性的无缝切换。
|
||||||
|
* process.env.NODE_ENV 将在打包环境通过编译器进行替换, 线上打包后无法获取到 process对象。 所以将配置属性统一封装到appConfig中。
|
||||||
|
*
|
||||||
|
* 环境地址环境枚举详见: appConfig.js
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2021/12/16 17:57
|
||||||
|
*/
|
||||||
|
import appConfig from '@/config/appConfig.js';
|
||||||
|
|
||||||
|
// uni-app 暂时不支持动态import(导包app报错), 需要将所有的env全部导入 = = 、
|
||||||
|
import development from './env.development.js';
|
||||||
|
import test from './env.test.js';
|
||||||
|
import demo from './env.demo.js';
|
||||||
|
import production from './env.production.js';
|
||||||
|
|
||||||
|
const allEnvMap = {
|
||||||
|
development: development,
|
||||||
|
test: test,
|
||||||
|
demo: demo,
|
||||||
|
production: production
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前环境变量
|
||||||
|
const processEnv = process.env.NODE_ENV
|
||||||
|
|
||||||
|
// 改变env环境
|
||||||
|
function changeEnv(envMode){
|
||||||
|
|
||||||
|
appConfig.env = allEnvMap[envMode || processEnv]
|
||||||
|
|
||||||
|
// // 动态导包的方式:设置全局env配置项目 : 当参数不存在, 那么获取node环境
|
||||||
|
// import(`./env.${envMode || processEnv}.js`).then(module => {
|
||||||
|
// appConfig.env = module.default
|
||||||
|
// }).catch(() => {
|
||||||
|
// appConfig.env = production //当出现错误, 比如本地没有复制dev文件时, 默认使用生产环境
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
|
||||||
|
export default { changeEnv: changeEnv }
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
export default {
|
||||||
|
'JEEPAY_BASE_URL': 'https://b.rscygroup.com', // 请求URL(生产环境)
|
||||||
|
'JEEPAY_BASE_URL_H5': 'https://b.rscygroup.com'
|
||||||
|
// 'JEEPAY_BASE_URL': 'http://192.168.1.8:9218' // 请求URL(测试环境)
|
||||||
|
// 'JEEPAY_BASE_URL': 'https://b.qilinshuzi.com' //支付网关URL
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
export default {
|
||||||
|
'JEEPAY_BASE_URL': 'https://b.rscygroup.com', // 请求URL(生产环境)
|
||||||
|
'JEEPAY_BASE_URL_H5': 'https://b.rscygroup.com'
|
||||||
|
// 'JEEPAY_BASE_URL': 'http://192.168.1.8:9218' // 请求URL(测试环境)
|
||||||
|
// 'JEEPAY_BASE_URL': 'https://b.qilinshuzi.com' //支付网关URL
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
export default {
|
||||||
|
'JEEPAY_BASE_URL': 'https://b.rscygroup.com', // 请求URL(生产环境)
|
||||||
|
'JEEPAY_BASE_URL_H5': 'https://b.rscygroup.com'
|
||||||
|
// 'JEEPAY_BASE_URL': 'http://192.168.1.8:9218' // 请求URL(测试环境)
|
||||||
|
// 'JEEPAY_BASE_URL': 'https://b.qilinshuzi.com' //支付网关URL
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
export default {
|
||||||
|
// 'JEEPAY_BASE_URL': 'https://b.shouyinbei.com' // 请求URL(测试地址)
|
||||||
|
'JEEPAY_BASE_URL_H5': 'https://b.rscygroup.com',
|
||||||
|
'JEEPAY_BASE_URL': 'https://b.rscygroup.com' //支付网关URL
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"extEnable": true,
|
||||||
|
"extAppid":"wx9b4f8ff05754599f",
|
||||||
|
"directCommit": false,
|
||||||
|
"ext": {
|
||||||
|
"name": "wechat"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,624 @@
|
||||||
|
/**
|
||||||
|
* api接口管理, 全部以$开头
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2021/12/17 09:57
|
||||||
|
*/
|
||||||
|
|
||||||
|
import http from './http.js'
|
||||||
|
import appConfig from '@/config/appConfig.js'
|
||||||
|
import {
|
||||||
|
Base64
|
||||||
|
} from 'js-base64'
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
|
||||||
|
export const req = {
|
||||||
|
list: (uri, params) => {
|
||||||
|
return http.req(uri, params, 'GET', false)
|
||||||
|
},
|
||||||
|
|
||||||
|
add: (uri, data) => {
|
||||||
|
return http.req(uri, data, 'POST', false)
|
||||||
|
},
|
||||||
|
|
||||||
|
getById: (uri, bizId) => {
|
||||||
|
return http.req(`${uri}/${bizId}`, {}, 'GET', false)
|
||||||
|
},
|
||||||
|
|
||||||
|
updateById: (uri, bizId, data) => {
|
||||||
|
return http.req(`${uri}/${bizId}`, data, 'PUT', false)
|
||||||
|
},
|
||||||
|
|
||||||
|
delById: (uri, bizId) => {
|
||||||
|
return http.req(`${uri}/${bizId}`, {}, 'DELETE', false)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export const reqLoad = {
|
||||||
|
list: (uri, params) => {
|
||||||
|
return http.req(uri, params, 'GET')
|
||||||
|
},
|
||||||
|
|
||||||
|
add: (uri, data) => {
|
||||||
|
return http.req(uri, data, 'POST')
|
||||||
|
},
|
||||||
|
|
||||||
|
getById: (uri, bizId) => {
|
||||||
|
return http.req(`${uri}/${bizId}`, {}, 'GET')
|
||||||
|
},
|
||||||
|
|
||||||
|
updateById: (uri, bizId, data) => {
|
||||||
|
return http.req(`${uri}/${bizId}`, data, 'PUT')
|
||||||
|
},
|
||||||
|
|
||||||
|
delById: (uri, bizId) => {
|
||||||
|
return http.req(`${uri}/${bizId}`, {}, 'DELETE')
|
||||||
|
},
|
||||||
|
|
||||||
|
// 通用 新增 or 更新
|
||||||
|
addOrUpdate: (bizId, url, data, showMessage = true) => {
|
||||||
|
//包含bizId 请求的是修改接口
|
||||||
|
if (bizId) {
|
||||||
|
return reqLoad.updateById(url, bizId, data).then((res) => {
|
||||||
|
if (showMessage) {
|
||||||
|
return infoBox.showSuccessToast('更新成功').then(() => res)
|
||||||
|
}
|
||||||
|
return Promise.resolve(res)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return reqLoad.add(url, data).then((res) => {
|
||||||
|
if (showMessage) {
|
||||||
|
return infoBox.showSuccessToast('新增成功').then(() => res)
|
||||||
|
}
|
||||||
|
return Promise.resolve(res)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 上传文件 url **/
|
||||||
|
export const API_URL_SINGLE_FILE_UPLOAD = '/api/ossFiles/singleFile'
|
||||||
|
|
||||||
|
/** 公告 **/
|
||||||
|
export const API_URL_SYS_ARTICLES = '/api/sysArticles'
|
||||||
|
|
||||||
|
/** 支付订单列表 */
|
||||||
|
export const API_URL_PAY_ORDER_LIST = '/api/payOrder'
|
||||||
|
|
||||||
|
/** 退款订单列表 */
|
||||||
|
export const API_URL_REFUND_LIST = '/api/refundOrder'
|
||||||
|
|
||||||
|
/** 商户应用 */
|
||||||
|
export const API_URL_MCH_APP_LIST = '/api/mchApps'
|
||||||
|
|
||||||
|
/** 门店列表 */
|
||||||
|
export const API_URL_MCH_STORE_LIST = '/api/mchStore'
|
||||||
|
|
||||||
|
/** 通知接收人列表 */
|
||||||
|
export const API_URL_WXMP_USER_LIST = '/api/wxmp'
|
||||||
|
|
||||||
|
/** 进件管理 */
|
||||||
|
export const API_URL_MCH_APPLYMENT_LIST = '/api/mchApplyments'
|
||||||
|
|
||||||
|
/** 员工管理 */
|
||||||
|
export const API_URL_SYS_USER_LIST = '/api/sysUsers'
|
||||||
|
|
||||||
|
/** 码牌管理 */
|
||||||
|
export const API_URL_SYS_CODE_LIST = '/api/mchQrCodes'
|
||||||
|
|
||||||
|
/** 通用设备管理 deviceType 1-喇叭 2-打印机 3-扫码POS 4-智能POS 6-刷脸设备*/
|
||||||
|
export const API_URL_SYS_DEVICE_LIST = '/api/store/device'
|
||||||
|
|
||||||
|
/** 辅助终端管理*/
|
||||||
|
export const API_URL_SYS_TERMINALS = '/api/mchTerminals'
|
||||||
|
|
||||||
|
/** 用户绑定门店列表 */
|
||||||
|
export const API_URL_USER_BIND_STORE_LIST = '/api/mchStore/userStoreRelas'
|
||||||
|
|
||||||
|
/** 商户支付通道列表 */
|
||||||
|
export const API_URL_PAY_PASSAGE_LIST = '/api/mch/payPassages'
|
||||||
|
/** 广告列表 */
|
||||||
|
export const API_URI_PAY_AD_LIST = '/api/advert'
|
||||||
|
/** 如意门店操作 */
|
||||||
|
export const API_URI_DEV_RUYI = '/api/alipayShop'
|
||||||
|
|
||||||
|
/** 会员管理 */
|
||||||
|
export const API_URL_MEMBERS = '/api/member'
|
||||||
|
|
||||||
|
/** 会员充值记录 */
|
||||||
|
export const API_URL_MEMBER_RECHARGE_RECORDS = '/api/member/rechargeRecord'
|
||||||
|
|
||||||
|
/** 会员充值规则管理 */
|
||||||
|
export const API_URL_MEMBER_RECHARGE_RULES = '/api/member/rechargeRule'
|
||||||
|
|
||||||
|
/** 会员账户流水 */
|
||||||
|
export const API_URL_MEMBER_ACCOUNT_HISTORY = '/api/member/accountHistory'
|
||||||
|
|
||||||
|
//营销红包开始
|
||||||
|
|
||||||
|
//红包规则
|
||||||
|
export const API_URL_MCH_REF_PACKET_RULE_LIST = '/api/redPacketRule'
|
||||||
|
//新增红包规则
|
||||||
|
export const API_URL_MCH_REF_PACKET_RULE_ADD = '/api/redPacketRule'
|
||||||
|
|
||||||
|
//顾客统计
|
||||||
|
export const API_URL_MCH_REF_PACKET_RULE_COUNT = '/api/redPacketUser/count'
|
||||||
|
//顾客列表
|
||||||
|
export const API_URL_MCH_REF_PACKET_USER_LIST = '/api/redPacketUser'
|
||||||
|
//顾客红包
|
||||||
|
export const API_URL_MCH_REF_PACKET_INFO_LIST = '/api/redPacketInfo'
|
||||||
|
//红包查询规则详情
|
||||||
|
export const API_URL_MCH_REF_PACKET_RULE_QUERY = '/api/redPacketRule'
|
||||||
|
//红包修改规则
|
||||||
|
export const API_URL_MCH_REF_PACKET_RULE_EDIT = '/api/redPacketRule/edit'
|
||||||
|
//红包余额变动明细列表
|
||||||
|
export const API_URL_MCH_REF_PACKET_CHANGE = '/api/redPacketChange'
|
||||||
|
//渠道列表
|
||||||
|
export const API_URL_MCH_ISV_LIST = '/api/isvInfo/isvInfoList'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* 密码登录 */
|
||||||
|
export function $loginByPwd(username, pwd, safetyCode) {
|
||||||
|
// 登录类型
|
||||||
|
let lt = ''
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
lt = Base64.encode('APP')
|
||||||
|
// #endif
|
||||||
|
// #ifdef H5 || MP-WEIXIN
|
||||||
|
lt = Base64.encode('LITE')
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
ia: Base64.encode(username),
|
||||||
|
ip: Base64.encode(pwd),
|
||||||
|
mc: safetyCode ? Base64.encode(safetyCode) : null,
|
||||||
|
lt: lt,
|
||||||
|
}
|
||||||
|
return http.req('/api/anon/auth/validate', data, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 验证码登录 */
|
||||||
|
export function $phoneCodeLogin(phone, code) {
|
||||||
|
// 登录类型
|
||||||
|
let lt = ''
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
lt = Base64.encode('APP')
|
||||||
|
// #endif
|
||||||
|
// #ifdef H5 || MP-WEIXIN
|
||||||
|
lt = Base64.encode('LITE')
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
phone: Base64.encode(phone),
|
||||||
|
code: Base64.encode(code),
|
||||||
|
lt: lt,
|
||||||
|
}
|
||||||
|
|
||||||
|
return http.req('/api/anon/auth/phoneCode', data, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 找回密码
|
||||||
|
export function $retrieve({
|
||||||
|
phone,
|
||||||
|
code,
|
||||||
|
newPwd
|
||||||
|
}) {
|
||||||
|
let data = {
|
||||||
|
phone: Base64.encode(phone),
|
||||||
|
code: Base64.encode(code),
|
||||||
|
newPwd: newPwd ? Base64.encode(newPwd) : ''
|
||||||
|
}
|
||||||
|
return http.req('/api/anon/cipher/retrieve', data, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 修改密码 */
|
||||||
|
export function $modifyPwd({
|
||||||
|
originalPwd,
|
||||||
|
confirmPwd
|
||||||
|
}) {
|
||||||
|
let data = {
|
||||||
|
originalPwd: Base64.encode(originalPwd),
|
||||||
|
confirmPwd: Base64.encode(confirmPwd)
|
||||||
|
}
|
||||||
|
return http.req("/api/current/modifyPwd", data, "PUT")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 注册新商户 */
|
||||||
|
export function $mchRegister({
|
||||||
|
mchName,
|
||||||
|
confirmPwd,
|
||||||
|
inviteCode,
|
||||||
|
phone,
|
||||||
|
code
|
||||||
|
}) {
|
||||||
|
let data = {
|
||||||
|
mchName: mchName, // 用户名称
|
||||||
|
confirmPwd: Base64.encode(confirmPwd), // 确认密码
|
||||||
|
inviteCode, // 邀请码
|
||||||
|
phone: Base64.encode(phone), // 手机号
|
||||||
|
code: Base64.encode(code), // 短信验证码
|
||||||
|
}
|
||||||
|
return http.req('/api/anon/register/mchRegister', data, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 发送短信验证码 */
|
||||||
|
export function $sendSms(data, smsType) {
|
||||||
|
return http.req('/api/anon/sms/code', {
|
||||||
|
phone: data.phone,
|
||||||
|
vercode: data.vercode,
|
||||||
|
vercodeToken: data.vercodeToken,
|
||||||
|
smsType: smsType
|
||||||
|
}, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 获取个人信息 */
|
||||||
|
export function $userInfo(cid1, cid2) {
|
||||||
|
return http.req('/api/current/user', {
|
||||||
|
cid1,
|
||||||
|
cid2
|
||||||
|
}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 获取公司信息 */
|
||||||
|
export function $getSiteInfos() {
|
||||||
|
return http.req('/api/anon/siteInfos', {}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 隐私政策与服务协议
|
||||||
|
export function $getTreaty() {
|
||||||
|
return http.req('/api/anon/treaty', {}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 快捷收银 */
|
||||||
|
export function $appPay(storeId, amount, sellerRemark, wayCode, authCode) {
|
||||||
|
let data = {
|
||||||
|
storeId,
|
||||||
|
amount,
|
||||||
|
sellerRemark,
|
||||||
|
wayCode,
|
||||||
|
authCode
|
||||||
|
}
|
||||||
|
|
||||||
|
// 二维码, 返回结果为 图片地址
|
||||||
|
if (wayCode == 'QR_CASHIER') {
|
||||||
|
data.payDataType = 'codeImgUrl'
|
||||||
|
}
|
||||||
|
|
||||||
|
return http.req('/api/pay/app', data, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 当前商户信息 */
|
||||||
|
export function $getMchInfo() {
|
||||||
|
return http.req('/api/mainChart', {}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 订单打印 */
|
||||||
|
export function $payOrderPrint(orderId) {
|
||||||
|
return http.req('/api/payOrder/print/' + orderId, {}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 订单退款 */
|
||||||
|
export function $payOrderRefund(orderId, refundAmount, refundReason, refundPassword) {
|
||||||
|
return http.req(
|
||||||
|
'/api/payOrder/refunds/' + orderId, {
|
||||||
|
refundAmount: refundAmount,
|
||||||
|
refundReason: refundReason,
|
||||||
|
refundPassword: Base64.encode(refundPassword),
|
||||||
|
refundModel: 1
|
||||||
|
},
|
||||||
|
'POST'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// // 首页统计信息
|
||||||
|
// export function $indexStatistics (queryDateRange) {
|
||||||
|
// return http.req('/api/mainChart/payDayCount', { queryDateRange }, 'GET')
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 首页统计信息
|
||||||
|
export function $indexStatistics(queryDateRange) {
|
||||||
|
return http.req('/api/payOrder/count?queryDateRange', {
|
||||||
|
queryDateRange
|
||||||
|
}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 统计报表
|
||||||
|
export function $getStatInfo(data) {
|
||||||
|
return http.req('/api/statistic/total', data, 'GET', false)
|
||||||
|
}
|
||||||
|
// 统计报表设备 门店 支付方式统计
|
||||||
|
export function $getStatistic(data) {
|
||||||
|
return http.req('/api/statistic', data, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 经纬度转换为areacode */
|
||||||
|
export function $location2areacode(location) {
|
||||||
|
return http.req('/api/mchStore/location2areacode/', {
|
||||||
|
location: location
|
||||||
|
}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 获取上传form信息 */
|
||||||
|
export function $ossFilesForm(bizType, file) {
|
||||||
|
let postData = {
|
||||||
|
bizType: bizType,
|
||||||
|
sourceFileName: file.name || file.path, // 如果没有name 则使用pach替换
|
||||||
|
sourceFileSize: file.size,
|
||||||
|
}
|
||||||
|
|
||||||
|
return http.req('/api/ossFiles/form', postData, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 系统设置 */
|
||||||
|
// 获取语音播报开关信息
|
||||||
|
export function $mchConfig(groupKey) {
|
||||||
|
return http.req('/api/mchConfig', {
|
||||||
|
groupKey: groupKey
|
||||||
|
}, 'GET')
|
||||||
|
}
|
||||||
|
// 修改语音播报开关信息
|
||||||
|
export function $orderConfig(configData, mchNo) {
|
||||||
|
console.log('mchNo', mchNo);
|
||||||
|
return http.req('/api/mchConfig/orderConfig', {
|
||||||
|
configData: configData,
|
||||||
|
mchNo: mchNo
|
||||||
|
}, 'PUT')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 修改个人信息 */
|
||||||
|
export function $modifyUser({
|
||||||
|
realname,
|
||||||
|
avatarUrl
|
||||||
|
}) {
|
||||||
|
return http.req("/api/current/user", {
|
||||||
|
realname,
|
||||||
|
avatarUrl
|
||||||
|
}, "PUT")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 获取密码规则 */
|
||||||
|
export function $getPasswordRules() {
|
||||||
|
return http.req("/api/anon/cipher/pwdRulesRegexp", "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证是否有密码
|
||||||
|
export function $isSipw() {
|
||||||
|
return http.req("/api/mchConfig/hasSipwValidate", "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证原支付密码是否正确
|
||||||
|
export function $isMchSipw(originalPwd) {
|
||||||
|
return http.req("/api/mchConfig/mchSipwValidate", {
|
||||||
|
originalPwd: Base64.encode(originalPwd)
|
||||||
|
}, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 更新支付密码 */
|
||||||
|
export function $updateMchSipw({
|
||||||
|
originalPwd,
|
||||||
|
confirmPwd
|
||||||
|
}) {
|
||||||
|
let data = {
|
||||||
|
originalPwd: Base64.encode(originalPwd),
|
||||||
|
confirmPwd: Base64.encode(confirmPwd)
|
||||||
|
}
|
||||||
|
return http.req("/api/mchConfig/mchSipw", data, "PUT")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 版本检测 */
|
||||||
|
export function $versionDetection({
|
||||||
|
versionNumber
|
||||||
|
}) {
|
||||||
|
return http.req("/api/anon/clientVersion/versionInfo", {
|
||||||
|
versionNumber: versionNumber
|
||||||
|
}, "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 查询用户权限 */
|
||||||
|
export function $getUserEntRoles(sysUserId) {
|
||||||
|
return http.req("/api/sysUsers/userEntRoles/" + sysUserId, {}, "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 更新用户权限 */
|
||||||
|
export function $updateUserEntRoles(sysUserId, ruleName, state) {
|
||||||
|
return http.req("/api/sysUsers/userEntRoles/" + sysUserId, {
|
||||||
|
ruleName,
|
||||||
|
state
|
||||||
|
}, "PUT")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 根据支付方式查询可配置的支付接口 */
|
||||||
|
export function $getAvailablePayInterface(appId, wayCode) {
|
||||||
|
return http.req(`/api/mch/payPassages/availablePayInterface/${appId}/${wayCode}`, "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 支付方式配置支付接口 */
|
||||||
|
export function $wayCodeConfigIfCode(appId, wayCode, ifCode) {
|
||||||
|
|
||||||
|
let reqData = {
|
||||||
|
appId: appId,
|
||||||
|
wayCode: wayCode,
|
||||||
|
ifCode: ifCode,
|
||||||
|
state: 1
|
||||||
|
}
|
||||||
|
return http.req(`/api/mch/payPassages/mchPassage`, reqData, "POST")
|
||||||
|
}
|
||||||
|
/*码牌扫码 二维码解析*/
|
||||||
|
export function $parseQrCodeUrl(qrUrl) {
|
||||||
|
return http.req('/api/mchQrCodes/parseQrCodeUrl', {
|
||||||
|
qrUrl
|
||||||
|
}, 'GET')
|
||||||
|
}
|
||||||
|
/*码牌绑定*/
|
||||||
|
export function $bindEmptyQR(qrcInfo) {
|
||||||
|
return http.req('/api/mchQrCodes/bindEmptyQR', qrcInfo, 'POST')
|
||||||
|
}
|
||||||
|
/*解绑码牌*/
|
||||||
|
export function $unBindQrc(qrcId) {
|
||||||
|
return http.req('/api/mchQrCodes/unbind/' + qrcId, {}, 'POST')
|
||||||
|
}
|
||||||
|
/*码牌查询受支持的云喇叭设备*/
|
||||||
|
export function $getHornList(qrcId) {
|
||||||
|
return http.req('/api/mchQrCodes/bindDevice/' + qrcId, 'GET')
|
||||||
|
}
|
||||||
|
/* 更新默认 */
|
||||||
|
export function $updateTrmDefault(trmId, defaultFlag) {
|
||||||
|
return http.req('/api/mchTerminals/trmDefaults', {
|
||||||
|
trmId,
|
||||||
|
defaultFlag
|
||||||
|
}, 'PUT')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 设备解绑 */
|
||||||
|
export function $deviceUnbind(deviceId) {
|
||||||
|
return http.req('/api/store/device/unbind/' + deviceId, {}, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 渠道报备列表 */
|
||||||
|
export function $terminalChannelBindList(trmId) {
|
||||||
|
return http.req('/api/mchTerminals/channelBindInfos/' + trmId, {}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 渠道报备 */
|
||||||
|
export function $terminalChannelBindSend(trmId, ifCode) {
|
||||||
|
return http.req('/api/mchTerminals/channelSendup/' + trmId, {
|
||||||
|
ifCode: ifCode,
|
||||||
|
state: 1
|
||||||
|
}, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 扫码登录
|
||||||
|
export function $scanCodeLogin(qrcodeNo, qrcodeStatus) {
|
||||||
|
return http.req("/api/current/qrcode/login", {
|
||||||
|
qrcodeNo,
|
||||||
|
qrcodeStatus
|
||||||
|
}, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 云喇叭 播报测试
|
||||||
|
export function $speakTest(devId, amount) {
|
||||||
|
return http.req("/api/store/device/speak/" + devId, amount, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 云打印 打印测试
|
||||||
|
export function $printTest(devId, amount) {
|
||||||
|
return http.req(`/api/store/device/print/${devId}`, {
|
||||||
|
amount
|
||||||
|
}, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 获取百度语音播报token */
|
||||||
|
export function $getBaiduToken() {
|
||||||
|
return http.req("/api/pushinfo/getBaiduToken", {}, "GET")
|
||||||
|
}
|
||||||
|
// 获取通知接收人二维码图片
|
||||||
|
export function $getWxMpInfo() {
|
||||||
|
return http.req("/api/wxmp/getWxmpInfo", {}, "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 获取进件通道列表 */
|
||||||
|
export function $getAllAllowApplymentIfCodeList() {
|
||||||
|
return http.req("/api/payConfig/ifCodes", {
|
||||||
|
infoId: 'CURRENT',
|
||||||
|
configMode: 'mchApplyment'
|
||||||
|
}, "GET")
|
||||||
|
}
|
||||||
|
/* 查询店长可以绑定的门店 */
|
||||||
|
export function $getBindStoreList(params) {
|
||||||
|
return http.req('/api/mchStore/bindStoreList', params, "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 提交unipush cid */
|
||||||
|
export function $pushInfoRegister(data) {
|
||||||
|
console.log('push cid', data);
|
||||||
|
return http.req("/api/pushinfo/register", data, "POST")
|
||||||
|
}
|
||||||
|
/* 获取广告接口*/
|
||||||
|
export function $adList(params) {
|
||||||
|
return http.req('/api/advert/appAdvert', params, 'GET')
|
||||||
|
}
|
||||||
|
/** 如意Lite 绑定解绑接口 */
|
||||||
|
export function $BindLite(data) {
|
||||||
|
return http.req('/api/alipayIot/bind/' + data.deviceId, data, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取支付宝扫码授权
|
||||||
|
export function $aliPayQrCodeOrApply(account = '', type = 'queryResult') {
|
||||||
|
return http.req(`/api/alipaySpOperation/${type}`, {
|
||||||
|
alipayAccount: account
|
||||||
|
}, type == 'apply' ? 'POST' : 'GET')
|
||||||
|
}
|
||||||
|
// 获取支付宝授权信息
|
||||||
|
export function $aliAccountInfo() {
|
||||||
|
return http.req('/api/alipaySpOperation/authInfo', {}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询蚂蚁店铺状态
|
||||||
|
export function $queryAliStore(storeId) {
|
||||||
|
return req.getById('/api/alipayShop/createResult', storeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获取上传图片 大小
|
||||||
|
export function $getUploadImgSize() {
|
||||||
|
return http.req('/api/defaultConfig', {}, "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 会员调账
|
||||||
|
export function $memberManual(params) {
|
||||||
|
return http.req('/api/member/manual/' + params.memberId, params, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询或修改会员配置信息
|
||||||
|
export function $findOrEditMemberConfig(data, mode = 'GET', uri = '') {
|
||||||
|
return http.req('/api/mchConfig' + uri, data, mode)
|
||||||
|
}
|
||||||
|
/* 会员数据统计 */
|
||||||
|
export function $memberInfoCount(params) {
|
||||||
|
return http.req('/api/member/count', params, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 查询商户支付应用 费率参数是否配置 */
|
||||||
|
export function $getMchPayPassage(appId, ifCode) {
|
||||||
|
return http.req(`/api/payConfig/existPayParams/${appId}/${ifCode}`, {}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 获取进件渠道列表 */
|
||||||
|
export function $getAllIsvInfoList(ifCode, range = 0) {
|
||||||
|
return http.req("/api/isvInfo/isvInfoList", {
|
||||||
|
pageNumber: "-1",
|
||||||
|
range: range,
|
||||||
|
ifCode: ifCode
|
||||||
|
}, "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 请求验证码
|
||||||
|
export function $isCode() {
|
||||||
|
return http.req("/api/anon/auth/vercode", "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
export function $pmdfb(data) {
|
||||||
|
return http.req("/api/store/device/setMarqueeInfo", data, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
export function $getImgWH(params) {
|
||||||
|
return http.req(`/api/store/device/getMarketPoint/${params}`, "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
export function $initializeImg(params) {
|
||||||
|
return http.req(`/api/store/device/getMarketPic/${params}`, "GET")
|
||||||
|
}
|
||||||
|
|
||||||
|
export function $uploadImg(data) {
|
||||||
|
return http.req(`/api/store/device/setMarketPic`, data, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 获取上传form信息 */
|
||||||
|
export function $NewOssFilesForm(data) {
|
||||||
|
return http.req("/api/ossFiles/form", data, "POST")
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import request from './businessHttp.js'
|
||||||
|
import useStorage from '@/commons/utils/useStroage.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录
|
||||||
|
* @param {Object} data
|
||||||
|
*/
|
||||||
|
export function login(data) {
|
||||||
|
return request('/login/wx/merchant/login', data, 'post')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 桌台列表
|
||||||
|
* @param {Object} areaId
|
||||||
|
*/
|
||||||
|
export function tableList(areaId) {
|
||||||
|
return request('/table/list', {
|
||||||
|
shopId: useStorage.get('userInfo').shopId,
|
||||||
|
areaId: areaId
|
||||||
|
}, 'post')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域列表
|
||||||
|
* @param {Object} data
|
||||||
|
*/
|
||||||
|
export function areaList(data) {
|
||||||
|
return request('/table/area', {
|
||||||
|
shopId: useStorage.get('userInfo').shopId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定桌码
|
||||||
|
* @param {Object} data
|
||||||
|
*/
|
||||||
|
export function tableBinding(data) {
|
||||||
|
return request('/table/binding', data, 'post')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录获取openid
|
||||||
|
* @param {Object} data
|
||||||
|
*/
|
||||||
|
export function wxlogin(data) {
|
||||||
|
return request('/login/wx/business/login', data)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
/**
|
||||||
|
* 因为两个小程序接口不一致,餐饮商超商家端的接口使用该http
|
||||||
|
*/
|
||||||
|
import useStorage from '@/commons/utils/useStroage.js'
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
// const baseURL = 'http://192.168.2.128:9000/cashierService'
|
||||||
|
// const baseURL = 'http://192.168.2.41:9888/cashierService'
|
||||||
|
let baseURL = 'https://wxcashiertest.sxczgkj.cn/cashierService'
|
||||||
|
// #ifdef H5
|
||||||
|
baseURL = '/ysk'
|
||||||
|
// #endif
|
||||||
|
// const baseURL = 'https://cashier.sxczgkj.cn/cashierService'
|
||||||
|
export default function(api = '', data = {}, method = 'GET') {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.request({
|
||||||
|
url: `${baseURL}${api}`,
|
||||||
|
method: method,
|
||||||
|
data: data,
|
||||||
|
header: {
|
||||||
|
'environment': 'wx',
|
||||||
|
'type': 'ios',
|
||||||
|
'version': '1.0.0',
|
||||||
|
'token': useStorage.get('iToken'),
|
||||||
|
'Authorization': useStorage.get('iToken'),
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
success: res => {
|
||||||
|
if (res.data.code == 0) {
|
||||||
|
resolve(res.data)
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
"title": res.data.msg
|
||||||
|
})
|
||||||
|
if(res.data.code==-4){
|
||||||
|
setTimeout(()=>{
|
||||||
|
go.to('PAGES_LOGIN', {}, 'redirect')
|
||||||
|
},2000)
|
||||||
|
}
|
||||||
|
reject(res.data.msg)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: err => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
"title": err.errMsg
|
||||||
|
})
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
class API {
|
||||||
|
constructor(url,req) {
|
||||||
|
const map={
|
||||||
|
add:'POST',
|
||||||
|
del:'DELETE',
|
||||||
|
update:'PUT',
|
||||||
|
get:'GET'
|
||||||
|
}
|
||||||
|
this.url=url
|
||||||
|
for(let key in map){
|
||||||
|
this[key]=function(data){
|
||||||
|
data=Array.isArray(data)?data:{...data,shopId:uni.getStorageSync('shopId')}
|
||||||
|
if(key==='del'){
|
||||||
|
delete data.shopId
|
||||||
|
}
|
||||||
|
return req(url, data,map[key])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default API
|
||||||
|
|
@ -0,0 +1,161 @@
|
||||||
|
/**
|
||||||
|
* HTTP的封装, 基于uni.request
|
||||||
|
* 包括: 通用响应结果的处理 和 业务的增删改查函数
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2021/12/16 18:35
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 导入全局属性
|
||||||
|
import appConfig from '@/config/appConfig.js'
|
||||||
|
import storageManage from '@/commons/utils/storageManage.js'
|
||||||
|
import { sm4DecryptByResData } from '@/commons/utils/encryptUtil.js'
|
||||||
|
import infoBox from "@/commons/utils/infoBox.js"
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
let baseUrl = 'http://101.37.12.135:8080'
|
||||||
|
// #ifdef H5
|
||||||
|
baseUrl = '/server3/mch'
|
||||||
|
// #endif
|
||||||
|
// #ifndef H5
|
||||||
|
baseUrl = 'http://101.37.12.135:8080/mch'
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// 多少 ms 以内, 不提示loading
|
||||||
|
const loadingShowTime = 200
|
||||||
|
|
||||||
|
// 通用处理逻辑
|
||||||
|
function commonsProcess(showLoading, httpReqCallback){
|
||||||
|
|
||||||
|
// 判断是否请求完成(用作 是否loading )
|
||||||
|
// 包括: 'ing', 'ingLoading', 'finish'
|
||||||
|
let reqState = 'ing'
|
||||||
|
|
||||||
|
// 是否已经提示的错误信息
|
||||||
|
let isShowErrorToast = false
|
||||||
|
|
||||||
|
|
||||||
|
// 请求完成, 需要处理的动作
|
||||||
|
let reqFinishFunc = () => {
|
||||||
|
|
||||||
|
if(reqState == 'ingLoading'){ // 关闭loading弹层
|
||||||
|
infoBox.hideLoading()
|
||||||
|
}
|
||||||
|
reqState = 'finish' // 请求完毕
|
||||||
|
}
|
||||||
|
|
||||||
|
// 明确显示loading
|
||||||
|
if(showLoading){
|
||||||
|
// xx ms内响应完成,不提示loading
|
||||||
|
setTimeout(() => {
|
||||||
|
if(reqState == 'ing'){
|
||||||
|
reqState = 'ingLoading'
|
||||||
|
infoBox.showLoading()
|
||||||
|
}
|
||||||
|
}, loadingShowTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpReqCallback().then((httpData) => {
|
||||||
|
|
||||||
|
reqFinishFunc(); // 请求完毕的动作
|
||||||
|
|
||||||
|
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
|
||||||
|
let { statusCode, data } = httpData
|
||||||
|
// 避免混淆重新命名
|
||||||
|
let bodyData = data
|
||||||
|
if(statusCode == 401){
|
||||||
|
|
||||||
|
// 清楚 token
|
||||||
|
storageManage.token(null, true)
|
||||||
|
|
||||||
|
// 提示信息
|
||||||
|
isShowErrorToast = true
|
||||||
|
// infoBox.showErrorToast('请登录').then(() => {
|
||||||
|
// go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH)
|
||||||
|
// })
|
||||||
|
return Promise.reject(bodyData) // 跳转到catch函数
|
||||||
|
}
|
||||||
|
// http响应码不正确
|
||||||
|
if(statusCode != 200){
|
||||||
|
isShowErrorToast = true
|
||||||
|
infoBox.showToast('服务器异常')
|
||||||
|
return Promise.reject(bodyData) // 跳转到catch函数
|
||||||
|
}
|
||||||
|
|
||||||
|
// 业务响应异常
|
||||||
|
if(bodyData.code != 0){
|
||||||
|
isShowErrorToast = true
|
||||||
|
infoBox.showToast(bodyData.msg)
|
||||||
|
if(bodyData.code == 5005){ // 密码已过期, 直接跳转到更改密码页面
|
||||||
|
uni.reLaunch({url: '/pageUser/setting/updatePwd'})
|
||||||
|
}
|
||||||
|
if(bodyData.code == 500){ // 密码已过期, 直接跳转到更改密码页面
|
||||||
|
uni.redirectTo({url: '/pages/login/index'})
|
||||||
|
}
|
||||||
|
return Promise.reject(bodyData)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加密数据
|
||||||
|
if(!bodyData.data && bodyData.encryptData){
|
||||||
|
|
||||||
|
return Promise.resolve({ bizData: sm4DecryptByResData(bodyData.encryptData), code: bodyData.code })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构造请求成功的响应数据
|
||||||
|
return Promise.resolve({ bizData: bodyData.data, code: bodyData.code })
|
||||||
|
|
||||||
|
}).catch( res => {
|
||||||
|
reqFinishFunc(); // 请求完毕的动作
|
||||||
|
// 如果没有提示错误, 那么此处提示 异常。
|
||||||
|
if(!isShowErrorToast){
|
||||||
|
infoBox.showToast(`请求网络异常`)
|
||||||
|
}
|
||||||
|
return Promise.reject(res)
|
||||||
|
|
||||||
|
}).finally(() => { // finally 是 then结束后再执行, 此处不适用。 需要在请求完成后立马调用: reqFinishFunc()
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 默认 显示loading(控制 xxs 内 不提示loading )
|
||||||
|
function req(uri, data, method = "GET", showLoading = true, extParams = {}){
|
||||||
|
|
||||||
|
// 放置token
|
||||||
|
let headerObject = {}
|
||||||
|
headerObject[appConfig.tokenKey] = storageManage.token()
|
||||||
|
headerObject["satoken"] = storageManage.token()
|
||||||
|
|
||||||
|
return commonsProcess(showLoading, () => {
|
||||||
|
return uni.request(
|
||||||
|
Object.assign({url: baseUrl + uri, data: data, method: method, header: headerObject}, extParams )
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 上传
|
||||||
|
function upload(uri, data, file, showLoading = true, extParams = {}){
|
||||||
|
|
||||||
|
// 放置token
|
||||||
|
let headerObject = {}
|
||||||
|
headerObject[appConfig.tokenKey] = storageManage.token()
|
||||||
|
|
||||||
|
return commonsProcess(showLoading, () => {
|
||||||
|
return uni.uploadFile(
|
||||||
|
Object.assign({url: baseUrl + uri, formData: data, name: "file", filePath: file.path, header: headerObject}, extParams )
|
||||||
|
).then((httpData) => {
|
||||||
|
// uni.upload 返回bodyData 的是 string类型。 需要解析。
|
||||||
|
httpData.data = JSON.parse(httpData.data)
|
||||||
|
return Promise.resolve(httpData)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
req : req,
|
||||||
|
upload : upload
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,182 @@
|
||||||
|
/**
|
||||||
|
* HTTP的封装, 基于uni.request
|
||||||
|
* 包括: 通用响应结果的处理 和 业务的增删改查函数
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2021/12/16 18:35
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 导入全局属性
|
||||||
|
import appConfig from '@/config/appConfig.js'
|
||||||
|
import storageManage from '@/commons/utils/storageManage.js'
|
||||||
|
import {
|
||||||
|
sm4DecryptByResData
|
||||||
|
} from '@/commons/utils/encryptUtil.js'
|
||||||
|
import infoBox from "@/commons/utils/infoBox.js"
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
let baseUrl = 'http://101.37.12.135:8080'
|
||||||
|
// #ifdef H5
|
||||||
|
baseUrl = '/server3'
|
||||||
|
// #endif
|
||||||
|
// 多少 ms 以内, 不提示loading
|
||||||
|
const loadingShowTime = 200
|
||||||
|
|
||||||
|
// 通用处理逻辑
|
||||||
|
function commonsProcess(showLoading, httpReqCallback) {
|
||||||
|
|
||||||
|
// 判断是否请求完成(用作 是否loading )
|
||||||
|
// 包括: 'ing', 'ingLoading', 'finish'
|
||||||
|
let reqState = 'ing'
|
||||||
|
|
||||||
|
// 是否已经提示的错误信息
|
||||||
|
let isShowErrorToast = false
|
||||||
|
|
||||||
|
|
||||||
|
// 请求完成, 需要处理的动作
|
||||||
|
let reqFinishFunc = () => {
|
||||||
|
|
||||||
|
if (reqState == 'ingLoading') { // 关闭loading弹层
|
||||||
|
infoBox.hideLoading()
|
||||||
|
}
|
||||||
|
reqState = 'finish' // 请求完毕
|
||||||
|
}
|
||||||
|
|
||||||
|
// 明确显示loading
|
||||||
|
if (showLoading) {
|
||||||
|
// xx ms内响应完成,不提示loading
|
||||||
|
setTimeout(() => {
|
||||||
|
if (reqState == 'ing') {
|
||||||
|
reqState = 'ingLoading'
|
||||||
|
infoBox.showLoading()
|
||||||
|
}
|
||||||
|
}, loadingShowTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpReqCallback().then((httpData) => {
|
||||||
|
console.log(httpData);
|
||||||
|
reqFinishFunc(); // 请求完毕的动作
|
||||||
|
|
||||||
|
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
|
||||||
|
let {
|
||||||
|
statusCode,
|
||||||
|
data
|
||||||
|
} = httpData
|
||||||
|
|
||||||
|
// 避免混淆重新命名
|
||||||
|
let bodyData = data
|
||||||
|
if (statusCode == 401) {
|
||||||
|
|
||||||
|
// 清楚 token
|
||||||
|
storageManage.token(null, true)
|
||||||
|
|
||||||
|
// 提示信息
|
||||||
|
isShowErrorToast = true
|
||||||
|
infoBox.showErrorToast('请登录').then(() => {
|
||||||
|
go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH)
|
||||||
|
})
|
||||||
|
return Promise.reject(bodyData) // 跳转到catch函数
|
||||||
|
}
|
||||||
|
// http响应码不正确
|
||||||
|
if (statusCode != 200) {
|
||||||
|
isShowErrorToast = true
|
||||||
|
infoBox.showErrorToast('服务器异常')
|
||||||
|
return Promise.reject(bodyData) // 跳转到catch函数
|
||||||
|
}
|
||||||
|
|
||||||
|
// 业务响应异常
|
||||||
|
if (bodyData.code != 200) {
|
||||||
|
isShowErrorToast = true
|
||||||
|
infoBox.showToast(bodyData.msg)
|
||||||
|
if (bodyData.code == 5005) { // 密码已过期, 直接跳转到更改密码页面
|
||||||
|
uni.reLaunch({
|
||||||
|
url: '/pageUser/setting/updatePwd'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if(bodyData.code == 500){ // 密码已过期, 直接跳转到更改密码页面
|
||||||
|
uni.redirectTo({url: '/pages/login/index'})
|
||||||
|
}
|
||||||
|
return Promise.reject(bodyData)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加密数据
|
||||||
|
if (!bodyData.data && bodyData.encryptData) {
|
||||||
|
|
||||||
|
return Promise.resolve({
|
||||||
|
bizData: sm4DecryptByResData(bodyData.encryptData),
|
||||||
|
code: bodyData.code
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构造请求成功的响应数据
|
||||||
|
return Promise.resolve({
|
||||||
|
bizData: bodyData.data,
|
||||||
|
code: bodyData.code
|
||||||
|
})
|
||||||
|
|
||||||
|
}).catch(res => {
|
||||||
|
reqFinishFunc(); // 请求完毕的动作
|
||||||
|
|
||||||
|
// 如果没有提示错误, 那么此处提示 异常。
|
||||||
|
if (!isShowErrorToast) {
|
||||||
|
infoBox.showErrorToast(`请求网络异常`)
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.reject(res)
|
||||||
|
|
||||||
|
}).finally(() => { // finally 是 then结束后再执行, 此处不适用。 需要在请求完成后立马调用: reqFinishFunc()
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 默认 显示loading(控制 xxs 内 不提示loading )
|
||||||
|
function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
|
||||||
|
let headerObject = {}
|
||||||
|
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||||
|
headerObject["satoken"] = storageManage.token()
|
||||||
|
headerObject["content-type"] = 'application/json'
|
||||||
|
|
||||||
|
return commonsProcess(showLoading, () => {
|
||||||
|
return uni.request(
|
||||||
|
Object.assign({
|
||||||
|
url: baseUrl + uri,
|
||||||
|
data: data,
|
||||||
|
method: method,
|
||||||
|
header: headerObject
|
||||||
|
}, extParams)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 上传
|
||||||
|
function upload(uri, data, file, showLoading = true, extParams = {}) {
|
||||||
|
|
||||||
|
// 放置token
|
||||||
|
let headerObject = {}
|
||||||
|
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||||
|
headerObject["satoken"] = storageManage.token()
|
||||||
|
|
||||||
|
return commonsProcess(showLoading, () => {
|
||||||
|
return uni.uploadFile(
|
||||||
|
Object.assign({
|
||||||
|
url: appConfig.env.JEEPAY_BASE_URL + uri,
|
||||||
|
formData: data,
|
||||||
|
name: "file",
|
||||||
|
filePath: file.path,
|
||||||
|
header: headerObject
|
||||||
|
}, extParams)
|
||||||
|
).then((httpData) => {
|
||||||
|
// uni.upload 返回bodyData 的是 string类型。 需要解析。
|
||||||
|
httpData.data = JSON.parse(httpData.data)
|
||||||
|
return Promise.resolve(httpData)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
req: req,
|
||||||
|
upload: upload
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import http from './http.js'
|
||||||
|
import appConfig from '@/config/appConfig.js'
|
||||||
|
import {
|
||||||
|
Base64
|
||||||
|
} from 'js-base64'
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
/* 登录 */
|
||||||
|
export function $login(postData) {
|
||||||
|
// return http.req('/login', params, 'GET')
|
||||||
|
return http.req('/login', postData, 'POST')
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,392 @@
|
||||||
|
// 代课下单
|
||||||
|
import http from './http.js'
|
||||||
|
import $API from '@/http/classApi.js'
|
||||||
|
import appConfig from '@/config/appConfig.js'
|
||||||
|
import {
|
||||||
|
Base64
|
||||||
|
} from 'js-base64'
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
|
||||||
|
const request = http.request
|
||||||
|
|
||||||
|
|
||||||
|
//就餐形式,默认堂食后付费
|
||||||
|
const useType = 'dine-in-after'
|
||||||
|
|
||||||
|
function getUseType() {
|
||||||
|
const type = uni.getStorageSync("useType")
|
||||||
|
return type ? type : useType
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前台桌订单信息
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function getCart(params) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/cart`,
|
||||||
|
method: "get",
|
||||||
|
params:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
useType: getUseType(),
|
||||||
|
...params
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 已上架商品列表
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function getGoodsLists(params,showLoading=true) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/activate`,
|
||||||
|
method: "get",
|
||||||
|
params:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...params
|
||||||
|
},
|
||||||
|
showLoading
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点单
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function addCart(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/addCart`,
|
||||||
|
method: "post",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
useType: getUseType(),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空购物车/支付订单
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function $clearCart(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/clearCart`,
|
||||||
|
method: "delete",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
useType: getUseType(),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除购物车某个商品
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function $removeCart(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/removeCart`,
|
||||||
|
method: "delete",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
useType: getUseType(),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 更新规格
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function $updateCart(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/updateCart`,
|
||||||
|
method: "put",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 批量打包
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function $allPack(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/pack`,
|
||||||
|
method: "put",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取取餐号
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function $getMasterId(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/masterId`,
|
||||||
|
method: "get",
|
||||||
|
params:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
useType: getUseType(),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 支付方式获取
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function $getPayType(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/payType`,
|
||||||
|
method: "get",
|
||||||
|
params:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 创建订单
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function $createOrder(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/order`,
|
||||||
|
method: "post",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
useType: getUseType(),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂起订单
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function $cacheOrder(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/pending`,
|
||||||
|
method: "post",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
useType: getUseType(),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取已挂起订单
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function $getCacheOrder(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/pending/cart`,
|
||||||
|
method: "get",
|
||||||
|
params:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
useType: getUseType(),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 会员点单/取消会员点单
|
||||||
|
export function $setUser(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/updateVip`,
|
||||||
|
method: "put",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 删除订单
|
||||||
|
export function $delOrder(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/place/order`,
|
||||||
|
method: "delete",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 支付订单
|
||||||
|
export function $payOrder(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/place/pay',
|
||||||
|
method: "put",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//退单
|
||||||
|
|
||||||
|
export function $returnCart(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/place/returnCart',
|
||||||
|
method: "put",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 选择台桌
|
||||||
|
export function $choseTable(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/place/choseTable',
|
||||||
|
method: "put",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 用餐人数
|
||||||
|
|
||||||
|
export function $choseCount(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/place/choseCount',
|
||||||
|
method: "put",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
useType: getUseType(),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量生成台桌
|
||||||
|
export function $fastCreateTable(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbShopTable/generate',
|
||||||
|
method: "post",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//打印当前台桌订单
|
||||||
|
export function $printOrder(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/place/printOrder',
|
||||||
|
method: "post",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//打印当前台桌菜品
|
||||||
|
|
||||||
|
export function $printDishes(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/place/printDishes',
|
||||||
|
method: "post",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 就餐模式切换
|
||||||
|
export function $changeUseType(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/place/choseModel',
|
||||||
|
method: "put",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 退款
|
||||||
|
export function $returnOrder(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/place/returnOrder',
|
||||||
|
method: "post",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取订单可用优惠券
|
||||||
|
export function $activateByOrderId(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbShopCoupon/activateByOrderId',
|
||||||
|
method: "get",
|
||||||
|
params:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//会员积分列表
|
||||||
|
export function $returnMemberPointsList(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/points/member-points/page',
|
||||||
|
method: "get",
|
||||||
|
params:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 会员积分账户信息
|
||||||
|
export function $returnMemberPoints(memberId) {
|
||||||
|
return request({
|
||||||
|
url: '/api/points/member-points/'+memberId,
|
||||||
|
method: "get",
|
||||||
|
params:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//002-获取订单可用积分及抵扣金额(支付页面使用)
|
||||||
|
export function $calcUsablePoints(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/points/member-points/calc-usable-points',
|
||||||
|
method: "get",
|
||||||
|
params:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 003-根据积分计算可抵扣金额
|
||||||
|
export function $calcDeDuctionPoints(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/points/member-points/calc-deduction-amount',
|
||||||
|
method: "get",
|
||||||
|
params:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
import http from './http.js'
|
||||||
|
const request=http.request
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品报损
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function productBreakage(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/tbProductStockDetail/frmLoss`,
|
||||||
|
method: 'post',
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 耗材报损
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function consumableBreakage(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/tbConsInfoFlow/frmLoss`,
|
||||||
|
method: 'post',
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
import http from './http.js'
|
||||||
|
const request = http.request
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品报损
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function get(params) {
|
||||||
|
return request({
|
||||||
|
url: `/freeDine`,
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
...params
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 耗材报损
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function edit(data) {
|
||||||
|
return request({
|
||||||
|
url: `/freeDine`,
|
||||||
|
method: 'put',
|
||||||
|
params: {
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,232 @@
|
||||||
|
import http from './http.js'
|
||||||
|
const request = http.request
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询耗材类型
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function gettbConsType(params) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbConsType',
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增耗材类型
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function posttbConsType(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbConsType',
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 修改耗材类型
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function puttbConsType(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbConsType',
|
||||||
|
method: "put",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查询耗材信息
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function gettbConsInfo(params) {
|
||||||
|
// return request({
|
||||||
|
// url: '/api/tbConsInfo',
|
||||||
|
// method: "get",
|
||||||
|
// params
|
||||||
|
// });
|
||||||
|
return request({
|
||||||
|
url: "/api/tbConsInfo",
|
||||||
|
method: "get",
|
||||||
|
params: {
|
||||||
|
...params,
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 耗材入库
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function posttbConsInfostockIn(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbConsInfo/stockIn',
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 修改单位耗材值耗材
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function postapitbConsInfo(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbConsInfo',
|
||||||
|
method: "put",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 新增耗材信息
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function posttbConsInfo(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbConsInfo',
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询查询耗材规格信息
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function getviewConSku(params) {
|
||||||
|
return request({
|
||||||
|
url: '/api/viewConSku',
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查询查询商品规格
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function gettbProductSpec(params) {
|
||||||
|
return request({
|
||||||
|
url: '/api/viewProductSkuShop',
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 新增商品规格耗材信息
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function posttbProskuCon(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbProskuCon',
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 新增商品规格耗材信息-修改后
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function posttbProskuCons(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbProskuCon',
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 修改商品规格耗材信息状态
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function puttbProskuCon(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbProskuCon',
|
||||||
|
method: "put",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 编辑单位耗材值
|
||||||
|
// export function puttbProskuCon(data) {
|
||||||
|
// return request({
|
||||||
|
// url: '/api/tbProskuCon',
|
||||||
|
// method: "put",
|
||||||
|
// data
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
/**
|
||||||
|
* 删除商品规格耗材信息状态
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function deletetbProskuCon(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbProskuCon',
|
||||||
|
method: "delete",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查询耗材流水信息
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function gettbConsInfoFlow(params) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbConsInfoFlow',
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 分组查询获取耗材流水信息
|
||||||
|
*/
|
||||||
|
// export function viewConInfoFlow(data) {
|
||||||
|
// return request({
|
||||||
|
// url: "/api/viewConInfoFlow",
|
||||||
|
// method: "get",
|
||||||
|
// params: {
|
||||||
|
// shopId: uni.getStorageSync("shopId"),
|
||||||
|
// ...data
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询耗材单位列表
|
||||||
|
*/
|
||||||
|
export function queryTbConUnitInfo(data) {
|
||||||
|
return request({
|
||||||
|
url: "/api/tbConUnit/queryTbConUnitInfo",
|
||||||
|
method: "get",
|
||||||
|
params: {
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增耗材单位
|
||||||
|
*/
|
||||||
|
export function addtbConUnit(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbConUnit',
|
||||||
|
method: "post",
|
||||||
|
data: {
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 修改耗材单位
|
||||||
|
*/
|
||||||
|
export function edittbConUnit(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbConUnit',
|
||||||
|
method: "put",
|
||||||
|
data: {
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
import http from './http.js'
|
||||||
|
const request=http.request
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取优惠券列表
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function getTbShopCoupon(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/tbShopCoupon`,
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取优惠券详情
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function getTbShopCouponInfo(id) {
|
||||||
|
return request({
|
||||||
|
url: `/api/tbShopCoupon/${id}`,
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加优惠券
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function addTbShopCoupon(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/tbShopCoupon`,
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除优惠券
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function delTbShopCoupon(data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/tbShopCoupon`,
|
||||||
|
method: 'delete',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
import http from './http.js'
|
||||||
|
import appConfig from '@/config/appConfig.js'
|
||||||
|
import {
|
||||||
|
Base64
|
||||||
|
} from 'js-base64'
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
|
||||||
|
/* 查询团购卷分类 */
|
||||||
|
export function $tbCouponCategory(data, mehtod = 'GET') {
|
||||||
|
return http.req('/api/tbCouponCategory', {
|
||||||
|
...data,
|
||||||
|
shopId: uni.getStorageSync('shopId')
|
||||||
|
}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
add: function(data) {
|
||||||
|
return $tbCouponCategory(data, 'POST')
|
||||||
|
},
|
||||||
|
del: function(data) {
|
||||||
|
return $tbCouponCategory(data, 'DELETE')
|
||||||
|
},
|
||||||
|
update: function(data) {
|
||||||
|
return $tbCouponCategory(data, 'PUT')
|
||||||
|
},
|
||||||
|
get: function(data) {
|
||||||
|
return $tbCouponCategory(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
import http from './http.js'
|
||||||
|
const request = http.request
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加打印机
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function tbPrintMachine(data, method = 'post') {
|
||||||
|
return request({
|
||||||
|
url: '/api/shop-config/printer',
|
||||||
|
method: method,
|
||||||
|
data: {
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印机列表
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function tbPrintMachineGet(params) {
|
||||||
|
return request({
|
||||||
|
url: '/api/shop-config/printer/list',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
sort: '',
|
||||||
|
...params
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打印机部分
|
||||||
|
export function tbShopCategoryget(params) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbShopCategory',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 修改打印机状态
|
||||||
|
export function shopConfigprinter(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/shop-config/printer/update-status',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// * 打印机详情
|
||||||
|
export function printerd(id) {
|
||||||
|
return request({
|
||||||
|
url: '/api/shop-config/printer/' + id,
|
||||||
|
method: 'get',
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 删除
|
||||||
|
export function delTableHandle(id) {
|
||||||
|
return request({
|
||||||
|
url: '/api/shop-config/printer/' + id,
|
||||||
|
method: 'DELETE',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import http from './http.js'
|
||||||
|
import appConfig from '@/config/appConfig.js'
|
||||||
|
import {
|
||||||
|
Base64
|
||||||
|
} from 'js-base64'
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
|
||||||
|
/* 上传图片 */
|
||||||
|
export function $uploadFile(file,data) {
|
||||||
|
return http.upload('/api/qiNiuContent', data,file)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,140 @@
|
||||||
|
import http from './http.js'
|
||||||
|
import $API from '@/http/classApi.js'
|
||||||
|
import appConfig from '@/config/appConfig.js'
|
||||||
|
import {
|
||||||
|
Base64
|
||||||
|
} from 'js-base64'
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
function objectToUrlParams(obj) {
|
||||||
|
let params = [];
|
||||||
|
for (let key in obj) {
|
||||||
|
if (obj.hasOwnProperty(key)) {
|
||||||
|
let value = obj[key];
|
||||||
|
let param = encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
||||||
|
params.push(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return params.join('&');
|
||||||
|
}
|
||||||
|
/* 商品列表 */
|
||||||
|
export function $tbProduct(data) {
|
||||||
|
return http.req('/api/tbProduct', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 添加商品 */
|
||||||
|
export function $addProduct(data) {
|
||||||
|
return http.req('/api/tbProduct', {...data,shopId:uni.getStorageSync('shopId')}, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 删除商品 */
|
||||||
|
export function $delProduct(ids) {
|
||||||
|
return http.req('/api/tbProduct', ids, 'DELETE')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 更新商品相关 */
|
||||||
|
export function $updateProduct(data) {
|
||||||
|
return http.req('/api/tbProduct', {...data,shopId:uni.getStorageSync('shopId')}, 'PUT')
|
||||||
|
}
|
||||||
|
/* 修改商品排序 */
|
||||||
|
export function $upProSort(data) {
|
||||||
|
return http.req('/api/tbProduct/upProSort', {...data,shopId:uni.getStorageSync('shopId')}, 'POST')
|
||||||
|
}
|
||||||
|
/* 商品详情(单个商品) */
|
||||||
|
export function $getProductDetail(product,showLoading=true) {
|
||||||
|
return http.req('/api/tbProduct/'+product, {shopId:uni.getStorageSync('shopId')}, 'GET',showLoading)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 设置热销商品 */
|
||||||
|
export function $goodsIsHot(data) {
|
||||||
|
return http.req('/api/tbProduct/isHot', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品分类列表
|
||||||
|
*/
|
||||||
|
export function $tbShopCategory(data) {
|
||||||
|
return http.req('/api/tbShopCategory', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 商品分类
|
||||||
|
*/
|
||||||
|
export const $productCategory=new $API('/api/tbShopCategory',http.req)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新商品库存状态
|
||||||
|
*/
|
||||||
|
export function $updateProductStatus(data){
|
||||||
|
return http.req('/api/stock/productStatus', {...data,shopId:uni.getStorageSync('shopId')}, 'PUT')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库存记录列表
|
||||||
|
*/
|
||||||
|
export function $getProductStockDetail(data){
|
||||||
|
return http.req('/api/tbProductStockDetail/stock', {...data,shopId:uni.getStorageSync('shopId')}, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库存记录变动数量
|
||||||
|
*/
|
||||||
|
export function $getProductStockDetailSum(data){
|
||||||
|
return http.req('/api/tbProductStockDetail/sum', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 新增盘点
|
||||||
|
*/
|
||||||
|
export function $addStocktakin(data){
|
||||||
|
return http.req('/api/tbProductStocktakin', {...data,shopId:uni.getStorageSync('shopId')}, 'POST')
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 盘点记录查询
|
||||||
|
*/
|
||||||
|
export function $getStocktakin(data){
|
||||||
|
return http.req('/api/tbProductStocktakin', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上下架商品
|
||||||
|
*/
|
||||||
|
export function $updateGrounding(data){
|
||||||
|
const ajaxData={...data,shopId:uni.getStorageSync('shopId')}
|
||||||
|
return http.req('/api/stock/grounding'+`?${objectToUrlParams(ajaxData)}`, ajaxData, 'PUT')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* 商品单位列表 */
|
||||||
|
export function $tbShopUnit(data) {
|
||||||
|
return http.req('/api/tbShopUnit', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 商品规格 */
|
||||||
|
export const $productSpec=new $API('/api/tbProductSpec',http.req)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// v2 api start
|
||||||
|
|
||||||
|
/* 商品列表 V2 */
|
||||||
|
export function $tbProductV2(data) {
|
||||||
|
return http.req('/api/tbProduct/list/v2', {...data,shopId:uni.getStorageSync('shopId')}, 'post')
|
||||||
|
}
|
||||||
|
/* 耗材与商品绑定关系 */
|
||||||
|
export function $tbProskuConV2(data) {
|
||||||
|
return http.req('/api/tbProskuCon/V2', data, 'POST')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 修改商品相关(快捷接口) */
|
||||||
|
export function $updateProductData(data) {
|
||||||
|
return http.req('/api/stock/updateProductData', data, 'POST')
|
||||||
|
}
|
||||||
|
/* 商品报损 */
|
||||||
|
export function $frmLoss(data) {
|
||||||
|
return http.req('/api/tbProductStockDetail/frmLoss', {...data,shopId:uni.getStorageSync('shopId')}, 'POST')
|
||||||
|
}
|
||||||
|
// v2 api end
|
||||||
|
|
@ -0,0 +1,241 @@
|
||||||
|
/**
|
||||||
|
* HTTP的封装, 基于uni.request
|
||||||
|
* 包括: 通用响应结果的处理 和 业务的增删改查函数
|
||||||
|
*
|
||||||
|
* @author terrfly
|
||||||
|
* @site https://www.jeequan.com
|
||||||
|
* @date 2021/12/16 18:35
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 导入全局属性
|
||||||
|
import appConfig from '@/config/appConfig.js'
|
||||||
|
import storageManage from '@/commons/utils/storageManage.js'
|
||||||
|
import {
|
||||||
|
sm4DecryptByResData
|
||||||
|
} from '@/commons/utils/encryptUtil.js'
|
||||||
|
import infoBox from "@/commons/utils/infoBox.js"
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
import { reject } from 'lodash';
|
||||||
|
// 测试服
|
||||||
|
let baseUrl = 'https://admintestpapi.sxczgkj.cn'
|
||||||
|
|
||||||
|
//预发布
|
||||||
|
// let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn'
|
||||||
|
|
||||||
|
//正式
|
||||||
|
// let baseUrl = 'https://cashieradmin.sxczgkj.cn'
|
||||||
|
|
||||||
|
// 王伟本地测
|
||||||
|
// let baseUrl = '/ww'
|
||||||
|
// let baseUrl = 'http://192.168.1.15:8000'
|
||||||
|
// 巩
|
||||||
|
// let baseUrl = 'http://192.168.1.9:8000'
|
||||||
|
// 多少 ms 以内, 不提示loading
|
||||||
|
const loadingShowTime = 200
|
||||||
|
|
||||||
|
|
||||||
|
function getHeader(){
|
||||||
|
const headerObject={}
|
||||||
|
headerObject["Authorization"] = storageManage.token()
|
||||||
|
return headerObject
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通用处理逻辑
|
||||||
|
function commonsProcess(showLoading, httpReqCallback) {
|
||||||
|
|
||||||
|
// 判断是否请求完成(用作 是否loading )
|
||||||
|
// 包括: 'ing', 'ingLoading', 'finish'
|
||||||
|
let reqState = 'ing'
|
||||||
|
|
||||||
|
// 是否已经提示的错误信息
|
||||||
|
let isShowErrorToast = false
|
||||||
|
|
||||||
|
|
||||||
|
// 请求完成, 需要处理的动作
|
||||||
|
let reqFinishFunc = () => {
|
||||||
|
|
||||||
|
if (reqState == 'ingLoading') { // 关闭loading弹层
|
||||||
|
infoBox.hideLoading()
|
||||||
|
}
|
||||||
|
reqState = 'finish' // 请求完毕
|
||||||
|
}
|
||||||
|
|
||||||
|
// 明确显示loading
|
||||||
|
if (showLoading) {
|
||||||
|
// xx ms内响应完成,不提示loading
|
||||||
|
setTimeout(() => {
|
||||||
|
if (reqState == 'ing') {
|
||||||
|
reqState = 'ingLoading'
|
||||||
|
infoBox.showLoading()
|
||||||
|
}
|
||||||
|
}, loadingShowTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpReqCallback().then((httpData) => {
|
||||||
|
reqFinishFunc(); // 请求完毕的动作
|
||||||
|
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
|
||||||
|
let {
|
||||||
|
statusCode,
|
||||||
|
data
|
||||||
|
} = httpData
|
||||||
|
// 避免混淆重新命名
|
||||||
|
let bodyData = data
|
||||||
|
if (statusCode == 500) {
|
||||||
|
isShowErrorToast = true
|
||||||
|
return Promise.reject(bodyData) // 跳转到catch函数
|
||||||
|
}
|
||||||
|
if (statusCode == 401) {
|
||||||
|
// storageManage.token(null, true)
|
||||||
|
// 提示信息
|
||||||
|
isShowErrorToast = true
|
||||||
|
// infoBox.showErrorToast('请登录').then(() => {
|
||||||
|
// go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH)
|
||||||
|
// })
|
||||||
|
return Promise.reject(bodyData) // 跳转到catch函数
|
||||||
|
}
|
||||||
|
// http响应码不正确
|
||||||
|
if (statusCode != 200 && statusCode != 204 && statusCode != 201) {
|
||||||
|
isShowErrorToast = true
|
||||||
|
data.message=data.message=='Bad credentials'?'用户名或密码错误':data.message
|
||||||
|
infoBox.showToast(data.message || '服务器异常')
|
||||||
|
return Promise.reject(bodyData) // 跳转到catch函数
|
||||||
|
}
|
||||||
|
|
||||||
|
// // 业务响应异常
|
||||||
|
// if (bodyData.hasOwnProperty('code') && bodyData.code != 200) {
|
||||||
|
// isShowErrorToast = true
|
||||||
|
// infoBox.showToast(bodyData.msg)
|
||||||
|
// if (bodyData.code == 5005) { // 密码已过期, 直接跳转到更改密码页面
|
||||||
|
// uni.reLaunch({
|
||||||
|
// url: '/pageUser/setting/updatePwd'
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// // if(bodyData.code == 500){ // 密码已过期, 直接跳转到更改密码页面
|
||||||
|
// // uni.redirectTo({url: '/pages/login/index'})
|
||||||
|
// // }
|
||||||
|
// return bodyData
|
||||||
|
// // return Promise.reject(bodyData)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 加密数据
|
||||||
|
if (!bodyData.data && bodyData.encryptData) {
|
||||||
|
|
||||||
|
return Promise.resolve({
|
||||||
|
bizData: sm4DecryptByResData(bodyData.encryptData),
|
||||||
|
code: bodyData.code
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构造请求成功的响应数据
|
||||||
|
return Promise.resolve(bodyData)
|
||||||
|
|
||||||
|
}).catch(res => {
|
||||||
|
if(res.status==401){
|
||||||
|
storageManage.token(null, true)
|
||||||
|
infoBox.showErrorToast(res.message||'请登录').then(() => {
|
||||||
|
uni.redirectTo({url: '/pages/login/index'})
|
||||||
|
reject()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// if(res.status==400){
|
||||||
|
// storageManage.token(null, true)
|
||||||
|
// infoBox.showErrorToast('').then(() => {
|
||||||
|
// go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH)
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
if(res.status==500){
|
||||||
|
infoBox.showErrorToast(res.message||'服务器异常').then(() => {
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// if(res&&res.msg){
|
||||||
|
// infoBox.showErrorToast(res.msg)
|
||||||
|
// }
|
||||||
|
reqFinishFunc(); // 请求完毕的动作
|
||||||
|
|
||||||
|
// 如果没有提示错误, 那么此处提示 异常。
|
||||||
|
if (!isShowErrorToast) {
|
||||||
|
infoBox.showErrorToast(`请求网络异常`)
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.reject(res)
|
||||||
|
|
||||||
|
}).finally(() => { // finally 是 then结束后再执行, 此处不适用。 需要在请求完成后立马调用: reqFinishFunc()
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 默认 显示loading(控制 xxs 内 不提示loading )
|
||||||
|
function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
|
||||||
|
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||||
|
return commonsProcess(showLoading, () => {
|
||||||
|
return uni.request(
|
||||||
|
Object.assign({
|
||||||
|
url: baseUrl + uri,
|
||||||
|
data: data,
|
||||||
|
method: method,
|
||||||
|
header: getHeader()
|
||||||
|
}, extParams)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 默认 显示loading(控制 xxs 内 不提示loading )
|
||||||
|
function request(args) {
|
||||||
|
const {
|
||||||
|
url,
|
||||||
|
data,
|
||||||
|
params,
|
||||||
|
method = "GET",
|
||||||
|
showLoading = true,
|
||||||
|
extParams = {}
|
||||||
|
} = args
|
||||||
|
let headerObject = {}
|
||||||
|
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||||
|
return commonsProcess(showLoading, () => {
|
||||||
|
return uni.request(
|
||||||
|
Object.assign({
|
||||||
|
url: baseUrl + url,
|
||||||
|
data: params||data,
|
||||||
|
method: method,
|
||||||
|
header: getHeader()
|
||||||
|
}, extParams)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 上传
|
||||||
|
function upload(uri, data, file, showLoading = true, extParams = {}) {
|
||||||
|
// 放置token
|
||||||
|
let headerObject = {}
|
||||||
|
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||||
|
|
||||||
|
return commonsProcess(showLoading, () => {
|
||||||
|
return uni.uploadFile(
|
||||||
|
Object.assign({
|
||||||
|
url: baseUrl + uri,
|
||||||
|
formData: data,
|
||||||
|
name: "file",
|
||||||
|
filePath: file.path||file.url,
|
||||||
|
header: getHeader()
|
||||||
|
}, extParams)
|
||||||
|
).then((httpData) => {
|
||||||
|
// uni.upload 返回bodyData 的是 string类型。 需要解析。
|
||||||
|
httpData.data = JSON.parse(httpData.data)
|
||||||
|
return Promise.resolve(httpData)
|
||||||
|
}).catch(err=>{
|
||||||
|
uni.hideLoading()
|
||||||
|
infoBox.showErrorToast(`上传失败`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
req: req,
|
||||||
|
request,
|
||||||
|
upload: upload
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue