export const getWeChatAuthCode = (e) => {
  return new Promise((resolve, reject) => {
    // 条件编译微信小程序、抖音小程序
    let provider = "";
    // #ifdef MP-WEIXIN
    provider = "weixin";
    // #endif

    // #ifdef MP-TOUTIAO
    provider = "toutiao";
    // #endif

    // 判断用户拒绝授权
    if (e.detail.errMsg === "getPhoneNumber:fail user deny") {
      reject();
      return;
    }

    uni.login({
      provider,
      onlyAuthorize: true,
      success: (res) => {
        resolve(res.code);
      },
      fail: (err) => {
        reject(err);
      },
    });
  });
};
