"use strict";const e=require("../vendor.js"),i=require("../../api/api.js"),o=require("../../utils/sok.js");exports.login=async(n,t=1)=>{if(1==t){var{code:a}=await e.index.login({provider:"weixin"});try{let{token:o,userInfo:n}=await i.loginCodeApi({loginCode:a});e.index.setStorageSync("token",o),e.index.setStorageSync("user",n)}catch(s){10==s.code&&e.index.setStorageSync("token",!1)}}else if(2==t){var{code:r}=n.detail,{code:a}=await e.index.login({provider:"alipay"});try{let{token:n,user:t}=await i.loginApi({phoneCode:r,loginCode:a});e.index.setStorageSync("token",n),e.index.setStorageSync("user",t),e.index.navigateBack(),o.init()}catch(s){console.log(s)}}};
