From 623c9333deaa14a55782be4d6b65dbd1916aad12 Mon Sep 17 00:00:00 2001 From: wx-jincw Date: Tue, 5 May 2026 23:10:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=85=AC=E4=BC=97=E5=8F=B7?= =?UTF-8?q?=E7=BD=91=E9=A1=B5=E6=8E=88=E6=9D=83=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/user.js | 13 +++++ app/libs/wechat.js | 32 ++++++++++++ app/pages.json | 10 ++++ app/pages/users/login/index.vue | 91 ++++++++++++++++++++++++++++++--- app/pages/webview/webview.vue | 38 ++++++++++++++ 5 files changed, 176 insertions(+), 8 deletions(-) create mode 100644 app/pages/webview/webview.vue diff --git a/app/api/user.js b/app/api/user.js index 4a4c187..5093b8c 100644 --- a/app/api/user.js +++ b/app/api/user.js @@ -24,6 +24,19 @@ export function loginH5(data) { return request.post("login", data, { noAuth : true }); } +/** + * 小程序:公众号网页授权 code 换登录态(后端待对接) + * 约定 data:{ token, uid } 已绑定直接登录;{ needBind: true } 需使用账号密码绑定后再拿 token + */ +export function loginMpByGzhCode(code, spread_spid) { + void code; + void spread_spid; + // 对接后启用,并删除下方占位 reject: + // return request.get('wechat/authorize/mp_gzh_login', { code, spread_spid: spread_spid || 0 }, { noAuth: true }); + // 本地联调「需绑定」分支时可改为:return Promise.resolve({ data: { needBind: true } }); + return Promise.reject(new Error('MP_GZH_LOGIN_PENDING')); +} + /** * h5用户手机号登录 * @param data object 用户手机号 也只能 diff --git a/app/libs/wechat.js b/app/libs/wechat.js index e43a00c..77fcbff 100644 --- a/app/libs/wechat.js +++ b/app/libs/wechat.js @@ -316,3 +316,35 @@ class AuthWechat { export default new AuthWechat(); // #endif + + +/** + * 小程序内打开 web-view 完成公众号网页授权,由 H5 落地页通过 postMessage 回传 { code } + * redirect_uri / appid 请按实际公众号与业务域名配置 + */ +export function wxGZHAuth() { + return new Promise((resolve, reject) => { + const redirectUri = encodeURIComponent('https://www.fjyfzh.com/gzh-mp/gzh-login'); + const url = + `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx49d7d3aba9479a85&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`; + uni.navigateTo({ + url: '/pages/webview/webview', + events: { + callbackData(data) { + // uni.navigateBack({ delta: 1 }); + if (data && (data.code || typeof data === 'string')) { + resolve(typeof data === 'string' ? { code: data } : data); + } else { + reject(new Error('未获取到公众号授权 code')); + } + } + }, + success(res) { + res.eventChannel.emit('acceptData', { url }); + }, + fail(err) { + reject(err || new Error('打开授权页失败')); + } + }); + }); +} \ No newline at end of file diff --git a/app/pages.json b/app/pages.json index 7cdbd00..6120da4 100644 --- a/app/pages.json +++ b/app/pages.json @@ -968,6 +968,16 @@ "navigationBarTitleText": "精品推荐" } }] + }, + { + "root": "pages/webview", + "name": "webview", + "pages": [{ + "path": "webview", + "style": { + "navigationBarTitleText": "微信授权" + } + }] } ], "globalStyle": { diff --git a/app/pages/users/login/index.vue b/app/pages/users/login/index.vue index 217b237..037b30f 100644 --- a/app/pages/users/login/index.vue +++ b/app/pages/users/login/index.vue @@ -48,6 +48,9 @@
登录
登录
+ +
微信登录
+
账号登录
@@ -62,6 +65,7 @@ import { loginH5, loginMobile, + loginMpByGzhCode, registerVerify, register, // getCodeApi, @@ -81,6 +85,11 @@ import { VUE_APP_API_URL } from "@/utils"; + // #ifdef MP-WEIXIN + import { + wxGZHAuth + } from "@/libs/wechat"; + // #endif const BACK_URL = "login_back_url"; @@ -106,7 +115,8 @@ appUserInfo: null, // 微信登录保存的用户信息 appleLoginStatus: false, // 苹果登录强制绑定手机号码状态 appleUserInfo: null, - appleShow: false // 苹果登录版本必须要求ios13以上的 + appleShow: false, // 苹果登录版本必须要求ios13以上的 + pendingGzhCode: '' // 公众号授权未绑定时,随账号密码一并提交 }; }, watch:{ @@ -254,7 +264,7 @@ this.getUserInfo(res.data); } }).catch(res => { - that.$util.Tips({ + this.$util.Tips({ title: res }); }); @@ -370,6 +380,60 @@ navTap: function(index) { this.current = index; }, + // #ifdef MP-WEIXIN + async mpGzhWechatLogin() { + const that = this; + try { + uni.showLoading({ + title: '授权中' + }); + const auth = await wxGZHAuth(); + const code = auth && auth.code ? auth.code : ''; + if (!code) { + uni.hideLoading(); + return that.$util.Tips({ + title: '未获取到授权码' + }); + } + const res = await loginMpByGzhCode(code, that.$Cache.get('spread')); + uni.hideLoading(); + const d = res.data || {}; + if (d.token) { + that.pendingGzhCode = ''; + that.$store.commit('LOGIN', { + token: d.token + }); + that.getUserInfo({ + uid: d.uid + }); + return; + } + if (d.needBind) { + that.pendingGzhCode = code; + uni.showModal({ + title: '提示', + content: '当前微信未绑定账号,请使用账号密码完成绑定登录', + showCancel: false + }); + return; + } + that.$util.Tips({ + title: d.msg || '登录失败' + }); + } catch (e) { + uni.hideLoading(); + const msg = (e && e.message) || e || '授权失败'; + if (msg === 'MP_GZH_LOGIN_PENDING') { + return that.$util.Tips({ + title: '公众号登录接口待对接' + }); + } + that.$util.Tips({ + title: typeof msg === 'string' ? msg : '授权失败' + }); + } + }, + // #endif async submit() { let that = this; if (!that.account) return that.$util.Tips({ @@ -381,14 +445,20 @@ if (!that.password) return that.$util.Tips({ title: '请填写密码' }); - loginH5({ - account: that.account, - password: that.password, - spread: that.$Cache.get("spread") - }) + const loginPayload = { + account: that.account, + password: that.password, + spread: that.$Cache.get("spread") + }; + // 绑定公众号授权:字段名请与后端约定(示例 mp_gzh_oauth_code) + if (that.pendingGzhCode) { + loginPayload.mp_gzh_oauth_code = that.pendingGzhCode; + } + loginH5(loginPayload) .then(({ data }) => { + that.pendingGzhCode = ''; this.$store.commit("LOGIN", { 'token': data.token }); @@ -400,7 +470,7 @@ }); }); }, -getUserInfo(data){ + getUserInfo(data){ this.$store.commit("SETUID", data.uid); getUserInfo().then(res => { this.$store.commit("UPDATE_USERINFO", res.data); @@ -602,6 +672,11 @@ getUserInfo(data){ color: #FFFFFF; font-size: 30rpx; } + + .logon-wechat { + margin-top: 32rpx; + background-color: #07c160; + } .tips { margin: 30rpx; diff --git a/app/pages/webview/webview.vue b/app/pages/webview/webview.vue new file mode 100644 index 0000000..5ed1ae3 --- /dev/null +++ b/app/pages/webview/webview.vue @@ -0,0 +1,38 @@ + + + + + \ No newline at end of file From 3081b11b7fed552d29feaa206490fff59a0ab3f6 Mon Sep 17 00:00:00 2001 From: wx-jincw Date: Thu, 7 May 2026 23:59:07 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E7=99=BB=E5=BD=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/property.js | 9 +++++++++ app/libs/wechat.js | 2 +- app/pages/users/login/index.vue | 13 +++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/api/property.js b/app/api/property.js index a507d56..fc0f7af 100644 --- a/app/api/property.js +++ b/app/api/property.js @@ -217,3 +217,12 @@ export function getAdminInfoByUid() { ); } +// 绑定微信(对应后台 api/front/bindingWx) +export function bindingWx(data) { + return request.post('bindingWx', data, { useAdminUrl: true }); +} + +// 解绑微信(对应后台 api/front/unbindWx) +export function unbindWx(data) { + return request.post('unbindWx', data, { useAdminUrl: true }); +} diff --git a/app/libs/wechat.js b/app/libs/wechat.js index 77fcbff..db96e88 100644 --- a/app/libs/wechat.js +++ b/app/libs/wechat.js @@ -324,7 +324,7 @@ export default new AuthWechat(); */ export function wxGZHAuth() { return new Promise((resolve, reject) => { - const redirectUri = encodeURIComponent('https://www.fjyfzh.com/gzh-mp/gzh-login'); + const redirectUri = encodeURIComponent('https://fzbfwy.com/login'); const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx49d7d3aba9479a85&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`; uni.navigateTo({ diff --git a/app/pages/users/login/index.vue b/app/pages/users/login/index.vue index 037b30f..4e5458b 100644 --- a/app/pages/users/login/index.vue +++ b/app/pages/users/login/index.vue @@ -49,7 +49,7 @@
登录
登录
-
微信登录
+
微信登录
@@ -470,6 +470,11 @@ }); }); }, + goWechatLogin() { + uni.navigateTo({ + url: "/pages/users/wechat_login/index" + }); + }, getUserInfo(data){ this.$store.commit("SETUID", data.uid); getUserInfo().then(res => { @@ -493,9 +498,13 @@ if (!backUrl.startsWith('/')) { backUrl = '/' + backUrl; } + // uni.reLaunch({ + // url: backUrl + // }); uni.reLaunch({ - url: backUrl + url: "/pages/index/index" }); + }) } } From 84c61d92e2048143b80d318d679198b605c74ad2 Mon Sep 17 00:00:00 2001 From: wx-jincw Date: Sun, 10 May 2026 16:16:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E7=89=A9=E8=B5=84=E9=A2=86=E7=94=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/property.js | 27 ++++ .../supply_chain/complaint/HandlePopup.vue | 4 +- .../supply_chain/material_receipt/index.vue | 144 +++++++++++++++--- 3 files changed, 153 insertions(+), 22 deletions(-) diff --git a/app/api/property.js b/app/api/property.js index fc0f7af..e9bb4e0 100644 --- a/app/api/property.js +++ b/app/api/property.js @@ -181,6 +181,33 @@ export function cancelBill(id) { ); } +// 审核单据通过 +export function auditBill(id) { + return request.get( + `autogencode/ckbill/auditBill/${id}`, + {}, + { useAdminUrl: true } + ); +} + +// 驳回单据 +export function rejectBill(id) { + return request.get( + `autogencode/ckbill/rejectBill/${id}`, + {}, + { useAdminUrl: true } + ); +} + +// 撤销审核 +export function cancelAuditBill(id) { + return request.get( + `autogencode/ckbill/cancelAuditBill/${id}`, + {}, + { useAdminUrl: true } + ); +} + // 部门树 export function getDeptTree() { return request.get( diff --git a/app/pages/supply_chain/complaint/HandlePopup.vue b/app/pages/supply_chain/complaint/HandlePopup.vue index 20bbd9e..95f0c67 100644 --- a/app/pages/supply_chain/complaint/HandlePopup.vue +++ b/app/pages/supply_chain/complaint/HandlePopup.vue @@ -20,7 +20,7 @@ - 反馈图片 + 处理图片 + + 领用审核 + - + - 领用物资 @@ -175,7 +171,14 @@ - + + + 审核通过 + 驳回 + 撤销审核 + + + 取消单据 查看凭证 @@ -210,11 +213,13 @@