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

/**
 * 用户修改手机号
 * @param {String} oriMobile 原来的手机号
 * @param {String} mobile 修改之后手机号
 * @param {String} password 密码
 * @param {String} smsCode 短信验证码
 */
function userMobileModify({ oriMobile, mobile, password, smsCode }) {
    const url = '/auth/comm/user/modifyMobile'
    let token = cache.getToken()
    let args = {
        oriMobile: oriMobile,
        mobile: mobile,
        password: password,
        smsCode: smsCode,
        reqChannel: 4
    }
    console.log('用户修改手机号 参数：')
    console.log(args)
    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)
                }
            })
    })
}

export {
    userMobileModify
}