122 lines
4.6 KiB
JavaScript
122 lines
4.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: ""
|
|
});
|
|
const jumpto = () => {
|
|
common_vendor.index.__f__("log", "at pages/index/callback.vue:37", "???");
|
|
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/index/callback.vue:48", "✅ 获取用户信息成功:", data);
|
|
ceshi.name = data.nickname;
|
|
ceshi.openid = data.openid;
|
|
common_vendor.index.setStorage({
|
|
key: "openid",
|
|
data: {
|
|
openid: data.openid
|
|
}
|
|
});
|
|
getUserMessage();
|
|
}).catch((err) => {
|
|
common_vendor.index.__f__("error", "at pages/index/callback.vue:61", "❌ 获取用户信息失败:", err);
|
|
});
|
|
};
|
|
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/index/callback.vue:69", "个人信息打印", data);
|
|
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/index/callback.vue:80", "机构打印", 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/index/callback.vue:102", "???/", 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/index/callback.vue:113", "???", data);
|
|
}).catch((err) => {
|
|
common_vendor.index.__f__("error", "at pages/index/callback.vue:116", "请求失败:", 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/index/callback.vue:131", "解析到的 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-dd49f168"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/callback.js.map
|