no message

This commit is contained in:
DESKTOP-369JRHT\12997 2024-05-31 10:37:17 +08:00
parent e2f89bd897
commit 4b7a37f890
5 changed files with 149 additions and 10 deletions

View File

@ -129,6 +129,43 @@ public class QrCodeUtils {
}
}
public void createLogoCodePictureByPos(InputStream backgroundStream, InputStream logoStream, String url, String outImgPath, Integer staffId, Integer storeId,String urls) {
try {
// 读取原图片信息
//使用工具类生成二维码
Image image = createQrCode(null, url, 200, 200);
// 查询当前店铺信息
if (ObjectUtils.isNotEmpty(storeId)){
LJStore store = storeService.selectStoreByStoreId(storeId);
// 查询加油员信息
LJStaff staff = null;
if (ObjectUtil.isNotEmpty(staffId)){
staff = staffService.selectStaffById(staffId);
}
LJStaff staff1 = staffService.selectStaffByStoreId(storeId);
}else {
}
// 输出图片
String urlsss = "/temp/qrCode/";
if (ObjectUtils.isNotEmpty(urls)){
urlsss = urls;
}
File file1 = new File(urlsss);
// 判断目录是否存在
if (!file1.exists()) {
file1.mkdirs();
}
FileOutputStream outImgStream = new FileOutputStream(outImgPath);
ImageIO.write((RenderedImage) image, "jpg", outImgStream);
outImgStream.flush();
outImgStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public void createLogoCodePictures(InputStream logoStream, String url, String outImgPath, Integer staffId, Integer storeId,String urls) {
try {
// 读取原图片信息

View File

@ -40,6 +40,11 @@ public class QRCodeController extends BaseController {
String type = map.get("type");
return getSuccessResult(iqrCodeService.createStoreQrCode(type,request));
}
@PostMapping("/createStoreQrCodeByPos")
public ResponseObject createStoreQrCodeByPos(HttpServletRequest request, @RequestBody Map<String,String> map) throws Exception {
String type = map.get("type");
return getSuccessResult(iqrCodeService.createStoreQrCodeByPos(type,request));
}
/**
* 根据店铺id查询二维码信息

View File

@ -22,6 +22,7 @@ public interface IQRCodeService extends IService<QRCode> {
public IPage<QRCode> selectQRCodeList(Page page, QRCode qrCode);
String createStoreQrCode(String type, HttpServletRequest request) throws Exception;
String createStoreQrCodeByPos(String type, HttpServletRequest request) throws Exception;
/**
* 根据店铺id查询二维码信息

View File

@ -90,6 +90,45 @@ public class QRCodeServiceImpl extends ServiceImpl<QRCodeMapper, QRCode> impleme
String saveFile = backendFileController.saveFile(resFile);
return saveFile;
}
@Override
public String createStoreQrCodeByPos(String type, HttpServletRequest request) throws Exception {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
Integer storeId = nowAccountInfo.getStoreId();
QRCode qrCode = selectQRCodeByStoreId(storeId);
// 根据id查询员工信息和店铺信息
LJStore store = storeService.selectStoreByStoreId(storeId);
//在图片上生成二维码
String backgroundImage = "";
// if (type.equals("0")){
// backgroundImage = "static/qrCodeImg/laigeyouhui_bg.jpg";
// }else {
// backgroundImage = "static/qrCodeImg/laigeyouhui_bg1.png";
// }
String logoImage = "static/qrCodeImg/logo.png";
// if (StringUtils.isNotEmpty(store.getLogo())){
// logoImage = store.getLogo();
// }
String url = qrCode.getCollection();
String area = store.getName();
String finalPath="/temp/qrCode/" + area + ".jpg";
InputStream backgroundStream = this.getClass().getClassLoader().getResourceAsStream(backgroundImage);
InputStream logoStream = this.getClass().getClassLoader().getResourceAsStream(logoImage);
//背景图片路径 loge图片 二维码 输出地址
qrCodeUtils.createLogoCodePictureByPos(backgroundStream, logoStream, url, finalPath, null,store.getId(),null);
File file1 = new File("/temp/qrCode/");
// 判断目录是否存在
if (!file1.exists()) {
file1.mkdirs();
}
File file =new File(finalPath);
FileInputStream fileInputStream =new FileInputStream(file);
MultipartFile resFile = new MockMultipartFile("file", file.getName(), null, fileInputStream);
// 返回图片路径
String saveFile = backendFileController.saveFile(resFile);
return saveFile;
}
@Override
public QRCode selectQRCode() {

View File

@ -7,11 +7,14 @@
<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>
<canvas id="qrcode" canvas-id="qrcode" style="width: 200px;height: 200px; margin: 0px auto; ">
<!-- <image url="https://cdn.uviewui.com/uview/resources/18496183264.png"></image> -->
</canvas>
</view>
<view class="title_">长按识别领取会员卡</view>
<view class="title_">扫码识别领取会员卡</view>
</view>
<view class="p-bottom">
@ -26,6 +29,7 @@
<script>
import request from "../../utils/request";
import config from '@/config'
import headers from '../../components/header/headers.vue'
import UQRCode from '../../uni_modules/Sansnn-uQRCode/js_sdk/uqrcode/uqrcode.js';
@ -33,6 +37,9 @@
data() {
return {
titles: "新增会员",
storeId: '',
collectionImg: '',
baseUrl: config.baseUrl,
}
},
@ -40,7 +47,10 @@
// this.actList = ["1", "1", "1", "1", "1", ]
// this.status = "nomore"
this.onReady()
// this.getStore()
this.getQRCodeInfoByStoreId()
// this.onReady2()
// await this.onReady()
},
onPullDownRefresh() {
console.log("刷新");
@ -56,7 +66,47 @@
headers
},
methods: {
onReady() {
// async getStore() {
// await request({
// url: 'business/storeInformation/store',
// method: 'get',
// params: this.form
// }).then((res) => {
// if (res.code == 200) {
// this.storeId = res.data.id
// } else {
// uni.showToast({
// title: res.data,
// icon: "none"
// })
// }
// })
// },
getQRCodeInfoByStoreId() {
request({
url: 'business/storeInformation/qrCode/createStoreQrCodeByPos',
method: 'post',
data: {
type: 0
}
}).then((res) => {
if (res.code == 200) {
this.collectionImg = res.data;
console.log("res", res)
this.onReady2()
} else {
uni.showToast({
title: res.data,
icon: "none"
})
}
})
},
onReady2() {
// uQRCode
var qr = new UQRCode();
//
@ -66,11 +116,18 @@
//
qr.make();
// canvas
var canvasContext = uni.createCanvasContext('qrcode', this); // this
// uQRCodecanvas
qr.canvasContext = canvasContext;
// canvas
qr.drawCanvas();
// var canvasContext = uni.createCanvasContext('qrcode', this); // this
// // uQRCodecanvas
// qr.canvasContext = canvasContext;
// // canvas
// qr.drawCanvas();
const url = this.baseUrl + this.collectionImg
// const url = ""
console.log("this.collectionImg()", url)
const ctx = uni.createCanvasContext('qrcode', this);
ctx.drawImage(url, 0, 0, 200, 200);
ctx.draw(true, () => {})
},
goback() {
uni.navigateTo({