import { api_wechatAuth, api_systemConfiguration, api_getDictionary} from "@/http/api.js" import { useLoginSuccess } from '@/share/useLoginSuccess.js' const { loginSuccess, transform } = useLoginSuccess() export function useWechatAuth() { /** * 微信登录2 */ const wechatAuth = () => { uni.showLoading({ title: "登录中", mask: true, }); api_wechatAuth({ redirectUrl: location.origin + location.pathname }).then(res => { uni.hideLoading(); if (res.state == "200"){ loginSuccess(res.user); transform(res.user); api_systemConfiguration({ idx: 0, sum: 9999, }).then(res2=>{ uni.setStorageSync('sysData',JSON.stringify(res2.list)) }) let postData = { "key": 'usertype', "type": "list", }; api_getDictionary(postData).then((data) => { uni.setStorageSync('groupData',JSON.stringify(data)) }); } else if (res.state == "501"){ uni.showModal({ title: '提示', content: res.remarks, showCancel: false, confirmColor: '#49b856', success: function(res1) { if (res1.confirm) { console.log('用户点击确定'); } else if (res1.cancel) { console.log('用户点击取消'); } } }); }else if (res.url){ window.location.href = res.url; } }); } return { wechatAuth }; }