Prechádzať zdrojové kódy

合并master统计接口服务

Rorschach 6 rokov pred
rodič
commit
06627d3df6

+ 3 - 0
component/follow/follow.js

@@ -32,6 +32,9 @@ export const followInit = (that) => {
         followData: that.data.followData,
         followPageTotalNo: res.data.data.totalNo
       })
+      httpRequestApi.userIntoPage('pages/index/index','首页动态').success((res)=>{
+        
+      })
     });
   }
   that.getWorks(1, 5);

+ 3 - 0
component/group/group.js

@@ -74,6 +74,9 @@ export const groupInit = (that) => {
       that.setData({
         groupData: that.data.groupData
       })
+      httpRequestApi.userIntoPage('pages/index/index','首页热团').success((res)=>{
+        
+      })
     }).fail((error) => {
       console.log('错误', error)
     })

+ 3 - 0
component/hot/hot.js

@@ -108,6 +108,9 @@ export const hotInit = (that) => {
       let recommendIndex = 'hotData.recommend';
       that.setData({
         [recommendIndex]: recommendTemp
+      });
+      httpRequestApi.userIntoPage('pages/index/index','首页推荐').success((res)=>{
+        
       })
     })
   }

+ 18 - 0
component/share/share.js

@@ -123,6 +123,7 @@ Component({
           author: data.author,
           iconImg: data.iconImg,
           title: data.title,
+          productId: data.productId,
           // path: data.path,
           QRData: {
             page: data.path,
@@ -393,6 +394,23 @@ Component({
         filePath: this.data.imgUrls,
         success: (res) => {
           console.log(res)
+          const data = {};
+          console.log('productId',this.data.productId)
+          // 团购分享记录
+          if(this.data.shareType === 'group'){
+            data.shareTypeEnum = 'POSTER';
+            data.shareContentEnum = 'GROUP';
+            data.productId = this.data.groupPurchaseInfo.productId;
+          }
+          // 朗读分享记录
+          if(this.data.shareType === 'works'){
+            data.shareTypeEnum = 'POSTER';
+            data.shareContentEnum = 'READ';
+            data.productId = this.data.productId;
+          }
+          httpRequestApi.shareRecord(data).success((res)=>{
+            console.log(res)
+          })
           this.setData({
             imgUrls: false
           })

+ 9 - 21
pages/groupPage/collage-details/collage-details.js

@@ -172,32 +172,20 @@ Page({
     if (ops.from === 'button') {
       console.log(ops.target)
     }
-    // const productId = this.data.productId;
-    // const groupId = this.data.groupId;
+
     const id = this.data.orderId;
+    const data = {
+      shareTypeEnum: 'LINK',
+      shareContentEnum: 'GROUP',
+      productId: this.data.productId
+    }
+    httpRequestApi.shareRecord(data).success((res) => {
+      console.log(res)
+    })
     return {
       title: '老师同学都在玩的配音show,你还在等什么?',
       path: `pages/groupPage/group-details/group-details?share=true&shareId=${id}`,
       imageUrl: `https://efunbox.lingjiao.cn/reader/resource/share/group_${this.data.productId}.jpg`,
-      success: function (res) {
-        // 转发成功
-        console.log("转发成功:" + JSON.stringify(res));
-        var shareTickets = res.shareTickets;
-        // if (shareTickets.length == 0) {
-        //   return false;
-        // }
-        // //可以获取群组信息
-        // wx.getShareInfo({
-        //   shareTicket: shareTickets[0],
-        //   success: function (res) {
-        //     console.log(res)
-        //   }
-        // })
-      },
-      fail: function (res) {
-        // 转发失败
-        console.log("转发失败:" + JSON.stringify(res));
-      }
     }
   }
 })

+ 3 - 0
pages/groupPage/grade-details/grade-details.js

@@ -337,6 +337,9 @@ Page({
       this.setData({
         lessonList: lessonTemp
       });
+      httpRequestApi.userIntoPage('pages/groupPage/grade-details/grade-details','课本详情页面').success((res)=>{
+        
+      })
     })
   },
   getGroupInfo: function (productId) {

+ 27 - 1
pages/groupPage/group-details/group-details.js

@@ -240,6 +240,9 @@ Page({
       if (this.data.article === '') {
         this.getBooksInfo(res.data.data.groupPurchaseOrder.productId)
       }
+      httpRequestApi.userIntoPage('pages/groupPage/group-details/group-details','团购详情页面').success((res)=>{
+        
+      })
       if (groupOrder.groupType === 'PROMOTION') {
         this.setData({
           colonelName: res.data.data.organizer.wechatName,
@@ -294,13 +297,16 @@ Page({
    */
   onLoad: function (options) {
     console.log(this.data.isIOS)
+    this.setData({
+      options:options
+    })
     if (options.scene || options.shareId) {
       console.log(123)
       this.setData({
         isLoading: true
       })
     }
-
+    
     console.log('onload', options)
     wx.setNavigationBarTitle({
       title: '拼团详情'
@@ -327,6 +333,7 @@ Page({
 
       }
     }, (error) => {
+      
       this.setData({
         hide: !this.data.hide,
         onLoadOption: options
@@ -363,7 +370,26 @@ Page({
         haveJoinHelp: res.data.data.joinShare, // 参加过助力团
       })
     });
+      // 增加一条记录
+    const data = {
+      "shareTypeEnum": "POSTER",
+      "shareContentEnum": "GROUP",
+      "productId": productId
+    }
+    if (this.data.option.shareId) {
+      data.shareTypeEnum = 'LINK'
+      httpRequestApi.shareTagRecord(data).success(res => {
+        console.log(res)
+      })
+    }
+    if (this.data.option.scene) {
+      httpRequestApi.shareTagRecord(data).success(res => {
+        console.log(res)
+      })
+    }
   },
+
+
   // 下拉刷新
   onPullDownRefresh: function () {
     //当前在团购页下拉加载

+ 17 - 4
pages/index/index.js

@@ -3,7 +3,9 @@
 import {
   getOpenidSessionKey
 } from '../../utils/httpUtil';
-import {formatDate} from '../../utils/util';
+import {
+  formatDate
+} from '../../utils/util';
 
 const app = getApp()
 
@@ -61,8 +63,12 @@ Page({
     hotInput: '12345',
     mineSettingInfo: '528',
     hide: true,
+<<<<<<< HEAD
     isIOS:app.globalData.isIOS,
     ifHaveMore: true
+=======
+    isIOS: app.globalData.isIOS,
+>>>>>>> master
   },
   jurisdiction: function () {
     //隐藏弹框
@@ -76,7 +82,7 @@ Page({
   switcher: function ({
     currentTarget
   }) {
-    if(currentTarget.dataset.index === this.data.myIndex) return;
+    if (currentTarget.dataset.index === this.data.myIndex) return;
     this.updateData(currentTarget.dataset.index);
   },
   // 根据index 更新template
@@ -147,6 +153,7 @@ Page({
   init: function () {
     httputil.getOpenidSessionKey((res) => {
       console.log('微信的用户信息', res)
+      
     }, (error) => {
       console.log(error);
       this.jurisdiction()
@@ -161,6 +168,7 @@ Page({
     httpRequestApi.getUserWorksInfo().success(res => {
       this.data.myData.user = res.data.data;
       this.data.myData.user.user.birthday = this.data.myData.user.user.birthday ?  formatDate(res.data.data.user.birthday,3) : '2018年1月1日';
+      httpRequestApi.userIntoPage('pages/index/index', '首页我的').success((res) => {})
       if(this.data.myData.user.myRead){
         this.data.myData.user.myRead.gmtCreated = formatDate(this.data.myData.user.myRead.gmtCreated,4)
       }
@@ -209,12 +217,13 @@ Page({
     if (this.data.myIndex === 0) {
       groupInit(this);
     }
-    
+
     wx.showNavigationBarLoading() //在标题栏中显示加载
     //模拟加载
-    setTimeout(function(){
+    setTimeout(function () {
       wx.hideNavigationBarLoading() //完成停止加载
       wx.stopPullDownRefresh() //停止下拉刷新
+<<<<<<< HEAD
     },1500);
   },
   // 获取全部课本
@@ -252,5 +261,9 @@ Page({
     }
     
   },
+=======
+    }, 1500);
+  }
+>>>>>>> master
 
 })

+ 3 - 5
pages/main/class/class.js

@@ -58,11 +58,9 @@ Page({
     httpRequestApi.getClassDetail(this.uid, option.id).success(res => {
       console.log(res);
       const classId = this.data.id;
-      // let productId = 0
-      // httpRequestApi.checkLesson(classId).success(res => {
-      //    productId = res.data.data[0];
-      
-      // });
+      httpRequestApi.userIntoPage('pages/main/class/class','官方课程页面').success((res)=>{
+        
+      })
       this.setData({
         title: res.data.data.lesson.title,
         videoUrl: res.data.data.lesson.playUrl,

+ 7 - 1
pages/main/reading/reading.js

@@ -26,6 +26,7 @@ Page({
 
         const uid = wx.getStorageSync('uid')
         httpRequestApi.getClassDetail(uid, option.id).success(res => {
+            console.log(res)
             wx.setNavigationBarTitle({
                 title: res.data.data.title //页面标题为路由参数
             })
@@ -37,10 +38,14 @@ Page({
                 id: res.data.data.lesson.id,
                 // readingText: res.data.data.lessonText.replace(reg,'')
                 readingText: res.data.data.lesson.lessonText,
-                grade: res.data.data.lesson.gradeClassify
+                grade: res.data.data.lesson.gradeClassify,
+                productId: res.data.data.product.id
             })
             console.log(this.data.readingText)
             console.log(this.data.img)
+            httpRequestApi.userIntoPage('pages/main/reading/reading','朗读页面').success((res)=>{
+        
+            })
         })
 
         this.recorderManager = wx.getRecorderManager();
@@ -296,6 +301,7 @@ Page({
                 "title": this.data.title,
                 "iconImg": this.data.img,
                 "summary": this.data.grade,
+                productId: this.data.productId
             };
             httpRequestApi.postWork(uid, data).success(res => {
                 wx.hideLoading({

+ 4 - 1
pages/social/replyDetail/replyDetail.js

@@ -15,6 +15,7 @@ Page({
         console.log(option)
         this.setData({
             postId: option.id,
+            productId: option.productId
             // count: option.count === 'undefined' ? 0 : option.count
         })
         wx.setNavigationBarTitle({
@@ -31,15 +32,17 @@ Page({
       });
     },
     replyDone:function(){
+        console.log(this.data.productId)
       const data = {
         postsId: this.data.postId,
+        productId: this.data.productId,
         content: encodeURI(this.data.replyInfo)
       }
       if(this.data.replyInfo){
         httpRequestApi.postReplyComment(this.uid, data).success(res => {
           this.setData({
             replyModal: false,
-            replyInfo: ''
+            replyInfo: '',
           });
           this.getReplyDetail();//更新 变化后的 replyTemp。
         });

+ 33 - 8
pages/social/works/works.js

@@ -87,13 +87,23 @@ Page({
     },
     onHide: function () {
         // this.data.stackSize >= 2
-        console.log(this.data.stackSize)
+        
         if (this.innerAudioContext) {
             this.innerAudioContext.pause();
         }
         this.videoCtx = null
     },
     onUnload: function () {
+        const data = {
+            "title": this.data.title,
+            "lessonId": this.data.classId,
+            "productId": this.data.productId,
+            "playStopTime": this.videoPlayTime || 0,
+            "userReadId": this.data.userReadId
+        }
+        httpRequestApi.playLogReport(data).success(res =>{
+            console.log(res)
+        })
         if (this.innerAudioContext) {
             this.innerAudioContext.destroy();
         }
@@ -131,7 +141,8 @@ Page({
                 classId: works.lessonId,
                 isLike: res.data.data.isLike,
                 isFans: res.data.data.isFans,
-                title: works.title
+                title: works.title,
+                userReadId: works.id
             })
             httpRequestApi.checkLesson(works.lessonId).success(res => {
                 const productId = res.data.data[0];
@@ -207,6 +218,7 @@ Page({
                 title: this.data.title,
                 path: `pages/social/works/works`,
                 scene: this.data.id,
+                productId:this.data.productId
                 // tip: this.data.tip,
             }
             // console.log(data)
@@ -239,7 +251,9 @@ Page({
         });
     },
     // 视频播放完毕销毁录音
-    videoEnd: function () {
+    videoEnd: function (e) {
+        console.log(e)
+        
         this.innerAudioContext.stop();
     },
     videoPause: function () {
@@ -262,6 +276,7 @@ Page({
     videoTimeupdate: function (e) {
         console.log('视频播放进度发生变化')
         console.log('视频当前时长', e.detail.currentTime);
+        this.videoPlayTime = e.detail.currentTime
         console.log('音频当前时长', this.innerAudioContext.currentTime)
         if (e.detail.currentTime - this.innerAudioContext.currentTime >= 1) {
             this.innerAudioContext.seek(e.detail.currentTime - 0.1);
@@ -315,11 +330,18 @@ Page({
     },
     onShareAppMessage: function () {
         console.log(this.data.productId);
-
+        const data = {
+            shareTypeEnum: 'LINK',
+            shareContentEnum: 'READ',
+            productId: this.data.productId
+          }
+          httpRequestApi.shareRecord(data).success((res) => {
+            console.log(res)
+          })
         return {
             title: '一样的课文,不一样的味道!我的配音表演已开始,求各位大咖围观、点评!',
             path: `pages/social/works/works?id=${this.data.id}&title=${this.data.title}&shareCard=true`,
-            imageUrl: `https://efunbox.lingjiao.cn/reader/resource/share/read_${this.data.productId}.jpg`
+            imageUrl: `https://efunbox.lingjiao.cn/reader/resource/share/read_${this.data.productId}.jpg`,
         }
     },
     follow: function () {
@@ -424,7 +446,7 @@ Page({
         let id = e.currentTarget.dataset.id;
         // let count = e.currentTarget.dataset.count;
         wx.navigateTo({
-            url: `../../social/replyDetail/replyDetail?id=${id}`
+            url: `../../social/replyDetail/replyDetail?id=${id}&productId=${this.data.productId}`
         })
     },
     //  绑定输入框内容
@@ -435,13 +457,15 @@ Page({
     },
     // 发布回复
     sendHandler: function () {
+        console.log(this.data.productId)
         if (this.data.inputValue !== '') {
             // let uid = wx.getStorageSync('uid');
             let data = {
                 "columnId": this.data.id,
                 colunmNames: 'what',
                 // "detailDesc": encodeURI(this.data.inputValue)
-                "detailDesc": this.data.inputValue
+                "detailDesc": this.data.inputValue,
+                productId: this.data.productId
             }
             httpRequestApi.postReply(this.uid, data).success(res => {
                 this.setData({
@@ -480,7 +504,8 @@ Page({
     replySB: function () {
         const data = {
             postsId: this.data.replySBId,
-            content: this.data.inputSBValue
+            content: this.data.inputSBValue,
+            productId: this.data.productId
         }
         httpRequestApi.postReplyComment(this.uid, data).success(res => {
             const replyWho = this.data.replyList[this.data.replyIndex];

+ 3 - 0
pages/user/myEdit/myEdit.js

@@ -114,6 +114,9 @@ Page({
           title: option.title
         });
       }
+      httpRequestApi.userIntoPage('pages/user/myEdit/myEdit','修改资料页面').success((res)=>{
+        
+      })
     });
 
   },

+ 2 - 0
pages/user/myworks/myworks.js

@@ -56,6 +56,7 @@ Page({
     let uid = this.data.uid;
     console.log('用户身份',uid);
     APIClient.getUserMsg(uid, pageNo, pageSize).success(res => {
+      console.log(res)
       res.data.data.user.birthday = formatDate(res.data.data.user.birthday,4)
       this.setData({
         wareCards: res.data.data,
@@ -67,6 +68,7 @@ Page({
       console.log(err);
     });
     APIClient.userWorks(uid, pageNo, pageSize).success(res => {
+      console.log(res)
       this.setData({
         worksList: this.data.worksList.concat(res.data.data.list),
         totalNo: res.data.data.totalNo

+ 39 - 1
utils/APIClient.js

@@ -418,5 +418,43 @@ module.exports = {
     return request.getInstance().header({
       uid: wx.getStorageSync('uid')
     }).url(url).send();
-  }
+  },
+  // 分享记录
+  shareRecord(data) {
+    let url = getBaseUrl('wx/ShareStatistics/share');
+    return request.getInstance().header({
+      uid: wx.getStorageSync('uid')
+    }).data(data).url(url).method('POST').send();
+  },
+  // 由分享进入的记录
+  shareTagRecord(data) {
+    let url = getBaseUrl('wx/ShareStatistics/click');
+    return request.getInstance().header({
+      uid: wx.getStorageSync('uid')
+    }).data(data).url(url).method('POST').send();
+  },
+  // 用户登录记录
+  userLoginRecord() {
+    let url = getBaseUrl('wx/loginLog');
+    return request.getInstance().header({
+      uid: wx.getStorageSync('uid')
+    }).url(url).send();
+  },
+  // 用户进入页面统计
+  userIntoPage(action,actionName) {
+    let url = getBaseUrl('wx/userEvent');
+    return request.getInstance().header({
+      uid: wx.getStorageSync('uid')
+    }).data({
+      action,
+      actionName
+    }).url(url).method('POST').send();
+  },
+  // 用户播放视频时长统计
+  playLogReport(data) {
+    let url = getBaseUrl('base/playLog');
+    return request.getInstance().header({
+      uid: wx.getStorageSync('uid')
+    }).data(data).url(url).method('POST').send();
+  },
 }

+ 66 - 49
utils/httpUtil.js

@@ -1,12 +1,13 @@
 const request = require('./WXHttpRequest.js');
 const url = require('./const.js');
 const util = require('./util.js');
+const httpRequestApi = require('./APIClient');
 
 const HOST = url.baseApi;
 
 
 function genAPIUrl(action) {
-	return HOST + action;
+    return HOST + action;
 }
 
 // 登录
@@ -15,81 +16,97 @@ function wxLogin(successcallback, failcallback) {
         title: '登录中...',
         icon: 'loading',
         duration: 1500,
-        mask:true
+        mask: true
     })
-    wx.login({  
-        success: function(res) {
+    wx.login({
+        success: function (res) {
             if (res.code) {
                 // 获取openid
-                console.log(res)
-                 let url = genAPIUrl('wx/user/openId')
-                 let data = { code: res.code }
-                 return request.getInstance().url(url).data(data).send().success(successcallback).fail(failcallback);
+                console.log('openId', res.code)
+                let url = genAPIUrl('wx/user/openId')
+                let data = {
+                    code: res.code
+                }
+                return request.getInstance().url(url).data(data).send().success(successcallback).fail(failcallback);
             } else {
                 console.log('获取用户登录态失败!' + res.errMsg)
             }
         }
     })
 }
+
+function userLoginRecord(uid) {
+    if (wx.getStorageSync('uid')) {
+        console.log('调用方法')
+        let url = genAPIUrl('wx/loginLog');
+        return request.getInstance().header({
+            uid: wx.getStorageSync('uid')
+        }).method('POST').url(url).send().success(()=>{}).fail(()=>{});
+    }
+
+}
 //登录
 function getLoginSchedule(sessionKey, openId, successcallback, failcallback) {
     wx.getSetting({
-        success: function(res) {
+        success: function (res) {
             // 已经授权,可以直接调用 getUserInfo 获取头像昵称
             wx.getUserInfo({
                 withCredentials: true,
                 success: function (res) {
-                  let url = genAPIUrl('wx/user/loginRegist');
-                  const userData = {
-                      encryptedData: res.encryptedData,
-                      sessionKey: sessionKey,
-                      iv: res.iv
-                  }
-                  request.getInstance().url(url).header({
-                      "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
-                  }).data(userData).method('POST').send().success(res => {
-                      wx.hideToast()
-                      wx.showToast({
-                          title: '登录成功',
-                          icon: 'success',
-                          duration: 1500,
-                          mask: true
-                      })
-                      wx.setStorageSync('uid', res.data.data.data.uid)
-                      wx.setStorageSync('user', res.data.data.data)
-                      console.log(res)
-                      successcallback(res)
-                  });
+                    let url = genAPIUrl('wx/user/loginRegist');
+                    const userData = {
+                        encryptedData: res.encryptedData,
+                        sessionKey: sessionKey,
+                        iv: res.iv
+                    }
+                    request.getInstance().url(url).header({
+                        "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
+                    }).data(userData).method('POST').send().success(res => {
+                        wx.hideToast()
+                        wx.showToast({
+                            title: '登录成功',
+                            icon: 'success',
+                            duration: 1500,
+                            mask: true
+                        })
+                        wx.setStorageSync('uid', res.data.data.data.uid)
+                        wx.setStorageSync('user', res.data.data.data)
+                        userLoginRecord()
+                        successcallback(res)
+
+                    });
                 },
-                fail: function(res) {
+                fail: function (res) {
                     failcallback(res)
                 }
             })
-          } 
-      })
+        }
+    })
+
 }
+
 // 获取原来的 openid 和 session_key
 function getOpenidSessionKey(successcallback, failcallback) {
     if (wx.getStorageSync('user')) {
-      successcallback(
-        wx.getStorageSync('user'),
-        //分享小程序按钮
-        wx.showShareMenu({
-          withShareTicket: true
-        })
-      );
-      return;
+        successcallback(
+            wx.getStorageSync('user'),
+            //分享小程序按钮
+            wx.showShareMenu({
+                withShareTicket: true
+            })
+        );
+        return;
     }
-    wxLogin(function(res) {
-      if(res.data.code == 200){
-        let sessionKey = res.data.data.session_key;
-        let openId = res.data.data.openid;
-        getLoginSchedule(sessionKey, openId, successcallback, failcallback);
-      }
+    wxLogin(function (res) {
+        if (res.data.code == 200) {
+            let sessionKey = res.data.data.session_key;
+            let openId = res.data.data.openid;
+            getLoginSchedule(sessionKey, openId, successcallback, failcallback);
+        }
 
-    },function(res) {
+    }, function (res) {
         failcallback(res);
-    })    
+    })
 }