import store from '../store'
import sensors from "sa-sdk-javascript";
import {
  addRecord
} from '../api/index'

import sdk from './buriedPoint'

const loginClick = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "发起登录",
    channelKey: channelKey,
    eventType: '7',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickLogin");
  }

};

const loginSuccess = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "登录成功",
    channelKey: channelKey,
    eventType: '8',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.login(phone)
    sensors.track("loginSuccess");
  }
  if (store.state.global.js === 0) {
    if (store.state.global.point === 0) {
      VuePageVisitor.setMp(phone);
    }
  }



};

const showSP = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "商品浏览",
    channelKey: channelKey,
    eventType: '0',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("lookSp", {
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice,
    });
  }
};

const buyClick = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "点击订购",
      channelKey: channelKey,
      eventType: '1',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("clickBuy", {
        attr4: product.spid,
        attr5: product.productName,
        attr6: product.originalPrice,
      });
    }
    if (store.state.global.js === 0) {
      if (store.state.global.point === 0) {
        for (let i = 0; i < sdk.length; i++) {
          if (sdk[i].spid === product.spid) {
            WoAnalytics.addPoint({
              ad: sdk[i].appid,
              ett: "点击",
              ea: "点击订购"
            })
          }
        }
      }
    }
  }, 200)



}

const buySuccess = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "订购成功",
      channelKey: channelKey,
      eventType: '3',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("buySuccess", {
        attr4: product.spid,
        attr5: product.productName,
        attr6: product.originalPrice,
      });
    }
  }, 600)

}

const buyFail = (response) => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "订购失败",
    channelKey: channelKey,
    eventType: '4',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("buyFail", {
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice,
      attr7: response.message
    });
  }
}

const getToken = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "认证成功",
      channelKey: channelKey,
      eventType: '2',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("getToken", {
        attr4: product.spid,
        attr5: product.productName,
        attr6: product.originalPrice
      });
    }
  }, 400)

}

const unBuyClick = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "点击退订",
      channelKey: channelKey,
      eventType: '5',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("clickUnBuy", {
        attr4: product.spid,
        attr5: product.productName,
        attr6: product.originalPrice,
      });
    }
    if (store.state.global.js === 0) {
      if (store.state.global.point === 0) {
        for (let i = 0; i < sdk.length; i++) {
          if (sdk[i].spid === product.spid) {
            WoAnalytics.addPoint({
              ad: sdk[i].appid,
              ett: "点击",
              ea: "点击退订"
            })
          }
        }
      }
    }
  }, 400)



}

const unBuySuccess = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData

  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "退订成功",
      channelKey: channelKey,
      eventType: '6',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("unBuySuccess", {
        attr4: product.spid,
        attr5: product.productName,
        attr6: product.originalPrice,
      });
    }
  }, 400)

}

const unBuyFail = (response) => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "退订失败",
      channelKey: channelKey,
      eventType: '13',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("unBuyFail", {
        attr4: product.spid,
        attr5: product.productName,
        attr6: product.originalPrice,
        attr7: response.message
      });
    }
  }, 400)

}

const memberClick = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "会员领取",
      channelKey: channelKey,
      eventType: '9',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("memberReceive", {
        attr4: product.productName,
        attr5: product.spid
      });
    }
    if (store.state.global.js === 0) {
      if (store.state.global.point === 0) {
        for (let i = 0; i < sdk.length; i++) {
          if (sdk[i].spid === product.spid) {
            WoAnalytics.addPoint({
              ad: sdk[i].appid,
              ett: "点击",
              ea: "点击领取会员"
            })
          }
        }
      }
    }
  }, 400)

}

const memberSuccess = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "领取成功",
      channelKey: channelKey,
      eventType: '10',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("memberSuccess", {
        attr4: product.productName,
        attr5: product.spid
      });
    }
  }, 400)

}

const memberFail = (response) => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "领取失败",
      channelKey: channelKey,
      eventType: '11',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("memberFail", {
        attr4: product.productName,
        attr5: product.spid,
        attr6: response.message
      });
    }
  }, 400)

}

