From 2c25c92cec8640af46165383ecb24b5060bf7e52 Mon Sep 17 00:00:00 2001
From: wangwei <wangwei1>
Date: Wed, 26 Dec 2018 10:57:32 +0800
Subject: [PATCH] =?UTF-8?q?=E7=A5=9E=E7=AD=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/components/author.vue      |  6 ++++
 src/components/bindMobile.vue  |  3 ++
 src/components/buy/index.vue   |  8 +++++
 src/components/index.vue       | 39 ++++++++++++++++++++--
 src/components/map/index.vue   | 13 ++++++++
 src/components/mine.vue        |  6 ++++
 src/components/myGoodsList.vue |  6 ++++
 src/components/order.vue       |  6 ++++
 src/main.js                    | 24 ++++++-------
 src/router/index.js            | 61 ++++++++++++++++------------------
 10 files changed, 126 insertions(+), 46 deletions(-)

diff --git a/src/components/author.vue b/src/components/author.vue
index 82966e9f..e519f5a7 100644
--- a/src/components/author.vue
+++ b/src/components/author.vue
@@ -30,6 +30,12 @@ export default {
   },
   methods: {
     onPageReload: function () {
+      this.$sa.track('buttonClick',{
+        tabTitle:'授权',
+        moduleTitle:'授权',
+        buttonType:'重新授权',
+        buttonName:'重新授权'
+      });
       window.location.reload()
     }
   }
diff --git a/src/components/bindMobile.vue b/src/components/bindMobile.vue
index b9c70534..b2539e01 100644
--- a/src/components/bindMobile.vue
+++ b/src/components/bindMobile.vue
@@ -122,6 +122,8 @@
         }
         this.time=30;
         this.timeO();
