/* * @Author: xiaolin * @Date: 2022-10-12 12:09:56 * @LastEditors: xiaolin * @LastEditTime: 2022-10-21 15:38:28 * @Description: file content * @FilePath: \image.platform.com\xyxJsSdkV2\src\bindPhone.js */ import request from "../utils/request.js"; import { checkLoginStatus } from "../src/login.js"; /** * @description: 绑定手机号 * @param { phone: "1341341340", code: "123456" } data * @return {*} */ export const bindPhone = async (data) => { console.log("bindPhone入参"+JSON.stringify(data)); try { const needValus = ["phone", "code"]; needValus.forEach((value) => { if (data[value] === undefined) { return Promise.reject({ msg: `invalid ${value}`, }); } }); const res = await request.api("COMMON", { do: "bindPhone", phone: data.phone, code: data.code, }); //要重新获取一次用户信息 await checkLoginStatus(); return Promise.resolve(res); } catch (error) { return Promise.reject(error); } }; /** * @description: 获取手机验证码 * @param { phone: "1341341340" } data * @return {*} */ export const getBindPhoneCode = async (data) => { console.log("getBindPhoneCode入参"+JSON.stringify(data)); try { const needValus = ["phone"]; needValus.forEach((value) => { if (data[value] === undefined) { return Promise.reject(`invalid ${value}`); } }); const res = await request.api("COMMON", { do: "getBindPhoneCode", phone: data.phone, }); return Promise.resolve(res); } catch (error) { return Promise.reject(error); } };