Merge remote-tracking branch 'origin/master'

This commit is contained in:
齐天大圣 2024-05-28 14:10:20 +08:00
commit ea25f5e16d
226 changed files with 20353 additions and 29561 deletions

View File

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 蓝鲸智慧油站系统
VUE_APP_TITLE = 百业兴智慧油站系统
# 开发环境配置
ENV = 'development'
@ -12,7 +12,7 @@ VUE_APP_PUBLIC_PATH = '/'
# 后端接口地址
#VUE_APP_SERVER_URL = 'http://192.168.31.55:8081/'
VUE_APP_SERVER_URL = 'http://192.168.31.178:8080'
VUE_APP_SERVER_URL = 'http://192.168.31.178:8081'

View File

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 蓝鲸智慧油站系统
VUE_APP_TITLE = 百业兴智慧油站系统
# 生产环境配置
ENV = 'production'

View File

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 蓝鲸智慧油站系统
VUE_APP_TITLE = 百业兴智慧油站系统
# 测试环境配置
ENV = 'staging'

View File

@ -37,10 +37,10 @@
</div>
<div class="title-logo">
<div >
<img src="../../assets/logo/logo.png" alt="" style="width: 60px;height: 50px; margin-right: 10px">
</div>
<div>
{{storeName || "蓝鲸智慧油站"}}欢迎您
{{storeName || "百业兴智慧油站"}}欢迎您
</div>
</div>

View File

@ -2,7 +2,7 @@
<div class="login">
<div class="box-center">
<div class="box-left">
<div class="bai-size">蓝鲸智慧加油站</div>
<div class="bai-size">百业兴智慧加油站</div>
<div class="bact-box">
<div class="sanhh">活动营销</div>
<div class="sanhh">节省人力</div>

View File

@ -100,26 +100,26 @@
></el-statistic>
</div>
</el-col>
<el-col :span="4">
<div class="sta" v-if="!refuelMoney">
<el-statistic
group-separator=","
:precision="2"
:value="0"
title="囤油卡余额"
>
<!-- <span></span>-->
</el-statistic>
</div>
<div v-if="refuelMoney && refuelMoney.length>0" style="display: flex;align-items: center;margin-top: 25px">
<div class="size-hui">囤油卡余额</div>
<div v-for="(item,index) in refuelMoney"
:key="index" style="margin-left: 20px;text-align: center">
<div class="size-hui">{{ item.oilName ? item.type + item.oilName : item.type }}</div>
<div class="size-bole">{{ item.refuelMoney || 0.00 }}</div>
</div>
</div>
</el-col>
<!-- <el-col :span="4">-->
<!-- <div class="sta" v-if="!refuelMoney">-->
<!-- <el-statistic-->
<!-- group-separator=","-->
<!-- :precision="2"-->
<!-- :value="0"-->
<!-- title="囤油卡余额"-->
<!-- >-->
<!-- &lt;!&ndash; <span></span>&ndash;&gt;-->
<!-- </el-statistic>-->
<!-- </div>-->
<!-- <div v-if="refuelMoney && refuelMoney.length>0" style="display: flex;align-items: center;margin-top: 25px">-->
<!-- <div class="size-hui">囤油卡余额</div>-->
<!-- <div v-for="(item,index) in refuelMoney"-->
<!-- :key="index" style="margin-left: 20px;text-align: center">-->
<!-- <div class="size-hui">{{ item.oilName ? item.type + item.oilName : item.type }}</div>-->
<!-- <div class="size-bole">{{ item.refuelMoney || 0.00 }}</div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </el-col>-->
</el-row>
</div>
</template>
@ -158,7 +158,7 @@
<el-dialog :close-on-click-modal="false" width="60%" :title="title" :visible.sync="openRecharge" append-to-body>
<template>
<el-tabs v-model="activeRecharge" type="card" @tab-click="handleClick">
<el-tab-pane label="储值卡" name="balance">
<el-tab-pane label="电子储值卡" name="balance">
<div>
<el-row>
<el-col :span="1.5">
@ -277,7 +277,7 @@
</div>
</div>
</el-tab-pane>
<el-tab-pane label="油卡" name="literCard" v-if="oilTypeList && oilTypeList.length>0">
<el-tab-pane label="电子囤油卡" name="literCard" v-if="oilTypeList && oilTypeList.length>0">
<el-row>
<el-col :span="24">
<div style="display: flex">

View File

