import path_setting
from in_common.base_request import BaseRequest


class janus_request(BaseRequest):
    def __init__(self):
        self.data = self.api_load(path_setting.CONTENTV7_CONFIG)
        self.data = self.api_load(path_setting.HOSPITALSEARCH_CONFIG)

        #品类聚合页面商品列表
        self.data = self.api_load(path_setting.TAG_SERVICE_CONFIG)

        #品类聚合页面标签和专场
        self.data = self.api_load(path_setting.POLYMER_CONFIG)

        #次卡商详页
        self.data = self.api_load(path_setting.BEAUTY_CARD_DETAIL_CONFIG)

    #搜索结果页-综合/百科tab
    def content_v7(self, query, device_id, current_city_id, version, is_first, tab_type, offset):
        #搜索词
        self.params['query'] = query
        #设备号
        self.params['device_id'] = device_id
        #当前城市
        self.params['current_city_id'] = current_city_id
        #APP版本
        self.params['version'] = version
        #是否为第一次请求
        self.params['is_first'] = is_first
        #类型
        self.params['tab_type'] = tab_type
        #请求的页数 0，10，20
        self.params['offset'] = offset

        return self.api_send(self.data['content_v7'])

    #医院主页搜索
    def hospital_search(self, query, device_id, hospital_id, current_city_id, version, offset, size):
        #搜索词
        self.params['query'] = query
        #设备号
        self.params['device_id'] = device_id
        #医院id
        self.params['hospital_id'] = hospital_id
        #当前城市
        self.params['current_city_id'] = current_city_id
        #APP版本
        self.params['version'] = version
        #请求的页数 0，10，20
        self.params['offset'] = offset
        # 单页请求数量
        self.params['size'] = size

        return self.api_send(self.data['hospital_search'])

    #购物车-猜你喜欢列表
    def mine_guess_you_like(self):
        return self.api_send(self.data["mine_guess_you_like"])

    #商祥页-详情
    def product_detail(self, service_id, service_item_id, version):
        self.params["service_id"] = service_id
        self.params["service_item_id"] = service_item_id
        self.params["version"] = version
        return self.api_send(self.data["product_detail"])

    #商祥页-sku信息
    def sku_info(self, service_id, service_item_id):
        self.params["service_id"] = service_id
        self.params["service_item_id"] = service_item_id
        return self.api_send(self.data["sku_info"])

    # 品类聚合页面商品列表
    def tag_service(self, size, tag_ids, offset, tag_id, version, device_id):
        print("fgx")
        self.params['size'] = size
        self.params['tag_ids'] = tag_ids
        self.params['offset'] = offset
        self.params['tag_id'] = tag_id
        self.params['version'] = version
        self.params['device_id'] = device_id

        return self.api_send(self.data["tag_service"])

    # 品类聚合页面标签和专场
    def polymer(self, version, category_polymer_id, device_id):
        self.params['version'] = version
        self.params['category_polymer_id'] = category_polymer_id
        self.params['device_id'] = device_id

        return self.api_send(self.data["polymer"])


    # 次卡商详页
    def beauty_card_detail(self, spu_id, sku_id, welfareId, version, current_city_id, lat, lng ):
        self.params['spu_id'] = spu_id
        self.params['sku_id'] = sku_id
        self.params['welfareId'] = welfareId
        self.params['version'] = version
        self.params['current_city_id'] = current_city_id
        self.params['lat'] = lat
        self.params['lng'] = lng

        return self.api_send(self.data["beauty_card_detail"])

    # 次卡商详-适应机构列表
    def service_hospital(self, offset, sku_id, size, version, current_city_id, lat, lng):
        self.params['offset'] = offset
        self.params['sku_id'] = sku_id
        self.params['size'] = size
        self.params['version'] = version
        self.params['current_city_id'] = current_city_id
        self.params['lat'] = lat
        self.params['lng'] = lng

        return self.api_send(self.data["service_hospital"])

if __name__ == '__main__':
    #打印购物车-猜你喜欢列表接口返回
    print(janus_request().mine_guess_you_like())
    #打印商祥页-详情接口返回
    print(janus_request().product_detail("5857263", "618788", "7.43.0"))
    #打印商祥页-sku信息接口返回
    print(janus_request().sku_info("5857263", "618788"))

    # 次卡商详页-适应机构
    print(janus_request().beauty_card_detail("100018", "10046",  "100018", "7.44.0", "beijing", "40.001879", "116.487194"))
    # 次卡商详页
    print(janus_request().service_hospital("0", "10046",  "1", "7.44.0", "beijing", "40.001879", "116.487194"))

