diff --git a/.env b/.env
index 5faa42e..3410a9b 100644
--- a/.env
+++ b/.env
@@ -1,4 +1,4 @@
-APP_DEBUG = false
+APP_DEBUG = true
DB_TYPE = mysql
DB_HOST = 127.0.0.1
diff --git a/README.md b/README.md
index 8542b11..1716303 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@
* 平台容易因为资质问题导致关站;
* 收取的手续费价格偏高;
-* 个人码在微信H5环境无法长按识别付款,能只技术PC端相机扫码付款。
+* 个人码在微信H5环境无法长按识别付款,只能通过PC端,相机扫码付款。
#### 码支付(mpay)
diff --git a/app/controller/api/PayManageController.php b/app/controller/api/PayManageController.php
index 540642c..08f11bf 100644
--- a/app/controller/api/PayManageController.php
+++ b/app/controller/api/PayManageController.php
@@ -143,7 +143,22 @@ class PayManageController extends BaseController
unlink($path);
}
}
-
+ // 上传二维码图片
+ public function uploadQrcode()
+ {
+ $img = $this->request->file('codeimg');
+ $path = public_path() . '/files/qrcode/';
+ if (!is_dir($path)) {
+ mkdir($path, 0777, true);
+ }
+ $info = $img->move($path, 'img' . time() . '.' . $img->getOriginalExtension());
+ if ($info) {
+ $imgpath = '/files/qrcode/';
+ return json(backMsg(0, '上传成功', ['imgpath' => $imgpath . $info->getFilename()]));
+ } else {
+ return json(backMsg(1, '上传失败'));
+ }
+ }
// 生成账号配置
private function createAccountConfig($acc)
{
diff --git a/public/files/wxpay2K103516.jpg b/public/files/wxpay2K103516.jpg
deleted file mode 100644
index 6e391c8..0000000
Binary files a/public/files/wxpay2K103516.jpg and /dev/null differ
diff --git a/view/pay_manage/add_channel.html b/view/pay_manage/add_channel.html
index df5fa23..cb5ef4f 100644
--- a/view/pay_manage/add_channel.html
+++ b/view/pay_manage/add_channel.html
@@ -25,7 +25,7 @@
@@ -61,10 +61,34 @@
layui.use(['form'], function () {
let form = layui.form;
- form.on('input-affix(scanning)', function () {
- window.open('https://cli.im/deqr', '_blank');
+ form.on('input-affix(scanning)', function (obj) {
+ const type = obj.elem.getAttribute('data-type');
+ if (type === '') {
+ layer.msg('请先选择二维码类型!', { tips: 2, time: 1200 });
+ return false;
+ }
+ if (type === 'img') {
+ uploadCodeImg(obj.elem);
+ return false;
+ }
+ if (type === 'link') {
+ window.open('https://cli.im/deqr', '_blank');
+ return false;
+ }
+ });
+ form.on('select(type)', function (data) {
+ const form = data.elem.form;
+ const value = data.value;
+ const inuptelem = form.querySelector('input[name="qrcode"]');
+ if (value === '0') {
+ inuptelem.setAttribute('data-type', 'link');
+ return false;
+ }
+ if (value === '1') {
+ inuptelem.setAttribute('data-type', 'img');
+ return false;
+ }
});
-
form.on('submit(save)', function (obj) {
let field = obj.field;
field.account_id = '';
@@ -88,6 +112,40 @@
})()
return false;
});
+ // 上传二维码图片
+ async function uploadCodeImg(elem) {
+ const input = document.createElement('input');
+ input.type = 'file';
+ input.accept = 'image/*';
+ input.onchange = async (event) => {
+ const file = event.target.files[0];
+ if (file) {
+ const formData = new FormData();
+ formData.append('codeimg', file);
+ try {
+ const response = await fetch('/api/PayManage/uploadQrcode', {
+ method: 'POST',
+ body: formData,
+ });
+ if (response.ok) {
+ const result = await response.json();
+ if (result.code === 0) {
+ layer.msg(result.msg, { icon: 1, time: 1200 });
+ elem.value = result.data.imgpath;
+ return result.data.imgpath;
+ } else {
+ layer.msg('上传失败:' + result.message, { tips: 2, time: 1200 });
+ }
+ } else {
+ layer.msg('上传失败:服务器错误', { tips: 2, time: 1200 });
+ }
+ } catch (error) {
+ layer.msg('上传失败:' + error.message, { tips: 2, time: 1200 });
+ }
+ }
+ };
+ input.click();
+ }
})