import http from '../utils/http'


/**
 * 登录/注册同一个接口
 * @author Seven
 * @data 2025-1-28
 * @param number // 验证码
 * @returns {  }
 * @see https://mall.gpxscs.cn/mobile/account/login/doMerchSmsRegisterAndLogin
 */

export function GetLogin (params){
  params.isFilter = true  
  return  new Promise((resolve, reject) => {
    http({
      url:'/api/mobile/account/login/doMerchSmsRegisterAndLogin',
      method:'post',
      data:params,
    }).then(res=>{
      resolve(res)
    }).catch(e => reject(console.warn(e)))
  })
}

/**
 * 获取验证码
 * @author Seven
 * @data 2025-1-6
 * @returns {  }
 * @see https://mall.gpxscs.cn/mobile/account/login/sendVerifyCode
 */

export function GetSmsCode(params){
  params.isFilter = true 
  return  new Promise((resolve, reject) => {
    http({
      url:'/api/mobile/account/login/sendVerifyCode',
      method:'post',
      data:params,
    }).then(res=>{
      resolve(res)
    }).catch(e => reject(console.warn(e)))
  })
}

/**
 * 获取店铺分类
 * @author Seven
 * @date 2025-3-24
 * @returns {  }
 * @see https://mall.gpxscs.cn/mobile/shop/store/biz-category/list
 */
export function GetStoreCategories() { 
  return new Promise((resolve, reject) => {
    http({
      url: '/api/mobile/shop/shop-base-store-category/list',
      method: 'post'
    }).then(res => {
      resolve(res)
    }).catch(e => reject(console.warn(e)))
  })
}
/**
 * 处理店铺分类数据，转换为 el-cascader 需要的格式
 * @param {Array} data 原始店铺分类数据
 * @returns {Array} 转换后的数据
 */
export function transformStoreCategories(data) {
  return data.map(item => ({
    value: item.store_category_id,
    label: item.store_category_name,
    children: item.children ? [
      // 添加一个与一级目录同名的选项
      {
        value: item.store_category_id,
        label: `${item.store_category_name} 分割比例(${item.split_ratio}%)`
      },
      ...item.children.map(child => ({
          value: child.store_category_id,
          label: `${child.store_category_name} 分割比例(${child.split_ratio}%)`
        }))
    ] : []
  }));
}

export function GetPostion (params){
  params.isFilter = true  
  return  new Promise((resolve, reject) => {
    http({
      url:'/api/mobile/shop/merch/baidu/place/v2/suggestion',
      method:'get',
      params,
    }).then(res=>{
      resolve(res)
    }).catch(e => reject(console.warn(e)))
  })
}

export function GetBank (data){
  return  new Promise((resolve, reject) => {
    http({
      url:'/api/mobile/shop/lakala/tk/bank/search',
      method:'post',
      data
    }).then(res=>{
      resolve(res)
    }).catch(e => reject(console.warn(e)))
  })
}

export function merchApply(data){
  return  new Promise((resolve, reject) => {
    http({
      url:'/api/mobile/shop/merch/apply',
      method:'post',
      data
    }).then(res=>{
      resolve(res)
    }).catch(e => reject(console.warn(e)))
  })
}

//获取审核状态
export function getApproval_status(){
  const phone={
    mobile:localStorage.getItem("mobilePhone")
  }
  return new Promise((resolve,reject)=>{
    http({
      url:'/api/mobile/shop/merch/fresh/approval/status',
      method:'post',
      data:phone
    }).then(res=>{
      resolve(res)
    }).catch(e => reject(console.warn(e)))
  })
}

//重新审核
export function re_apply(params){
    return new Promise((resolve,reject)=>{
      http({
        url:'/api/mobile/shop/merch/re-apply',
        method:'post',
        data:params
      }).then(res=>{
        resolve(res)
      }).catch(e => reject(console.warn(e)))
    })
}

/**
 * 获取申请信息详情
 * @author Seven
 * @data 2025-3-4
 * @param {  }
 * @returns { mobile:13199998888  }
 * @see https://mall.gpxscs.cn/mobile/shop/merch/detail
 */

 export function GetAuditInfo(data) {
  return  new Promise((resolve, reject) => {
    http({
      url:'/api/mobile/shop/merch/detail',
      method:'post',
      data,
    }).then(res=>{
      resolve(res)
    }).catch(e => reject(console.warn(e)))
  })
}

/**
 * 账号密码登录
 * @author Seven
 * @data 2025-1-6
 * @returns {  }
 * @see https://mall.gpxscs.cn/api/admin/account/account-user-base/doLogin
 */

export function GetAccountLogin(params){
  return  new Promise((resolve, reject) => {
    http({
      url:'/api/admin/account/account-user-base/doLogin',
      method:'post',
      params,
    }).then(res=>{
      resolve(res)
    }).catch(e => reject(console.warn(e)))
  })
}

/**
 * 获取图形验证码
 * @author Seven
 * @data 2025-1-6
 * @returns {  }
 * @see https://mall.gpxscs.cn/api/admin/shop/shop-base-config/image
 */

export function GetVerifyCode(params){
  return  new Promise((resolve, reject) => {
    http({
      url:'/api/admin/shop/shop-base-config/image',
      method:'GET',
      params,
    }).then(res=>{
      resolve(res)
    }).catch(e => reject(console.warn(e)))
  })
}
//获取入驻信息
export function GetMerchDetail(){
return new Promise((resolve,reject)=>{
  http({
    url:'/api/mobile/shop/merch/detail',
    method:'post',
    data:{mobile:localStorage.getItem('mobilePhone')}
  }).then(res=>{
    resolve(res)
  }).catch(e=>reject(console.warn(e)))
})
}

export function GetAppDistrict(){
  return new Promise((resolve,reject)=>{
    http({
      url:'/api/mobile/shop/shop-base-district/getAppDistrict',
      method:'get'
    }).then(res=>{
      resolve(res)
    }).catch(e=>reject(console.warn(e)))
  })
}