import {
	app
} from '../../../../../app/weapps-api';

export default async function (instance) {
	try {
		wx.showLoading({
			title: '请稍后'
		})
		const res = await app.cloud.unionIdLoginInWxApp()
		if (!res) throw new Error('登录失败')
		wx.hideLoading()
		return res
	} catch (e) {
		wx.hideLoading()
		console.error('登录失败：', e);
		app.showModal({
			title: '登录失败',
			content: e.errMsg || e.message || JSON.stringify(e),
			showCancel: false,
		})
		throw e;
	}
}