+
+        this.$sa.track('clickSendcode',{});
         sendMobileCodeApi(json).then(res=>{
           if(res === '操作成功'){
             Toast('验证码已发送');
@@ -143,6 +145,7 @@
         }
       },
       bindMobile(){
+        this.$sa.track('clickSignUp',{});
         if(this.flag){
           this.flag = false;
           if(this.msgCode===''||!this.msgCode) {
diff --git a/src/components/buy/index.vue b/src/components/buy/index.vue
index c9aafea8..582e8a30 100644
--- a/src/components/buy/index.vue
+++ b/src/components/buy/index.vue
@@ -388,6 +388,14 @@
               });
             }
 
+            this.$sa.track('viewCourseDetail',{
+              courseID:this.groupDetail.id,
+              courseCate:this.groupDetail.course_type === 1 ? '体验课' : '正式课',
+              lessonNumber:this.groupDetail.watch_num,
+              courseTitle:this.groupDetail.name,
+              coursePrice:this.groupDetail.original_price/100,
+              discountPrice:this.groupDetail.current_price/100
+            });
             if(this.groupDetail.goods_type === 2){
               if(localStorage.getItem('cc_token')){
                 getStatusWechatApi({goods_id:this.shopId}).then(res=>{
diff --git a/src/components/index.vue b/src/components/index.vue
index c15e2a9d..810f73d2 100644
--- a/src/components/index.vue
+++ b/src/components/index.vue
@@ -3,7 +3,7 @@
     <div class="banner-block">
       <swiper :options="swiperOption" class="banner" ref="mySwiper">
         <swiper-slide v-for="(data,index) in bannerList"  :key="index">
-          <img class="banner" :src="data.url+'?imageslim'" @click="toBannerUrl(data.link)">
+          <img class="banner" :src="data.url+'?imageslim'" @click="toBannerUrl(data)">
         </swiper-slide>
       </swiper>
     </div>
@@ -116,16 +116,39 @@
     },
     methods:{
       toOld(e){
+        this.$sa.track('buttonClick',{
+          tabTitle:'首页',
+          moduleTitle:'功能按钮',
+          buttonType:'板块按钮',
+          buttonName:'晚安电台'
+        });
         // this.$sa.quick('trackHeatMap',e.srcElement)
         window.location.href = 'https://appanqlfkth3717.h5.xiaoeknow.com/content_page/eyJ0eXBlIjozLCJyZXNvdXJjZV90eXBlIjoiIiwicmVzb3VyY2VfaWQiOiIiLCJwcm9kdWN0X2lkIjoicF81YjE0YjdjMjdjNDZiX2Rvd0xicDc1IiwiYXBwX2lkIjoiYXBwYU5RTGZrdEgzNzE3In0?state=2f12ab00cbc58f98cdc8193c8151437f_Sc7T3q'
       },
       toBannerUrl(data){
-        window.location.href = data
+        this.$sa.track('adClick',{
+          adTitle:data.title,
+          adID:data.link,
+          adPage:'首页'
+        });
+        window.location.href = data.link
       },
       toHear(){
+        this.$sa.track('buttonClick',{
+          tabTitle:'首页',
+          moduleTitle:'功能按钮',
+          buttonType:'板块按钮',
+          buttonName:'磨耳朵'
+        });
         this.$router.push({name:'collection'})
       },
       toNewUrl(){
+        this.$sa.track('buttonClick',{
+          tabTitle:'首页',
+          moduleTitle:'课程',
+          buttonType:'没课banner',
+          buttonName:'没有更多课程'
+        });
         window.location.href = this.newUrl
       },
       initPage(){
@@ -160,6 +183,12 @@
         })
       },
       toGoodsList(){
+        this.$sa.track('buttonClick',{
+          tabTitle:'首页',
+          moduleTitle:'课程',
+          buttonType:'板块按钮',
+          buttonName:'我的课程'
+        });
         this.$router.push({name:'myGoodsList'})
       },
       dateParse(dateString){
@@ -188,6 +217,12 @@
         }
       },
      toMap(data) {
+       this.$sa.track('buttonClick',{
+         tabTitle:'首页',
+         moduleTitle:'课程',
+         buttonType:'课程',
+         buttonName:'进入课程'
+       });
         if(this.dateCompare(new Date(),this.dateParse(data.start_at))<1){
           this.$router.push({
             name: 'map',
diff --git a/src/components/map/index.vue b/src/components/map/index.vue
index 6e62c4eb..f34b68f7 100644
--- a/src/components/map/index.vue
+++ b/src/components/map/index.vue
@@ -317,6 +317,19 @@
       },
       // 切换主题
       changeCateGory(data,flag){
+        // 神策埋点
+        this.$sa.track('selectCategory',{
+          themeID:data.category_id,
+          themeName:data.category_name,
+          courseID:'',
+          courseCate:this.$route.query.course_type == 0 ? '正式课' : '体验课',
+          lessonNumber:'',
+          courseTitle:'',
+          periodID:'',
+          periodName:'',
+          teacherID:'',
+          teacherName:''
+        });
         if(!flag){
           this.parent_category_id = data.category_id;
           this.$router.push({name:'map',query:{periods_id:this.periods_id,course_type:this.shopType,parent_category_id: this.parent_category_id}});
diff --git a/src/components/mine.vue b/src/components/mine.vue
index 66f8add5..93265cfa 100644
--- a/src/components/mine.vue
+++ b/src/components/mine.vue
@@ -46,6 +46,12 @@
         })
       },
       clearBoth(){
+        this.$sa.track('buttonClick',{
+          tabTitle:'我的',
+          moduleTitle:'我的',
+          buttonType:'清楚缓存',
+          buttonName:'清楚缓存'
+        });
         localStorage.clear();
         Toast('清除成功')
 
diff --git a/src/components/myGoodsList.vue b/src/components/myGoodsList.vue
index f77f8928..b672a50f 100644
--- a/src/components/myGoodsList.vue
+++ b/src/components/myGoodsList.vue
@@ -59,6 +59,12 @@
         }
       },
       toMap(data){
+        this.$sa.track('buttonClick',{
+          tabTitle:'课程列表',
+          moduleTitle:'课程',
+          buttonType:'课程',
+          buttonName:'进入课程'
+        });
         if(this.dateCompare(new Date(),this.dateParse(data.start_at))<1) {
           this.$router.push({
             name: 'map',
diff --git a/src/components/order.vue b/src/components/order.vue
index c4b53dd6..298f7afd 100644
--- a/src/components/order.vue
+++ b/src/components/order.vue
@@ -80,6 +80,12 @@
         })
       },
       shareOrder(data){
+        this.$sa.track('buttonClick',{
+          tabTitle:'订单',
+          moduleTitle:'订单',
+          buttonType:'分享',
+          buttonName:'团购分享'
+        });
         this.showShare = true;
         let shareData = JSON.parse(data.share_desc);
         let that =this;
diff --git a/src/main.js b/src/main.js
index e7168385..a5ab2893 100644
--- a/src/main.js
+++ b/src/main.js
@@ -6,20 +6,20 @@ import router from './router'
 import store from './store'
 import MintUI from 'mint-ui'
 import VueClipboard from 'vue-clipboard2'
-// import sa from'sa-sdk-javascript';
+import sa from'sa-sdk-javascript';
 import 'mint-ui/lib/style.css'
 Vue.config.productionTip = false;
-// Vue.prototype.$sa = sa;
-// Vue.prototype.$sa.init({
-//   server_url: 'http://47.107.250.38:8106/sa?project=default', // 替换成自己的神策地址
-//   heatmap: {
-//     //是否开启点击图,默认 default 表示开启,自动采集 $WebClick 事件,可以设置 'not_collect' 表示关闭
-//     clickmap:'default',
-//     show_log: true, // 打印console,自己配置,可以看到自己是否踩点成功,以及
-//     //是否开启触达注意力图,默认 default 表示开启,自动采集 $WebStay 事件,可以设置 'not_collect' 表示关闭
-//     scroll_notice_map:'default',
-//   }
-// });
+Vue.prototype.$sa = sa;
+Vue.prototype.$sa.init({
+  server_url: 'http://47.107.250.38:8106/sa?project=default', // 替换成自己的神策地址
+  heatmap: {
+    //是否开启点击图,默认 default 表示开启,自动采集 $WebClick 事件,可以设置 'not_collect' 表示关闭
+    clickmap:'default',
+    show_log: true, // 打印console,自己配置,可以看到自己是否踩点成功,以及
+    //是否开启触达注意力图,默认 default 表示开启,自动采集 $WebStay 事件,可以设置 'not_collect' 表示关闭
+    scroll_notice_map:'default',
+  }
+});
 Vue.use(MintUI);
 Vue.use(VueClipboard);
 /* eslint-disable no-new */
diff --git a/src/router/index.js b/src/router/index.js
index 43c8c7d4..551dbd5e 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -5,6 +5,27 @@ import Router from 'vue-router'
 import sa from'sa-sdk-javascript';
 Vue.use(Router);
 
+let browser = {
+  versions: function () {
+    let u = navigator.userAgent, app = navigator.appVersion;
+
+    return {         //移动终端浏览器版本信息
+      trident: u.indexOf('Trident') > -1, //IE内核
+      presto: u.indexOf('Presto') > -1, //opera内核
+      webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
+      gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') === -1, //火狐内核
+      mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
+      ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
+      android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
+      iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
+      iPad: u.indexOf('iPad') > -1, //是否iPad
+      webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部
+    };
+  }(),
+
+  language: (navigator.browserLanguage || navigator.language).toLowerCase()
+};
+let ua = window.navigator.userAgent.toLowerCase();
 const router =new Router({
   routes: [
     {
@@ -162,47 +183,23 @@ const router =new Router({
 });
 
 router.beforeEach((to,from,next)=> {
-  // Vue.nextTick(() => {
-  //   sa.quick("autoTrackSinglePage");
-  // });
-  let ua = window.navigator.userAgent.toLowerCase();
+  // 神策路由埋点
+  Vue.nextTick(() => {
+    sa.quick("autoTrackSinglePage");
+  });
+  // 判断是否是微信环境 排除本地
   if(ua.match(/MicroMessenger/i) == 'micromessenger' || ua.match(/_SQ_/i) == '_sq_'){
     if(to.name == 'noWechat'){
       next({name:'index'});
     }
   }else{
-    if(to.name !== 'noWechat') {
+    if(to.name !== 'noWechat' && process.env.NODE_ENV === 'production') {
       next({name:'noWechat'});
     }
   }
-  let browser = {
-    versions: function () {
-      let u = navigator.userAgent, app = navigator.appVersion;
-
-      return {         //移动终端浏览器版本信息
-        trident: u.indexOf('Trident') > -1, //IE内核
-        presto: u.indexOf('Presto') > -1, //opera内核
-        webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
-        gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') === -1, //火狐内核
-        mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
-        ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
-        android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
-        iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
-        iPad: u.indexOf('iPad') > -1, //是否iPad
-        webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部
-      };
-    }(),
-
-    language: (navigator.browserLanguage || navigator.language).toLowerCase()
-  };
-  if (browser.versions.mobile) {//判断是否是移动设备打开。browser代码在下面
-    let ua = navigator.userAgent.toLowerCase();//获取判断用的对象
-    if (ua.match(/MicroMessenger/i) == "micromessenger") {
-
-    }else{
-    }
-  }
+  // 移动端判断
   store.dispatch('isMobile',browser.versions.mobile);
+  // 默认title
   document.title = '唱唱启蒙英语';
   let goOn=function(){
     if(localStorage.getItem('retUrl') && localStorage.getItem('retUrl') !== null && localStorage.getItem('retUrl') !== ''){
-- 
2.21.0