import { AxiosRequestData } from '@/data/axios_request'
import cache from "@/utils/cache"

/**
 * 获取短信验证码
 * @param {String} phoneNo 用户手机号
 */
function getSmscode(phoneNo) {
    const url = '/sms/getSmscode'
    let token = cache.getToken()
    let args = {
        phoneNo: phoneNo,
    }
    return new Promise(function (resolve, reject) {
        AxiosRequestData(url, token, args, false, 1)
            .then(val => {
                console.log('获取短信验证码 结果：')
                console.log(val)
                if (val.code === 0) {
                    resolve(val)
                } else {
                    reject(val.msg)
                }
            })
    })
}

const SMS = {
    getSmscode
}

export default SMS