@ -7,7 +7,7 @@ function resolve(dir) {
const CompressionPlugin = require('compression-webpack-plugin')
const name = process.env.VUE_APP_TITLE || '蓝鲸智慧油站系统' // 网页标题
const name = process.env.VUE_APP_TITLE || '百业兴智慧油站系统' // 网页标题
const port = process.env.port || process.env.npm_config_port || 81 // 端口

View File

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 蓝鲸智慧油站系统
VUE_APP_TITLE = 百业兴智慧油站系统
# 开发环境配置
ENV = 'development'
@ -11,6 +11,8 @@ VUE_APP_BASE_API = '/dev-api'
VUE_APP_PUBLIC_PATH = '/'
# 后端接口地址
#VUE_APP_SERVER_URL = 'http://192.168.31.55:8081/'
VUE_APP_SERVER_URL = 'http://192.168.31.178:8080/'
VUE_APP_SERVER_URL = 'http://192.168.31.96:8080/'
# cp端地址
VUE_PC_SERVER_URL = 'http://47.95.206.185:85/'

View File

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 蓝鲸智慧油站系统
VUE_APP_TITLE = 百业兴智慧油站系统
# 生产环境配置
ENV = 'production'
@ -14,4 +14,4 @@ VUE_APP_PUBLIC_PATH = '/oilZt/'
VUE_APP_SERVER_URL = 'https://www.tuofeng.cc/oilAdmin/'
# cp端地址
VUE_PC_SERVER_URL = 'http://192.168.1.6:82/'
VUE_PC_SERVER_URL = 'https://www.tuofeng.cc/oilAdmin/'

View File

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 蓝鲸智慧油站系统
VUE_APP_TITLE = 百业兴智慧油站系统
# 测试环境配置
ENV = 'staging'
@ -11,6 +11,6 @@ VUE_APP_BASE_API = '/stage-api'
VUE_APP_PUBLIC_PATH = '/'
# 后端接口地址
VUE_APP_SERVER_URL = 'http://192.168.1.6:8008/'
VUE_APP_SERVER_URL = 'https://www.tuofeng.cc/oilAdmin/'
# cp端地址
VUE_PC_SERVER_URL = 'http://192.168.1.6:82/'
VUE_PC_SERVER_URL = 'https://www.tuofeng.cc/oilAdmin/'

View File

@ -9,17 +9,17 @@ $yellow:#FEC171;
$panGreen: #30B08F;
// 默认菜单主题风格
$base-menu-color:#ffffff;// 菜单全部字体颜色
$base-menu-color-active:#ffffff;// 父级菜单激活的字体颜色
$base-menu-background:#5a91ff;
$base-logo-title-color: #ffffff;
$base-menu-color:#144a6e;// 菜单全部字体颜色
$base-menu-color-active:#144a6e;// 父级菜单激活的字体颜色
$base-menu-background:#fff;
$base-logo-title-color: #455ced;
$base-menu-light-color:#ffffff;
$base-menu-light-background:#ffffff;
$base-logo-light-title-color: #1a5982;
$base-sub-menu-background: #4e77cc;//展开的背景色
$base-sub-menu-hover:#001528;
$base-sub-menu-background: #c6c6c6;//展开的背景色
$base-sub-menu-hover: #adadad;
$base-sidebar-width: 200px;

View File

@ -28,11 +28,9 @@
</el-dropdown>
</div>
<div class="title-logo">
<div >
<img src="../../assets/logo/logo.png" alt="" style="width: 60px;height: 50px; margin-right: 10px">
</div>
<div>
蓝鲸智慧油站欢迎您
百业兴智慧油站欢迎您
</div>
</div>
@ -107,8 +105,8 @@ export default {
height: 90px;
overflow: hidden;
position: relative;
background: #144a6e;
background-image: url("../../assets/images/kkx.png") ;
background: #455ced;
//background-image: url("../../assets/images/kkx.png") ;
background-size: 100% 100%;
background-size: cover;
background-repeat: no-repeat;

View File

@ -2,11 +2,11 @@
<div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
<transition name="sidebarLogoFade">
<router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
<img v-if="logo" :src="logo" class="sidebar-logo" />
<h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
<!-- <img v-if="logo" :src="logo" class="sidebar-logo" />-->
<h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
</router-link>
<router-link v-else key="expand" class="sidebar-logo-link" to="/">
<img v-if="logo" :src="logo" class="sidebar-logo" />
<!-- <img v-if="logo" :src="logo" class="sidebar-logo" />-->
<h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
</router-link>
</transition>
@ -76,7 +76,7 @@ export default {
& .sidebar-title {
display: inline-block;
margin: 0;
color: #fff;
color: #000;
font-weight: 700;
line-height: 50px;
font-size: 16px;

View File

@ -5,7 +5,7 @@ const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dyn
const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
const state = {
title: '',
theme: '#409EFF',
theme: '#072d50',
sideTheme: storageSetting.sideTheme || sideTheme,
showSettings: showSettings,
topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav,

View File

@ -2,7 +2,7 @@
<div class="login">
<div class="box-center">
<div class="box-left">
<div class="bai-size">蓝鲸智慧加油站-中台</div>
<div class="bai-size">百业兴智慧加油站-中台</div>
<div class="bact-box">
<div class="sanhh">活动营销</div>
<div class="sanhh">节省人力</div>

View File

@ -7,7 +7,7 @@ function resolve(dir) {
const CompressionPlugin = require('compression-webpack-plugin')
const name = process.env.VUE_APP_TITLE || '蓝鲸智慧油站系统' // 网页标题
const name = process.env.VUE_APP_TITLE || '百业兴智慧油站系统' // 网页标题
const port = process.env.port || process.env.npm_config_port || 81 // 端口

View File

@ -39,4 +39,8 @@ public class ReceiveParameterPos {
* 订单描述
*/
private String content;
/**
* 订单描述
*/
private Double oilCardAmount;
}

View File

@ -28,6 +28,7 @@ import com.fuint.business.userManager.vo.LJUserVo;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -58,6 +59,7 @@ public class FyPayServiceImpl implements FyPayService {
/**
* 条码支付
*
* @param map1
* @return
*/
@ -75,9 +77,9 @@ public class FyPayServiceImpl implements FyPayService {
String mchntCd = map1.get("mchntCd");
String goodsDes = map1.get("goodsDes");
Map<String, String> map = Builder.buildFuiou22();
map.put("auth_code",authCode);
map.put("mchnt_order_no",orderNo);
map.put("order_type",payType);
map.put("auth_code", authCode);
map.put("mchnt_order_no", orderNo);
map.put("order_type", payType);
map.put("order_amt", allAmount);
map.put("ins_cd", insCd);
map.put("mchnt_cd", mchntCd);
@ -87,17 +89,17 @@ public class FyPayServiceImpl implements FyPayService {
// 请求报文
String reqBody = Message.requestMsg(map);
// 响应报文
String rspXml = Message.responseMsg(reqBody,Const.fuiou_31_url);
String rspXml = Message.responseMsg(reqBody, Const.fuiou_31_url);
//响应报文验签
Map<String, String> resMap = Utils.xmlStr2Map(rspXml);
String str = resMap.get("sign");
String resultCode = resMap.get("result_code");
if (!resultCode.equals("000000")){
if (!resultCode.equals("000000")) {
throw new RuntimeException(resMap.get("result_msg"));
}
if (Utils.verifySign(resMap, str)){
if (Utils.verifySign(resMap, str)) {
ThreadUtil.execAsync(() -> {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@ -105,7 +107,7 @@ public class FyPayServiceImpl implements FyPayService {
public void run() {
try {
Map<String, String> orderQueryRes = queryOrder(map1);
if(!orderQueryRes.get("msg").equals("unpaid")){
if (!orderQueryRes.get("msg").equals("unpaid")) {
timer.cancel();
}
} catch (Exception e) {
@ -113,10 +115,10 @@ public class FyPayServiceImpl implements FyPayService {
}
}
//定时器 不延时 立即开始 0.5s一次
}, 0, 500);
}, 0, 500);
Thread.currentThread().interrupt();
});
}else {
} else {
throw new Exception("验签失败,请联系管理员!");
}
return resMap;
@ -137,8 +139,8 @@ public class FyPayServiceImpl implements FyPayService {
@Override
public Map<String, String> queryOrder(Map<String, String> map1) throws Exception {
Map<String, String> resMap =new HashMap<>();
resMap.put("msg","error");
Map<String, String> resMap = new HashMap<>();
resMap.put("msg", "error");
try {
String orderNo = map1.get("orderNo");
String payType = map1.get("payType");
@ -146,35 +148,35 @@ public class FyPayServiceImpl implements FyPayService {
String mchntCd = map1.get("mchntCd");
Double allAmount = Double.valueOf(map1.get("allAmount"));
Map<String, String> map = Builder.buildFuiou30();
map.put("mchnt_order_no",orderNo);
map.put("order_type",payType);
map.put("mchnt_order_no", orderNo);
map.put("order_type", payType);
map.put("ins_cd", insCd);
map.put("mchnt_cd", mchntCd);
Integer storeId1 = Integer.valueOf(map1.get("storeId"));
// 余额新增
String type = "";
String payStates="";
String payStatus="unpaid";
String payStates = "";
String payStatus = "unpaid";
if (!ObjectUtil.isEmpty(map1.get("type"))) {
type = map1.get("type");
}
ReceiveParameter receiveParameter = new ReceiveParameter();
receiveParameter.setOrderNo(orderNo);
receiveParameter.setGoodsMoney(allAmount/100);
receiveParameter.setGoodsMoney(allAmount / 100);
receiveParameter.setStoreId(storeId1);
receiveParameter.setPayType(payType);
// 请求报文
String reqBody = Message.requestMsg(map);
// 响应报文
String rspXml = Message.responseMsg(reqBody,Const.fuiou_34_url);
String rspXml = Message.responseMsg(reqBody, Const.fuiou_34_url);
//响应报文验签
Map<String, String> reqMap = Utils.xmlStr2Map(rspXml);
String str = reqMap.get("sign");
if (Utils.verifySign(reqMap, str)){
if (Utils.verifySign(reqMap, str)) {
OilOrder oilOrder = oilOrderService.selectOilOrderByOrderNo(orderNo);
List<OilOrder> list = oilOrderService.selectOilOrder(orderNo);
LJOrder goodsOrder = goodsOrderService.selectGoodsOrder(orderNo);
@ -182,18 +184,19 @@ public class FyPayServiceImpl implements FyPayService {
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(storeId1);
List<ReturnRecord> returnRecords = returnRecordService.selectReturnRecordByOrderNo(orderNo);
Date date = new Date();
if (reqMap.get("trans_stat").equals("SUCCESS")){
if (reqMap.get("trans_stat").equals("SUCCESS")) {
payStatus = "paid";
if (!ObjectUtil.isEmpty(oilOrder)){
if (!ObjectUtil.isEmpty(oilOrder)) {
// 油品订单
oilOrder.setOrderStatus("paid");
oilOrder.setPayTime(date);
oilOrderService.updateCardAndActiveById(oilOrder.getStoreId(),oilOrder.getUserId(),oilOrder.getActiveId(),oilOrder.getCouponId(),oilOrder.getActiveType(),oilOrder.getOrderAmount(),oilOrder.getPayAmount(), Integer.valueOf(oilOrder.getOils()));
oilOrderService.updateCardAndActiveById(oilOrder.getStoreId(), oilOrder.getUserId(), oilOrder.getActiveId(), oilOrder.getCouponId(), oilOrder.getActiveType(), oilOrder.getOrderAmount(), oilOrder.getPayAmount(), Integer.valueOf(oilOrder.getOils()));
oilOrderService.insertFavorable(oilOrder, Double.valueOf(map1.get("oilCardAmount")));
if (ObjectUtil.isNotEmpty(oilOrder.getStaffId())) staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getPayAmount(),"1",orderNo);
if (ObjectUtil.isNotEmpty(oilOrder.getStaffId()))
staffCommissionService.countStaffCommission(oilOrder.getStaffId(), oilOrder.getStoreId(), oilOrder.getOrderAmount(), oilOrder.getPayAmount(), "1", orderNo);
// 修改油罐容量
List<JSONObject> jsonObjects = JSONArray.parseArray(map1.get("oilOrder"), JSONObject.class);
if (jsonObjects.size()<=1) {
if (jsonObjects.size() <= 1) {
Integer tankId = Integer.valueOf(jsonObjects.get(0).get("tankId").toString());
oilOrder.setTankId(tankId);
@ -202,41 +205,42 @@ public class FyPayServiceImpl implements FyPayService {
if (ObjectUtil.isNotEmpty(oilOrder.getUserId())) integralSettingsService.refuelPoints(oilOrder);
//修改优惠券使用状态
if (oilOrder.getCouponId()!=null){
if (oilOrder.getCouponId() != null) {
CardFavorableRecord byId = cardFavorableRecordService.getById(oilOrder.getCouponId());
if (!ObjectUtil.isEmpty(byId)){
if (!ObjectUtil.isEmpty(byId)) {
byId.setStatus("1");
cardFavorableRecordService.updateById(byId);
}
}
}
if (!ObjectUtil.isEmpty(goodsOrder)){
if (!ObjectUtil.isEmpty(goodsOrder)) {
// 商品订单
goodsOrder.setStatus("paid");
goodsOrder.setPayTime(date);
goodsOrderService.insertFavorable(goodsOrder);
Boolean isMember = false;
if (goodsOrder.getUserId()!=null){
if (goodsOrder.getUserId() != null) {
isMember = true;
}
if (ObjectUtil.isNotEmpty(goodsOrder.getStaffId())) staffCommissionService.countStaffCommission(goodsOrder.getStaffId(),goodsOrder.getStoreId(),goodsOrder.getAmount(),goodsOrder.getPayAmount(),"2",orderNo);
if (!map1.get("goodsOrder").equals("[]")){
if (ObjectUtil.isNotEmpty(goodsOrder.getStaffId()))
staffCommissionService.countStaffCommission(goodsOrder.getStaffId(), goodsOrder.getStoreId(), goodsOrder.getAmount(), goodsOrder.getPayAmount(), "2", orderNo);
if (!map1.get("goodsOrder").equals("[]")) {
List<JSONObject> goods = JSONArray.parseArray(map1.get("goodsOrder"), JSONObject.class);
OrderGoods orderGoods = new OrderGoods();
for (JSONObject good : goods) {
orderGoods.setOrderId(goodsOrder.getId());
orderGoods.setGoodsId(Integer.valueOf(good.get("id").toString()));
orderGoods.setNum(Integer.valueOf(good.get("num").toString()));
orderGoodsService.insertOrderGoods(orderGoods,storeId1,isMember);
orderGoodsService.insertOrderGoods(orderGoods, storeId1, isMember);
}
}
}
if (!ObjectUtil.isEmpty(cashierOrder)){
if (!ObjectUtil.isEmpty(cashierOrder)) {
// 收银台订单
cashierOrder.setStatus("paid");
cashierOrder.setPayTime(date);
}
if (!ArrayUtil.isEmpty(returnRecords)){
if (!ArrayUtil.isEmpty(returnRecords)) {
for (ReturnRecord returnRecord : returnRecords) {
// 挂账归还信息
returnRecord.setReturnType("1");
@ -248,27 +252,28 @@ public class FyPayServiceImpl implements FyPayService {
receiveParameter.setType("7");
receiveParameter.setContent("挂账订单");
}
if (!ArrayUtil.isEmpty(list)){
if (list.size()>1){
if (!ArrayUtil.isEmpty(list)) {
if (list.size() > 1) {
Double oilLiters = 0.0;
for (OilOrder order : list){
for (OilOrder order : list) {
oilLiters += order.getOilNum();
}
for (OilOrder order : list) {
if (order.getOrderType().equals("主订单")){
if (ObjectUtil.isNotEmpty(order.getStaffId()))staffCommissionService.countStaffCommission(order.getStaffId(),order.getStoreId(),order.getOrderAmount(),order.getPayAmount(),"1",orderNo);
if (order.getOrderType().equals("主订单")) {
if (ObjectUtil.isNotEmpty(order.getStaffId()))
staffCommissionService.countStaffCommission(order.getStaffId(), order.getStoreId(), order.getOrderAmount(), order.getPayAmount(), "1", orderNo);
}
// 添加多个油品订单
order.setOrderStatus("paid");
order.setPayTime(date);
oilOrderService.updateOilOrder(order);
oilOrderService.updateCardAndActiveById(order.getStoreId(),order.getUserId(),order.getActiveId(),order.getCouponId(),order.getActiveType(),order.getOrderAmount(),order.getPayAmount(), Integer.valueOf(order.getOils()));
oilOrderService.updateCardAndActiveById(order.getStoreId(), order.getUserId(), order.getActiveId(), order.getCouponId(), order.getActiveType(), order.getOrderAmount(), order.getPayAmount(), Integer.valueOf(order.getOils()));
// 修改油罐容量
List<JSONObject> jsonObjects = JSONArray.parseArray(map1.get("oilOrder"), JSONObject.class);
for (JSONObject jsonObject : jsonObjects) {
oilOrderService.addOilTrack(jsonObject,oilOrder.getStoreId());
oilOrderService.addOilTrack(jsonObject, oilOrder.getStoreId());
}
}
}
@ -276,7 +281,7 @@ public class FyPayServiceImpl implements FyPayService {
if ("CVR".equals(type)) {
payStates = "paid";
receiveParameter.setType("2");
if (ObjectUtil.isNotEmpty(goodsOrder) && ObjectUtil.isNotEmpty(goodsOrder.getUserId())){
if (ObjectUtil.isNotEmpty(goodsOrder) && ObjectUtil.isNotEmpty(goodsOrder.getUserId())) {
receiveParameter.setUserId(goodsOrder.getUserId());
}
// if (!ObjectUtil.isEmpty(map1.get("orderId"))) {
@ -291,23 +296,23 @@ public class FyPayServiceImpl implements FyPayService {
}
// 修改商户账号余额信息
Double amount = merchantConfig.getAmount();
merchantConfig.setAmount(amount+(allAmount/100));
merchantConfig.setAmount(amount + (allAmount / 100));
merchantConfigService.updateMerch(merchantConfig);
resMap.put("msg","success");
}else if (reqMap.get("trans_stat").equals("USERPAYING")){
resMap.put("msg","unpaid");
}else {
resMap.put("msg", "success");
} else if (reqMap.get("trans_stat").equals("USERPAYING")) {
resMap.put("msg", "unpaid");
} else {
payStatus = "payFail";
if (!ObjectUtil.isEmpty(oilOrder)){
if (!ObjectUtil.isEmpty(oilOrder)) {
oilOrder.setOrderStatus("payFail");
}
if (!ObjectUtil.isEmpty(goodsOrder)){
if (!ObjectUtil.isEmpty(goodsOrder)) {
goodsOrder.setStatus("payFail");
}
if (!ObjectUtil.isEmpty(cashierOrder)){
if (!ObjectUtil.isEmpty(cashierOrder)) {
cashierOrder.setStatus("payFail");
}
if (!ArrayUtil.isEmpty(returnRecords)){
if (!ArrayUtil.isEmpty(returnRecords)) {
for (ReturnRecord returnRecord : returnRecords) {
returnRecord.setReturnType("0");
returnRecord.setPayStatus("payFail");
@ -317,8 +322,8 @@ public class FyPayServiceImpl implements FyPayService {
receiveParameter.setType("7");
receiveParameter.setContent("挂账订单");
}
if (!ArrayUtil.isEmpty(list)){
if (list.size()>1) {
if (!ArrayUtil.isEmpty(list)) {
if (list.size() > 1) {
for (OilOrder order : list) {
order.setOrderStatus("payFail");
oilOrderService.updateOilOrder(order);
@ -338,33 +343,37 @@ public class FyPayServiceImpl implements FyPayService {
payStates = "payFail";
}
}
if (!ObjectUtil.isEmpty(oilOrder)){
Double discountAmount = 0.0;
if (!ObjectUtil.isEmpty(oilOrder)) {
discountAmount = oilOrder.getDiscountAmount();
receiveParameter.setType("1");
if (oilOrder.getUserId()!=null){
if (oilOrder.getUserId() != null) {
receiveParameter.setUserId(oilOrder.getUserId());
}
receiveParameter.setContent("油品订单");
oilOrderService.updateOilOrder(oilOrder);
}
if (!ObjectUtil.isEmpty(goodsOrder)){
if (!ObjectUtil.isEmpty(goodsOrder)) {
discountAmount = goodsOrder.getDiscount();
receiveParameter.setType("2");
if (goodsOrder.getUserId()!=null){
if (goodsOrder.getUserId() != null) {
receiveParameter.setUserId(goodsOrder.getUserId());
}
receiveParameter.setContent("商品订单");
goodsOrderService.updateGoodOrder(goodsOrder);
}
if (!ObjectUtil.isEmpty(cashierOrder)){
if (!ObjectUtil.isEmpty(cashierOrder)) {
discountAmount = cashierOrder.getOilDiscountAmount() + cashierOrder.getGoodsDiscountAmount();
receiveParameter.setType("6");
if (!ObjectUtil.isEmpty(oilOrder)){
if (oilOrder.getUserId()!=null){
if (!ObjectUtil.isEmpty(oilOrder)) {
if (oilOrder.getUserId() != null) {
receiveParameter.setUserId(oilOrder.getUserId());
}
}
if (!ObjectUtil.isEmpty(goodsOrder)){
if (goodsOrder.getUserId()!=null){
if (!ObjectUtil.isEmpty(goodsOrder)) {
if (goodsOrder.getUserId() != null) {
receiveParameter.setUserId(goodsOrder.getUserId());
}
}
@ -379,7 +388,7 @@ public class FyPayServiceImpl implements FyPayService {
CardValueRecord byId = cardValueRecordService.getById(id);
receiveParameter.setType("3");
if (byId.getMtUserId()!=null){
if (byId.getMtUserId() != null) {
receiveParameter.setUserId(byId.getMtUserId());
}
receiveParameter.setContent("储值卡订单");
@ -391,45 +400,45 @@ public class FyPayServiceImpl implements FyPayService {
CardFuelRecord cardFuelRecord = cardFuelRecordService.queryById(id);
receiveParameter.setType("5");
if (cardFuelRecord.getMtUserId()!=null){
if (cardFuelRecord.getMtUserId() != null) {
receiveParameter.setUserId(cardFuelRecord.getMtUserId());
}
receiveParameter.setContent("囤油卡订单");
}
if ("IOS".equals(type)) {
// 积分商城
String storeId = ObjectUtil.isEmpty(map1.get("storeId"))?"-1":map1.get("storeId");
integralOrdersService.editPayStatus(orderNo, payStates,Integer.parseInt(storeId));
String storeId = ObjectUtil.isEmpty(map1.get("storeId")) ? "-1" : map1.get("storeId");
integralOrdersService.editPayStatus(orderNo, payStates, Integer.parseInt(storeId));
IntegralOrders integralOrders = integralOrdersService.queryIntegralOrdersByOrderNo(orderNo, Integer.parseInt(storeId));
receiveParameter.setType("4");
if (integralOrders.getUserId()!=null){
if (integralOrders.getUserId() != null) {
receiveParameter.setUserId(integralOrders.getUserId());
}
receiveParameter.setContent("积分订单");
}
if (!reqMap.get("trans_stat").equals("USERPAYING")){
this.insertAllOrderInfo(receiveParameter,payStatus);
if (!reqMap.get("trans_stat").equals("USERPAYING")) {
this.insertAllOrderInfo(receiveParameter, payStatus,discountAmount);
}
if (ObjectUtil.isNotEmpty(merchantConfig)){
if (ObjectUtil.isNotEmpty(merchantConfig)) {
// 添加配置记录信息
MerchantConfigRecord merchantConfigRecord = new MerchantConfigRecord();
merchantConfigRecord.setMerchantId(merchantConfig.getId());
if (payStatus.equals("paid")){
if (payStatus.equals("paid")) {
merchantConfigRecord.setIsSuccess("yes");
}else {
} else {
merchantConfigRecord.setIsSuccess("no");
}
merchantConfigRecord.setAmount(allAmount/100.0);
merchantConfigRecord.setAmount(allAmount / 100.0);
merchantConfigRecord.setType("0");
merchantConfigRecord.setStoreId(merchantConfig.getStoreId());
merchantConfigRecord.setOrderNo(orderNo);
merchantConfigRecordService.insertMerchantConfigRecord(merchantConfigRecord);
}
}
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
@ -442,9 +451,9 @@ public class FyPayServiceImpl implements FyPayService {
try {
// 查询商户配置信息
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(receiveParameter.getStoreId());
if (ObjectUtil.isEmpty(merchantConfig)){
res.put("code","error");
res.put("msg","暂未配置商户信息");
if (ObjectUtil.isEmpty(merchantConfig)) {
res.put("code", "error");
res.put("msg", "暂未配置商户信息");
return res;
}
// MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(16);
@ -460,34 +469,34 @@ public class FyPayServiceImpl implements FyPayService {
map.put("ins_cd", merchantConfig.getInsCd());
// 商户号
map.put("mchnt_cd", merchantConfig.getMchntCd());
// 订单号
map.put("mchnt_order_no",receiveParameter.getOrderNo());
// 订单总金额
// 订单号
map.put("mchnt_order_no", receiveParameter.getOrderNo());
// 订单总金额
Integer goodsMoney = (int) (receiveParameter.getGoodsMoney() * 100);
map.put("order_amt", goodsMoney.toString());
// 订单描述
// 订单描述
map.put("goods_des", receiveParameter.getContent());
if (receiveParameter.getPayType().equals("WECHAT")){
map.put("trade_type","LETPAY");
if (receiveParameter.getPayType().equals("WECHAT")) {
map.put("trade_type", "LETPAY");
// 微信open_id
map.put("sub_openid", userVo.getOpenId());
System.out.println("微信open_id:"+userVo.getOpenId());
System.out.println("微信open_id:" + userVo.getOpenId());
// appid
map.put("sub_appid", merchantConfig.getAppid());
} else if (receiveParameter.getPayType().equals("ALIPAY")){
map.put("trade_type","FWC");
} else if (receiveParameter.getPayType().equals("ALIPAY")) {
map.put("trade_type", "FWC");
// 支付宝userId
map.put("sub_openid", userVo.getUserId());
System.out.println("支付宝userId:"+userVo.getUserId());
System.out.println("支付宝userId:" + userVo.getUserId());
// appid
map.put("sub_appid", merchantConfig.getAlipayAppid());
}else {
res.put("code","error");
res.put("msg","暂不支持其他支付方式");
} else {
res.put("code", "error");
res.put("msg", "暂不支持其他支付方式");
return res;
}
if (ObjectUtil.isNotEmpty(merchantConfig)){
if (ObjectUtil.isNotEmpty(merchantConfig)) {
// 添加配置记录信息
MerchantConfigRecord merchantConfigRecord = new MerchantConfigRecord();
@ -502,35 +511,38 @@ public class FyPayServiceImpl implements FyPayService {
// 请求报文
String reqBody = Message.requestMsg(map);
// 响应报文
String rspXml = Message.responseMsg(reqBody,Const.fuiou_32_url);
// 响应报文
String rspXml = Message.responseMsg(reqBody, Const.fuiou_32_url);
//响应报文验签
Map<String, String> resMap = Utils.xmlStr2Map(rspXml);
log.info("--FyPayServiceImpl--:{}",resMap);
log.info("--FyPayServiceImpl--:{}", resMap);
String str = resMap.get("sign");
if (Utils.verifySign(resMap, str)){
if (Utils.verifySign(resMap, str)) {
System.out.println(resMap);
OilOrder oilOrder = oilOrderService.selectOilOrderByOrderNo(receiveParameter.getOrderNo());
// 添加订单信息
this.insertAllOrderInfo(receiveParameter);
Double discountAmount = 0.0;
if (ObjectUtil.isNotEmpty(oilOrder)) discountAmount = oilOrder.getDiscountAmount();
this.insertAllOrderInfo(receiveParameter, discountAmount);
res.put("code","success");
res.put("msg","成功");
res.put("code", "success");
res.put("msg", "成功");
ReturnParameter returnParameter = new ReturnParameter();
returnParameter.setOrderNo(receiveParameter.getOrderNo());
returnParameter.setReservedPayInfo(resMap.get("reserved_pay_info"));
returnParameter.setReservedTransactionId(resMap.get("reserved_transaction_id"));
res.put("data",returnParameter);
res.put("resultMsg",resMap.get("result_msg"));
res.put("data", returnParameter);
res.put("resultMsg", resMap.get("result_msg"));
return res;
}else {
throw new Exception("验签失败,请联系管理员!");
} else {
throw new Exception("验签失败,请联系管理员!");
}
}catch (Exception e){
res.put("code","error");
res.put("msg",e.getMessage());
} catch (Exception e) {
res.put("code", "error");
res.put("msg", e.getMessage());
e.printStackTrace();
}
return res;
@ -542,7 +554,7 @@ public class FyPayServiceImpl implements FyPayService {
/**
* 添加所有订单信息
*/
private void insertAllOrderInfo(ReceiveParameter receiveParameter,String payStatus){
private void insertAllOrderInfo(ReceiveParameter receiveParameter, String payStatus,Double discountAmount) {
AllOrderInfo allOrderInfo = new AllOrderInfo();
allOrderInfo.setOrderNo(receiveParameter.getOrderNo());
allOrderInfo.setType(receiveParameter.getType());
@ -553,12 +565,13 @@ public class FyPayServiceImpl implements FyPayService {
allOrderInfo.setUserId(receiveParameter.getUserId());
allOrderInfo.setPayChannel("cashier");
allOrderInfo.setStatus(payStatus);
if (payStatus.equals("paid")){
allOrderInfo.setDiscountAmount(discountAmount);
if (payStatus.equals("paid")) {
allOrderInfo.setPayTime(new Date());
}
allOrderInfo.setContent(receiveParameter.getContent());
AllOrderInfo allOrderInfo1 = allOrderInfoService.selectAllOrderInfoByOrderNo(receiveParameter.getOrderNo());
if (ObjectUtil.isEmpty(allOrderInfo1)){
if (ObjectUtil.isEmpty(allOrderInfo1)) {
allOrderInfoService.insertAllOrderInfo(allOrderInfo);
}
}
@ -566,7 +579,7 @@ public class FyPayServiceImpl implements FyPayService {
/**
* 添加所有订单信息
*/
private void insertAllOrderInfo(ReceiveParameter receiveParameter){
private void insertAllOrderInfo(ReceiveParameter receiveParameter,Double discountAmount) {
AllOrderInfo allOrderInfo = new AllOrderInfo();
allOrderInfo.setOrderNo(receiveParameter.getOrderNo());
allOrderInfo.setType(receiveParameter.getType());
@ -577,8 +590,9 @@ public class FyPayServiceImpl implements FyPayService {
allOrderInfo.setPayChannel("applet");
allOrderInfo.setStatus("unpaid");
allOrderInfo.setContent(receiveParameter.getContent());
allOrderInfo.setDiscountAmount(discountAmount);
AllOrderInfo allOrderInfo1 = allOrderInfoService.selectAllOrderInfoByOrderNo(receiveParameter.getOrderNo());
if (ObjectUtil.isEmpty(allOrderInfo1)){
if (ObjectUtil.isEmpty(allOrderInfo1)) {
allOrderInfoService.insertAllOrderInfo(allOrderInfo);
}
}
@ -597,9 +611,9 @@ public class FyPayServiceImpl implements FyPayService {
map.put("ins_cd", insCd);
map.put("mchnt_cd", mchntCd);
map.put("term_id", "88888888");
map.put("mchnt_order_no",orderNo);
map.put("mchnt_order_no", orderNo);
map.put("random_str", "orderNo");
map.put("order_type",payType);
map.put("order_type", payType);
map.put("refund_order_no", refundOrderNo);
map.put("refund_amt", refundAmt);
map.put("total_amt", totalAmt);
@ -612,13 +626,13 @@ public class FyPayServiceImpl implements FyPayService {
// 请求报文
String reqBody = Message.requestMsg(map);
// 响应报文
String rspXml = Message.responseMsg(reqBody,Const.fuiou_33_url);
String rspXml = Message.responseMsg(reqBody, Const.fuiou_33_url);
//响应报文验签
Map<String, String> resMap = Utils.xmlStr2Map(rspXml);
String str = resMap.get("sign");
if (Utils.verifySign(resMap, str)){
if (Utils.verifySign(resMap, str)) {
}
return resMap;
@ -630,20 +644,20 @@ public class FyPayServiceImpl implements FyPayService {
try {
// 查询商户配置信息
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(receiveParameterPos.getStoreId());
if (ObjectUtil.isEmpty(merchantConfig)){
res.put("code","error");
res.put("msg","暂未配置商户信息");
if (ObjectUtil.isEmpty(merchantConfig)) {
res.put("code", "error");
res.put("msg", "暂未配置商户信息");
return res;
}
String publicKey = merchantConfig.getPublicKey();
String privateKey = merchantConfig.getPrivateKey();
Const.INS_PUBLIC_KEY = publicKey;
Const.INS_PRIVATE_KEY = privateKey;
String allAmount = String.valueOf(receiveParameterPos.getGoodsMoney()*100);
String allAmount = String.valueOf((int) (receiveParameterPos.getGoodsMoney() * 100));
Map<String, String> map = Builder.buildFuiou22();
map.put("auth_code",receiveParameterPos.getAuthCode());
map.put("mchnt_order_no",receiveParameterPos.getOrderNo());
map.put("order_type",receiveParameterPos.getPayType());
map.put("auth_code", receiveParameterPos.getAuthCode());
map.put("mchnt_order_no", receiveParameterPos.getOrderNo());
map.put("order_type", receiveParameterPos.getPayType());
map.put("order_amt", allAmount);
map.put("ins_cd", merchantConfig.getInsCd());
map.put("mchnt_cd", merchantConfig.getMchntCd());
@ -653,25 +667,27 @@ public class FyPayServiceImpl implements FyPayService {
// 请求报文
String reqBody = Message.requestMsg(map);
// 响应报文
String rspXml = Message.responseMsg(reqBody,Const.fuiou_31_url);
String rspXml = Message.responseMsg(reqBody, Const.fuiou_31_url);
//响应报文验签
Map<String, String> resMap = Utils.xmlStr2Map(rspXml);
String str = resMap.get("sign");
String resultCode = resMap.get("result_code");
if (!resultCode.equals("000000")){
if (!resultCode.equals("000000")) {
throw new RuntimeException(resMap.get("result_msg"));
}
if (Utils.verifySign(resMap, str)){
if (Utils.verifySign(resMap, str)) {
ThreadUtil.execAsync(() -> {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
try {
Map<String, String> orderQueryRes = queryOrderPos(receiveParameterPos,merchantConfig.getInsCd(),merchantConfig.getMchntCd());
if(!orderQueryRes.get("msg").equals("unpaid")){
Map<String, String> orderQueryRes = queryOrderPos(receiveParameterPos, merchantConfig.getInsCd(), merchantConfig.getMchntCd());
if (!orderQueryRes.get("msg").equals("unpaid")) {
res.put("code", "success");
res.put("msg", "success");
timer.cancel();
}
} catch (Exception e) {
@ -679,50 +695,114 @@ public class FyPayServiceImpl implements FyPayService {
}
}
//定时器 不延时 立即开始 0.5s一次
}, 0, 500);
}, 0, 500);
Thread.currentThread().interrupt();
});
}else {
} else {
throw new Exception("验签失败,请联系管理员!");
}
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
return null;
return res;
}
@Override
public Map<String, String> queryOrderPos(ReceiveParameterPos receiveParameterPos,String insCd,String mchntCd) {
Map<String, String> resMap =new HashMap<>();
resMap.put("msg","error");
public Map<String, String> queryOrderPos(ReceiveParameterPos receiveParameterPos, String insCd, String mchntCd) {
Map<String, String> resMap = new HashMap<>();
resMap.put("msg", "error");
try {
Map<String, String> map = Builder.buildFuiou30();
map.put("mchnt_order_no",receiveParameterPos.getOrderNo());
map.put("order_type",receiveParameterPos.getType());
map.put("mchnt_order_no", receiveParameterPos.getOrderNo());
map.put("order_type", receiveParameterPos.getPayType());
map.put("ins_cd", insCd);
map.put("mchnt_cd", mchntCd);
String payStatus = "unpaid";
// 请求报文
String reqBody = Message.requestMsg(map);
// 响应报文
String rspXml = Message.responseMsg(reqBody,Const.fuiou_34_url);
String rspXml = Message.responseMsg(reqBody, Const.fuiou_34_url);
//响应报文验签
Map<String, String> reqMap = Utils.xmlStr2Map(rspXml);
String str = reqMap.get("sign");
if (Utils.verifySign(reqMap, str)){
if (reqMap.get("trans_stat").equals("SUCCESS")){
resMap.put("msg","success");
}else if (reqMap.get("trans_stat").equals("USERPAYING")){
resMap.put("msg","unpaid");
}else {
resMap.put("msg","payFail");
if (Utils.verifySign(reqMap, str)) {
OilOrder oilOrder = oilOrderService.selectOilOrderByOrderNo(receiveParameterPos.getOrderNo());
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(receiveParameterPos.getStoreId());
ReceiveParameter receiveParameter = new ReceiveParameter();
BeanUtils.copyProperties(receiveParameterPos, receiveParameter);
Double discountAmount = 0.0;
if (ObjectUtil.isNotEmpty(oilOrder)) discountAmount = oilOrder.getDiscountAmount();
this.insertAllOrderInfo(receiveParameter, receiveParameterPos.getPayType(),discountAmount);
if (reqMap.get("trans_stat").equals("SUCCESS")) {
payStatus = "paid";
if (!ObjectUtil.isEmpty(oilOrder)) {
// 油品订单
oilOrder.setOrderStatus("paid");
oilOrder.setPayTime(new Date());
oilOrderService.updateCardAndActiveById(oilOrder.getStoreId(), oilOrder.getUserId(), oilOrder.getActiveId(), oilOrder.getCouponId(), oilOrder.getActiveType(), oilOrder.getOrderAmount(), oilOrder.getPayAmount(), Integer.valueOf(oilOrder.getOils()));
oilOrderService.insertFavorable(oilOrder, receiveParameterPos.getOilCardAmount());
if (ObjectUtil.isNotEmpty(oilOrder.getStaffId()))
staffCommissionService.countStaffCommission(oilOrder.getStaffId(), oilOrder.getStoreId(), oilOrder.getOrderAmount(), oilOrder.getPayAmount(), "1", receiveParameterPos.getOrderNo());
// 修改油罐容量
oilOrderService.addOilTracks(oilOrder, oilOrder.getStoreId());
if (ObjectUtil.isNotEmpty(oilOrder.getUserId())) integralSettingsService.refuelPoints(oilOrder);
//修改优惠券使用状态
if (oilOrder.getCouponId() != null) {
CardFavorableRecord byId = cardFavorableRecordService.getById(oilOrder.getCouponId());
if (!ObjectUtil.isEmpty(byId)) {
byId.setStatus("1");
cardFavorableRecordService.updateById(byId);
}
}
}
// 修改商户账号余额信息
Double amount = merchantConfig.getAmount();
merchantConfig.setAmount(amount + receiveParameterPos.getGoodsMoney());
merchantConfigService.updateMerch(merchantConfig);
resMap.put("msg", "success");
} else if (reqMap.get("trans_stat").equals("USERPAYING")) {
payStatus = "unpaid";
resMap.put("msg", "unpaid");
} else {
payStatus = "payFail";
if (!ObjectUtil.isEmpty(oilOrder)) {
oilOrder.setOrderStatus("payFail");
}
resMap.put("msg", "payFail");
}
if (!ObjectUtil.isEmpty(oilOrder)) {
receiveParameter.setType("1");
if (oilOrder.getUserId() != null) {
receiveParameter.setUserId(oilOrder.getUserId());
}
receiveParameter.setContent("油品订单");
oilOrderService.updateOilOrder(oilOrder);
}
if (ObjectUtil.isNotEmpty(merchantConfig)) {
// 添加配置记录信息
MerchantConfigRecord merchantConfigRecord = new MerchantConfigRecord();
merchantConfigRecord.setMerchantId(merchantConfig.getId());
if (payStatus.equals("paid")) {
merchantConfigRecord.setIsSuccess("yes");
} else {
merchantConfigRecord.setIsSuccess("no");
}
merchantConfigRecord.setAmount(receiveParameterPos.getGoodsMoney());
merchantConfigRecord.setType("0");
merchantConfigRecord.setStoreId(merchantConfig.getStoreId());
merchantConfigRecord.setOrderNo(receiveParameterPos.getOrderNo());
merchantConfigRecordService.insertMerchantConfigRecord(merchantConfigRecord);
}
}
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
return null;
return resMap;
}
@Override
@ -730,9 +810,9 @@ public class FyPayServiceImpl implements FyPayService {
Map<String, String> res = new HashMap<>();
// 查询商户配置信息
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(receiveParameterPos.getStoreId());
if (ObjectUtil.isEmpty(merchantConfig)){
res.put("code","error");
res.put("msg","暂未配置商户信息");
if (ObjectUtil.isEmpty(merchantConfig)) {
res.put("code", "error");
res.put("msg", "暂未配置商户信息");
return res;
}
Map<String, String> map = Builder.buildFuiou25();
@ -740,14 +820,14 @@ public class FyPayServiceImpl implements FyPayService {
map.put("ins_cd", merchantConfig.getInsCd());
map.put("mchnt_cd", merchantConfig.getMchntCd());
map.put("term_id", "88888888");
map.put("mchnt_order_no",receiveParameterPos.getOrderNo());
map.put("mchnt_order_no", receiveParameterPos.getOrderNo());
map.put("random_str", "orderNo");
map.put("order_type",receiveParameterPos.getPayType());
map.put("order_type", receiveParameterPos.getPayType());
map.put("goods_des", receiveParameterPos.getContent());
double amount = receiveParameterPos.getGoodsMoney() * 100;
map.put("order_amt", String.valueOf((int) amount));
String nowtime = DateUtil.format(new Date(), "yyyyMMddHHmmss");
map.put("txn_begin_ts",nowtime);
map.put("txn_begin_ts", nowtime);
String publicKey = merchantConfig.getPublicKey();
String privateKey = merchantConfig.getPrivateKey();
@ -757,13 +837,13 @@ public class FyPayServiceImpl implements FyPayService {
// 请求报文
String reqBody = Message.requestMsg(map);
// 响应报文
String rspXml = Message.responseMsg(reqBody,Const.fuiou_35_url);
String rspXml = Message.responseMsg(reqBody, Const.fuiou_35_url);
//响应报文验签
Map<String, String> resMap = Utils.xmlStr2Map(rspXml);
String str = resMap.get("sign");
if (Utils.verifySign(resMap, str)){
if (Utils.verifySign(resMap, str)) {
System.out.println(resMap);
}
return resMap;

View File

@ -42,6 +42,15 @@ public class AllOrderInfoController extends BaseController {
return getSuccessResult(list);
}
@GetMapping("getPageListByPos")
public ResponseObject getPageListByPos(AllOrderInfo allOrderInfo,
@RequestParam(value = "page",defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize){
Page page =new Page(pageNo,pageSize);
IPage<AllOrderInfoVo> list = allOrderInfoService.getPageListByPos(page, allOrderInfo);
return getSuccessResult(list);
}
@GetMapping("sumPayMoney")
@ -196,6 +205,11 @@ public class AllOrderInfoController extends BaseController {
@GetMapping("getIndexData4Pos")
public ResponseObject getIndexData4Pos(){
AllOrderInfoVo indexData4Pos = allOrderInfoService.getIndexData4Pos();
return getSuccessResult(allOrderInfoService.getIndexData4Pos());
}
@GetMapping("getOperatingDataPos")
public ResponseObject getOperatingDataPos(AllOrderInfoDto allOrderInfo){
return getSuccessResult(allOrderInfoService.getOperatingDataPos(allOrderInfo));
}
}

View File

@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.order.entity.HandoverRecord;
import com.fuint.business.order.service.HandoverRecordService;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil;
import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject;
import org.springframework.http.HttpHeaders;
@ -111,6 +113,12 @@ public class HandoverRecordController extends BaseController {
return getSuccessResult(handoverRecordService.handover(staffId));
}
@GetMapping("handoverByPos")
public ResponseObject handoverByPos() {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
return getSuccessResult(handoverRecordService.handover(nowAccountInfo.getStaffId()));
}
@GetMapping("handoverByAllOrder")
public ResponseObject handoverByAllOrder() {
return getSuccessResult(handoverRecordService.handoverByAllOrder());

View File

@ -114,6 +114,17 @@ public class OilOrderController extends BaseController {
return getSuccessResult(order);
}
/**
* 批量添加订单信息 并支付
* @param oilOrderVo
* @return
*/
@PostMapping("/scanAppletQrCodePos")
public ResponseObject scanAppletQrCodePos(@Validated @RequestBody OilOrderVo oilOrderVo){
Map<String, String> order = orderService.scanAppletQrCodePos(oilOrderVo);
return getSuccessResult(order);
}
/**
* 小程序支付接口
* @param map
@ -322,4 +333,13 @@ public class OilOrderController extends BaseController {
return getSuccessResult(orderService.getInfoByEm(order));
}
/**
* pos端扫码支付
* @param oilOrderVo
* @return
*/
@PostMapping("addOrderPos")
public ResponseObject addOrderPos(@RequestBody OilOrderVo oilOrderVo) throws Exception {
return getSuccessResult(orderService.addOrderPos(oilOrderVo));
}
}

View File

@ -51,6 +51,10 @@ public class AllOrderInfo extends BaseEntity implements Serializable {
* 支付金额
*/
private Double payMoney;
/**
* 优惠金额
*/
private Double discountAmount;
/**
* 支付时间
*/

View File

@ -174,6 +174,7 @@
aoi.create_by AS createBy,
aoi.update_time AS updateTime,
aoi.update_by AS updateBy,
aoi.content AS content,
mu.name userName,
mu.mobile userMobile
from all_order_info aoi
@ -185,6 +186,9 @@
<if test="allOrderInfo.orderNo != null and allOrderInfo.orderNo != ''">
and aoi.order_no = #{allOrderInfo.orderNo}
</if>
<if test="allOrderInfo.status != null and allOrderInfo.status != ''">
and aoi.status = #{allOrderInfo.status}
</if>
<if test="allOrderInfo.payChannel != null and allOrderInfo.payChannel != ''">
and aoi.pay_channel = #{allOrderInfo.payChannel}
</if>
@ -299,17 +303,23 @@
</select>
<select id="getTradingData" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
select
SUM(CASE WHEN pay_type = 'CASH' THEN pay_money ELSE 0 END) AS CASH,
SUM(CASE WHEN pay_type = 'WECHAT' THEN pay_money ELSE 0 END) AS WECHAT,
SUM(CASE WHEN pay_type = 'ALIPAY' THEN pay_money ELSE 0 END) AS ALIPAY,
SUM(CASE WHEN pay_type = 'balance' THEN pay_money ELSE 0 END) AS balance,
COUNT(CASE WHEN pay_type = 'CASH' THEN 0 END) AS CASHCount,
COUNT(CASE WHEN pay_type = 'WECHAT' THEN 0 END) AS WECHATCount,
COUNT(CASE WHEN pay_type = 'ALIPAY' THEN 0 END) AS ALIPAYCount,
COUNT(CASE WHEN pay_type = 'balance' THEN 0 END) AS balanceCount,
SUM(CASE WHEN aoi.status = 'refund' THEN pay_money ELSE 0 END) AS refBalance,
COUNT(CASE WHEN aoi.status = 'refund' THEN 0 END) AS refBalanceCount
SUM(CASE WHEN pay_type = 'CASH' THEN pay_money ELSE 0 END) AS CASH,
SUM(CASE WHEN pay_type = 'WECHAT' THEN pay_money ELSE 0 END) AS WECHAT,
SUM(CASE WHEN pay_type = 'ALIPAY' THEN pay_money ELSE 0 END) AS ALIPAY,
SUM(CASE WHEN pay_type = 'balance' THEN pay_money ELSE 0 END) AS balance,
COUNT(CASE WHEN pay_type = 'CASH' THEN 0 END) AS CASHCount,
COUNT(CASE WHEN pay_type = 'WECHAT' THEN 0 END) AS WECHATCount,
COUNT(CASE WHEN pay_type = 'ALIPAY' THEN 0 END) AS ALIPAYCount,
COUNT(CASE WHEN pay_type = 'balance' THEN 0 END) AS balanceCount,
SUM(CASE WHEN aoi.status = 'refund' THEN pay_money ELSE 0 END) AS refBalance,
COUNT(CASE WHEN aoi.status = 'refund' THEN 0 END) AS refBalanceCount,
SUM(pay_money) AS sumBalance,
count(*) AS countBalance,
SUM(CASE WHEN aoi.content = '储值卡订单' THEN pay_money ELSE 0 END) AS userBalance,
COUNT(CASE WHEN aoi.content = '储值卡订单' THEN 0 END) AS userBalanceCount,
SUM(CASE WHEN aoi.content = '油品充值' THEN pay_money ELSE 0 END) AS oilBalance,
COUNT(CASE WHEN aoi.content = '油品充值' THEN 0 END) AS oilBalanceCount
from all_order_info aoi
left join mt_user mu ON aoi.user_id = mu.id
<where>
@ -346,12 +356,15 @@
</select>
<select id="getIndexData4Pos" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
SUM(pay_money) AS total_pay_money,
COUNT(*) AS total_count,
SUM(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) AS total_refund
SUM(pay_money) AS totalPayMoney,
COUNT(*) AS totalCount,
COUNT(CASE WHEN status = 'refund' THEN 1 ELSE NULL END) AS totalRefund -- 计算退款订单的总数
-- SUM(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) AS totalRefund
FROM
all_order_info
WHERE
DATE(pay_time) = CURDATE();
</select>
<!-- WHERE-->
<!-- DATE(pay_time) = CURDATE();-->
</mapper>

View File

@ -23,6 +23,7 @@ public interface AllOrderInfoService {
* @return
*/
IPage<AllOrderInfoVo> getPageList(Page page, AllOrderInfo allOrderInfo);
IPage<AllOrderInfoVo> getPageListByPos(Page page, AllOrderInfo allOrderInfo);
/**
* 统计总的金额
@ -88,6 +89,7 @@ public interface AllOrderInfoService {
IPage<SysDeptVo> runningWaterByTissue(Page page, AllOrderInfoDto allOrderInfo);
AllOrderInfoVo getIndexData4Pos();
AllOrderInfoVo getOperatingDataPos(AllOrderInfoDto allOrderInfo);
}

View File

@ -60,6 +60,7 @@ public interface HandoverRecordService {
boolean deleteById(Integer id);
public Map<String, Object> handover(Integer staffId);
public Map<String, Object> handoverByPos(Integer staffId);
public Map<String, Object> handoverByAllOrder();

View File

@ -108,6 +108,12 @@ public interface OilOrderService extends IService<OilOrder> {
*/
Map<String,String> scanAppletQrCode(Map<String,String> map);
/**
* 扫描小程序中二维码所处理的逻辑POS端
* @param oilOrderVo
*/
Map<String,String> scanAppletQrCodePos(OilOrderVo oilOrderVo);
/**
* 小程序添加油品订单信息
* @param oilOrder
@ -209,12 +215,12 @@ public interface OilOrderService extends IService<OilOrder> {
* @param oilOrderVo
* @return
*/
int addOrderPos(OilOrderVo oilOrderVo);
Map<String,String> addOrderPos(OilOrderVo oilOrderVo) throws Exception;
/**
* 添加订单信息 主扫
* @param oilOrderVo
* @return
*/
int addOrderPosScan(OilOrderVo oilOrderVo) throws Exception;
Map<String, String> addOrderPosScan(OilOrderVo oilOrderVo) throws Exception;
}

View File

@ -28,8 +28,10 @@ import com.fuint.business.order.vo.Excel.OilDepotExcel;
import com.fuint.business.order.vo.Excel.TradingExcel;
import com.fuint.business.order.vo.OrderGoodsVo;
import com.fuint.business.petrolStationManagement.entity.OilGun;
import com.fuint.business.petrolStationManagement.entity.OilName;
import com.fuint.business.petrolStationManagement.entity.OilTracking;
import com.fuint.business.petrolStationManagement.service.OilGunService;
import com.fuint.business.petrolStationManagement.service.OilNameService;
import com.fuint.business.petrolStationManagement.service.OilTankService;
import com.fuint.business.petrolStationManagement.service.OilTrackingService;
import com.fuint.business.store.entity.MtStore;
@ -84,6 +86,27 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
return pageList;
}
@Resource
OilOrderService oilOrderService;
@Resource
OilNameService oilNameService;
@Override
public IPage<AllOrderInfoVo> getPageListByPos(Page page, AllOrderInfo allOrderInfo) {
AccountInfo accountInfoByToken = TokenUtil.getNowAccountInfo();
allOrderInfo.setPayChannel("POS");
allOrderInfo.setStoreId(accountInfoByToken.getStoreId());
IPage<AllOrderInfoVo> pageList = allOrderInfoMapper.getPageList(page, allOrderInfo);
for (AllOrderInfoVo record : pageList.getRecords()) {
if ("油品订单".equals(record.getContent())) {
OilOrder oilOrder = oilOrderService.selectOilOrderByOrderNo(record.getOrderNo());
OilName oilName = oilNameService.selectOilNameById(Integer.parseInt(oilOrder.getOils()));
record.setOilName(oilName.getOilName());
record.setShengshu(oilOrder.getOilNum());
}
}
return pageList;
}
public String sumPayMoney(AllOrderInfo allOrderInfo){
String sumPayMoney = allOrderInfoMapper.sumPayMoney(allOrderInfo);
@ -160,8 +183,8 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
OrderGoodsService orderGoodsService;
@Resource
OilTankService oilTankService;
@Resource
OilOrderService oilOrderService;
// @Resource
// OilOrderService oilOrderService;
@Resource
OilTrackingService oilTrackingService;
@Resource
@ -438,12 +461,16 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
if (ObjectUtil.isEmpty(allOrderInfo.getDeptId())) {
IPage<SysDeptVo> sysDepts = sysDeptMapper.selectChildrenDeptById2(new Page(1,10000),nowAccountInfo.getDeptId(),allOrderInfo.getDeptId(),allOrderInfo.getDeptType());
if (ObjectUtil.isEmpty(sysDepts.getRecords())) throw new RuntimeException("组织下没有油站!");
if (ObjectUtil.isEmpty(sysDepts.getRecords())) {
throw new RuntimeException("组织下没有油站!");
}
allOrderInfo.setStoreIds(sysDepts.getRecords().stream().map(SysDeptVo::getDeptId).collect(Collectors.toList()));
List<MtStore> mtStores = mtStoreMapper.queryStoresByDeptIds(allOrderInfo.getStoreIds());
if (ObjectUtil.isEmpty(mtStores)) throw new RuntimeException("组织下没有油站");
if (ObjectUtil.isEmpty(mtStores)) {
throw new RuntimeException("组织下没有油站");
}
allOrderInfo.setStoreIds(mtStores.stream().map(MtStore::getId).map(Long::valueOf).collect(Collectors.toList()));
} else {
List<Long> depts = new ArrayList<>();
@ -464,12 +491,16 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
if (ObjectUtil.isEmpty(allOrderInfo.getDeptId())) {
IPage<SysDeptVo> sysDepts = sysDeptMapper.selectChildrenDeptById2( new Page(1,10000),nowAccountInfo.getDeptId(),allOrderInfo.getDeptId(),allOrderInfo.getDeptType());
if (ObjectUtil.isEmpty(sysDepts.getRecords())) throw new RuntimeException("组织下没有油站!");
if (ObjectUtil.isEmpty(sysDepts.getRecords())) {
throw new RuntimeException("组织下没有油站!");
}
allOrderInfo.setStoreIds(sysDepts.getRecords().stream().map(SysDeptVo::getDeptId).collect(Collectors.toList()));
List<MtStore> mtStores = mtStoreMapper.queryStoresByDeptIds(allOrderInfo.getStoreIds());
if (ObjectUtil.isEmpty(mtStores)) throw new RuntimeException("组织下没有油站");
if (ObjectUtil.isEmpty(mtStores)) {
throw new RuntimeException("组织下没有油站");
}
allOrderInfo.setStoreIds(mtStores.stream().map(MtStore::getId).map(Long::valueOf).collect(Collectors.toList()));
} else {
List<Long> depts = new ArrayList<>();
@ -514,6 +545,7 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
@Override
public void tradingExportExcel(HttpServletResponse response, AllOrderInfoDto order) {
IPage<AllOrderInfoVo> tradingPage = getTradingPage(new Page(1, 100000), order);
@ -899,13 +931,19 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
@Override
public AllOrderInfoVo getIndexData4Pos(){
return allOrderInfoMapper.getIndexData4Pos(new AllOrderInfoDto());
AllOrderInfoDto allOrderInfoDto = new AllOrderInfoDto();
AllOrderInfoVo indexData4Pos = allOrderInfoMapper.getIndexData4Pos(allOrderInfoDto);
return allOrderInfoMapper.getIndexData4Pos(allOrderInfoDto);
}
@Override
// 获取经营数据
public AllOrderInfoVo getOperatingDataPos(){
return allOrderInfoMapper.getIndexData4Pos(new AllOrderInfoDto());
public AllOrderInfoVo getOperatingDataPos(AllOrderInfoDto allOrderInfo){
AllOrderInfoVo tradingData = allOrderInfoMapper.getTradingData(allOrderInfo);
return allOrderInfoMapper.getTradingData(allOrderInfo);
}

View File

@ -124,7 +124,49 @@ public class HandoverRecordServiceImpl implements HandoverRecordService {
return this.handoverRecordMapper.deleteById(id) > 0;
}
@Override
public Map<String, Object> handoverByPos(Integer staffId) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
MtStore mtStore = new MtStore();
try {
mtStore = storeService.queryStoreById2(nowAccountInfo.getStoreId());
} catch (BusinessCheckException e) {
e.printStackTrace();
}
// 获取当前日期
LocalDate today = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 格式化当前时间
String formattedEndTime = LocalDateTime.now().format(formatter);
Map<String, Object> handoverMap = new HashMap<>();
String startTime = "2023-01-01 12:12:12";
HandoverRecord handoverRecord = selectByTime(staffId);
if (!ObjectUtil.isEmpty(handoverRecord) && !ObjectUtil.isEmpty(handoverRecord.getEndTime())) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
startTime = sdf.format(handoverRecord.getEndTime());
}
String handoverType = "POS机交班";
Integer staff = nowAccountInfo.getStaffId();
LJStaff ljStaff = iljStaffService.selectStaffById(staff);
// 填充 baseInfo
Map<String, Object> baseInfo = new HashMap<>();
baseInfo.put("storeName", mtStore.getName());
baseInfo.put("realName", ljStaff.getRealName());
baseInfo.put("handoverType", handoverType);
baseInfo.put("startTime", startTime);
baseInfo.put("endTime", formattedEndTime);
// 订单查询
// 订单金额优惠金额会员充值退款金额实收金额
return baseInfo;
}
@Override
public Map<String, Object> handover(Integer staffId) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();

View File

@ -9,6 +9,7 @@ public class AllOrderInfoVo extends AllOrderInfo {
private String userMobile;
private String storeName;
private String mchntCd;
private String orderStatus;
private Double sumPayMoney;
//交易金额
@ -26,6 +27,11 @@ public class AllOrderInfoVo extends AllOrderInfo {
private String oilName;
private Double shengshu;
private String CASH;
private String WECHAT;
private String ALIPAY;
@ -37,6 +43,19 @@ public class AllOrderInfoVo extends AllOrderInfo {
private String refBalance;
private String refBalanceCount;
private String sumBalance;
private String countBalance;
private String userBalance;
private String userBalanceCount;
private String oilBalance;
private String oilBalanceCount;
private String totalPayMoney;
private String totalCount;
private String totalRefund;
}

View File

@ -29,6 +29,9 @@ public class OilOrderVo extends OilOrder {
// 优惠券优惠金额
@TableField(exist = false)
private Double couponAmount;
@TableField(exist = false)
private String authCode;
@TableField(exist = false)
private Double oilCardAmount1;
}

View File

@ -123,7 +123,7 @@
and store_id = #{oilGun.storeId}
</select>
<select id="selectListByStoreId" resultType="com.fuint.business.petrolStationManagement.vo.OilGunVO">
SELECT og.*,onu.oil_name FROM oil_gun og
SELECT og.*,onu.oil_name,onu.oil_Price FROM oil_gun og
LEFT JOIN oil_number onu on og.number_id = onu.number_id
where og.status = '启用'
<if test="storeId != null">

View File

@ -102,6 +102,9 @@ public class PrinterServiceImpl implements PrinterService {
@Override
public String getToken(Integer storeId) {
PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId);
if (ObjectUtil.isEmpty(infoByStoreId)){
return "error";
}
RequestMethod.getInstance().init(infoByStoreId.getAppKey(),infoByStoreId.getAppSecret());
try {

View File

@ -55,7 +55,7 @@ public class ChainStoreInfoServiceImpl extends ServiceImpl<ChainStoreInfoMapper,
}
String ancestors = sysDept.getAncestors();
if (!"0".equals(sysDept.getAncestors())) {
ancestors = sysDept.getAncestors()+sysDept.getDeptId();
ancestors = sysDept.getAncestors()+ "," +sysDept.getDeptId();
}
IPage<ChainStoreInfo> res = baseMapper.listVo(page,chainStoreInfo,ancestors);

View File

@ -224,7 +224,8 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
String roleId = param.get("roleIds").toString();
String accountName = param.get("accountName").toString();
String accountStatus = param.get("accountStatus").toString();
String realName = param.get("realName").toString();
String realName = "";
if (ObjectUtil.isNotEmpty(param.get("realName"))) realName = param.get("realName").toString();
String password = param.get("password").toString();
String mobile = param.get("mobile").toString();

View File

@ -53,7 +53,7 @@ public interface ISysDeptService extends IService<SysDept>
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts);
/**
* 查询除蓝鲸总部的父级信息
* 查询除百业兴总部的父级信息
* @param deptId
* @return
*/

View File

@ -229,11 +229,11 @@
<!-- mvn install:install-file -DgroupId=yly_sdk -DartifactId=yly_sdk -Dversion=2.2 -Dpackaging=jar -Dfile=D:\workspaces\oilSystem\fuintBackend\lib\yly_sdk_2.2.jar-->
<!--<dependency>
<dependency>
<groupId>yly_sdk</groupId>
<artifactId>yly_sdk</artifactId>
<version>2.2</version>
</dependency>-->
</dependency>
</dependencies>

View File

@ -1,8 +1,8 @@
version: 1.0.0
files:
- url: 蓝鲸智慧油站收银台 Setup 1.0.0.exe
- url: 百业兴智慧油站收银台 Setup 1.0.0.exe
sha512: l8J4ix1xsfolq3NvAnhnnJqGvA/5vEESaDt+SJn9cld2YBC/RhWK0OuTSW+bXSm/EAfIFCciDGZ589pkTKALPg==
size: 76790468
path: 蓝鲸智慧油站收银台 Setup 1.0.0.exe
path: 百业兴智慧油站收银台 Setup 1.0.0.exe
sha512: l8J4ix1xsfolq3NvAnhnnJqGvA/5vEESaDt+SJn9cld2YBC/RhWK0OuTSW+bXSm/EAfIFCciDGZ589pkTKALPg==
releaseDate: '2023-09-06T05:42:03.990Z'

View File

@ -1,3 +1,3 @@
API_HOST = 'https://www.fuint.cn/fuint-application/'
NODE_ENV = 'development'
SYSTEM_NAME = '蓝鲸智慧油站收银台'
SYSTEM_NAME = '百业兴智慧油站收银台'

View File

@ -28,7 +28,7 @@
"url": "http://127.0.0.1"
}
],
"productName": "蓝鲸智慧油站收银台",
"productName": "百业兴智慧油站收银台",
"appId": "cn.fuint.cashier",
"directories": {
"output": "build"

View File

@ -59,7 +59,7 @@ function info() {
dialog.showMessageBox({
title: '关于',
type: 'info',
message: '蓝鲸智慧油站收银台',
message: '百业兴智慧油站收银台',
detail: `版本信息:${version}\n引擎版本:${process.versions.v8}\n当前系统:${os.type()} ${os.arch()} ${os.release()}`,
noLink: true,
buttons: ['查看官网', '确定']

View File

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 蓝鲸智慧收银台
VUE_APP_TITLE = 百业兴智慧收银台
# 开发环境配置
ENV = 'development'
@ -11,5 +11,5 @@ VUE_APP_BASE_API = '/dev-api'
VUE_APP_PUBLIC_PATH = '/'
# 后端接口地址
#VUE_APP_SERVER_URL = 'http://192.168.31.55:8081/'
VUE_APP_SERVER_URL = 'http://192.168.31.178:8080/'
VUE_APP_SERVER_URL = 'http://192.168.31.96:8080/'

View File

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 蓝鲸智慧油站收银台
VUE_APP_TITLE = 百业兴智慧油站收银台
# 生产环境配置
ENV = 'production'

View File

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 蓝鲸智慧油站收银台
VUE_APP_TITLE = 百业兴智慧油站收银台
# 测试环境配置
ENV = 'staging'

View File

@ -1,7 +1,7 @@
{
"name": "fuintCashier",
"version": "1.0.1",
"description": "蓝鲸智慧油站收银台",
"description": "百业兴智慧油站收银台",
"author": "FSQ",
"license": "MIT",
"scripts": {

View File

@ -594,7 +594,7 @@
<el-dialog :close-on-click-modal="false" width="60%" title="会员充值" :visible.sync="openRecharge" append-to-body>
<template>
<el-tabs v-model="activeRecharge" type="card" @tab-click="handleClick">
<el-tab-pane label="储值卡" name="balance">
<el-tab-pane label="电子储值卡" name="balance">
<div style="font-size: 14px">
<div style="font-size: 14px;height: 50px;line-height: 50px">充值金额</div>
<div v-if="cardValueList.length>0"
@ -708,7 +708,7 @@
</div>
</div>
</el-tab-pane>
<el-tab-pane label="油卡" name="literCard">
<el-tab-pane label="电子囤油卡" name="literCard">
<el-row>
<el-col :span="24">
<div style="display: flex">
@ -3377,7 +3377,7 @@
}else {
this.oilActualPay = this.oilAmount.toFixed(2)
}
console.log("不使用囤油卡",this.oilAmount, this.oilDiscount,this.couponAmount,this.fullReduction)
console.log("不使用囤油卡",this.oilAmount, this.oilDiscount,this.couponAmount,this.fullReduction,this.oilCardAmount)
},
// 使
countAmountUnBalance(){
@ -3896,7 +3896,7 @@
if (flag) amount = item.oilPrice * item.liters
oilAmount += amount
})
this.oilCardAmount = this.oilAmount - oilAmount
if (oilAmount>0) this.oilCardAmount = this.oilAmount - oilAmount
this.countAmountFull()
})
},

View File

@ -181,9 +181,9 @@
<div class="app-left">
<div class="app-left-top">
<div class="app-left-img">
<img src="../../assets/images/lanlogo.png" alt="">
<!-- <img src="../../assets/images/lanlogo.png" alt="">-->
</div>
<div class="app-left-title">蓝鲸油站收银 </div>
<div class="app-left-title">百业兴油站收银 </div>
</div>
<div class="app-left-box" v-for="(item,index) in tabarr" v-if="item.name !== '积分'" :class="{'bule': leftindex == item.index1}" :key="index" @click="gocomponents(index,item.path)">

View File

@ -101,25 +101,25 @@
></el-statistic>
</div>
</el-col>
<el-col :span="4">
<div class="sta" v-if="!refuelMoney">
<el-statistic
group-separator=","
:precision="2"
:value="0"
title="囤油卡余额"
>
</el-statistic>
</div>
<div v-if="refuelMoney && refuelMoney.length>0" style="display: flex;align-items: center;margin-top: 25px">
<div class="size-hui">囤油卡余额</div>
<div v-for="(item,index) in refuelMoney"
:key="index" style="margin-left: 20px;text-align: center">
<div class="size-hui">{{ item.oilName ? item.type + item.oilName : item.type }}</div>
<div class="size-bole">{{ item.refuelMoney || 0.00 }}</div>
</div>
</div>
</el-col>
<!-- <el-col :span="4">-->
<!-- <div class="sta" v-if="!refuelMoney">-->
<!-- <el-statistic-->
<!-- group-separator=","-->
<!-- :precision="2"-->
<!-- :value="0"-->
<!-- title="囤油卡余额"-->
<!-- >-->
<!-- </el-statistic>-->
<!-- </div>-->
<!-- <div v-if="refuelMoney && refuelMoney.length>0" style="display: flex;align-items: center;margin-top: 25px">-->
<!-- <div class="size-hui">囤油卡余额</div>-->
<!-- <div v-for="(item,index) in refuelMoney"-->
<!-- :key="index" style="margin-left: 20px;text-align: center">-->
<!-- <div class="size-hui">{{ item.oilName ? item.type + item.oilName : item.type }}</div>-->
<!-- <div class="size-bole">{{ item.refuelMoney || 0.00 }}</div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </el-col>-->
</el-row>
</div>
</template>
@ -158,7 +158,7 @@
<el-dialog :close-on-click-modal="false" width="60%" :title="title" :visible.sync="openRecharge" append-to-body>
<template>
<el-tabs v-model="activeRecharge" type="card" @tab-click="handleClick">
<el-tab-pane label="储值卡" name="balance">
<el-tab-pane label="电子储值卡" name="balance">
<div>
<el-row>
<el-col :span="1.5">
@ -278,7 +278,7 @@
</div>
</div>
</el-tab-pane>
<el-tab-pane label="油卡" name="literCard">
<el-tab-pane label="电子囤油卡" name="literCard">
<el-row>
<el-col :span="24">
<div style="display: flex">

View File

@ -2,7 +2,7 @@
<div class="login">
<div class="box-center">
<div class="box-left">
<div class="bai-size">蓝鲸智慧加油站收银台</div>
<div class="bai-size">百业兴智慧加油站收银台</div>
<div class="bact-box">
<div class="sanhh">活动营销</div>
<div class="sanhh">节省人力</div>

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,10 @@
// launchtypelocalremote, localremote
"version": "0.0",
"configurations": [{
"app-plus" :
{
"launchtype" : "local"
},
"default" :
{
"launchtype" : "local"

View File

@ -1,75 +1,75 @@
{
"name": "WX-lift",
"appid": "__UNI__7A6878C",
"description": "",
"versionName": "1.0.0",
"versionCode": "100",
"transformPx": false,
/* 5+App */
"app-plus": {
"usingComponents": true,
"nvueStyleCompiler": "uni-app",
"compilerVersion": 3,
"splashscreen": {
"alwaysShowBeforeRender": true,
"waiting": true,
"autoclose": true,
"delay": 0
},
/* */
"modules": {},
/* */
"distribute": {
/* android */
"android": {
"permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios */
"ios": {},
/* SDK */
"sdkConfigs": {}
}
},
/* */
"quickapp": {},
/* */
"mp-weixin": {
"appid": "wx7ad01a99a7247643",
"setting": {
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true
},
"usingComponents": true
},
"mp-alipay": {
"usingComponents": true
},
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao": {
"usingComponents": true
},
"uniStatistics": {
"enable": false
},
"vueVersion": "2"
}
"name" : "WX-lift",
"appid" : "__UNI__7A6878C",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
/* 5+App */
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
/* */
"modules" : {},
/* */
"distribute" : {
/* android */
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios */
"ios" : {},
/* SDK */
"sdkConfigs" : {}
}
},
/* */
"quickapp" : {},
/* */
"mp-weixin" : {
"appid" : "wx64893d1680461e30",
"setting" : {
"urlCheck" : false,
"es6" : true,
"postcss" : true,
"minified" : true
},
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "2"
}

View File

@ -64,12 +64,54 @@
"navigationStyle": "custom"
}
},
{
"path": "AddVip/AddCode",
"style": {
"navigationBarTitleText": "新增会员",
"navigationStyle": "custom"
}
},
{
"path": "changeShifts/changeShifts",
"style": {
"navigationBarTitleText": "交接班",
"navigationStyle": "custom"
}
},
{
"path": "changeShifts/list",
"style": {
"navigationBarTitleText": "交班记录",
"navigationStyle": "custom"
}
},
{
"path": "messageList/messageList",
"style": {
"navigationBarTitleText": "消息列表",
"navigationStyle": "custom"
}
},
{
"path": "PaymentCode/PaymentCode",
"style": {
"navigationBarTitleText": "收款码",
"navigationStyle": "custom"
}
},
{
"path": "PaymentCode/SetUpCode",
"style": {
"navigationBarTitleText": "设置金额",
"navigationStyle": "custom"
}
},
{
"path": "scanQrcode/index",
"style": {
"navigationBarTitleText": "扫码支付",
"navigationStyle": "custom"
}
}
]

View File

@ -6,12 +6,12 @@
<view class="title_top">京博加油站</view>
<view class="title_centen">
<view class="sm-size">今日营业额()</view>
<view class="big-size">30000000.00</view>
<view class="big-size">{{indexData.totalPayMoney}}</view>
</view>
<!-- 123-->
<!-- 123-->
<view class="ds-ab">
<view class="sm-size">收款笔数 0</view>
<view class="sm-size">退款笔数 0</view>
<view class="sm-size">收款笔数 {{indexData.totalCount}}</view>
<view class="sm-size">退款笔数 {{indexData.totalRefund}}</view>
</view>
<view class="jg-box">
<view class="s-box" @click="goCollection()">
@ -20,13 +20,13 @@
</view>
<view class="">收款</view>
</view>
<view class="s-box">
<view class="s-box" @click="goRecharge()">
<view class="">
<image src="/static/imgs/cz.png" mode=""></image>
</view>
<view class="">充值</view>
</view>
<view class="s-box">
<view class="s-box" @click="goCode()">
<view class="">
<image src="/static/imgs/skm.png" mode=""></image>
</view>
@ -54,7 +54,7 @@
</view>
<view class="">订单</view>
</view>
<view class="ss-box">
<view class="ss-box" @click="gochangeShifts()">
<view class="">
<image src="/static/imgs/jjb.png" mode=""></image>
</view>
@ -72,6 +72,7 @@
</template>
<script>
import request from "../../utils/request";
import headers from '../../components/header/headers.vue'
import tabbar from '../../components/tabbar/tabbar.vue'
export default {
@ -82,11 +83,17 @@
List: [],
show: false,
status: 'loading',
indexData: {
totalPayMoney: '0',
totalCount: '0',
totalRefund: '0',
}
}
},
onShow() {
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
this.getIndexData();
},
onPullDownRefresh() {
console.log("刷新");
@ -103,9 +110,25 @@
tabbar
},
methods: {
goRecharge() {
uni.navigateTo({
url: "/pagesHome/MemberRecharge/MemberRecharge"
})
},
goCode() {
uni.navigateTo({
url: '/pagesHome/PaymentCode/PaymentCode'
})
},
gochangeShifts() {
uni.navigateTo({
url: '/pagesHome/changeShifts/changeShifts'
})
},
goAdd() {
uni.navigateTo({
url: '/pagesHome/AddVip/AddVip'
url: '/pagesHome/AddVip/AddCode'
})
},
goCollection() {
@ -125,6 +148,24 @@
},
goback() {
uni.navigateBack()
},
//
getIndexData() {
request({
url: 'business/allOrderInfo/getIndexData4Pos',
method: 'get',
params: this.form
}).then((res) => {
if (res.code == 200) {
this.indexData = res.data
} else {
uni.showToast({
title: res.data,
icon: "none"
})
}
})
}
}
}
@ -253,4 +294,4 @@
overflow: hidden;
margin-left: 10px;
}
</style>
</style>

View File

@ -8,12 +8,12 @@
<view class="input_box">
<u-icon name="account" color="#0864E9" size="22"></u-icon>
<input type="text" v-model="form.username" placeholder="请输入账号" />
<input type="text" style="color: #333;" v-model="form.username" placeholder="请输入账号" />
</view>
<view class="input_box">
<u-icon name="lock" color="#0864E9" size="22"></u-icon>
<input type="text" v-model="form.password" placeholder="请输入密码" />
<input type="text" style="color: #333;" v-model="form.password" placeholder="请输入密码" />
</view>
<view class="anniu" @click="goGoGo">
@ -81,10 +81,10 @@
uni.navigateTo({
url: '/pages/index/index'
})
}else{
} else {
uni.showToast({
title:res.data,
icon:"none"
title: res.data,
icon: "none"
})
}
})

View File

@ -17,7 +17,7 @@
</view>
</view>
<view class="jg-box">
<view class="h-box">
<view class="h-box" @click="golist()">
<view class="">消息通知</view>
<u-icon name="arrow-right" size="18"></u-icon>
</view>
@ -63,7 +63,7 @@
List: [],
show: false,
status: 'loading',
userInfo:{},
userInfo: {},
}
},
onShow() {
@ -86,10 +86,15 @@
tabbar
},
methods: {
golist() {
uni.navigateTo({
url: '/pagesHome/messageList/messageList'
})
},
//
getUserInfo(){
getUserInfo() {
request({
url: 'backendApi/account/info/'+uni.getStorageSync("accountId"),
url: 'backendApi/account/info/' + uni.getStorageSync("accountId"),
method: 'get',
}).then((res) => {
this.userInfo = res.data.account

View File

@ -0,0 +1,139 @@
<template>
<view class="content">
<view class="container">
<headers :titles="titles"><u-icon name="arrow-left" color="#fff" size="22"></u-icon></headers>
<view class="box-">
<view class="title_">扫码成为京博加油站会员</view>
<view
style="background: #fff;width: 215px; height: 220px; border-radius: 8px ; margin: 15px auto; box-sizing: border-box; padding-top: 10px; ">
<canvas id="qrcode" canvas-id="qrcode"
style="width: 200px;height: 200px; margin: 0px auto; "></canvas>
</view>
<view class="title_">长按识别领取会员卡</view>
</view>
<view class="p-bottom">
<view class="anniu" @click="goback()">
手动添加
</view>
</view>
</view>
</view>
</template>
<script>
import headers from '../../components/header/headers.vue'
import UQRCode from '../../uni_modules/Sansnn-uQRCode/js_sdk/uqrcode/uqrcode.js';
export default {
data() {
return {
titles: "新增会员",
}
},
onShow() {
this.onReady()
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
},
onPullDownRefresh() {
console.log("刷新");
uni.stopPullDownRefresh()
},
onReachBottom() {
// this.show = true
setTimeout(() => {
console.log("加载执行");
}, 2000)
},
components: {
headers
},
methods: {
onReady() {
// uQRCode
var qr = new UQRCode();
//
qr.data = "https://uqrcode.cn/doc";
// canvas
qr.size = 200;
//
qr.make();
// canvas
var canvasContext = uni.createCanvasContext('qrcode', this); // this
// uQRCodecanvas
qr.canvasContext = canvasContext;
// canvas
qr.drawCanvas();
},
goback() {
uni.navigateTo({
url: '/pagesHome/AddVip/AddVip'
})
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #fff;
// background: linear-gradient(180deg, #B2D2FC 0%, #B2D2FC 14%, rgba(255, 255, 255, 0.84) 24%, rgba(255, 255, 255, 0.84) 100%);
height: 100vh;
}
.container {
width: 100%;
background: #fff;
box-sizing: border-box;
padding-top: 88px;
}
.img-box {
image {
width: 100%;
height: 100%;
}
}
.p-bottom {
width: 100%;
height: 68px;
background: #fff;
position: fixed;
bottom: 0px;
left: 0px;
}
.anniu {
height: 40px;
background: #0864E9;
width: 80%;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
border-radius: 50px;
margin: 5px auto;
}
.box- {
width: 95%;
margin: 15px auto;
border-radius: 8px;
background: #0864E9;
height: 400px;
}
.title_ {
text-align: center;
width: 100%;
font-weight: bold;
font-size: 16px;
color: #FFFFFF;
margin-bottom: 15px;
}
</style>

View File

@ -7,52 +7,62 @@
<view class="h-box">
<view class="">会员姓名</view>
<view class="r-input">
<input type="text" placeholder="请输入" />
<input type="text" v-model="dataForm.name" placeholder="请输入" />
</view>
</view>
<view class="h-box">
<view class="">手机号码</view>
<view class="r-input">
<input type="text" placeholder="请输入" />
<input type="text" v-model="dataForm.mobile" placeholder="请输入" />
</view>
</view>
<view class="h-box">
<!-- <view class="h-box">
<view class="">支付密码</view>
<view class="r-input">
<input type="text" placeholder="请输入" />
</view>
</view>
</view> -->
<view class="h-box">
<view class="">性别</view>
<view class="d-s">
<view class="">请选择</view>
<view class="d-s" @click="showXingbie = true">
<view class="">{{sex}}</view>
<u-icon name="arrow-right" color="#2979ff" size="18"></u-icon>
</view>
</view>
<view class="h-box">
<view class="">生日</view>
<view class="d-s">
<view class="">请选择</view>
<view class="d-s" @click="showTime= true">
<view class="">{{dataForm.birthday?dataForm.birthday:"请选择"}}</view>
<u-icon name="arrow-right" color="#2979ff" size="18"></u-icon>
</view>
</view>
<view class="h-box">
<view class="">会员等级</view>
<view class="d-s">
<view class="">请选择</view>
<view class="d-s" @click="showGrade = true">
<view class="">{{gradeName}}</view>
<u-icon name="arrow-right" color="#2979ff" size="18"></u-icon>
</view>
</view>
<view class="h-box">
<view class="">备注</view>
<view class="r-input">
<input type="text" placeholder="请输入" />
<input type="text" v-model="dataForm.description" placeholder="请输入" />
</view>
</view>
</view>
<u-picker :show="showXingbie" :columns="xingbieList" keyName="name" @cancel="showXingbie = false"
@confirm="chooseXingbie"></u-picker>
<u-datetime-picker :show="showTime" v-model="dataForm.birthday" mode="date" @cancel="showTime = false"
@confirm="chooseTime"></u-datetime-picker>
<u-picker :show="showGrade" :columns="gradeList" keyName="name" @cancel="showGrade = false"
@confirm="chooseGrade"></u-picker>
<view class="p-bottom">
<view class="anniu" @click="goback()">
@ -64,17 +74,55 @@
</template>
<script>
import request from "../../utils/request";
import headers from '../../components/header/headers.vue'
export default {
data() {
return {
titles: "新增会员",
showGrade: false,
showXingbie: false,
showTime: false,
gradeList: [],
xingbieList: [
[{
id: 1,
name: "男"
}, {
id: 0,
name: "女"
}]
],
form: {},
value1: '',
sex: '请选择',
gradeName: '请选择',
dataForm: {
address: "",
birthday: "",
cardBalance: 0,
description: "",
endTime: "",
gradeId: "",
id: "",
idcard: "",
literCard: "0",
mobile: "",
name: "",
official: "",
points: 0,
refuelMoney: "0",
sex: 1,
startTime: "",
status: "qy",
userNo: ""
}
}
},
onShow() {
this.getGradeList()
},
onPullDownRefresh() {
console.log("刷新");
@ -90,8 +138,65 @@
headers
},
methods: {
//
getGradeList() {
request({
url: 'business/userManager/userGrade/list',
method: 'get',
params: this.form
}).then((res) => {
if (res.data) {
this.gradeList = []
this.gradeList.push(res.data.records)
console.log(res.data.records)
} else {
uni.showToast({
title: res.data,
icon: "none"
})
}
})
},
chooseGrade(e) {
console.log(123123, e.value[0])
const data = e.value[0]
this.showGrade = false
this.dataForm.gradeId = data.id
this.gradeName = data.name
},
chooseXingbie(e) {
console.log(123123, e.value[0])
const data = e.value[0]
this.showXingbie = false
this.dataForm.sex = data.id
this.sex = data.name
},
chooseTime(e) {
console.log(123123, e)
this.showTime = false
},
goback() {
uni.navigateBack()
request({
url: 'business/userManager/user',
method: 'post',
data: this.dataForm
}).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '添加成功!',
icon: "none"
})
uni.navigateBack()
} else {
uni.showToast({
title: '添加失败,请重试',
icon: "none"
})
}
})
}
}
}

View File

@ -5,25 +5,36 @@
<view class="top-time">
<view style="margin-right: 10px;">选择时间</view>
<view class="lan-time">2024/05/11 00:00-2024/05/11 23:59</view>
<view class="lan-time">
<span @click="clickStartTime">{{startTime}}</span>
<span>-</span>
<span @click="clickEndTime">{{endTime}}</span>
</view>
</view>
<u-datetime-picker :show="showStartTime" v-model="startTimeValue" mode="datetime" @confirm="clickStart"
@close="showStartTime = false" @cancel="showStartTime = false"></u-datetime-picker>
<u-datetime-picker :show="showEndTime" v-model="endTimeValue" mode="datetime" @confirm="clickEnd"
@close="showEndTime = false" @cancel="showEndTime = false"></u-datetime-picker>
<view class="hm-box">
<view class="hm-top">营业收入</view>
<view class="lan-title">0.00</view>
<view class="lan-title">{{dataForm.sumBalance}}</view>
<view class="b-bs">
<view class="">
<view class="hui-">营业额/笔数</view>
<view class="lan-">0.00/0</view>
<view class="lan-">{{dataForm.sumBalance}}/{{dataForm.countBalance}}</view>
</view>
<view class="">
<view class="hui-">会员充值/笔数</view>
<view class="lan-">0.00/0</view>
<view class="lan-">{{dataForm.userBalance}}/{{dataForm.userBalanceCount}}</view>
</view>
</view>
<view class="b-bs">
<view class="">
<view class="hui-">退款金额/笔数</view>
<view class="lan-">0.00/0</view>
<view class="lan-">{{dataForm.refBalance}}/{{dataForm.refBalanceCount}}</view>
</view>
</view>
@ -39,7 +50,7 @@
<view class="h-b-box">
<view class="">
<view class="hui-">营业额/笔数</view>
<view class="lan-">0.00/0</view>
<view class="lan-">{{dataForm.cash}}/{{dataForm.cashcount}}</view>
</view>
<view class="">
<view class="hui-">会员充值/笔数</view>
@ -87,18 +98,41 @@
</template>
<script>
import request from "../../utils/request";
import headers from '../../components/header/headers.vue'
export default {
data() {
return {
titles: "经营数据",
startTime: "",
endTime: "",
startTimeValue: "",
endTimeValue: "",
showStartTime: false,
showEndTime: false,
dataForm: {
},
}
},
onShow() {
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
let start = new Date();
start.setHours(0)
start.setMinutes(0)
start.setSeconds(0)
start.setMilliseconds(0)
// formatDateToYYMMDDHHMM(start);
// formatDateToYYMMDDHHMM(new Date());
this.startTime = this.formatDateToYYMMDDHHMM(start);
this.endTime = this.formatDateToYYMMDDHHMM(new Date());
// this.startTime = start
// this.endTime = new Date()
this.getIndexData()
},
onPullDownRefresh() {
console.log("刷新");
@ -116,8 +150,75 @@
methods: {
goback() {
uni.navigateBack()
},
clickStartTime(e) {
this.showStartTime = true
console.log(123, e)
// const date = new Date(timestamp);
},
clickEndTime(e) {
this.showEndTime = true
},
clickStart(e) {
console.log('123123', e)
this.showStartTime = false
this.startTime = this.formatDateToYYMMDDHHMM(new Date(e.value));
},
clickEnd(e) {
this.showEndTime = false
this.startTime = this.formatDateToYYMMDDHHMM(new Date(e.value));
},
//
getIndexData() {
request({
url: 'business/allOrderInfo/getOperatingDataPos',
method: 'get',
params: this.form
}).then((res) => {
if (res.code == 200) {
this.dataForm = res.data
} else {
uni.showToast({
title: res.data,
icon: "none"
})
}
})
},
formatTimestamp(timestamp) {
// const date = new Date(Number(timestamp));
// const year = date.getFullYear();
// const month = String(date.getMonth() + 1).padStart(2, '0');
// const day = String(date.getDate()).padStart(2, '0');
// const hours = String(date.getHours()).padStart(2, '0');
// const minutes = String(date.getMinutes()).padStart(2, '0');
// const seconds = String(date.getSeconds()).padStart(2, '0');
// return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
},
formatDateToYYMMDDHHMM(date) {
const year = String(date.getFullYear()); //
const month = String(date.getMonth() + 1).padStart(2, '0'); //
const day = String(date.getDate()).padStart(2, '0'); //
const hours = String(date.getHours()).padStart(2, '0'); //
const minutes = String(date.getMinutes()).padStart(2, '0'); //
// return `${year}/${month}/${day} ${hours}:${minutes}`;
return `${year}/${month}/${day}`;
}
}
},
watch: {
// startTime(newVal) {
// this.startTime = this.formatTimestamp(newVal);
// },
// endTime(newVal) {
// this.endTime = this.formatTimestamp(newVal);
// }
},
}
</script>

View File

@ -3,15 +3,27 @@
<view class="container">
<headers :titles="titles"><u-icon name="arrow-left" color="#fff" size="22"></u-icon></headers>
<view class="input-box">
<view style="margin-right: 10px;">收款金额</view>
<view style="margin-right: 10px;">收款金额</view>
<view class="">{{AmountCollected}}</view>
<!-- <input type="number" /> -->
</view>
<view class="input-box">
<view style="margin-right: 10px;">优惠后收款金额</view>
<view class="">{{paymentAmount}}</view>
<!-- <input type="number" /> -->
</view>
<view class="input-box">
<view style="margin-right: 10px;">优惠金额</view>
<view class="">{{DiscountAmount}}</view>
<!-- <input type="number" /> -->
</view>
<view class="input-box">
<view style="margin-right: 10px;">储值卡消费金额</view>
<view class="">{{balanceRedece}}</view>
<!-- <input type="number" /> -->
</view>
<!-- <view class="title_">选择油号</view>
<view class="warp-box">
@ -23,8 +35,8 @@
</view> -->
<view class="title_">选择油枪</view>
<view class="warp-box">
<view class="w-box" :class="{ 'acv' : spearIndex == index }" @click="getspearIndex(index)"
v-for="(item,index) in spearList" :key="index">
<view class="w-box" :class="{ 'acv' : spearIndex == index }" v-for="(item,index) in spearList"
:key="index" @click="getspearIndex(index,item)">
{{item.gunName}}
</view>
@ -34,7 +46,7 @@
<view class="kuang-top">
<view class="w-shi">添加备注</view>
<view style="color: #E8E8E8;"> | </view>
<view class="w-shi" @click="gosearchVip()">搜索会员</view>
<view class="w-shi" @click="gosearchVip()">{{userInfo ? userInfo.mobile : '搜索会员'}}</view>
</view>
<!-- 键盘区域 -->
<view class="num-box">
@ -46,16 +58,19 @@
</view>
<view class="Centralimg" v-if="item.type == 'img' ">
<view class="icon-box">
<image src="/static/imgs/smzf.png" v-if="item.value == 'smzf' "></image>
<image src="/static/imgs/skzf.png" v-if="item.value == 'skzf' "></image>
<image src="/static/imgs/hyzf.png" v-if="item.value == 'hyzf' "></image>
<image src="/static/imgs/xjzf.png" v-if="item.value == 'xjzf' "></image>
<image src="/static/imgs/smzf.png" v-if="item.value == 'smzf' " @click="scanQrcode()">
</image>
<image src="/static/imgs/skzf.png" v-if="item.value == 'skzf' " @click="swipeCard()"></image>
<image src="/static/imgs/hyzf.png" v-if="item.value == 'hyzf' "
@click="scanAppletQrCode()"></image>
<image src="/static/imgs/xjzf.png" v-if="item.value == 'xjzf' " @click="cashPay()">
</image>
<image src="/static/imgs/scjian.png" style="height: 30px;" v-if="!item.value"></image>
</view>
<view class="icon-size" v-if="item.value == 'smzf' ">扫码支付</view>
<view class="icon-size" v-if="item.value == 'skzf' ">刷卡支付</view>
<view class="icon-size" v-if="item.value == 'hyzf' ">会员支付</view>
<view class="icon-size" v-if="item.value == 'xjzf' ">现金支付</view>
<view class="icon-size" v-if="item.value == 'smzf' " @click="scanQrcode()">扫码支付</view>
<view class="icon-size" v-if="item.value == 'skzf' " @click="swipeCard()">刷卡支付</view>
<view class="icon-size" v-if="item.value == 'hyzf' " @click="scanAppletQrCode()">会员支付</view>
<view class="icon-size" v-if="item.value == 'xjzf' " @click="cashPay()">现金支付</view>
</view>
</view>
@ -75,8 +90,25 @@
export default {
data() {
return {
AmountCollected: '',
DiscountAmount: '',
userId: "",
userInfo: "",
AmountCollected: "",
paymentAmount: "",
DiscountAmount: 0,
balance: 0,
balanceRedece: 0,
// 使
isOilStorageCard: false,
authCode: "",
oilName: "",
tankId: "",
oilPrice: "",
oilGunNum: "",
oilCardAmount: 0,
levelAmount: 0,
activeAmount: 0,
//
oilOrder: {},
titles: "收款",
oilList: [
"92#", "95#", "98#"
@ -86,6 +118,8 @@
"1号枪", "2号枪", "3号枪"
],
spearIndex: 0,
orderNo: "",
preferentialData: {},
//
keyboardList: [{
value: '1',
@ -155,6 +189,13 @@
}
},
onLoad(e) {
if (e.userId) {
this.userId = e.userId
this.AmountCollected = e.AmountCollected
this.getUser();
}
},
onShow() {
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
@ -174,46 +215,323 @@
headers
},
methods: {
//
getPaymentPreferential() {
if (!this.AmountCollected || !this.userInfo) {
return;
}
this.DiscountAmount = 0;
let type = 0;
if (this.balanceRedece == 0) {
type = 2
} else {
type = 0
}
let map = {
// 0 1
type: type,
//
amount: this.AmountCollected,
//Id
oilId: this.oilName,
//id
storeId: uni.getStorageSync("storeId"),
//
mtUserLevel: this.userInfo.gradeId,
//id
userId: this.userInfo.id,
}
request({
url: "business/marketingActivity/activeExchange/getPaymentActive",
method: 'get',
params: map,
}).then((res) => {
this.preferentialData = res.data
if (res.data.memberFavorableAmount) {
this.DiscountAmount += res.data.memberFavorableAmount
this.oilOrder.levelAmount = res.data.memberFavorableAmount
}
if (res.data.cardFavorableAmount) {
this.DiscountAmount += res.data.cardFavorableAmount
}
if (res.data.activeFavorableAmount) {
this.DiscountAmount += res.data.activeFavorableAmount
this.oilOrder.activeAmount = res.data.activeFavorableAmount
}
this.countAmount()
})
},
//
getUser() {
request({
url: '/business/userManager/user/' + this.userId,
method: 'get',
}).then((res) => {
this.userInfo = res.data
this.balance = res.data.cardBalance
this.getPaymentPreferential()
})
},
//
countAmount() {
if (this.balance >= (this.AmountCollected - this.DiscountAmount - this.oilCardAmount)) {
this.balanceRedece = this.AmountCollected - this.DiscountAmount - this.oilCardAmount
this.paymentAmount = 0
} else {
this.balanceRedece = this.balance
this.paymentAmount = (this.AmountCollected - this.DiscountAmount - this.balance - this.oilCardAmount)
.toFixed(2)
}
},
//
scanQrcode() {
if (!this.AmountCollected) {
uni.showToast({
title: "请先输入收款金额",
icon: "none"
})
return;
}
let _this = this
uni.scanCode({
onlyFromCamera: true,
success: (res) => {
console.log('扫描二维码成功,结果:' + JSON.stringify(res) + res.result);
_this.authCode = res.result
_this.payMent()
},
error: (res) => {
console.log('扫描二维码出现错误')
}
})
},
//
scanAppletQrCode() {
if (!this.AmountCollected) {
uni.showToast({
title: "请先输入收款金额",
icon: "none"
})
return;
}
this.oilOrder.payType = "APPLET_CODE"
this.oilOrder.orderNo = this.orderNo
this.oilOrder.orderAmount = this.AmountCollected
this.oilOrder.payAmount = this.paymentAmount
this.oilOrder.discountAmount = this.DiscountAmount
this.oilOrder.balanceAmount = this.balanceRedece
this.oilOrder.isOilStorageCard = this.isOilStorageCard
this.oilOrder.isUseChildCard = this.isUseChildCard
this.oilOrder.activeId = this.preferentialData.activeId
this.oilOrder.cardFavorableId = this.preferentialData.cardFavorableId
this.oilOrder.recordId = this.preferentialData.recordId
this.oilOrder.type = this.preferentialData.type
this.oilOrder.balanceAmountSale = this.balanceRedece
this.oilOrder.levelAmount = this.levelAmount
this.oilOrder.activeAmount = this.activeAmount
this.oilOrder.oils = this.oilName
this.oilOrder.tankId = this.tankId
this.oilOrder.oilPrice = this.oilPrice
this.oilOrder.oilCardAmount1 = this.oilCardAmount
this.oilOrder.userId = this.userInfo.id
this.oilOrder.oilGunNum = this.oilGunNum
this.oilOrder.payUser = this.userInfo.mobile
let _this = this
uni.scanCode({
onlyFromCamera: true,
success: (res) => {
console.log('扫描二维码成功,结果:' + JSON.stringify(res) + res.result);
_this.authCode = res.result
_this.oilOrder.authCode = _this.authCode
request({
url: '/business/oilOrder/scanAppletQrCodePos',
method: 'post',
data: _this.oilOrder
}).then((resp) => {
if (resp.data.success == 'success') {
_this.reset()
// uni.showToast({
// title: "",
// icon: "success"
// })
uni.navigateTo({
url:"/pagesHome/PaymentResults/PaymentResults"
})
} else {
uni.showToast({
title: resp.data.error,
icon: "none"
})
}
})
},
error: (res) => {
console.log('扫描二维码出现错误')
}
})
},
//
swipeCard(){
uni.showToast({
title:"暂未开发",
icon:"error"
})
},
//
cashPay() {
if (!this.AmountCollected) {
uni.showToast({
title: "请先输入收款金额",
icon: "none"
})
return;
}
this.oilOrder.payType = "CASH"
this.payMent()
},
getOilCardAmount() {
if (!this.userInfo) {
return;
}
request({
url: '/business/marketingActivity/cardFuelRecord/getRecordByUserId',
method: 'get',
params: {
mtUserId: this.userInfo.id
}
}).then((res) => {
res.data.forEach(item => {
if (item.oilType == this.oilName) {
let liters = this.AmountCollected / this.oilPrice
this.oilCardAmount = item.lockupPrice * liters
}
})
})
},
//
payMent() {
this.oilOrder.orderNo = this.orderNo
this.oilOrder.orderAmount = this.AmountCollected
this.oilOrder.payAmount = this.paymentAmount
this.oilOrder.discountAmount = this.DiscountAmount
this.oilOrder.balanceAmount = this.balanceRedece
this.oilOrder.isOilStorageCard = this.isOilStorageCard
this.oilOrder.isUseChildCard = this.isUseChildCard
this.oilOrder.activeId = this.preferentialData.activeId
this.oilOrder.cardFavorableId = this.preferentialData.cardFavorableId
this.oilOrder.recordId = this.preferentialData.recordId
this.oilOrder.type = this.preferentialData.type
this.oilOrder.balanceAmountSale = this.balanceRedece
this.oilOrder.levelAmount = this.levelAmount
this.oilOrder.activeAmount = this.activeAmount
this.oilOrder.authCode = this.authCode
this.oilOrder.oils = this.oilName
this.oilOrder.tankId = this.tankId
this.oilOrder.oilPrice = this.oilPrice
this.oilOrder.oilCardAmount1 = this.oilCardAmount
this.oilOrder.userId = this.userInfo.id
this.oilOrder.oilGunNum = this.oilGunNum
this.oilOrder.payUser = this.userInfo.mobile
request({
url: "business/oilOrder/addOrderPos",
method: 'post',
data: this.oilOrder
}).then((res) => {
this.orderNo = res.data.orderNo
if (res.data.code == 1) {
this.reset()
// uni.showToast({
// title: "",
// icon: "success"
// })
uni.navigateTo({
url:"/pagesHome/PaymentResults/PaymentResults"
})
} else if (res.data.code == 2) {
uni.showToast({
title: "请先配置商户号",
icon: "none"
})
} else {
uni.showToast({
title: "支付失败,请联系管理员",
icon: "none"
})
}
})
},
//
reset() {
this.userId = "";
this.userInfo = "";
this.AmountCollected = "";
this.DiscountAmount = 0;
this.balanceRedece = 0;
this.isOilStorageCard = false;
this.balanceRedece = 0;
this.authCode = "";
this.oilName = "";
this.tankId = "";
this.oilPrice = "";
this.oilCardAmount = 0;
this.paymentAmount = 0;
this.levelAmount = 0;
this.activeAmount = 0;
this.getOilGun()
},
//
getOilGun(){
getOilGun() {
request({
url: 'business/petrolStationManagement/oilGun/queryOilGunList',
method: 'get',
}).then((res) => {
this.spearList = res.data
if (this.spearList.length > 0) {
this.oilGunNum = this.spearList[0].id
this.oilName = this.spearList[0].oilName
this.tankId = this.spearList[0].tankId
this.oilPrice = this.spearList[0].oilPrice
}
})
},
//
gosearchVip() {
uni.navigateTo({
url: '/pagesHome/searchVip/searchVip'
url: '/pagesHome/searchVip/searchVip?AmountCollected=' + this.AmountCollected
})
},
//
KeyboardLogic(data) {
console.log(data);
// console.log(data);
if (data.type == 'num') {
this.AmountCollected = this.AmountCollected + data.value
if (!this.userInfo) this.paymentAmount = this.AmountCollected
this.getPaymentPreferential()
}
if (data.type == 'img') {
if (!data.value) {
console.log('1');
this.AmountCollected = this.AmountCollected.substring(0, this.AmountCollected.length - 1);
}
if (data.value == 'skzf') {
uni.navigateTo({
url: '/pagesHome/CardPayment/CardPayment'
})
// if (data.value == 'skzf') {
// uni.navigateTo({
// url: '/pagesHome/CardPayment/CardPayment'
// })
}
// }
}
},
getoilIndex(num) {
this.oilIndex = num
},
getspearIndex(num) {
getspearIndex(num, data) {
this.spearIndex = num
this.oilGunNum = data.id
this.oils = data.oilName
this.tankId = data.tankId
this.oilPrice = data.oilPrice
this.getPaymentPreferential()
},
goback() {
uni.navigateBack()

View File

@ -0,0 +1,120 @@
<template>
<view class="content">
<view class="container">
<headers :titles="titles"><u-icon name="arrow-left" color="#fff" size="22"></u-icon></headers>
<view class="img-box">
<view class="title_">请扫码支付</view>
<canvas id="qrcode" canvas-id="qrcode" style="width: 200px;height: 200px; margin: 15px auto;"></canvas>
<view class="z-size">
<view class="" @click="setAmount">设置金额</view>
<view class="">保存图片</view>
</view>
</view>
</view>
</view>
</template>
<script>
import headers from '../../components/header/headers.vue'
import UQRCode from '../../uni_modules/Sansnn-uQRCode/js_sdk/uqrcode/uqrcode.js';
export default {
data() {
return {
titles: "刷卡支付",
}
},
onLoad() {
this.onReady()
},
onShow() {
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
},
onPullDownRefresh() {
console.log("刷新");
uni.stopPullDownRefresh()
},
onReachBottom() {
// this.show = true
setTimeout(() => {
console.log("加载执行");
}, 2000)
},
components: {
headers
},
methods: {
//
setAmount() {
uni.navigateTo({
url: "/pagesHome/PaymentCode/SetUpCode"
})
},
onReady() {
// uQRCode
var qr = new UQRCode();
//
qr.data = "https://uqrcode.cn/doc";
// canvas
qr.size = 200;
//
qr.make();
// canvas
var canvasContext = uni.createCanvasContext('qrcode', this); // this
// uQRCodecanvas
qr.canvasContext = canvasContext;
// canvas
qr.drawCanvas();
},
goback() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #0864e9;
// background: linear-gradient(180deg, #B2D2FC 0%, #B2D2FC 14%, rgba(255, 255, 255, 0.84) 24%, rgba(255, 255, 255, 0.84) 100%);
height: 100vh;
}
.container {
width: 100%;
background: #0864e9;
box-sizing: border-box;
padding-top: 88px;
}
.img-box {
width: 95%;
height: 300px;
background: #FFFFFF;
border-radius: 8px;
margin: 15px auto;
box-sizing: border-box;
padding: 15px;
}
.title_ {
width: 100%;
text-align: center;
font-weight: bold;
font-size: 16px;
color: #333333;
margin-bottom: 15px;
}
.z-size {
width: 200px;
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 auto;
}
</style>

View File

@ -0,0 +1,87 @@
<template>
<view class="content">
<view class="container">
<headers :titles="titles"><u-icon name="arrow-left" color="#fff" size="22"></u-icon></headers>
<view class="b-box">
<view class="">金额</view>
<view style="text-align: right;"><input type="text" placeholder="请输入金额" /></view>
</view>
<view class="b-box">
<view class="">备注</view>
<view style="text-align: right;"><input type="text" placeholder="请输入备注" /></view>
</view>
</view>
</view>
</template>
<script>
import headers from '../../components/header/headers.vue'
export default {
data() {
return {
titles: "设置金额",
}
},
onShow() {
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
},
onPullDownRefresh() {
console.log("刷新");
uni.stopPullDownRefresh()
},
onReachBottom() {
// this.show = true
setTimeout(() => {
console.log("加载执行");
}, 2000)
},
components: {
headers
},
methods: {
goback() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #f8f8f8;
// background: linear-gradient(180deg, #B2D2FC 0%, #B2D2FC 14%, rgba(255, 255, 255, 0.84) 24%, rgba(255, 255, 255, 0.84) 100%);
height: 100vh;
}
.container {
width: 100%;
background: #f8f8f8;
box-sizing: border-box;
padding-top: 88px;
}
.img-box {
image {
width: 100%;
height: 100%;
}
}
.b-box {
width: 95%;
margin: 15px auto;
display: flex;
align-items: center;
justify-content: space-between;
font-weight: bold;
font-size: 16px;
color: #333333;
background: #fff;
box-sizing: border-box;
padding: 10px;
}
</style>

View File

@ -2,11 +2,51 @@
<view class="content">
<view class="container">
<headers :titles="titles"><u-icon name="arrow-left" color="#fff" size="22"></u-icon></headers>
<view class="lan-box">
<view class="">收银员:{{ handoverList && handoverList.baseInfo ? handoverList.baseInfo.realName : '未知姓名' }}
</view>
<view class="b-ss">
<view class="">今日累计:{{indexData.totalPayMoney}}</view>
<view class="d-s">
<view class="">交班记录</view>
<u-icon name="arrow-right" color="#fff" size="18"></u-icon>
</view>
</view>
</view>
<view class="box_">
<view class="top-box">
员工交接单
</view>
<view class="h-box">门店:{{handoverList && handoverList.baseInfo ? handoverList.baseInfo.storeName : '-'}}
</view>
<view class="h-box">
上班时间:{{ handoverList && handoverList.baseInfo ? handoverList.baseInfo.startTime : '-' }}</view>
<view class="h-box">
下班时间:{{ handoverList && handoverList.baseInfo ? handoverList.baseInfo.endTime : '-' }}</view>
<view class="">
<view class="h-box">
订单金额:{{ handoverList && handoverList.orderSummary ? handoverList.orderSummary.oilOrder : 0+ handoverList && handoverList.orderSummary ? handoverList.orderSummary.cardOrder : 0 }}
</view>
<view class="h-box">
优惠金额:{{ handoverList && handoverList.orderSummary ? handoverList.orderSummary.oilDiacount : 0 }}
</view>
<view class="h-box">
会员充值:{{ handoverList && handoverList.orderSummary ? handoverList.orderSummary.cardPaid : 0 }}
</view>
<view class="h-box">
退款金额:{{ handoverList && handoverList.orderSummary ? handoverList.orderSummary.oilRefund : 0 + handoverList && handoverList.orderSummary ? handoverList.orderSummary.cardRefund : 0 }}
</view>
<view class="h-box">
实收金额:{{ (Number)(handoverList && handoverList.orderSummary ? handoverList.orderSummary.oilPaid : 0) + (Number)(handoverList && handoverList.orderSummary ? handoverList.orderSummary.cardPaid : 0) }}
</view>
</view>
<view style="width: 100%; height: 78px; "></view>
<view class="bottom-d">
<view class="anniu">
交班
</view>
</view>
</view>
@ -14,18 +54,27 @@
</template>
<script>
import request from "../../utils/request";
import headers from '../../components/header/headers.vue'
export default {
data() {
return {
titles: "交接班",
handoverList: "",
indexData: {
totalPayMoney: '0',
totalCount: '0',
totalRefund: '0',
}
}
},
onShow() {
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
this.handoverByPos()
},
onPullDownRefresh() {
console.log("刷新");
@ -43,6 +92,41 @@
methods: {
goback() {
uni.navigateBack()
},
//
handoverByPos() {
request({
url: 'business/handoverRecord/handoverByPos',
method: 'get',
params: this.form
}).then((res) => {
if (res.code == 200) {
this.handoverList = res.data;
} else {
uni.showToast({
title: res.data,
icon: "none"
})
}
})
},
//
getIndexData() {
request({
url: 'business/allOrderInfo/getIndexData4Pos',
method: 'get',
params: this.form
}).then((res) => {
if (res.code == 200) {
this.indexData = res.data
} else {
uni.showToast({
title: res.data,
icon: "none"
})
}
})
}
}
}
@ -68,4 +152,76 @@
height: 100%;
}
}
.lan-box {
width: 100%;
height: 100px;
background: #0864e9;
box-sizing: border-box;
padding: 15px;
color: #fff;
font-weight: bold;
}
.b-ss {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin: 15px auto;
}
.d-s {
display: flex;
align-items: center;
}
.box_ {
width: 95%;
border-radius: 8px;
box-sizing: border-box;
padding: 15px;
border: 1px solid #0864e9;
margin: 15px auto;
}
.top-box {
width: 100%;
border-bottom: 1px solid #F0F0F0;
box-sizing: border-box;
padding-bottom: 15px;
font-weight: bold;
font-size: 16px;
color: #0864E9;
}
.h-box {
font-weight: 500;
font-size: 14px;
color: #333333;
margin: 15px auto;
}
.bottom-d {
width: 100%;
position: fixed;
bottom: 0px;
left: 0px;
height: 98px;
background: #FFFFFF;
box-shadow: 0px -1px 4px 0px rgba(67, 104, 212, 0.1);
}
.anniu {
width: 265px;
height: 48px;
background: #0864E9;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
border-radius: 50px;
margin: 10px auto;
}
</style>

View File

@ -0,0 +1,133 @@
<template>
<view class="content">
<view class="container">
<headers :titles="titles"><u-icon name="arrow-left" color="#fff" size="22"></u-icon></headers>
<view class="time-bs">
<view class="time-box" @click="show = true">开始日期</view>
<view class="">-</view>
<view class="time-box" @click="show = true">结束日期</view>
</view>
<view class="box_">
<view class="top-title">
<view class="name_">姓名</view>
<view class="price_">400.00</view>
</view>
<view class="time">2024-05-11 07:10-2024-05-13 16:45</view>
</view>
<u-datetime-picker :show="show" v-model="value1" mode="datetime"></u-datetime-picker>
</view>
</view>
</template>
<script>
import headers from '../../components/header/headers.vue'
export default {
data() {
return {
titles: "交班记录",
show: false,
value1: Number(new Date()),
}
},
onShow() {
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
},
onPullDownRefresh() {
console.log("刷新");
uni.stopPullDownRefresh()
},
onReachBottom() {
// this.show = true
setTimeout(() => {
console.log("加载执行");
}, 2000)
},
components: {
headers
},
methods: {
goback() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #f8f8f8;
// background: linear-gradient(180deg, #B2D2FC 0%, #B2D2FC 14%, rgba(255, 255, 255, 0.84) 24%, rgba(255, 255, 255, 0.84) 100%);
height: 100vh;
}
.container {
width: 100%;
background: #f8f8f8;
box-sizing: border-box;
padding-top: 88px;
}
.box_ {
width: 95%;
background: #FFFFFF;
border-radius: 8px;
box-sizing: border-box;
margin: 10px auto;
box-sizing: border-box;
padding: 15px;
}
.top-title {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.name_ {
font-weight: bold;
font-size: 16px;
color: #333333;
}
.price_ {
font-weight: bold;
font-size: 16px;
color: #0864E9;
}
.time {
font-weight: 500;
font-size: 14px;
color: #333333;
margin: 0px auto;
margin-top: 15px;
}
.time-bs {
width: 100%;
box-sizing: border-box;
background: #FFFFFF;
padding: 15px;
display: flex;
align-items: center;
justify-content: space-around;
}
.time-box {
border: 1px solid #0864E9;
box-sizing: border-box;
padding: 5px 15px;
border-radius: 8px;
font-size: 14px;
color: #333;
display: flex;
align-items: center;
justify-content: center;
}
</style>

View File

@ -0,0 +1,111 @@
<template>
<view class="content">
<view class="container">
<headers :titles="titles"><u-icon name="arrow-left" color="#fff" size="22"></u-icon></headers>
<view class="box_">
<view class="title_">日交易汇总-2024/05/13</view>
<view class="size_">收银员:李莎</view>
<view class="size_">实收金额:400.00</view>
<view class="size_">订单金额:100.00</view>
<view class="size_">会员充值:300.00</view>
<view class="bottom_">
<view class="">查看详情</view>
<u-icon name="arrow-right" color="#333" size="18"></u-icon>
</view>
</view>
</view>
</view>
</template>
<script>
import headers from '../../components/header/headers.vue'
export default {
data() {
return {
titles: "消息列表",
}
},
onShow() {
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
},
onPullDownRefresh() {
console.log("刷新");
uni.stopPullDownRefresh()
},
onReachBottom() {
// this.show = true
setTimeout(() => {
console.log("加载执行");
}, 2000)
},
components: {
headers
},
methods: {
goback() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #f8f8f8;
// background: linear-gradient(180deg, #B2D2FC 0%, #B2D2FC 14%, rgba(255, 255, 255, 0.84) 24%, rgba(255, 255, 255, 0.84) 100%);
height: 100vh;
}
.container {
width: 100%;
background: #f8f8f8;
box-sizing: border-box;
padding-top: 88px;
}
.img-box {
image {
width: 100%;
height: 100%;
}
}
.box_ {
width: 95%;
background: #FFFFFF;
border-radius: 8px;
box-sizing: border-box;
margin: 10px auto;
box-sizing: border-box;
padding: 15px;
}
.title_ {
font-weight: bold;
font-size: 16px;
color: #333333;
margin-bottom: 10px;
}
.size_ {
font-weight: 500;
font-size: 14px;
color: #333333;
margin-bottom: 10px;
}
.bottom_ {
border-top: 1px solid #E8E8E8;
width: 100%;
box-sizing: border-box;
padding-top: 10px;
display: flex;
align-items: center;
justify-content: space-between;
}
</style>

View File

@ -9,25 +9,27 @@
</view>
</view>
<view class="box_" v-for="item in 7" :key="index">
<view class="box_" v-for="item,index in orderList" :key="index">
<view class="b-bx">
<view class="title_">京博加油站</view>
<view class="zt-size">待支付</view>
<!-- <view class="title_">京博加油站</view> -->
<view class="zt-size" v-if="item.orderStatus == 'paid'">已支付</view>
<view class="zt-size" v-if="item.orderStatus == 'refund'">已退款</view>
<view class="zt-size" v-if="item.orderStatus == 'unpaid'">未支付</view>
</view>
<view class="centne">
<view class="touxiang"></view>
<view class="right-centne">
<view class="h_">订单号:0000000000</view>
<view class="h_">油号:95#</view>
<view class="h_">升数:50L</view>
<view class="h_">下单时间:2024-05-11 14:50</view>
<view class="h_">订单号:{{item.orderNo}}</view>
<view class="h_">油号:{{item.oilName}}</view>
<view class="h_">升数:{{item.shengshu}}L</view>
<view class="h_">下单时间:{{item.payTime}}</view>
<view class="b-bx">
<view class="">应付:400.00</view>
<view class="">应付:{{item.goodsMoney}}</view>
<view class="">优惠:0.00</view>
</view>
</view>
</view>
<view class="end-box">实付:400.00</view>
<view class="end-box">实付:{{item.payMoney}}</view>
</view>
<view style="width: 100%; height: 20px; "></view>
@ -36,6 +38,7 @@
</template>
<script>
import request from "../../utils/request";
import headers from '../../components/header/headers.vue'
export default {
@ -45,16 +48,23 @@
tabindex: 0,
tablist: [
"全部",
"待支付",
"已完成",
"已取消",
]
"已退款",
"支付失败",
],
orderList: [],
form: {
page: 1,
pageSize: 10,
status: ''
}
}
},
onShow() {
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
this.getPageListByPos();
},
onPullDownRefresh() {
console.log("刷新");
@ -69,13 +79,45 @@
components: {
headers
},
methods: {
getindex(index) {
this.tabindex == index
this.orderList = []
this.tabindex = index
if (index == 0) {
this.form.status = ''
} else if (index == 1) {
this.form.status = 'paid'
} else if (index == 2) {
this.form.status = 'refund'
} else if (index == 3) {
this.form.status = 'unpaid'
}
this.getPageListByPos()
},
goback() {
uni.navigateBack()
}
},
getPageListByPos() {
request({
url: 'business/allOrderInfo/getPageListByPos',
method: 'get',
params: this.form
}).then((res) => {
if (res.code == 200) {
this.orderList = res.data.records;
} else {
uni.showToast({
title: res.data,
icon: "none"
})
}
})
},
}
}
</script>

View File

@ -0,0 +1,41 @@
<template>
<view class="container">
<mumu-get-qrcode @success='qrcodeSucess' @error="qrcodeError"></mumu-get-qrcode> //
</view>
</template>
<script>
import mumuGetQrcode from '@/uni_modules/mumu-getQrcode/components/mumu-getQrcode/mumu-getQrcode.vue' //
export default {
components: {
mumuGetQrcode //
},
data() {
return {
}
},
name: 'Qrcode',
methods: {
qrcodeSucess(data) { //
console.log(data,123)
uni.showModal({
title: '成功',
content: data,
success: () => {
console.log(111)
}
})
},
qrcodeError(err) { //
uni.showModal({
title: '摄像头授权失败',
content: '摄像头授权失败,请检测当前浏览器是否有摄像头权限。',
success: () => {
console.log(222)
uni.navigateBack({}) //
}
})
}
}
};
</script>

View File

@ -5,27 +5,27 @@
<view class="top-box">
<view class="inputbox">
<u-icon name="search" size="20"></u-icon>
<input type="text" />
<input type="text" v-model="paramsQuery.mobile" />
</view>
<u-icon name="scan" color="#fff" size="38"></u-icon>
<u-icon name="search" color="#fff" size="38" @click="getList"></u-icon>
</view>
<view class="box_" v-for="(item,index) in 8" :key="index">
<view class="box_" v-for="(item,index) in list" :key="index" @click="toCollection(item.id)">
<view class="leftbox">
<view class="title_">会员信息</view>
<view class="d-s">
<view class="hui">会员名称:</view>
<view class="hei"> 胡桃</view>
<view class="hei"> {{item.name}}</view>
</view>
<view class="d-s">
<view class="hui">手机号:</view>
<view class="hei"> 153****9968</view>
<view class="hei"> {{item.mobile}}</view>
</view>
<view class="d-s">
<view class="hui">账户余额:</view>
<view class="hei"> 1854.96</view>
<view class="hei"> {{item.cardBalance}}</view>
</view>
</view>
@ -35,33 +35,49 @@
</view>
</view>
<view class="bottom-b"></view>
<view class="p-bottom" @click="govipjs()">
<!-- <view class="p-bottom" @click="govipjs()">
<view class="anniu">
会员支付
</view>
</view>
</view> -->
</view>
</template>
<script>
import request from "../../utils/request";
import headers from '../../components/header/headers.vue'
export default {
data() {
return {
titles: "会员查询",
//
list:[],
total:0,
paramsQuery:{
page:1,
pageSize:30,
},
AmountCollected:"",
}
},
onLoad(e) {
this.AmountCollected = e.AmountCollected
},
onShow() {
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
this.getList()
},
onPullDownRefresh() {
console.log("刷新");
uni.stopPullDownRefresh()
},
onReachBottom() {
if (this.list.length < this.total) {
this.paramsQuery.page++;
this.getList()
}
// this.show = true
setTimeout(() => {
console.log("加载执行");
@ -71,6 +87,26 @@
headers
},
methods: {
toCollection(id){
uni.navigateTo({
url:"/pagesHome/Collection/Collection?userId="+id+"&AmountCollected="+this.AmountCollected
})
},
getList(){
request({
url: '/business/userManager/user/list',
method: 'get',
params: this.paramsQuery
}).then((res) => {
if (this.paramsQuery.page == 1) {
this.list = res.data.records
} else {
this.list = this.list.concat(res.data.records)
}
this.total = res.data.total
})
},
govipjs() {
uni.navigateTo({
url: '/pagesHome/PaymentResults/PaymentResults'

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,392 @@
# 介绍
`uQRCode`是一款基于`Javascript`环境开发的二维码生成插件,适用所有`Javascript`运行环境的前端应用和`Node.js`应用。
`uQRCode`可扩展性高,它支持自定义渲染二维码,可通过`uQRCode API`得到二维码绘制关键信息后,使用`canvas`、`svg`或`js`操作`dom`的方式绘制二维码图案。还可自定义二维码样式,如随机颜色、圆点、方块、块与块之间的间距等。
欢迎加入群聊【uQRCode交流群】[695070434](https://jq.qq.com/?_wv=1027&k=JRjzDqiw)。
# 设计器
uQRCode发布了配套的可视化设计器可根据自己喜好在设计器中设计二维码样式一键生成配置代码复制到项目中详情请在微信小程序搜索“柚子二维码”或扫描下方小程序码体验。
![uQRCode设计器](https://uqrcode.cn/mp_weixin_code.jpg)
## 设计器模板示例
![uQRCode设计器](https://uqrcode.cn/yz_1.png)
![uQRCode设计器](https://uqrcode.cn/yz_2.png)
![uQRCode设计器](https://uqrcode.cn/yz_3.png)
![uQRCode设计器](https://uqrcode.cn/yz_4.png)
![uQRCode设计器](https://uqrcode.cn/yz_5.png)
![uQRCode设计器](https://uqrcode.cn/yz_6.png)
![uQRCode设计器](https://uqrcode.cn/yz_7.png)
![uQRCode设计器](https://uqrcode.cn/yz_8.png)
![uQRCode设计器](https://uqrcode.cn/yz_9.png)
# 快速上手
> 在`uni-app`中,我们更推荐使用组件方式来生成二维码,组件方式大大提高了页面的可读性以及避开了一些平台容易出问题的地方,当组件无法满足需求的时候,再考虑切换成原生方式。
官方文档:[https://uqrcode.cn/doc](https://uqrcode.cn/doc)。
github地址[https://github.com/Sansnn/uQRCode](https://github.com/Sansnn/uQRCode)。
npm地址[https://www.npmjs.com/package/uqrcodejs](https://www.npmjs.com/package/uqrcodejs)。
uni-app插件市场地址[https://ext.dcloud.net.cn/plugin?id=1287](https://ext.dcloud.net.cn/plugin?id=1287)。
## 原生方式
原生方式仅需要获取`uqrcode.js`文件便可使用。详细配置请移步到:文档 > [原生](https://uqrcode.cn/doc/document/native.html)。
### 安装
1. 通过`npm`安装,成功后即可使用`import`或`require`进行引用。
``` bash
# npm安装
npm install uqrcodejs
# 或者
npm install @uqrcode/js
```
2. 通过项目开源地址获取`uqrcode.js`,下载`uqrcode.js`后,将其复制到您项目指定目录,在页面中引入`uqrcode.js`文件即可开始使用。
### 引入
- 通过`import`引入。
``` javascript
// npm安装
import UQRCode from 'uqrcodejs'; // npm install uqrcodejs
// 或者
import UQRCode from '@uqrcode/js'; // npm install @uqrcode/js
```
- `Node.js`通过`require`引入。
``` javascript
// npm安装
const UQRCode = require('uqrcodejs'); // npm install uqrcodejs
// 或者
const UQRCode = require('@uqrcode/js'); // npm install @uqrcode/js
```
- 原生浏览器环境在js脚本加载时添加到`window`。
``` html
<script type="text/javascript" src="uqrcode.js"></script>
<script>
var UQRCode = window.UQRCode;
</script>
```
### 简单用法
`uQRCode`基于`Canvas API`封装了一套方法,建议开发者使用`canvas`生成,一键调用,非常方便。以下是示例:
- HTML示例
- DOM部分
``` html
<canvas id="qrcode" width="200" height="200"></canvas>
```
- JS部分
``` javascript
// 获取uQRCode实例
var qr = new UQRCode();
// 设置二维码内容
qr.data = "https://uqrcode.cn/doc";
// 设置二维码大小必须与canvas设置的宽高一致
qr.size = 200;
// 调用制作二维码方法
qr.make();
// 获取canvas元素
var canvas = document.getElementById("qrcode");
// 获取canvas上下文
var canvasContext = canvas.getContext("2d");
// 设置uQRCode实例的canvas上下文
qr.canvasContext = canvasContext;
// 调用绘制方法将二维码图案绘制到canvas上
qr.drawCanvas();
```
- uni-app示例
- Template部分
``` html
<canvas id="qrcode" canvas-id="qrcode" style="width: 200px;height: 200px;"></canvas>
```
- JS部分
``` javascript
onReady() {
// 获取uQRCode实例
var qr = new UQRCode();
// 设置二维码内容
qr.data = "https://uqrcode.cn/doc";
// 设置二维码大小必须与canvas设置的宽高一致
qr.size = 200;
// 调用制作二维码方法
qr.make();
// 获取canvas上下文
var canvasContext = uni.createCanvasContext('qrcode', this); // 如果是组件this必须传入
// 设置uQRCode实例的canvas上下文
qr.canvasContext = canvasContext;
// 调用绘制方法将二维码图案绘制到canvas上
qr.drawCanvas();
}
```
- 微信小程序推荐使用Canvas 2D关于Canvas 2D的使用请参考微信开放文档。
### 高级用法
考虑到部分平台可能不支持`canvas`,所以`uQRCode`并没有强制要求和`canvas`一起使用,您还可以选择其他方式来生成二维码,例如使用`js`操作`dom`进行绘制或是使用`svg`绘制等。以下是示例:
- uni-app v-for+view
```html
<template>
<view>
<view class="qrcode">
<view v-for="(row, rowI) in modules" :key="rowI" style="display: flex;flex-direction: row;">
<view v-for="(col, colI) in row" :key="colI">
<view v-if="col.isBlack" style="width: 10px;height: 10px;background-color: black;">
<!-- 黑色码点 -->
</view>
<view v-else style="width: 10px;height: 10px;background-color: white;">
<!-- 白色码点 -->
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import UQRCode from '../../uni_modules/Sansnn-uQRCode/js_sdk/uqrcode/uqrcode.js';
export default {
data() {
return {
modules: []
}
},
onLoad() {
const qr = new UQRCode();
qr.data = 'uQRCode';
qr.make();
this.modules = qr.modules;
},
methods: {
}
}
</script>
```
- js操作dom
``` html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>uQRCode二维码生成</title>
</head>
<body>
<div id="qrcode" style="position: relative;"></div>
<script type="text/javascript" src="uqrcode.js"></script>
<script>
// 引入uQRCode
var UQRCode = window.UQRCode;
// 获取uQRCode实例
var qr = new UQRCode();
// 设置二维码内容
qr.data = "https://uqrcode.cn/doc";
// 设置二维码大小必须与canvas设置的宽高一致
qr.size = 200;
// 设置二维码前景图,可以是路径
qr.foregroundImageSrc =
'data:image/png;base64,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';
// 调用制作二维码方法
qr.make();
var drawModules = qr.getDrawModules();
// 遍历drawModules创建dom元素
var qrHtml = '';
for (var i = 0; i < drawModules.length; i++) {
var drawModule = drawModules[i];
switch (drawModule.type) {
case 'tile':
/* 绘制小块 */
qrHtml += `<div style="position: absolute;left: ${drawModule.x}px;top: ${drawModule.y}px;width: ${drawModule.width}px;height: ${drawModule.height}px;background: ${drawModule.color};"></div>`;
break;
case 'image':
/* 绘制图像 */
qrHtml += `<img style="position: absolute;left: ${drawModule.x}px;top: ${drawModule.y}px;width: ${drawModule.width}px;height: ${drawModule.height}px;" src="${drawModule.imageSrc}" />`;
break;
}
}
document.getElementById('qrcode').innerHTML = qrHtml;
</script>
</body>
</html>
```
- svg
``` html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>uQRCode二维码生成</title>
</head>
<body>
<svg id="qrcode" width="200" height="200" xmlns="http://www.w3.org/2000/svg" version="1.1"></svg>
<script type="text/javascript" src="uqrcode.js"></script>
<script>
// 引入uQRCode
var UQRCode = window.UQRCode;
// 获取uQRCode实例
var qr = new UQRCode();
// 设置二维码内容
qr.data = "https://uqrcode.cn/doc";
// 设置二维码大小必须与canvas设置的宽高一致
qr.size = 200;
// 设置二维码前景图,可以是路径
qr.foregroundImageSrc =
'data:image/png;base64,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';
// 调用制作二维码方法
qr.make();
var drawModules = qr.getDrawModules();
// 遍历drawModules创建svg元素
var qrHtml = '';
for (var i = 0; i < drawModules.length; i++) {
var drawModule = drawModules[i];
switch (drawModule.type) {
case 'tile':
/* 绘制小块 */
qrHtml += `<rect x="${drawModule.x}" y="${drawModule.y}" width="${drawModule.width}" height="${drawModule.height}" style="fill: ${drawModule.color};" />`;
break;
case 'image':
/* 绘制图像 */
qrHtml += `<image href="${drawModule.imageSrc}" x="${drawModule.x}" y="${drawModule.y}" width="${drawModule.width}" height="${drawModule.height}" />`;
break;
}
}
document.getElementById('qrcode').innerHTML = qrHtml;
</script>
</body>
</html>
```
> 更多用法大家自行探索咯,期待分享哟~
### 导出临时文件路径
原生方式基于`Canvas`的,请自行参阅各平台`Canvas`的导出方式。以下是部分示例:
- uni-app
```javascript
// 通过uni.createCanvasContext方式创建绘制上下文的对应导出API为uni.canvasToTempFilePath
// 调用完ctx.draw()方法后不能第一时间导出,否则会异常,需要有一定的延时
setTimeout(() => {
uni.canvasToTempFilePath(
{
canvasId: this.canvasId,
fileType: this.fileType,
width: this.canvasWidth,
height: this.canvasHeight,
success: res => {
console.log(res);
},
fail: err => {
console.log(err);
}
},
// this // 组件内使用必传当前实例
);
}, 300);
```
- Canvas2D
```javascript
// 得到base64
console.log(canvas.toDataURL());
// 得到buffer
console.log(canvas.toBuffer());
```
### 保存二维码到本地相册
必须在导出临时文件路径成功后再执行保存。uni-app通用保存方式H5除外
```javascript
uni.saveImageToPhotosAlbum({
filePath: tempFilePath,
success: res => {
console.log(res);
},
fail: err => {
console.log(err);
}
});
```
H5可以通过设置`<a>`标签`href`属性的方式进行保存:
```javascript
const aEle = document.createElement('a');
aEle.download = 'uQRCode'; // 设置下载的文件名,默认是'下载'
aEle.href = tempFilePath;
document.body.appendChild(aEle);
aEle.click();
aEle.remove(); // 下载之后把创建的元素删除
```
经过测试PC端浏览器可以下载部分安卓自带或第三方浏览器可以下载安卓微信浏览器不适用移动端iOS所有浏览器均不适用差异较大还是推荐各位导出文件给图片组件显示然后提示用户通过长按图片进行保存这种方式。
## uni-app组件方式
### 安装
通过uni-app插件市场地址安装[https://ext.dcloud.net.cn/plugin?id=1287](https://ext.dcloud.net.cn/plugin?id=1287)。详细配置请移步到:文档 > [uni-app组件](https://uqrcode.cn/doc/document/uni-app.html)。
### 引入
uni-app默认为easycom模式可直接键入`<uqrcode>`标签。
### 简单用法
安装`uqrcode`组件后,在`template`中键入`<uqrcode/>`。设置`ref`属性可使用组件内部方法,`canvas-id`属性为组件内部的canvas组件标识`value`属性为二维码生成对应内容,`options`为配置选项可配置二维码样式绘制Logo等详见[options](https://uqrcode.cn/doc/document/uni-app.html#options) 。
``` html
<uqrcode ref="uqrcode" canvas-id="qrcode" value="https://uqrcode.cn/doc" :options="{ margin: 10 }"></uqrcode>
```
### 导出临时文件路径
为了保证方法调用成功,请在 [complete](https://uqrcode.cn/doc/document/uni-app.html#complete) 事件返回`success=true`后调用。
```javascript
// uqrcode为组件的ref名称
this.$refs.uqrcode.toTempFilePath({
success: res => {
console.log(res);
}
});
```
### 保存二维码到本地相册
为了保证方法调用成功,请在 [complete](https://uqrcode.cn/doc/document/uni-app.html#complete) 事件返回`success=true`后调用。
```javascript
// uqrcode为组件的ref名称
this.$refs.uqrcode.save({
success: () => {
uni.showToast({
icon: 'success',
title: '保存成功'
});
}
});
```
## 更多使用说明请前往官方文档查看:[https://uqrcode.cn/doc](https://uqrcode.cn/doc)。

View File

@ -0,0 +1,12 @@
## 4.0.62022-12-12
修复`getDrawModules`,第一次获取结果正常,后续获取`tile`模块不存在的问题;
修复安卓type:normal因Canvas API使用了小数或为0的参数导致生成异常的问题安卓非2d Canvas部分API参数不支持携带小数部分API参数必须大于0
## 4.0.12022-11-28
优化组件loading属性的表现
新增组件type选项normal以便于在某些条件编译初始为type=2d时还可以选择使用非2d组件类型
修复组件条件编译在其他编辑器语法提示报错;
修复原生对es5的支持。
## 4.0.02022-11-21
v4版本源代码全面开放开源地址[https://github.com/Sansnn/uQRCode](https://github.com/Sansnn/uQRCode)
升级说明v4为大版本更新虽然已尽可能兼容上一代版本但不可避免的还是存在一些细节差异若更新后出现问题请参考对照[v3 文档](https://uqrcode.cn/doc/v3)[v4 文档](https://uqrcode.cn/doc)进行修改。

View File

@ -0,0 +1 @@
export const cacheImageList = [];

View File

@ -0,0 +1,41 @@
function Queue() {
let waitingQueue = this.waitingQueue = [];
let isRunning = this.isRunning = false; // 记录是否有未完成的任务
function execute(task, resolve, reject) {
task()
.then((data) => {
resolve(data);
})
.catch((e) => {
reject(e);
})
.finally(() => {
// 等待任务队列中如果有任务则触发它否则设置isRunning = false,表示无任务状态
if (waitingQueue.length) {
const next = waitingQueue.shift();
execute(next.task, next.resolve, next.reject);
} else {
isRunning = false;
}
});
}
this.exec = function(task) {
return new Promise((resolve, reject) => {
if (isRunning) {
waitingQueue.push({
task,
resolve,
reject
});
} else {
isRunning = true;
execute(task, resolve, reject);
}
});
}
}
/* 队列实例某些平台一起使用多个组件时需要通过队列逐一绘制否则部分绘制方法异常nvue端的iOS gcanvas尤其明显在不通过队列绘制时会出现图片丢失的情况 */
export const queueDraw = new Queue();
export const queueLoadImage = new Queue();

View File

@ -0,0 +1,3 @@
declare module '*/common/cache' {
export const cacheImageList: Array;
}

View File

@ -0,0 +1,4 @@
declare module '*/common/queue' {
export const queueDraw: any;
export const queueLoadImage: any;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,241 @@
const isWeex = typeof WXEnvironment !== 'undefined';
const isWeexIOS = isWeex && /ios/i.test(WXEnvironment.platform);
const isWeexAndroid = isWeex && !isWeexIOS;
import GLmethod from '../context-webgl/GLmethod';
const GCanvasModule =
(typeof weex !== 'undefined' && weex.requireModule) ? (weex.requireModule('gcanvas')) :
(typeof __weex_require__ !== 'undefined') ? (__weex_require__('@weex-module/gcanvas')) : {};
let isDebugging = false;
let isComboDisabled = false;
const logCommand = (function () {
const methodQuery = [];
Object.keys(GLmethod).forEach(key => {
methodQuery[GLmethod[key]] = key;
})
const queryMethod = (id) => {
return methodQuery[parseInt(id)] || 'NotFoundMethod';
}
const logCommand = (id, cmds) => {
const mId = cmds.split(',')[0];
const mName = queryMethod(mId);
console.log(`=== callNative - componentId:${id}; method: ${mName}; cmds: ${cmds}`);
}
return logCommand;
})();
function joinArray(arr, sep) {
let res = '';
for (let i = 0; i < arr.length; i++) {
if (i !== 0) {
res += sep;
}
res += arr[i];
}
return res;
}
const commandsCache = {}
const GBridge = {
callEnable: (ref, configArray) => {
commandsCache[ref] = [];
return GCanvasModule.enable({
componentId: ref,
config: configArray
});
},
callEnableDebug: () => {
isDebugging = true;
},
callEnableDisableCombo: () => {
isComboDisabled = true;
},
callSetContextType: function (componentId, context_type) {
GCanvasModule.setContextType(context_type, componentId);
},
callReset: function(id){
GCanvasModule.resetComponent && canvasModule.resetComponent(componentId);
},
render: isWeexIOS ? function (componentId) {
return GCanvasModule.extendCallNative({
contextId: componentId,
type: 0x60000001
});
} : function (componentId) {
return callGCanvasLinkNative(componentId, 0x60000001, 'render');
},
render2d: isWeexIOS ? function (componentId, commands, callback) {
if (isDebugging) {
console.log('>>> >>> render2d ===');
console.log('>>> commands: ' + commands);
}
GCanvasModule.render([commands, callback?true:false], componentId, callback);
} : function (componentId, commands,callback) {
if (isDebugging) {
console.log('>>> >>> render2d ===');
console.log('>>> commands: ' + commands);
}
callGCanvasLinkNative(componentId, 0x20000001, commands);
if(callback){
callback();
}
},
callExtendCallNative: isWeexIOS ? function (componentId, cmdArgs) {
throw 'should not be here anymore ' + cmdArgs;
} : function (componentId, cmdArgs) {
throw 'should not be here anymore ' + cmdArgs;
},
flushNative: isWeexIOS ? function (componentId) {
const cmdArgs = joinArray(commandsCache[componentId], ';');
commandsCache[componentId] = [];
if (isDebugging) {
console.log('>>> >>> flush native ===');
console.log('>>> commands: ' + cmdArgs);
}
const result = GCanvasModule.extendCallNative({
"contextId": componentId,
"type": 0x60000000,
"args": cmdArgs
});
const res = result && result.result;
if (isDebugging) {
console.log('>>> result: ' + res);
}
return res;
} : function (componentId) {
const cmdArgs = joinArray(commandsCache[componentId], ';');
commandsCache[componentId] = [];
if (isDebugging) {
console.log('>>> >>> flush native ===');
console.log('>>> commands: ' + cmdArgs);
}
const result = callGCanvasLinkNative(componentId, 0x60000000, cmdArgs);
if (isDebugging) {
console.log('>>> result: ' + result);
}
return result;
},
callNative: function (componentId, cmdArgs, cache) {
if (isDebugging) {
logCommand(componentId, cmdArgs);
}
commandsCache[componentId].push(cmdArgs);
if (!cache || isComboDisabled) {
return GBridge.flushNative(componentId);
} else {
return undefined;
}
},
texImage2D(componentId, ...args) {
if (isWeexIOS) {
if (args.length === 6) {
const [target, level, internalformat, format, type, image] = args;
GBridge.callNative(
componentId,
GLmethod.texImage2D + ',' + 6 + ',' + target + ',' + level + ',' + internalformat + ',' + format + ',' + type + ',' + image.src
)
} else if (args.length === 9) {
const [target, level, internalformat, width, height, border, format, type, image] = args;
GBridge.callNative(
componentId,
GLmethod.texImage2D + ',' + 9 + ',' + target + ',' + level + ',' + internalformat + ',' + width + ',' + height + ',' + border + ',' +
+ format + ',' + type + ',' + (image ? image.src : 0)
)
}
} else if (isWeexAndroid) {
if (args.length === 6) {
const [target, level, internalformat, format, type, image] = args;
GCanvasModule.texImage2D(componentId, target, level, internalformat, format, type, image.src);
} else if (args.length === 9) {
const [target, level, internalformat, width, height, border, format, type, image] = args;
GCanvasModule.texImage2D(componentId, target, level, internalformat, width, height, border, format, type, (image ? image.src : 0));
}
}
},
texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image) {
if (isWeexIOS) {
if (arguments.length === 8) {
GBridge.callNative(
componentId,
GLmethod.texSubImage2D + ',' + 6 + ',' + target + ',' + level + ',' + xoffset + ',' + yoffset, + ',' + format + ',' + type + ',' + image.src
)
}
} else if (isWeexAndroid) {
GCanvasModule.texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image.src);
}
},
bindImageTexture(componentId, src, imageId) {
GCanvasModule.bindImageTexture([src, imageId], componentId);
},
perloadImage([url, id], callback) {
GCanvasModule.preLoadImage([url, id], function (image) {
image.url = url;
image.id = id;
callback(image);
});
},
measureText(text, fontStyle, componentId) {
return GCanvasModule.measureText([text, fontStyle], componentId);
},
getImageData (componentId, x, y, w, h, callback) {
GCanvasModule.getImageData([x, y,w,h],componentId,callback);
},
putImageData (componentId, data, x, y, w, h, callback) {
GCanvasModule.putImageData([x, y,w,h,data],componentId,callback);
},
toTempFilePath(componentId, x, y, width, height, destWidth, destHeight, fileType, quality, callback){
GCanvasModule.toTempFilePath([x, y, width,height, destWidth, destHeight, fileType, quality], componentId, callback);
}
}
export default GBridge;

View File

@ -0,0 +1,18 @@
class FillStyleLinearGradient {
constructor(x0, y0, x1, y1) {
this._start_pos = { _x: x0, _y: y0 };
this._end_pos = { _x: x1, _y: y1 };
this._stop_count = 0;
this._stops = [0, 0, 0, 0, 0];
}
addColorStop = function (pos, color) {
if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) {
this._stops[this._stop_count] = { _pos: pos, _color: color };
this._stop_count++;
}
}
}
export default FillStyleLinearGradient;

View File

@ -0,0 +1,8 @@
class FillStylePattern {
constructor(img, pattern) {
this._style = pattern;
this._img = img;
}
}
export default FillStylePattern;

View File

@ -0,0 +1,17 @@
class FillStyleRadialGradient {
constructor(x0, y0, r0, x1, y1, r1) {
this._start_pos = { _x: x0, _y: y0, _r: r0 };
this._end_pos = { _x: x1, _y: y1, _r: r1 };
this._stop_count = 0;
this._stops = [0, 0, 0, 0, 0];
}
addColorStop(pos, color) {
if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) {
this._stops[this._stop_count] = { _pos: pos, _color: color };
this._stop_count++;
}
}
}
export default FillStyleRadialGradient;

View File

@ -0,0 +1,666 @@
import FillStylePattern from './FillStylePattern';
import FillStyleLinearGradient from './FillStyleLinearGradient';
import FillStyleRadialGradient from './FillStyleRadialGradient';
import GImage from '../env/image.js';
import {
ArrayBufferToBase64,
Base64ToUint8ClampedArray
} from '../env/tool.js';
export default class CanvasRenderingContext2D {
_drawCommands = '';
_globalAlpha = 1.0;
_fillStyle = 'rgb(0,0,0)';
_strokeStyle = 'rgb(0,0,0)';
_lineWidth = 1;
_lineCap = 'butt';
_lineJoin = 'miter';
_miterLimit = 10;
_globalCompositeOperation = 'source-over';
_textAlign = 'start';
_textBaseline = 'alphabetic';
_font = '10px sans-serif';
_savedGlobalAlpha = [];
timer = null;
componentId = null;
_notCommitDrawImageCache = [];
_needRedrawImageCache = [];
_redrawCommands = '';
_autoSaveContext = true;
// _imageMap = new GHashMap();
// _textureMap = new GHashMap();
constructor() {
this.className = 'CanvasRenderingContext2D';
//this.save()
}
setFillStyle(value) {
this.fillStyle = value;
}
set fillStyle(value) {
this._fillStyle = value;
if (typeof(value) == 'string') {
this._drawCommands = this._drawCommands.concat("F" + value + ";");
} else if (value instanceof FillStylePattern) {
const image = value._img;
if (!image.complete) {
image.onload = () => {
var index = this._needRedrawImageCache.indexOf(image);
if (index > -1) {
this._needRedrawImageCache.splice(index, 1);
CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
this._redrawflush(true);
}
}
this._notCommitDrawImageCache.push(image);
} else {
CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
}
//CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
this._drawCommands = this._drawCommands.concat("G" + image._id + "," + value._style + ";");
} else if (value instanceof FillStyleLinearGradient) {
var command = "D" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," +
value._end_pos._x.toFixed(2) + "," + value._end_pos._y.toFixed(2) + "," +
value._stop_count;
for (var i = 0; i < value._stop_count; ++i) {
command += ("," + value._stops[i]._pos + "," + value._stops[i]._color);
}
this._drawCommands = this._drawCommands.concat(command + ";");
} else if (value instanceof FillStyleRadialGradient) {
var command = "H" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," + value._start_pos._r
.toFixed(2) + "," +
value._end_pos._x.toFixed(2) + "," + value._end_pos._y.toFixed(2) + "," + value._end_pos._r.toFixed(2) + "," +
value._stop_count;
for (var i = 0; i < value._stop_count; ++i) {
command += ("," + value._stops[i]._pos + "," + value._stops[i]._color);
}
this._drawCommands = this._drawCommands.concat(command + ";");
}
}
get fillStyle() {
return this._fillStyle;
}
get globalAlpha() {
return this._globalAlpha;
}
setGlobalAlpha(value) {
this.globalAlpha = value;
}
set globalAlpha(value) {
this._globalAlpha = value;
this._drawCommands = this._drawCommands.concat("a" + value.toFixed(2) + ";");
}
get strokeStyle() {
return this._strokeStyle;
}
setStrokeStyle(value) {
this.strokeStyle = value;
}
set strokeStyle(value) {
this._strokeStyle = value;
if (typeof(value) == 'string') {
this._drawCommands = this._drawCommands.concat("S" + value + ";");
} else if (value instanceof FillStylePattern) {
CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
this._drawCommands = this._drawCommands.concat("G" + image._id + "," + value._style + ";");
} else if (value instanceof FillStyleLinearGradient) {
var command = "D" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," +
value._end_pos._x.toFixed(2) + "," + value._end_pos._y.toFixed(2) + "," +
value._stop_count;
for (var i = 0; i < value._stop_count; ++i) {
command += ("," + value._stops[i]._pos + "," + value._stops[i]._color);
}
this._drawCommands = this._drawCommands.concat(command + ";");
} else if (value instanceof FillStyleRadialGradient) {
var command = "H" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," + value._start_pos._r
.toFixed(2) + "," +
value._end_pos._x.toFixed(2) + "," + value._end_pos._y + ",".toFixed(2) + value._end_pos._r.toFixed(2) + "," +
value._stop_count;
for (var i = 0; i < value._stop_count; ++i) {
command += ("," + value._stops[i]._pos + "," + value._stops[i]._color);
}
this._drawCommands = this._drawCommands.concat(command + ";");
}
}
get lineWidth() {
return this._lineWidth;
}
setLineWidth(value) {
this.lineWidth = value;
}
set lineWidth(value) {
this._lineWidth = value;
this._drawCommands = this._drawCommands.concat("W" + value + ";");
}
get lineCap() {
return this._lineCap;
}
setLineCap(value) {
this.lineCap = value;
}
set lineCap(value) {
this._lineCap = value;
this._drawCommands = this._drawCommands.concat("C" + value + ";");
}
get lineJoin() {
return this._lineJoin;
}
setLineJoin(value) {
this.lineJoin = value
}
set lineJoin(value) {
this._lineJoin = value;
this._drawCommands = this._drawCommands.concat("J" + value + ";");
}
get miterLimit() {
return this._miterLimit;
}
setMiterLimit(value) {
this.miterLimit = value
}
set miterLimit(value) {
this._miterLimit = value;
this._drawCommands = this._drawCommands.concat("M" + value + ";");
}
get globalCompositeOperation() {
return this._globalCompositeOperation;
}
set globalCompositeOperation(value) {
this._globalCompositeOperation = value;
let mode = 0;
switch (value) {
case "source-over":
mode = 0;
break;
case "source-atop":
mode = 5;
break;
case "source-in":
mode = 0;
break;
case "source-out":
mode = 2;
break;
case "destination-over":
mode = 4;
break;
case "destination-atop":
mode = 4;
break;
case "destination-in":
mode = 4;
break;
case "destination-out":
mode = 3;
break;
case "lighter":
mode = 1;
break;
case "copy":
mode = 2;
break;
case "xor":
mode = 6;
break;
default:
mode = 0;
}
this._drawCommands = this._drawCommands.concat("B" + mode + ";");
}
get textAlign() {
return this._textAlign;
}
setTextAlign(value) {
this.textAlign = value
}
set textAlign(value) {
this._textAlign = value;
let Align = 0;
switch (value) {
case "start":
Align = 0;
break;
case "end":
Align = 1;
break;
case "left":
Align = 2;
break;
case "center":
Align = 3;
break;
case "right":
Align = 4;
break;
default:
Align = 0;
}
this._drawCommands = this._drawCommands.concat("A" + Align + ";");
}
get textBaseline() {
return this._textBaseline;
}
setTextBaseline(value) {
this.textBaseline = value
}
set textBaseline(value) {
this._textBaseline = value;
let baseline = 0;
switch (value) {
case "alphabetic":
baseline = 0;
break;
case "middle":
baseline = 1;
break;
case "top":
baseline = 2;
break;
case "hanging":
baseline = 3;
break;
case "bottom":
baseline = 4;
break;
case "ideographic":
baseline = 5;
break;
default:
baseline = 0;
break;
}
this._drawCommands = this._drawCommands.concat("E" + baseline + ";");
}
get font() {
return this._font;
}
setFontSize(size) {
var str = this._font;
var strs = str.trim().split(/\s+/);
for (var i = 0; i < strs.length; i++) {
var values = ["normal", "italic", "oblique", "normal", "small-caps", "normal", "bold",
"bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900",
"normal", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed",
"semi-expanded", "expanded", "extra-expanded", "ultra-expanded"
];
if (-1 == values.indexOf(strs[i].trim())) {
if (typeof size === 'string') {
strs[i] = size;
} else if (typeof size === 'number') {
strs[i] = String(size) + 'px';
}
break;
}
}
this.font = strs.join(" ");
}
set font(value) {
this._font = value;
this._drawCommands = this._drawCommands.concat("j" + value + ";");
}
setTransform(a, b, c, d, tx, ty) {
this._drawCommands = this._drawCommands.concat("t" +
(a === 1 ? "1" : a.toFixed(2)) + "," +
(b === 0 ? "0" : b.toFixed(2)) + "," +
(c === 0 ? "0" : c.toFixed(2)) + "," +
(d === 1 ? "1" : d.toFixed(2)) + "," + tx.toFixed(2) + "," + ty.toFixed(2) + ";");
}
transform(a, b, c, d, tx, ty) {
this._drawCommands = this._drawCommands.concat("f" +
(a === 1 ? "1" : a.toFixed(2)) + "," +
(b === 0 ? "0" : b.toFixed(2)) + "," +
(c === 0 ? "0" : c.toFixed(2)) + "," +
(d === 1 ? "1" : d.toFixed(2)) + "," + tx + "," + ty + ";");
}
resetTransform() {
this._drawCommands = this._drawCommands.concat("m;");
}
scale(a, d) {
this._drawCommands = this._drawCommands.concat("k" + a.toFixed(2) + "," +
d.toFixed(2) + ";");
}
rotate(angle) {
this._drawCommands = this._drawCommands
.concat("r" + angle.toFixed(6) + ";");
}
translate(tx, ty) {
this._drawCommands = this._drawCommands.concat("l" + tx.toFixed(2) + "," + ty.toFixed(2) + ";");
}
save() {
this._savedGlobalAlpha.push(this._globalAlpha);
this._drawCommands = this._drawCommands.concat("v;");
}
restore() {
this._drawCommands = this._drawCommands.concat("e;");
this._globalAlpha = this._savedGlobalAlpha.pop();
}
createPattern(img, pattern) {
if (typeof img === 'string') {
var imgObj = new GImage();
imgObj.src = img;
img = imgObj;
}
return new FillStylePattern(img, pattern);
}
createLinearGradient(x0, y0, x1, y1) {
return new FillStyleLinearGradient(x0, y0, x1, y1);
}
createRadialGradient = function(x0, y0, r0, x1, y1, r1) {
return new FillStyleRadialGradient(x0, y0, r0, x1, y1, r1);
};
createCircularGradient = function(x0, y0, r0) {
return new FillStyleRadialGradient(x0, y0, 0, x0, y0, r0);
};
strokeRect(x, y, w, h) {
this._drawCommands = this._drawCommands.concat("s" + x + "," + y + "," + w + "," + h + ";");
}
clearRect(x, y, w, h) {
this._drawCommands = this._drawCommands.concat("c" + x + "," + y + "," + w +
"," + h + ";");
}
clip() {
this._drawCommands = this._drawCommands.concat("p;");
}
resetClip() {
this._drawCommands = this._drawCommands.concat("q;");
}
closePath() {
this._drawCommands = this._drawCommands.concat("o;");
}
moveTo(x, y) {
this._drawCommands = this._drawCommands.concat("g" + x.toFixed(2) + "," + y.toFixed(2) + ";");
}
lineTo(x, y) {
this._drawCommands = this._drawCommands.concat("i" + x.toFixed(2) + "," + y.toFixed(2) + ";");
}
quadraticCurveTo = function(cpx, cpy, x, y) {
this._drawCommands = this._drawCommands.concat("u" + cpx + "," + cpy + "," + x + "," + y + ";");
}
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y, ) {
this._drawCommands = this._drawCommands.concat(
"z" + cp1x.toFixed(2) + "," + cp1y.toFixed(2) + "," + cp2x.toFixed(2) + "," + cp2y.toFixed(2) + "," +
x.toFixed(2) + "," + y.toFixed(2) + ";");
}
arcTo(x1, y1, x2, y2, radius) {
this._drawCommands = this._drawCommands.concat("h" + x1 + "," + y1 + "," + x2 + "," + y2 + "," + radius + ";");
}
beginPath() {
this._drawCommands = this._drawCommands.concat("b;");
}
fillRect(x, y, w, h) {
this._drawCommands = this._drawCommands.concat("n" + x + "," + y + "," + w +
"," + h + ";");
}
rect(x, y, w, h) {
this._drawCommands = this._drawCommands.concat("w" + x + "," + y + "," + w + "," + h + ";");
}
fill() {
this._drawCommands = this._drawCommands.concat("L;");
}
stroke(path) {
this._drawCommands = this._drawCommands.concat("x;");
}
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
let ianticlockwise = 0;
if (anticlockwise) {
ianticlockwise = 1;
}
this._drawCommands = this._drawCommands.concat(
"y" + x.toFixed(2) + "," + y.toFixed(2) + "," +
radius.toFixed(2) + "," + startAngle + "," + endAngle + "," + ianticlockwise +
";"
);
}
fillText(text, x, y) {
let tmptext = text.replace(/!/g, "!!");
tmptext = tmptext.replace(/,/g, "!,");
tmptext = tmptext.replace(/;/g, "!;");
this._drawCommands = this._drawCommands.concat("T" + tmptext + "," + x + "," + y + ",0.0;");
}
strokeText = function(text, x, y) {
let tmptext = text.replace(/!/g, "!!");
tmptext = tmptext.replace(/,/g, "!,");
tmptext = tmptext.replace(/;/g, "!;");
this._drawCommands = this._drawCommands.concat("U" + tmptext + "," + x + "," + y + ",0.0;");
}
measureText(text) {
return CanvasRenderingContext2D.GBridge.measureText(text, this.font, this.componentId);
}
isPointInPath = function(x, y) {
throw new Error('GCanvas not supported yet');
}
drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
if (typeof image === 'string') {
var imgObj = new GImage();
imgObj.src = image;
image = imgObj;
}
if (image instanceof GImage) {
if (!image.complete) {
imgObj.onload = () => {
var index = this._needRedrawImageCache.indexOf(image);
if (index > -1) {
this._needRedrawImageCache.splice(index, 1);
CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
this._redrawflush(true);
}
}
this._notCommitDrawImageCache.push(image);
} else {
CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id);
}
var srcArgs = [image, sx, sy, sw, sh, dx, dy, dw, dh];
var args = [];
for (var arg in srcArgs) {
if (typeof(srcArgs[arg]) != 'undefined') {
args.push(srcArgs[arg]);
}
}
this.__drawImage.apply(this, args);
//this.__drawImage(image,sx, sy, sw, sh, dx, dy, dw, dh);
}
}
__drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
const numArgs = arguments.length;
function drawImageCommands() {
if (numArgs === 3) {
const x = parseFloat(sx) || 0.0;
const y = parseFloat(sy) || 0.0;
return ("d" + image._id + ",0,0," +
image.width + "," + image.height + "," +
x + "," + y + "," + image.width + "," + image.height + ";");
} else if (numArgs === 5) {
const x = parseFloat(sx) || 0.0;
const y = parseFloat(sy) || 0.0;
const width = parseInt(sw) || image.width;
const height = parseInt(sh) || image.height;
return ("d" + image._id + ",0,0," +
image.width + "," + image.height + "," +
x + "," + y + "," + width + "," + height + ";");
} else if (numArgs === 9) {
sx = parseFloat(sx) || 0.0;
sy = parseFloat(sy) || 0.0;
sw = parseInt(sw) || image.width;
sh = parseInt(sh) || image.height;
dx = parseFloat(dx) || 0.0;
dy = parseFloat(dy) || 0.0;
dw = parseInt(dw) || image.width;
dh = parseInt(dh) || image.height;
return ("d" + image._id + "," +
sx + "," + sy + "," + sw + "," + sh + "," +
dx + "," + dy + "," + dw + "," + dh + ";");
}
}
this._drawCommands += drawImageCommands();
}
_flush(reserve, callback) {
const commands = this._drawCommands;
this._drawCommands = '';
CanvasRenderingContext2D.GBridge.render2d(this.componentId, commands, callback);
this._needRender = false;
}
_redrawflush(reserve, callback) {
const commands = this._redrawCommands;
CanvasRenderingContext2D.GBridge.render2d(this.componentId, commands, callback);
if (this._needRedrawImageCache.length == 0) {
this._redrawCommands = '';
}
}
draw(reserve, callback) {
if (!reserve) {
this._globalAlpha = this._savedGlobalAlpha.pop();
this._savedGlobalAlpha.push(this._globalAlpha);
this._redrawCommands = this._drawCommands;
this._needRedrawImageCache = this._notCommitDrawImageCache;
if (this._autoSaveContext) {
this._drawCommands = ("v;" + this._drawCommands);
this._autoSaveContext = false;
} else {
this._drawCommands = ("e;X;v;" + this._drawCommands);
}
} else {
this._needRedrawImageCache = this._needRedrawImageCache.concat(this._notCommitDrawImageCache);
this._redrawCommands += this._drawCommands;
if (this._autoSaveContext) {
this._drawCommands = ("v;" + this._drawCommands);
this._autoSaveContext = false;
}
}
this._notCommitDrawImageCache = [];
if (this._flush) {
this._flush(reserve, callback);
}
}
getImageData(x, y, w, h, callback) {
CanvasRenderingContext2D.GBridge.getImageData(this.componentId, x, y, w, h, function(res) {
res.data = Base64ToUint8ClampedArray(res.data);
if (typeof(callback) == 'function') {
callback(res);
}
});
}
putImageData(data, x, y, w, h, callback) {
if (data instanceof Uint8ClampedArray) {
data = ArrayBufferToBase64(data);
CanvasRenderingContext2D.GBridge.putImageData(this.componentId, data, x, y, w, h, function(res) {
if (typeof(callback) == 'function') {
callback(res);
}
});
}
}
toTempFilePath(x, y, width, height, destWidth, destHeight, fileType, quality, callback) {
CanvasRenderingContext2D.GBridge.toTempFilePath(this.componentId, x, y, width, height, destWidth, destHeight,
fileType, quality,
function(res) {
if (typeof(callback) == 'function') {
callback(res);
}
});
}
}

View File

@ -0,0 +1,11 @@
export default class WebGLActiveInfo {
className = 'WebGLActiveInfo';
constructor({
type, name, size
}) {
this.type = type;
this.name = name;
this.size = size;
}
}

View File

@ -0,0 +1,21 @@
import {getTransferedObjectUUID} from './classUtils';
const name = 'WebGLBuffer';
function uuid(id) {
return getTransferedObjectUUID(name, id);
}
export default class WebGLBuffer {
className = name;
constructor(id) {
this.id = id;
}
static uuid = uuid;
uuid() {
return uuid(this.id);
}
}

View File

@ -0,0 +1,21 @@
import {getTransferedObjectUUID} from './classUtils';
const name = 'WebGLFrameBuffer';
function uuid(id) {
return getTransferedObjectUUID(name, id);
}
export default class WebGLFramebuffer {
className = name;
constructor(id) {
this.id = id;
}
static uuid = uuid;
uuid() {
return uuid(this.id);
}
}

View File

@ -0,0 +1,298 @@
export default {
"DEPTH_BUFFER_BIT": 256,
"STENCIL_BUFFER_BIT": 1024,
"COLOR_BUFFER_BIT": 16384,
"POINTS": 0,
"LINES": 1,
"LINE_LOOP": 2,
"LINE_STRIP": 3,
"TRIANGLES": 4,
"TRIANGLE_STRIP": 5,
"TRIANGLE_FAN": 6,
"ZERO": 0,
"ONE": 1,
"SRC_COLOR": 768,
"ONE_MINUS_SRC_COLOR": 769,
"SRC_ALPHA": 770,
"ONE_MINUS_SRC_ALPHA": 771,
"DST_ALPHA": 772,
"ONE_MINUS_DST_ALPHA": 773,
"DST_COLOR": 774,
"ONE_MINUS_DST_COLOR": 775,
"SRC_ALPHA_SATURATE": 776,
"FUNC_ADD": 32774,
"BLEND_EQUATION": 32777,
"BLEND_EQUATION_RGB": 32777,
"BLEND_EQUATION_ALPHA": 34877,
"FUNC_SUBTRACT": 32778,
"FUNC_REVERSE_SUBTRACT": 32779,
"BLEND_DST_RGB": 32968,
"BLEND_SRC_RGB": 32969,
"BLEND_DST_ALPHA": 32970,
"BLEND_SRC_ALPHA": 32971,
"CONSTANT_COLOR": 32769,
"ONE_MINUS_CONSTANT_COLOR": 32770,
"CONSTANT_ALPHA": 32771,
"ONE_MINUS_CONSTANT_ALPHA": 32772,
"BLEND_COLOR": 32773,
"ARRAY_BUFFER": 34962,
"ELEMENT_ARRAY_BUFFER": 34963,
"ARRAY_BUFFER_BINDING": 34964,
"ELEMENT_ARRAY_BUFFER_BINDING": 34965,
"STREAM_DRAW": 35040,
"STATIC_DRAW": 35044,
"DYNAMIC_DRAW": 35048,
"BUFFER_SIZE": 34660,
"BUFFER_USAGE": 34661,
"CURRENT_VERTEX_ATTRIB": 34342,
"FRONT": 1028,
"BACK": 1029,
"FRONT_AND_BACK": 1032,
"TEXTURE_2D": 3553,
"CULL_FACE": 2884,
"BLEND": 3042,
"DITHER": 3024,
"STENCIL_TEST": 2960,
"DEPTH_TEST": 2929,
"SCISSOR_TEST": 3089,
"POLYGON_OFFSET_FILL": 32823,
"SAMPLE_ALPHA_TO_COVERAGE": 32926,
"SAMPLE_COVERAGE": 32928,
"NO_ERROR": 0,
"INVALID_ENUM": 1280,
"INVALID_VALUE": 1281,
"INVALID_OPERATION": 1282,
"OUT_OF_MEMORY": 1285,
"CW": 2304,
"CCW": 2305,
"LINE_WIDTH": 2849,
"ALIASED_POINT_SIZE_RANGE": 33901,
"ALIASED_LINE_WIDTH_RANGE": 33902,
"CULL_FACE_MODE": 2885,
"FRONT_FACE": 2886,
"DEPTH_RANGE": 2928,
"DEPTH_WRITEMASK": 2930,
"DEPTH_CLEAR_VALUE": 2931,
"DEPTH_FUNC": 2932,
"STENCIL_CLEAR_VALUE": 2961,
"STENCIL_FUNC": 2962,
"STENCIL_FAIL": 2964,
"STENCIL_PASS_DEPTH_FAIL": 2965,
"STENCIL_PASS_DEPTH_PASS": 2966,
"STENCIL_REF": 2967,
"STENCIL_VALUE_MASK": 2963,
"STENCIL_WRITEMASK": 2968,
"STENCIL_BACK_FUNC": 34816,
"STENCIL_BACK_FAIL": 34817,
"STENCIL_BACK_PASS_DEPTH_FAIL": 34818,
"STENCIL_BACK_PASS_DEPTH_PASS": 34819,
"STENCIL_BACK_REF": 36003,
"STENCIL_BACK_VALUE_MASK": 36004,
"STENCIL_BACK_WRITEMASK": 36005,
"VIEWPORT": 2978,
"SCISSOR_BOX": 3088,
"COLOR_CLEAR_VALUE": 3106,
"COLOR_WRITEMASK": 3107,
"UNPACK_ALIGNMENT": 3317,
"PACK_ALIGNMENT": 3333,
"MAX_TEXTURE_SIZE": 3379,
"MAX_VIEWPORT_DIMS": 3386,
"SUBPIXEL_BITS": 3408,
"RED_BITS": 3410,
"GREEN_BITS": 3411,
"BLUE_BITS": 3412,
"ALPHA_BITS": 3413,
"DEPTH_BITS": 3414,
"STENCIL_BITS": 3415,
"POLYGON_OFFSET_UNITS": 10752,
"POLYGON_OFFSET_FACTOR": 32824,
"TEXTURE_BINDING_2D": 32873,
"SAMPLE_BUFFERS": 32936,
"SAMPLES": 32937,
"SAMPLE_COVERAGE_VALUE": 32938,
"SAMPLE_COVERAGE_INVERT": 32939,
"COMPRESSED_TEXTURE_FORMATS": 34467,
"DONT_CARE": 4352,
"FASTEST": 4353,
"NICEST": 4354,
"GENERATE_MIPMAP_HINT": 33170,
"BYTE": 5120,
"UNSIGNED_BYTE": 5121,
"SHORT": 5122,
"UNSIGNED_SHORT": 5123,
"INT": 5124,
"UNSIGNED_INT": 5125,
"FLOAT": 5126,
"DEPTH_COMPONENT": 6402,
"ALPHA": 6406,
"RGB": 6407,
"RGBA": 6408,
"LUMINANCE": 6409,
"LUMINANCE_ALPHA": 6410,
"UNSIGNED_SHORT_4_4_4_4": 32819,
"UNSIGNED_SHORT_5_5_5_1": 32820,
"UNSIGNED_SHORT_5_6_5": 33635,
"FRAGMENT_SHADER": 35632,
"VERTEX_SHADER": 35633,
"MAX_VERTEX_ATTRIBS": 34921,
"MAX_VERTEX_UNIFORM_VECTORS": 36347,
"MAX_VARYING_VECTORS": 36348,
"MAX_COMBINED_TEXTURE_IMAGE_UNITS": 35661,
"MAX_VERTEX_TEXTURE_IMAGE_UNITS": 35660,
"MAX_TEXTURE_IMAGE_UNITS": 34930,
"MAX_FRAGMENT_UNIFORM_VECTORS": 36349,
"SHADER_TYPE": 35663,
"DELETE_STATUS": 35712,
"LINK_STATUS": 35714,
"VALIDATE_STATUS": 35715,
"ATTACHED_SHADERS": 35717,
"ACTIVE_UNIFORMS": 35718,
"ACTIVE_ATTRIBUTES": 35721,
"SHADING_LANGUAGE_VERSION": 35724,
"CURRENT_PROGRAM": 35725,
"NEVER": 512,
"LESS": 513,
"EQUAL": 514,
"LEQUAL": 515,
"GREATER": 516,
"NOTEQUAL": 517,
"GEQUAL": 518,
"ALWAYS": 519,
"KEEP": 7680,
"REPLACE": 7681,
"INCR": 7682,
"DECR": 7683,
"INVERT": 5386,
"INCR_WRAP": 34055,
"DECR_WRAP": 34056,
"VENDOR": 7936,
"RENDERER": 7937,
"VERSION": 7938,
"NEAREST": 9728,
"LINEAR": 9729,
"NEAREST_MIPMAP_NEAREST": 9984,
"LINEAR_MIPMAP_NEAREST": 9985,
"NEAREST_MIPMAP_LINEAR": 9986,
"LINEAR_MIPMAP_LINEAR": 9987,
"TEXTURE_MAG_FILTER": 10240,
"TEXTURE_MIN_FILTER": 10241,
"TEXTURE_WRAP_S": 10242,
"TEXTURE_WRAP_T": 10243,
"TEXTURE": 5890,
"TEXTURE_CUBE_MAP": 34067,
"TEXTURE_BINDING_CUBE_MAP": 34068,
"TEXTURE_CUBE_MAP_POSITIVE_X": 34069,
"TEXTURE_CUBE_MAP_NEGATIVE_X": 34070,
"TEXTURE_CUBE_MAP_POSITIVE_Y": 34071,
"TEXTURE_CUBE_MAP_NEGATIVE_Y": 34072,
"TEXTURE_CUBE_MAP_POSITIVE_Z": 34073,
"TEXTURE_CUBE_MAP_NEGATIVE_Z": 34074,
"MAX_CUBE_MAP_TEXTURE_SIZE": 34076,
"TEXTURE0": 33984,
"TEXTURE1": 33985,
"TEXTURE2": 33986,
"TEXTURE3": 33987,
"TEXTURE4": 33988,
"TEXTURE5": 33989,
"TEXTURE6": 33990,
"TEXTURE7": 33991,
"TEXTURE8": 33992,
"TEXTURE9": 33993,
"TEXTURE10": 33994,
"TEXTURE11": 33995,
"TEXTURE12": 33996,
"TEXTURE13": 33997,
"TEXTURE14": 33998,
"TEXTURE15": 33999,
"TEXTURE16": 34000,
"TEXTURE17": 34001,
"TEXTURE18": 34002,
"TEXTURE19": 34003,
"TEXTURE20": 34004,
"TEXTURE21": 34005,
"TEXTURE22": 34006,
"TEXTURE23": 34007,
"TEXTURE24": 34008,
"TEXTURE25": 34009,
"TEXTURE26": 34010,
"TEXTURE27": 34011,
"TEXTURE28": 34012,
"TEXTURE29": 34013,
"TEXTURE30": 34014,
"TEXTURE31": 34015,
"ACTIVE_TEXTURE": 34016,
"REPEAT": 10497,
"CLAMP_TO_EDGE": 33071,
"MIRRORED_REPEAT": 33648,
"FLOAT_VEC2": 35664,
"FLOAT_VEC3": 35665,
"FLOAT_VEC4": 35666,
"INT_VEC2": 35667,
"INT_VEC3": 35668,
"INT_VEC4": 35669,
"BOOL": 35670,
"BOOL_VEC2": 35671,
"BOOL_VEC3": 35672,
"BOOL_VEC4": 35673,
"FLOAT_MAT2": 35674,
"FLOAT_MAT3": 35675,
"FLOAT_MAT4": 35676,
"SAMPLER_2D": 35678,
"SAMPLER_CUBE": 35680,
"VERTEX_ATTRIB_ARRAY_ENABLED": 34338,
"VERTEX_ATTRIB_ARRAY_SIZE": 34339,
"VERTEX_ATTRIB_ARRAY_STRIDE": 34340,
"VERTEX_ATTRIB_ARRAY_TYPE": 34341,
"VERTEX_ATTRIB_ARRAY_NORMALIZED": 34922,
"VERTEX_ATTRIB_ARRAY_POINTER": 34373,
"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING": 34975,
"IMPLEMENTATION_COLOR_READ_TYPE": 35738,
"IMPLEMENTATION_COLOR_READ_FORMAT": 35739,
"COMPILE_STATUS": 35713,
"LOW_FLOAT": 36336,
"MEDIUM_FLOAT": 36337,
"HIGH_FLOAT": 36338,
"LOW_INT": 36339,
"MEDIUM_INT": 36340,
"HIGH_INT": 36341,
"FRAMEBUFFER": 36160,
"RENDERBUFFER": 36161,
"RGBA4": 32854,
"RGB5_A1": 32855,
"RGB565": 36194,
"DEPTH_COMPONENT16": 33189,
"STENCIL_INDEX8": 36168,
"DEPTH_STENCIL": 34041,
"RENDERBUFFER_WIDTH": 36162,
"RENDERBUFFER_HEIGHT": 36163,
"RENDERBUFFER_INTERNAL_FORMAT": 36164,
"RENDERBUFFER_RED_SIZE": 36176,
"RENDERBUFFER_GREEN_SIZE": 36177,
"RENDERBUFFER_BLUE_SIZE": 36178,
"RENDERBUFFER_ALPHA_SIZE": 36179,
"RENDERBUFFER_DEPTH_SIZE": 36180,
"RENDERBUFFER_STENCIL_SIZE": 36181,
"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE": 36048,
"FRAMEBUFFER_ATTACHMENT_OBJECT_NAME": 36049,
"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL": 36050,
"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE": 36051,
"COLOR_ATTACHMENT0": 36064,
"DEPTH_ATTACHMENT": 36096,
"STENCIL_ATTACHMENT": 36128,
"DEPTH_STENCIL_ATTACHMENT": 33306,
"NONE": 0,
"FRAMEBUFFER_COMPLETE": 36053,
"FRAMEBUFFER_INCOMPLETE_ATTACHMENT": 36054,
"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT": 36055,
"FRAMEBUFFER_INCOMPLETE_DIMENSIONS": 36057,
"FRAMEBUFFER_UNSUPPORTED": 36061,
"FRAMEBUFFER_BINDING": 36006,
"RENDERBUFFER_BINDING": 36007,
"MAX_RENDERBUFFER_SIZE": 34024,
"INVALID_FRAMEBUFFER_OPERATION": 1286,
"UNPACK_FLIP_Y_WEBGL": 37440,
"UNPACK_PREMULTIPLY_ALPHA_WEBGL": 37441,
"CONTEXT_LOST_WEBGL": 37442,
"UNPACK_COLORSPACE_CONVERSION_WEBGL": 37443,
"BROWSER_DEFAULT_WEBGL": 37444
};

View File

@ -0,0 +1,142 @@
let i = 1;
const GLmethod = {};
GLmethod.activeTexture = i++; //1
GLmethod.attachShader = i++;
GLmethod.bindAttribLocation = i++;
GLmethod.bindBuffer = i++;
GLmethod.bindFramebuffer = i++;
GLmethod.bindRenderbuffer = i++;
GLmethod.bindTexture = i++;
GLmethod.blendColor = i++;
GLmethod.blendEquation = i++;
GLmethod.blendEquationSeparate = i++; //10
GLmethod.blendFunc = i++;
GLmethod.blendFuncSeparate = i++;
GLmethod.bufferData = i++;
GLmethod.bufferSubData = i++;
GLmethod.checkFramebufferStatus = i++;
GLmethod.clear = i++;
GLmethod.clearColor = i++;
GLmethod.clearDepth = i++;
GLmethod.clearStencil = i++;
GLmethod.colorMask = i++; //20
GLmethod.compileShader = i++;
GLmethod.compressedTexImage2D = i++;
GLmethod.compressedTexSubImage2D = i++;
GLmethod.copyTexImage2D = i++;
GLmethod.copyTexSubImage2D = i++;
GLmethod.createBuffer = i++;
GLmethod.createFramebuffer = i++;
GLmethod.createProgram = i++;
GLmethod.createRenderbuffer = i++;
GLmethod.createShader = i++; //30
GLmethod.createTexture = i++;
GLmethod.cullFace = i++;
GLmethod.deleteBuffer = i++;
GLmethod.deleteFramebuffer = i++;
GLmethod.deleteProgram = i++;
GLmethod.deleteRenderbuffer = i++;
GLmethod.deleteShader = i++;
GLmethod.deleteTexture = i++;
GLmethod.depthFunc = i++;
GLmethod.depthMask = i++; //40
GLmethod.depthRange = i++;
GLmethod.detachShader = i++;
GLmethod.disable = i++;
GLmethod.disableVertexAttribArray = i++;
GLmethod.drawArrays = i++;
GLmethod.drawArraysInstancedANGLE = i++;
GLmethod.drawElements = i++;
GLmethod.drawElementsInstancedANGLE = i++;
GLmethod.enable = i++;
GLmethod.enableVertexAttribArray = i++; //50
GLmethod.flush = i++;
GLmethod.framebufferRenderbuffer = i++;
GLmethod.framebufferTexture2D = i++;
GLmethod.frontFace = i++;
GLmethod.generateMipmap = i++;
GLmethod.getActiveAttrib = i++;
GLmethod.getActiveUniform = i++;
GLmethod.getAttachedShaders = i++;
GLmethod.getAttribLocation = i++;
GLmethod.getBufferParameter = i++; //60
GLmethod.getContextAttributes = i++;
GLmethod.getError = i++;
GLmethod.getExtension = i++;
GLmethod.getFramebufferAttachmentParameter = i++;
GLmethod.getParameter = i++;
GLmethod.getProgramInfoLog = i++;
GLmethod.getProgramParameter = i++;
GLmethod.getRenderbufferParameter = i++;
GLmethod.getShaderInfoLog = i++;
GLmethod.getShaderParameter = i++; //70
GLmethod.getShaderPrecisionFormat = i++;
GLmethod.getShaderSource = i++;
GLmethod.getSupportedExtensions = i++;
GLmethod.getTexParameter = i++;
GLmethod.getUniform = i++;
GLmethod.getUniformLocation = i++;
GLmethod.getVertexAttrib = i++;
GLmethod.getVertexAttribOffset = i++;
GLmethod.isBuffer = i++;
GLmethod.isContextLost = i++; //80
GLmethod.isEnabled = i++;
GLmethod.isFramebuffer = i++;
GLmethod.isProgram = i++;
GLmethod.isRenderbuffer = i++;
GLmethod.isShader = i++;
GLmethod.isTexture = i++;
GLmethod.lineWidth = i++;
GLmethod.linkProgram = i++;
GLmethod.pixelStorei = i++;
GLmethod.polygonOffset = i++; //90
GLmethod.readPixels = i++;
GLmethod.renderbufferStorage = i++;
GLmethod.sampleCoverage = i++;
GLmethod.scissor = i++;
GLmethod.shaderSource = i++;
GLmethod.stencilFunc = i++;
GLmethod.stencilFuncSeparate = i++;
GLmethod.stencilMask = i++;
GLmethod.stencilMaskSeparate = i++;
GLmethod.stencilOp = i++; //100
GLmethod.stencilOpSeparate = i++;
GLmethod.texImage2D = i++;
GLmethod.texParameterf = i++;
GLmethod.texParameteri = i++;
GLmethod.texSubImage2D = i++;
GLmethod.uniform1f = i++;
GLmethod.uniform1fv = i++;
GLmethod.uniform1i = i++;
GLmethod.uniform1iv = i++;
GLmethod.uniform2f = i++; //110
GLmethod.uniform2fv = i++;
GLmethod.uniform2i = i++;
GLmethod.uniform2iv = i++;
GLmethod.uniform3f = i++;
GLmethod.uniform3fv = i++;
GLmethod.uniform3i = i++;
GLmethod.uniform3iv = i++;
GLmethod.uniform4f = i++;
GLmethod.uniform4fv = i++;
GLmethod.uniform4i = i++; //120
GLmethod.uniform4iv = i++;
GLmethod.uniformMatrix2fv = i++;
GLmethod.uniformMatrix3fv = i++;
GLmethod.uniformMatrix4fv = i++;
GLmethod.useProgram = i++;
GLmethod.validateProgram = i++;
GLmethod.vertexAttrib1f = i++; //new
GLmethod.vertexAttrib2f = i++; //new
GLmethod.vertexAttrib3f = i++; //new
GLmethod.vertexAttrib4f = i++; //new //130
GLmethod.vertexAttrib1fv = i++; //new
GLmethod.vertexAttrib2fv = i++; //new
GLmethod.vertexAttrib3fv = i++; //new
GLmethod.vertexAttrib4fv = i++; //new
GLmethod.vertexAttribPointer = i++;
GLmethod.viewport = i++;
export default GLmethod;

View File

@ -0,0 +1,23 @@
const GLtype = {};
[
"GLbitfield",
"GLboolean",
"GLbyte",
"GLclampf",
"GLenum",
"GLfloat",
"GLint",
"GLintptr",
"GLsizei",
"GLsizeiptr",
"GLshort",
"GLubyte",
"GLuint",
"GLushort"
].sort().map((typeName, i) => GLtype[typeName] = 1 >> (i + 1));
export default GLtype;

View File

@ -0,0 +1,21 @@
import {getTransferedObjectUUID} from './classUtils';
const name = 'WebGLProgram';
function uuid(id) {
return getTransferedObjectUUID(name, id);
}
export default class WebGLProgram {
className = name;
constructor(id) {
this.id = id;
}
static uuid = uuid;
uuid() {
return uuid(this.id);
}
}

View File

@ -0,0 +1,21 @@
import {getTransferedObjectUUID} from './classUtils';
const name = 'WebGLRenderBuffer';
function uuid(id) {
return getTransferedObjectUUID(name, id);
}
export default class WebGLRenderbuffer {
className = name;
constructor(id) {
this.id = id;
}
static uuid = uuid;
uuid() {
return uuid(this.id);
}
}

View File

@ -0,0 +1,22 @@
import {getTransferedObjectUUID} from './classUtils';
const name = 'WebGLShader';
function uuid(id) {
return getTransferedObjectUUID(name, id);
}
export default class WebGLShader {
className = name;
constructor(id, type) {
this.id = id;
this.type = type;
}
static uuid = uuid;
uuid() {
return uuid(this.id);
}
}

View File

@ -0,0 +1,11 @@
export default class WebGLShaderPrecisionFormat {
className = 'WebGLShaderPrecisionFormat';
constructor({
rangeMin, rangeMax, precision
}) {
this.rangeMin = rangeMin;
this.rangeMax = rangeMax;
this.precision = precision;
}
}

View File

@ -0,0 +1,22 @@
import {getTransferedObjectUUID} from './classUtils';
const name = 'WebGLTexture';
function uuid(id) {
return getTransferedObjectUUID(name, id);
}
export default class WebGLTexture {
className = name;
constructor(id, type) {
this.id = id;
this.type = type;
}
static uuid = uuid;
uuid() {
return uuid(this.id);
}
}

View File

@ -0,0 +1,22 @@
import {getTransferedObjectUUID} from './classUtils';
const name = 'WebGLUniformLocation';
function uuid(id) {
return getTransferedObjectUUID(name, id);
}
export default class WebGLUniformLocation {
className = name;
constructor(id, type) {
this.id = id;
this.type = type;
}
static uuid = uuid;
uuid() {
return uuid(this.id);
}
}

View File

@ -0,0 +1,3 @@
export function getTransferedObjectUUID(name, id) {
return `${name.toLowerCase()}-${id}`;
}

View File

@ -0,0 +1,74 @@
import GContext2D from '../context-2d/RenderingContext';
import GContextWebGL from '../context-webgl/RenderingContext';
export default class GCanvas {
// static GBridge = null;
id = null;
_needRender = true;
constructor(id, { disableAutoSwap }) {
this.id = id;
this._disableAutoSwap = disableAutoSwap;
if (disableAutoSwap) {
this._swapBuffers = () => {
GCanvas.GBridge.render(this.id);
}
}
}
getContext(type) {
let context = null;
if (type.match(/webgl/i)) {
context = new GContextWebGL(this);
context.componentId = this.id;
if (!this._disableAutoSwap) {
const render = () => {
if (this._needRender) {
GCanvas.GBridge.render(this.id);
this._needRender = false;
}
}
setInterval(render, 16);
}
GCanvas.GBridge.callSetContextType(this.id, 1); // 0 for 2d; 1 for webgl
} else if (type.match(/2d/i)) {
context = new GContext2D(this);
context.componentId = this.id;
// const render = ( callback ) => {
//
// const commands = context._drawCommands;
// context._drawCommands = '';
//
// GCanvas.GBridge.render2d(this.id, commands, callback);
// this._needRender = false;
// }
// //draw方法触发
// context._flush = render;
// //setInterval(render, 16);
GCanvas.GBridge.callSetContextType(this.id, 0);
} else {
throw new Error('not supported context ' + type);
}
return context;
}
reset() {
GCanvas.GBridge.callReset(this.id);
}
}

View File

@ -0,0 +1,96 @@
let incId = 1;
const noop = function () { };
class GImage {
static GBridge = null;
constructor() {
this._id = incId++;
this._width = 0;
this._height = 0;
this._src = undefined;
this._onload = noop;
this._onerror = noop;
this.complete = false;
}
get width() {
return this._width;
}
set width(v) {
this._width = v;
}
get height() {
return this._height;
}
set height(v) {
this._height = v;
}
get src() {
return this._src;
}
set src(v) {
if (v.startsWith('//')) {
v = 'http:' + v;
}
this._src = v;
GImage.GBridge.perloadImage([this._src, this._id], (data) => {
if (typeof data === 'string') {
data = JSON.parse(data);
}
if (data.error) {
var evt = { type: 'error', target: this };
this.onerror(evt);
} else {
this.complete = true;
this.width = typeof data.width === 'number' ? data.width : 0;
this.height = typeof data.height === 'number' ? data.height : 0;
var evt = { type: 'load', target: this };
this.onload(evt);
}
});
}
addEventListener(name, listener) {
if (name === 'load') {
this.onload = listener;
} else if (name === 'error') {
this.onerror = listener;
}
}
removeEventListener(name, listener) {
if (name === 'load') {
this.onload = noop;
} else if (name === 'error') {
this.onerror = noop;
}
}
get onload() {
return this._onload;
}
set onload(v) {
this._onload = v;
}
get onerror() {
return this._onerror;
}
set onerror(v) {
this._onerror = v;
}
}
export default GImage;

View File

@ -0,0 +1,24 @@
export function ArrayBufferToBase64 (buffer) {
var binary = '';
var bytes = new Uint8ClampedArray(buffer);
for (var len = bytes.byteLength, i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return btoa(binary);
}
export function Base64ToUint8ClampedArray(base64String) {
const padding = '='.repeat((4 - base64String.length % 4) % 4);
const base64 = (base64String + padding)
.replace(/\-/g, '+')
.replace(/_/g, '/');
const rawData = atob(base64);
const outputArray = new Uint8ClampedArray(rawData.length);
for (let i = 0; i < rawData.length; ++i) {
outputArray[i] = rawData.charCodeAt(i);
}
return outputArray;
}

View File

@ -0,0 +1,39 @@
import GCanvas from './env/canvas';
import GImage from './env/image';
import GWebGLRenderingContext from './context-webgl/RenderingContext';
import GContext2D from './context-2d/RenderingContext';
import GBridgeWeex from './bridge/bridge-weex';
export let Image = GImage;
export let WeexBridge = GBridgeWeex;
export function enable(el, { bridge, debug, disableAutoSwap, disableComboCommands } = {}) {
const GBridge = GImage.GBridge = GCanvas.GBridge = GWebGLRenderingContext.GBridge = GContext2D.GBridge = bridge;
GBridge.callEnable(el.ref, [
0, // renderMode: 0--RENDERMODE_WHEN_DIRTY, 1--RENDERMODE_CONTINUOUSLY
-1, // hybridLayerType: 0--LAYER_TYPE_NONE 1--LAYER_TYPE_SOFTWARE 2--LAYER_TYPE_HARDWARE
false, // supportScroll
false, // newCanvasMode
1, // compatible
'white',// clearColor
false // sameLevel: newCanvasMode = true && true => GCanvasView and Webview is same level
]);
if (debug === true) {
GBridge.callEnableDebug();
}
if (disableComboCommands) {
GBridge.callEnableDisableCombo();
}
var canvas = new GCanvas(el.ref, { disableAutoSwap });
canvas.width = el.style.width;
canvas.height = el.style.height;
return canvas;
};

Some files were not shown because too many files have changed in this diff Show More