const clickBlindBox = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "点击盲盒",
    channelKey: channelKey,
    eventType: '12',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickBlindBox", {
      attr5: product.spid,
      attr4: product.productName,
    });
  }
}

const pageBrowseTime = () => {
  let time = localStorage.getItem('duration')
  let duration = time ? time : 0
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "页面浏览时长",
      channelKey: channelKey,
      eventType: '14',
      fromSource: fromSource,
      productId: product.id,
      duration: duration,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("pageStay", {
        attr4: product.spid,
        attr5: product.productName,
        attr6: product.originalPrice,
        attr7: duration,
      });
    }
    if (store.state.global.js === 0) {
      if (store.state.global.point === 0) {
        for (let i = 0; i < sdk.length; i++) {
          if (sdk[i].spid === product.spid) {
            WoAnalytics.addPoint({
              ad: sdk[i].appid,
              ett: "停留时常",
              ea: "页面浏览时长(首页)",
              dr: duration
            })
            WoAnalytics.addPoint({
              ad: sdk[i].appid,
              ett: "关闭",
              ea: "pageClose"
            })
          }
        }
      }
    }
  }, 400)



}
const clickBanner = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "点击banner",
      channelKey: channelKey,
      eventType: '15',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("clickBanner", {
        attr4: product.spid,
        attr5: product.productName,
        attr6: product.originalPrice
      });
    }
  }, 400)

}
const explainBrowseTime = () => {
  let time = localStorage.getItem('ruleTime')
  let ruleTime = time ? time : 0
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData

  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "产品说明浏览时长",
      channelKey: channelKey,
      eventType: '16',
      fromSource: fromSource,
      productId: product.id,
      duration: ruleTime,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("explainStay", {
        attr4: product.spid,
        attr5: product.productName,
        attr6: product.originalPrice,
        attr7: ruleTime,
      });
    }
    if (store.state.global.js === 0) {
      if (store.state.global.point === 0) {
        for (let i = 0; i < sdk.length; i++) {
          if (sdk[i].spid === product.spid) {
            WoAnalytics.addPoint({
              ad: sdk[i].appid,
              ett: "停留时常",
              ea: "页面浏览时长(产品说明页面)",
              dr: ruleTime
            })
          }
        }
      }
    }
  }, 400)
}
const clickOrderRecord = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "点击订购记录",
    channelKey: channelKey,
    eventType: '17',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("searchOrderRecord", {
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}
const clcikReceive = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "点击领取话费",
      channelKey: channelKey,
      eventType: '18',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("clickGivecharge", {
        attr4: product.spid,
        attr5: product.productName,
        attr6: product.originalPrice
      });
    }
  }, 400)

}
const clickFollow = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "点击关注公众号",
      channelKey: channelKey,
      eventType: '19',
      fromSource: fromSource,
      productId: product.id,
      anonymousId: anonymousId,
      testId: testId,
      testGroupId: testGroupId,
      tid: tid
    });
    if (store.state.global.sensors === 0) {
      sensors.track("clickFollow", {
        attr4: product.spid,
        attr5: product.productName,
        attr6: product.originalPrice
      });
    }
  }, 400)

}
const clickRecommend = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "点击推荐",
    channelKey: channelKey,
    eventType: '20',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickRecommend", {
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}
const clickUnsubscribe = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "点击确定",
    channelKey: channelKey,
    eventType: '21',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickUnsubscribe", {
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}
const clickUnsubscribeGo = () => {
  let {
    channelKey,
    userid,
    phone,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "点击去看看",
    channelKey: channelKey,
    eventType: '22',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickUnsubscribeGo", {
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}

//打开页面
const openPage = () => {
  let {
    phone,
    product,
  } = store.state.addrData
  if (store.state.global.js === 0) {
    if (store.state.global.point === 0) {
      if (phone) VuePageVisitor.setMp(phone);
      sdk.forEach(val => {
        if (product.spid === val.spid) {
          WoAnalytics.addPoint({
            ad: val.appid,
            ett: "打开",
            ea: "pageOpen"
          }).then(res => {
            localStorage.setItem('pageOpenTime', new Date())
          })
        }
      })
    }
  }
}

// 流量激活
const flowJihuo = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "点击流量激活",
    channelKey: channelKey,
    eventType: '23',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickTraffic",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}
// 一键拨号
const dialNumber = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "点击一键拨号",
    channelKey: channelKey,
    eventType: '24',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickDialing",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}

// 流量无法激活-点击试试解决
const jihuoSolve = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "流量无法激活-试试解决",
    channelKey: channelKey,
    eventType: '25',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("activateClick1",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}

// 流量无法激活-坚持退订
const jihuoUnbuy = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "流量无法激活-坚持退订",
    channelKey: channelKey,
    eventType: '26',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("activateClickinsist1",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}

// 会员无法领取-点击试试解决
const memberSolve = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "会员无法领取-试试解决",
    channelKey: channelKey,
    eventType: '27',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("activateClick2",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}

// 会员无法领取-坚持退订
const memberUnbuy = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "会员无法领取-坚持退订",
    channelKey: channelKey,
    eventType: '28',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("activateClickinsist2",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}

//退订原因 --点击最近不用客户端
const unbuyReason = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "退订原因-最近不用客户端",
    channelKey: channelKey,
    eventType: '29',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickRecentlyclient",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}

//退订原因 --点击流量用不完
const unbuyReason1 = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "退订原因-点击流量用不完",
    channelKey: channelKey,
    eventType: '29',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickTrafficup",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}
//退订原因 --点击价格太贵
const unbuyReason2 = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "退订原因-价格太贵",
    channelKey: channelKey,
    eventType: '30',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickPriceexpensive",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}
//退订原因 --点击误点误操作
const unbuyReason3 = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "退订原因-误点误操作",
    channelKey: channelKey,
    eventType: '31',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickMisoperation",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}

//退订原因 --点击其他
const unbuyReason4 = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "退订原因-其他",
    channelKey: channelKey,
    eventType: '32',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickOther",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}

//退订原因 --流量无法激活
const unbuyReason5 = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "退订原因-流量无法激活",
    channelKey: channelKey,
    eventType: '33',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickBeactivated",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}
//退订原因 --会员无法领取
const unbuyReason6 = () => {
  let {
    channelKey,
    userid,
    product,
    fromSource,
    testId,
    testGroupId,
    tid,
    anonymousId
  } = store.state.addrData
  addRecord({
    userid: userid,
    accessResource: "退订原因-会员无法领取",
    channelKey: channelKey,
    eventType: '34',
    fromSource: fromSource,
    productId: product.id,
    anonymousId: anonymousId,
    testId: testId,
    testGroupId: testGroupId,
    tid: tid
  });
  if (store.state.global.sensors === 0) {
    sensors.track("clickMemberreceive",{
      attr4: product.spid,
      attr5: product.productName,
      attr6: product.originalPrice
    });
  }
}

// 三选一会员领取页埋点
const memberPage = () => {
  let userid = localStorage.getItem('userid');
  let channelKey = process.env.VUE_APP_CHANNEL
  let anonymousId = sensors.store._state.$device_id
  setTimeout(() => {
    addRecord({
      userid: userid,
      accessResource: "浏览三选一会员领取页",
      channelKey: channelKey,
      eventType: '99',
      fromSource: '订购页',
      productId: 66,
      anonymousId: anonymousId,
      testId: '',
      testGroupId: '',
      tid: ''
    });
  }, 400)

}


export default {
  loginSuccess,
  showSP,
  loginClick,
  buyClick,
  buySuccess,
  buyFail,
  getToken,
  unBuyClick,
  unBuySuccess,
  unBuyFail,
  memberClick,
  memberSuccess,
  memberFail,
  clickBlindBox,
  pageBrowseTime,
  explainBrowseTime,
  clickBanner,
  clickOrderRecord,
  clcikReceive,
  clickFollow,
  clickRecommend,
  clickUnsubscribe,
  clickUnsubscribeGo,
  // closePage,
  openPage,
  flowJihuo,
  dialNumber,
  jihuoSolve,
  jihuoUnbuy,
  memberSolve,
  memberUnbuy,
  unbuyReason,
  unbuyReason1,
  unbuyReason2,
  unbuyReason3,
  unbuyReason4,
  unbuyReason5,
  unbuyReason6,
  memberPage
}