// 2 years ago
parent
commit
8fdb6a6301

+ 22 - 11
api/global.js

@@ -1,15 +1,26 @@
 import {
-    request
+  request
 } from "../utils/request";
 module.exports = {
-    //获取充值配置信息
-    getProducts: data => request('/v3/product', 'get', data),
-    // 购买vip
-    buyVip: data => request('/order', 'post', data, true),
-    // 购买次数
-    buyNum: data => request('/v3/pay', 'post', data),
-    // 获取任务配置
-    getTasks: data => request('/v3/task', 'get', data),
-    // 提交任务
-    submitTask: data => request('/v3/task', 'post', data),
+  //获取充值配置信息
+  getProducts: data => request('/v3/product', 'get', data),
+  // 购买vip
+  buyVip: data => request('/order', 'post', data, true),
+  // 购买次数
+  buyNum: data => request('/v3/pay', 'post', data),
+  // 获取任务配置
+  getTasks: data => request('/v3/task', 'get', data),
+  // 提交任务
+  submitTask: data => request('/v3/task', 'post', data),
+  // 行为记录接口
+  /* 
+    NEW_YEAR_ACTIVITY_BANNER("banner点击数"),
+    NEW_YEAR_ACTIVITY_CHOOSE_TEMPLATE("各模板选择数"),
+    NEW_YEAR_ACTIVITY_GENERATE_TEMPLATE("各模板生成的作品数"),
+    NEW_YEAR_ACTIVITY_SEND_BLESSING("发送祝福按钮点击数"),
+    NEW_YEAR_ACTIVITY_APP_LINK("小程序链接点开数"),
+    NEW_YEAR_ACTIVITY_SHARE("分享按钮点击数"),
+    NEW_YEAR_ACTIVITY_PLAY_TOO("我也要玩点击数"),
+  */
+  actionRecord: data => request('/userEvent/v2', 'post', data),
 }

+ 30 - 24
component/activityPop/index.js

@@ -1,30 +1,36 @@
 let app = getApp()
