145 lines
5.6 KiB
JavaScript
145 lines
5.6 KiB
JavaScript
"use strict";
|
||
const common_vendor = require("../../common/vendor.js");
|
||
const compontent_useWeChatAuth = require("../../compontent/useWeChatAuth.js");
|
||
const _sfc_main = {
|
||
__name: "callback",
|
||
setup(__props) {
|
||
compontent_useWeChatAuth.useWeChatAuth();
|
||
const ceshi = common_vendor.reactive({
|
||
name: "",
|
||
openid: "",
|
||
accessToken: ""
|
||
});
|
||
const jumpto = () => {
|
||
common_vendor.index.__f__("log", "at pages/login/callback.vue:51", "???");
|
||
common_vendor.index.navigateTo({
|
||
url: "/pages/pay/index"
|
||
});
|
||
};
|
||
const getOpenId = (code) => {
|
||
const url = `https://www.focusnu.com/nursing-unit/weixin/wechat/callback?code=${encodeURIComponent(code)}`;
|
||
fetch(url).then((res) => res.json()).then((data) => {
|
||
common_vendor.index.__f__("log", "at pages/login/callback.vue:62", "✅ 获取用户信息成功:", data);
|
||
ceshi.name = data.data.nickname;
|
||
ceshi.openid = data.data.openid;
|
||
ceshi.accessToken = data.accessToken;
|
||
common_vendor.index.setStorage({
|
||
key: "openid",
|
||
data: {
|
||
openid: data.data.openid,
|
||
accessToken: data.accessToken
|
||
}
|
||
});
|
||
getUserMessage();
|
||
}).catch((err) => {
|
||
common_vendor.index.__f__("error", "at pages/login/callback.vue:77", "❌ 获取用户信息失败:", err);
|
||
});
|
||
};
|
||
const look = common_vendor.ref("");
|
||
const getUserMessage = () => {
|
||
const url = `https://www.focusnu.com/nursing-unit/h5Api/nuBizAdvisoryInfo/queryWeixinInfo?openId=${encodeURIComponent(ceshi.openid)}&wechatName=${encodeURIComponent(ceshi.name)}`;
|
||
fetch(url).then((res) => res.json()).then((data) => {
|
||
common_vendor.index.__f__("log", "at pages/login/callback.vue:88", "个人信息打印", data);
|
||
const urlpost = `${data.result.serverUrl}/weiXinPay/getUserInfo`;
|
||
const payload = {
|
||
openid: ceshi.openid,
|
||
access_token: ceshi.accessToken
|
||
// serverUrl: serve.value
|
||
};
|
||
common_vendor.index.__f__("log", "at pages/login/callback.vue:97", "???/", payload);
|
||
fetch(urlpost, {
|
||
method: "POST",
|
||
headers: {
|
||
"Content-Type": "application/json"
|
||
},
|
||
body: JSON.stringify(payload)
|
||
}).then((res) => res.json()).then((data2) => {
|
||
look.value = data2;
|
||
common_vendor.index.__f__("log", "at pages/login/callback.vue:109", "!!!!!!!!!!!!!!!!!!!!!!!", data2);
|
||
}).catch((err) => {
|
||
common_vendor.index.__f__("error", "at pages/login/callback.vue:112", "请求失败:", err);
|
||
});
|
||
getjigou();
|
||
});
|
||
};
|
||
const jigouArray = common_vendor.ref([]);
|
||
const getjigou = () => {
|
||
const url = `https://www.focusnu.com/nursing-unit/sys/sysDepart/queryInstitutionsList`;
|
||
fetch(url).then((res) => res.json()).then((data) => {
|
||
jigouArray.value = [...data];
|
||
common_vendor.index.__f__("log", "at pages/login/callback.vue:127", "机构打印", jigouArray.value);
|
||
});
|
||
};
|
||
const secondArray = common_vendor.ref([]);
|
||
const jigouClick = (element) => {
|
||
const url = `${element.serverUrl}/h5Api/nuBaseInfo/list`;
|
||
fetch(url).then((res) => res.json()).then((data) => {
|
||
secondArray.value = [...data.result];
|
||
});
|
||
common_vendor.index.setStorage({
|
||
key: "serverUrl",
|
||
data: {
|
||
url: element.serverUrl
|
||
}
|
||
});
|
||
const urlpost = `https://www.focusnu.com/nursing-unit/h5Api/nuBizAdvisoryInfo/editNuBizAdvisoryInfo`;
|
||
const payload = {
|
||
openId: ceshi.openid,
|
||
serverUrl: element.serverUrl
|
||
};
|
||
common_vendor.index.__f__("log", "at pages/login/callback.vue:149", "???/", payload);
|
||
fetch(urlpost, {
|
||
method: "POST",
|
||
headers: {
|
||
"Content-Type": "application/json"
|
||
},
|
||
body: JSON.stringify(payload)
|
||
}).then((res) => res.json()).then((data) => {
|
||
common_vendor.index.__f__("log", "at pages/login/callback.vue:160", "???", data);
|
||
}).catch((err) => {
|
||
common_vendor.index.__f__("error", "at pages/login/callback.vue:163", "请求失败:", err);
|
||
});
|
||
};
|
||
common_vendor.onLoad(() => {
|
||
var _a;
|
||
const href = window.location.href;
|
||
const queryString = (_a = href.split("?")[1]) == null ? void 0 : _a.split("#")[0];
|
||
const query = {};
|
||
if (queryString) {
|
||
queryString.split("&").forEach((pair) => {
|
||
const [key, value] = pair.split("=");
|
||
query[key] = decodeURIComponent(value);
|
||
});
|
||
}
|
||
common_vendor.index.__f__("log", "at pages/login/callback.vue:178", "解析到的 query 参数:", query);
|
||
if (query.code) {
|
||
getOpenId(query.code);
|
||
}
|
||
});
|
||
return (_ctx, _cache) => {
|
||
return {
|
||
a: common_vendor.t(ceshi.name),
|
||
b: common_vendor.t(ceshi.openid),
|
||
c: common_vendor.f(jigouArray.value, (item, index, i0) => {
|
||
return {
|
||
a: common_vendor.t(item.departName),
|
||
b: common_vendor.o(($event) => jigouClick(item), index),
|
||
c: `https://www.focusnu.com/nursing-unit/sys/common/static/${item.picUrl}`,
|
||
d: index
|
||
};
|
||
}),
|
||
d: common_vendor.f(secondArray.value, (item, index, i0) => {
|
||
return {
|
||
a: common_vendor.t(item.nuName),
|
||
b: index,
|
||
c: common_vendor.o(jumpto, index)
|
||
};
|
||
})
|
||
};
|
||
};
|
||
}
|
||
};
|
||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-47aa4dce"]]);
|
||
wx.createPage(MiniProgramPage);
|
||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/callback.js.map
|