export const back = (url) => { console.log('调用返回方法back'); try { const arr = getCurrentPages() if (arr.length >= 2) { return uni.navigateBack() } else { uni.reLaunch({ url: url?url:'/pages/index/index' }) } } catch (error) { console.error('页面返回出错', error) //TODO handle the exception } } import { APIuserlogin, APIuser } from "@/common/api/api.js"; export const getOpenId = () => { // #ifdef MP-WEIXIN return new Promise((resolve, reject) => { uni.login({ provider: "weixin", success: (data) => { // 微信小程序环境 uni.getUserInfo({ provider: "weixin", success: async (infoRes) => { let res = await APIuserlogin({ code: data.code, //临时登录凭证 rawData: infoRes.rawData, source: "wechat", }); if (res) { resolve(res.userInfo .wechatOpenId); } else { reject(false); } }, fail: (err) => { reject(false); }, }); }, }); }) // #endif // #ifdef MP-ALIPAY // #endif }