+import {
+  actionRecord
+} from '~/api/global'
 Component({
-    data: {
-        state: false
+  data: {
+    state: false
+  },
+  lifetimes: {
+    attached() {
+      let state = app.globalData.activityPop
+      if (this.data.state != state) {
+        this.setData({
+          state
+        })
+      }
     },
-    lifetimes: {
-        attached() {
-            let state = app.globalData.activityPop
-            if (this.data.state != state) {
-                this.setData({
-                    state
-                })
-            }
-        },
+  },
+  methods: {
+    close() {
+      getApp().globalData.activityPop = false;
+      this.setData({
+        state: false
+      })
     },
-    methods: {
-        close() {
-            getApp().globalData.activityPop = false;
-            this.setData({
-                state: false
-            })
-        },
-        jumpDet() {
-            this.close()
-            wx.navigateTo({
-                url: '/pages/activityList/index',
-            })
-        }
+    async jumpDet() {
+      await actionRecord({
+        action: 'NEW_YEAR_ACTIVITY_BANNER'
+      })
+      this.close()
+      wx.navigateTo({
+        url: '/pages/activityList/index',
+      })
     }
+  }
 })

+ 1 - 1
component/activityPop/index.less

@@ -11,7 +11,7 @@
     background-color: rgba(0, 0, 0, 0.46);
 
     .closeImg {
-        width: 52rpx;
+        width: 50rpx;
         height: 62rpx;
         margin-top: 250rpx;
         margin-left: 80%;

+ 1 - 1
component/activityPop/index.wxss

@@ -11,7 +11,7 @@
   background-color: rgba(0, 0, 0, 0.46);
 }
 .popBox .closeImg {
-  width: 52rpx;
+  width: 50rpx;
   height: 62rpx;
   margin-top: 250rpx;
   margin-left: 80%;

+ 29 - 2
pages/activityDet/index.js

@@ -3,6 +3,9 @@ import {
   getShareText,
   saveActivity
 } from '~/api/activity'
+import {
+  actionRecord
+} from '~/api/global'
 /*微信录音*/
 let recorderManager = wx.getRecorderManager();
 let dsq
@@ -57,7 +60,6 @@ Page({
     this.setData({
       configure,
       avatar: configure.photoText,
-      toWidth: '',
       fromWidth: configure.fromText.length * configure.fromFontSize,
       toWidth: configure.toText.length * configure.toFontSize,
       id: options.id,
@@ -65,6 +67,25 @@ Page({
       tens: configure.bgMusicLength[0],
       bits: configure.bgMusicLength[1]
     })
+    this.innerAudioContext = wx.createInnerAudioContext();
+    // 录音授权
+    wx.getSetting({
+      success(res) {
+        console.log(res);
+        if (!res.authSetting['scope.record']) {
+          wx.authorize({
+            scope: 'scope.record',
+            success() {
+              // 用户已经同意小程序使用录音功能,后续调用接口不会弹窗询问
+            }
+          })
+        }
+      }
+    })
+    await actionRecord({
+      action: 'NEW_YEAR_ACTIVITY_CHOOSE_TEMPLATE',
+      targetContent: options.id
+    })
   },
   async changeAvatar(e) {
     const {
@@ -78,7 +99,6 @@ Page({
   },
   play() {
     if (this.data.state == 'before') {
-      this.innerAudioContext = wx.createInnerAudioContext();
       this.innerAudioContext.src = this.data.configure.bgMusic; // 这里可以是录音的临时路径
       this.innerAudioContext.play();
       this.innerAudioContext.onEnded((res) => {
@@ -181,6 +201,10 @@ Page({
         greetingCard,
         uploadState: false
       })
+      await actionRecord({
+        action: 'NEW_YEAR_ACTIVITY_CHOOSE_TEMPLATE',
+        targetContent: this.data.id
+      })
     })
   },
   playUserAudio() {
@@ -295,6 +319,9 @@ Page({
     from,
   }) {
     if (from == 'button') {
+      actionRecord({
+        action: 'NEW_YEAR_ACTIVITY_SEND_BLESSING',
+      })
       const promise = new Promise(resolve => {
         this.createActivityImg().then(res => {
           resolve(res)

+ 18 - 5
pages/greeting/index.js

@@ -6,6 +6,9 @@ import {
   getShareText,
   playAudioEvent
 } from '~/api/activity'
+import {
+  actionRecord
+} from '~/api/global'
 Page({
   /**
    * 页面的初始数据
@@ -32,17 +35,20 @@ Page({
    */
   async onLoad(options) {
     console.log(options);
+    this.setData({
+      uid: wx.getStorageSync('uid')
+    })
     if (options.cardId) {
       let oneCard = await getOneActivity(options.cardId)
       this.setData({
         list: oneCard ? [oneCard] : [],
         userId: options.uid
       })
+      await actionRecord({
+        action: 'NEW_YEAR_ACTIVITY_APP_LINK',
+      })
     }
     this.getMyActivity()
-    this.setData({
-      uid: wx.getStorageSync('uid')
-    })
     this.innerAudioContext = wx.createInnerAudioContext();
     this.innerAudioContext.onTimeUpdate(() => {
       this.setDuration('playTime', this.innerAudioContext.currentTime)
@@ -64,7 +70,7 @@ Page({
       pageSize: 6
     })
     if (this.data.userId) {
-      let firstCard = this.data.list.length>0?this.data.list[0]:''
+      let firstCard = this.data.list.length > 0 ? this.data.list[0] : ''
       console.log(firstCard);
       list = list.filter(item => {
         return item.id != firstCard.id
@@ -72,6 +78,7 @@ Page({
     }
     list = [...this.data.list, ...list]
     let isMy = false
+    console.log(list);
     if (list.length > 0) {
       isMy = list[0].uid == wx.getStorageSync('uid')
     }
@@ -157,7 +164,10 @@ Page({
       [`list[${index}].likeAmount`]: ++this.data.list[index].likeAmount
     })
   },
-  jump() {
+  async jump() {
+    await actionRecord({
+      action: 'NEW_YEAR_ACTIVITY_PLAY_TOO',
+    })
     wx.navigateTo({
       url: '/pages/activityList/index',
     })
@@ -204,6 +214,9 @@ Page({
           resolve(res)
         })
       })
+      actionRecord({
+        action: 'NEW_YEAR_ACTIVITY_SHARE',
+      })
       return {
         title: '',
         path: `/pages/greeting/index?&uid=${wx.getStorageSync('uid')}`,