99 lines
3.8 KiB
JavaScript
99 lines
3.8 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const _sfc_main = {
|
|
__name: "callback",
|
|
setup(__props) {
|
|
common_vendor.ref(0);
|
|
const ceshi = common_vendor.reactive({
|
|
name: "",
|
|
openid: "",
|
|
accessToken: ""
|
|
});
|
|
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) => {
|
|
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:94", "❌ 获取用户信息失败:", err);
|
|
});
|
|
};
|
|
common_vendor.ref("");
|
|
const getUserMessage = () => {
|
|
const url = `https://www.focusnu.com/nursing-unit/h5Api/nuBizAdvisoryInfo/queryWeixinInfo?openId=${encodeURIComponent(ceshi.openid)}`;
|
|
fetch(url).then((res) => res.json()).then((data) => {
|
|
common_vendor.index.__f__("log", "at pages/login/callback.vue:105", "个人信息打印", data);
|
|
common_vendor.index.setStorageSync("token", data.result.token);
|
|
common_vendor.index.setStorageSync("serverUrl", data.result.serverUrl);
|
|
common_vendor.index.__f__("log", "at pages/login/callback.vue:108", "???token存储", data.result.token);
|
|
const post = `${data.result.serverUrl}/weiXinPay/getJsApiInfo`;
|
|
const pay = {
|
|
access_token: ceshi.accessToken
|
|
};
|
|
common_vendor.index.__f__("log", "at pages/login/callback.vue:115", "???/", pay);
|
|
fetch(post, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify(pay)
|
|
}).then((res) => res.json()).then((data2) => {
|
|
common_vendor.index.__f__("log", "at pages/login/callback.vue:126", "???调取微信", data2);
|
|
}).catch((err) => {
|
|
common_vendor.index.__f__("error", "at pages/login/callback.vue:130", "请求失败:", err);
|
|
});
|
|
if (!data.result.tel) {
|
|
common_vendor.index.redirectTo({
|
|
url: `/pages/login/phonebumber`
|
|
});
|
|
} else {
|
|
common_vendor.index.redirectTo({
|
|
url: `/pages/index/index`
|
|
});
|
|
}
|
|
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:180", "机构打印", jigouArray.value);
|
|
});
|
|
};
|
|
common_vendor.ref([]);
|
|
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:231", "解析到的 query 参数:", query);
|
|
if (query.code) {
|
|
getOpenId(query.code);
|
|
}
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return {};
|
|
};
|
|
}
|
|
};
|
|
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
|