import fetch from 'isomorphic-fetch'
import getTaskList from './common'
import barcodeActionType from '../actiontype/barcodeCommon'

// const changeStatus = (data)=>{
      
//       let {taskId,currentTaskType}=data.taskInfo;
//       let url = `http://192.168.10.128:8080/web/flat/work/lr/status/${taskId}/${currentTaskType}`
//       return (dispatch)=>{
//             fetch(url,{
//                 credentials : 'include',
//                 method : 'PUT',
//                 mode : 'cors',
//                 body : {}
//             }).then((response)=>response.json())
//              .then((json)=>{
//                   if(json.data){
//                         getTaskList(data)
//                   }
//              })
//       }
// }


const changeTaskStatus = (data)=>{
      return {

      }
}

//test 输入条形码获取商品信息

const getBarCodeProductInfo = (data)=>{
      let {barcode,commonInfo}=data;
    //   let {taskInfo,storeInfo,userInfo}=commonInfo;
    //   let storeId=storeInfo.id;
    //   let {currentTaskType,taskId,area}=taskInfo;
      console.log(barcode,commonInfo,'这是吴加宝打印的数据')
      let url=`http://192.168.10.128:8080/web/flat/barcode/13/336/A/LR/${barcode}`
      return (dispatch)=>{
            fetch(url,{
                method : 'GET',
                mode : 'cors'
            }).then((response)=>response.json())
            .then((json)=>{
                if(json.meta.success&&json.data){
                    dispatch(saveProductInfo(json.data))
                }
            })

      }
}
const saveProductInfo = (data)=>{
      return{
          type : barcodeActionType.GETPRODUCTINFO,
          data
      }
  }

  export {getBarCodeProductInfo}