import config from '@/config';
import http from '@/service/httpDecorator';
import qs from 'qs';
const { talosHost } = config;

export default {
  // 查询商品sku详情
  detailInfo: params => {
    return http.post(`${talosHost}/api/kdsp/activity/activity-goods-special/detail`, { ...params });
  },
  checkGroupBuyCreateOrder: params => {
    return http.post(`${talosHost}/api/kdsp/checkCanOpenJoinGroup?${qs.stringify(params)}`);
  },
  // 详情图片
  getDetailPic: url => {
    return http.get(url, { strategy: 'default', hideLoading: 1, skip: 1, hideToast: 1 });
  },
  // 商品详情地址列表
  addrList(data) {
    return http.get(`${talosHost}/api/kdsp/addr/receiver/list`, data, {
      hideLoading: true
    });
  },

  // 查询活动模板列表-根据活动id
  getTemplateList(activityId) {
    return http.get(`${talosHost}/api/kdsp/activity/activity-goods-special/template-list`, {
      params: { activityId }
    });
  },
  // 入口活动列表
  getGoodsList(params) {
    return http.get(`${talosHost}/api/kdsp/activity/activity-goods-special/goods-list/v2`, {
      params
    });
  },
  getWxConfig(url = window.location.href.split('#')[0]) {
    return http.post(`${talosHost}/api/kdsp/wx/mp/getJsapiSign`, {
      url: url,
      appId: 'wx2f44c7fe7b08458d'
    });
  },
  getScheme(params) {
    return http.get(
      `${talosHost}/api/kdsp/ka/info/getShareMiniUrl`,
      { params },
      { hideLoading: true }
    );
  },
  // 获取百人团订单
  getGroupOrderList(params) {
    return http.get(`${talosHost}/api/kdsp/group-order/list`, { params });
  },
  // 获取小程序码
  getQrcodeUrl(params) {
    const qsString = qs.stringify(params);
    return http.get(`${talosHost}/api/kdsp/playBill/getMakePicData?${qsString}`);
  },
  getGroupShareInfo(orderNo) {
    return http.get(`${talosHost}/api/kdsp/groupShareInfo?orderNo=${orderNo}`);
  },
  getPlayBillUrl(m) {
    return http.get(`http://192.168.25.122/api/kdsp/playBill/getPlayBillUrl?m=${m}`);
  },
  makePlayBillPicUrl(activityInfoId) {
    return http.get(
      `http://192.168.25.122/api/kdsp/activity/activity-info/makePlayBillPicUrl?activityInfoId=${activityInfoId}`
    );
  }
};
