import path_setting
from in_common.base_request import BaseRequest


class janus_request(BaseRequest):
    def __init__(self):
        #捜索结果页-综合/百科tab
        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)

        #医生医院sug列表
        self.data = self.api_load(path_setting.KEYWORDTIP_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"])

    #商祥页-美券列表-我的美券点击-744版本及以后-新接口
    def product_coupon_my_list(self, start_num, tab_id):
        self.params["start_num"] = start_num
        self.params["tab_id"] = tab_id
        return self.api_send(self.data["product_coupon_my_list"])

    # 品类聚合页面商品列表
    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):
        print("fgx")
        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"])

    #医生医院sug列表
    def keyword_tip(self, query, lat, lng, version, device_id = '97B6764B-2135-4761-9911-701C38CBC272', tab_type = '0'):
        self.params['query'] = query
        self.params['lat'] = lat
        self.params['lng'] = lng
        self.params['version'] = version

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

    #次卡-确认订单
    def beauty_card_order_confirm(self, sku_id, number, use_bc_coupon, bc_coupon_id):
        self.params["sku_id"] = sku_id
        self.params["number"] = number
        self.params["use_bc_coupon"] = use_bc_coupon
        self.params["bc_coupon_id"] = bc_coupon_id
        return self.api_send(self.data["beauty_card_order_confirm"])

    #次卡-确认订单页面-修改手机号
    def beauty_card_update_phone(self, authorize_phone, authorize_phone_type, vfc_code):
        self.params["authorize_phone"] = authorize_phone
        self.params["authorize_phone_type"] = authorize_phone_type
        self.params["vfc_code"] = vfc_code
        return self.api_send(self.data["beauty_card_update_phone"])

    #次卡-提交订单
    def beauty_card_order_submit(self, phone, sku_id, number, is_doctor_see, gain_coupon_id, deduction_price):
        self.params["phone"] = phone
        self.params["sku_id"] = sku_id
        self.params["number"] = number
        self.params["is_doctor_see"] = is_doctor_see
        self.params["gain_coupon_id"] = gain_coupon_id
        self.params["deduction_price"] = deduction_price
        return self.api_send(self.data["beauty_card_order_submit"])

    #次卡-支付平台
    def beauty_card_payment_method(self, payment_id):
        self.params["payment_id"] = payment_id
        return self.api_send(self.data["beauty_card_payment_method"])

    #次卡-微信支付
    def beauty_card_prepay_wechat(self, payment_id):
        self.params["payment_id"] = payment_id
        return self.api_send(self.data["beauty_card_prepay_wechat"])

    #次卡-支付宝支付
    def beauty_card_prepay_alipay(self, is_huabei, payment_id):
        self.params["is_huabei"] = is_huabei
        self.params["payment_id"] = payment_id
        return self.api_send(self.data["beauty_card_prepay_alipay"])

    #次卡-订单详情
    def beauty_card_payment_detail(self, payment_id):
        self.params["payment_id"] = payment_id
        return self.api_send(self.data["beauty_card_payment_detail"])

    # 新版本我的美券列表
    def product_my_list(self,start_num,tab_id):
        self.params['start_num'] = start_num
        self.params['tab_id'] = tab_id
        return self.api_send(self.data['coupon_my_list'])


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"))
    #打印商祥页-美券列表-我的美券点击-744版本及以后-新接口返回
    print(janus_request().product_coupon_my_list(0, 0))

    #品类聚合页面商品列表接口返回
    print(janus_request().tag_service())
    print("fgx")

    #品类聚合页面标签和专场
    print(janus_request().polymer())
    print("fgx")

    #打印次卡-确认订单接口返回
    print(janus_request().beauty_card_order_confirm("10176", 1, 1, 0))
    #打印次卡-确认订单页面-修改手机号接口返回
    print(janus_request().beauty_card_update_phone("+8612348543876", 1, "084430"))
    #打印次卡-提交订单接口返回
    print(janus_request().beauty_card_order_submit("12345678912", "10176", 1, 1, 0, 0))
    #打印次卡-支付平台接口返回
    print(janus_request().beauty_card_payment_method("101670448736595"))
    #打印次卡-微信支付接口返回
    print(janus_request().beauty_card_prepay_wechat("101353630959868"))
    # 打印次卡-支付宝支付接口返回
    print(janus_request().beauty_card_prepay_alipay(0, "101353630959868"))
    #打印次卡 - 订单详情接口返回
    print(janus_request().beauty_card_payment_detail("101353630959868"))

    print(janus_request().product_my_list(0, 0))

