package com.danding.yang800.Presenter;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

import com.danding.yang800.Adapter.AfterServiceAdapter;
import com.danding.yang800.AfterServiceActivity;
import com.danding.yang800.Entity.AfterServiceInfo;
import com.danding.yang800.General.HttpCallBack;
import com.danding.yang800.Util.LogUtil;
import com.danding.yang800.Util.StringUtil;
import com.danding.yang800.Util.ToastUtil;
import com.danding.yang800.Util.VolleyUtil;
import com.danding.yang800.WriteLogisticsActivity;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.HashMap;

public class WriteLogisticsActivityPresenter {
    private WriteLogisticsActivity context;
    SharedPreferences sp;
    public WriteLogisticsActivityPresenter(WriteLogisticsActivity context) {
        sp = context.getSharedPreferences("variable", Context.MODE_PRIVATE);
        this.context = context;
    }


    public void submit( String id, String expName, String expNum) {
        if (expName.equals("")||expNum.equals("")){
            ToastUtil.show(context,"物流公司或物流单号不能为空！");
            return;
        }
        HashMap<String, String> map = new HashMap<>();
        map.put("id", id);
        map.put("expName", expName);
        map.put("expNum", expNum);
        LogUtil.d(expName+"expName"+expNum);
        new VolleyUtil(context).request(context, "xhr.SafterSale.delivery", true, map, new HttpCallBack() {
            @Override
            public void onSuccess(JSONObject json) {
                LogUtil.d(json.toString()+"asdasdsad");
                try {
                    ToastUtil.show(context,"提交成功");
                    Intent intent = new Intent();
                    context.setResult(0, intent);
                    context.finish();
                } catch (Exception e) {

                }


            }

            @Override
            public void onerrSuccess() {
            }

            @Override
            public void onCatch() {
            }

            @Override
            public void onFail() {
            }
        });
    }


}
