提交 0d2250b8 authored 作者: lhh's avatar lhh

埋点添加

上级 bf845e1e
......@@ -20,7 +20,6 @@
}
});
}
},
onShow: function() {
console.log('App Show')
......
......@@ -4,6 +4,9 @@ export function addCartItem(data) {
return request({
method: 'POST',
url: '/cart/add',
// header: {
// 'content-type': 'application/json;charset=utf-8'
// },
data: data
})
}
......
function jsonToQueryString(json) {
return Object.keys(json)
.map(key => encodeURIComponent(key) + '=' + encodeURIComponent(json[key]))
.join('&');
}
export function eventSite(params) {
var p = jsonToQueryString(Object.assign({
experiment_id: '7028276368903241728',
experiment_connection_id: '7201846824305426432',
}, params))
var xhr = new XMLHttpRequest();
xhr.open('GET', `https://saas-dml-pro.ezijing.com/api/lab/v1/experiment/member/event-create-by-shop?${p}`, true);
xhr.withCredentials = true;
xhr.send();
}
export function getCurrentTime() {
var currentTime = new Date();
var year = currentTime.getFullYear();
var month = currentTime.getMonth() + 1; // 月份从0开始,因此需要1
var day = currentTime.getDate();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
return `${year}-${toDo(month)}-${toDo(day)} ${toDo(hours)}:${toDo(minutes)}:${toDo(seconds)}`
}
function toDo(n) {
return n < 10 ? '0' + n : n
}
\ No newline at end of file
......@@ -37,3 +37,11 @@ export function fetchHotProductList(params) {
params:params
})
}
export function setEventSite(params) {
return request({
method: 'GET',
url: '/api/lab/v1/experiment/member/event-create-by-shop',
params:params
})
}
\ No newline at end of file
......@@ -11,7 +11,7 @@ export default class Request {
config = {
baseUrl: '',
header: {
'content-type': 'application/json;charset=UTF-8'
'content-type': 'application/json;charset=utf-8'
},
method: 'GET',
dataType: 'json',
......
......@@ -63,10 +63,11 @@
},
"h5" : {
"devServer" : {
"https" : false,
"port" : 8060
"https" : true,
"port" : 8060,
"host" : "dev.ezijing.com"
},
"domain" : "localhost",
// "domain" : "dev.ezijing.com",
"router" : {
"base" : ""
}
......
{
"name": "mall-app-web",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}
......@@ -145,7 +145,7 @@
<view class="f-header m-t">
<image src="/static/icon_recommend_product.png"></image>
<view class="tit-box">
<text class="tit">猜你喜欢</text>
<text class="tit" @click="handleEventSite()">猜你喜欢</text>
<text class="tit2">你喜欢的都在这里了</text>
</view>
<text class="yticon icon-you" v-show="false"></text>
......@@ -168,12 +168,14 @@
<script>
import {
fetchContent,
fetchRecommendProductList
fetchRecommendProductList,
setEventSite
} from '@/api/home.js';
import {
formatDate
} from '@/utils/date';
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
import { eventSite, getCurrentTime } from '../../api/event';
export default {
components: {
uniLoadMore
......@@ -199,6 +201,9 @@
loadingType:'more'
};
},
onShow() {
this.handleEventSite()
},
onLoad() {
this.loadData();
},
......@@ -254,6 +259,14 @@
},
},
methods: {
handleEventSite(name) {
eventSite({
event_english_name: 'enter_brand_homepage',
event_name: '进入品牌首页',
action_type: '首页',
entry_time: getCurrentTime(),
})
},
/**
* 加载数据
*/
......
......@@ -34,6 +34,7 @@
</template>
<script>
import { eventSite, getCurrentTime } from '../../api/event';
import {
fetchOrderDetail,
payOrderSuccess
......@@ -60,6 +61,16 @@
},
//确认支付
confirm: async function() {
eventSite({
event_english_name: 'payment',
event_name: '付款',
action_type: '付款',
product_name: this.orderInfo.orderItemList[0].productBrand,
product_id: this.orderInfo.orderItemList[0].id,
operation_time: getCurrentTime(),
payment_channel: this.payType != 1 ? '微信' : '支付宝',
payment_amount: this.orderInfo.payAmount
})
if(USE_ALIPAY){
if(this.payType!=1){
uni.showToast({
......
......@@ -124,6 +124,7 @@
</template>
<script>
import { eventSite, getCurrentTime } from '../../api/event';
import {
generateConfirmOrder,
generateOrder
......@@ -229,6 +230,16 @@
}
generateOrder(orderParam).then(response => {
let orderId = response.data.order.id;
eventSite({
event_english_name: 'place_order',
event_name: '提交订单',
product_name: this.cartPromotionItemList[0].productBrand,
product_id: this.cartPromotionItemList[0].id,
action_type: '提交订单',
operation_time: getCurrentTime(),
order_number: orderId,
order_amount: response.data.order.payAmount
})
uni.showModal({
title: '提示',
content: '订单创建成功,是否要立即支付?',
......
......@@ -37,15 +37,15 @@
<text class="price">{{item.payAmount}}</text>
</view>
<view class="action-box b-t" v-if="item.status == 0">
<button class="action-btn" @click="cancelOrder(item.id)">取消订单</button>
<button class="action-btn" @click="cancelOrder(item)">取消订单</button>
<button class="action-btn recom" @click="payOrder(item.id)">立即付款</button>
</view>
<view class="action-box b-t" v-if="item.status == 2">
<button class="action-btn" >查看物流</button>
<button class="action-btn recom" @click="receiveOrder(item.id)">确认收货</button>
<button class="action-btn recom" @click="receiveOrder(item)">确认收货</button>
</view>
<view class="action-box b-t" v-if="item.status == 3">
<button class="action-btn recom" >评价商品</button>
<button class="action-btn recom" @click="pjsp(item)">评价商品</button>
</view>
</view>
......@@ -58,6 +58,7 @@
</template>
<script>
import { eventSite, getCurrentTime } from '../../api/event';
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
import empty from "@/components/empty";
import {
......@@ -165,6 +166,17 @@
},
},
methods: {
pjsp(item) {
eventSite({
event_english_name: 'rate_the_product',
event_name: '评价商品',
action_type: '评价商品',
product_name: item.orderItemList[0].productBrand,
product_id: item.orderItemList[0].id,
operation_time: getCurrentTime(),
order_number: item.id,
})
},
//获取订单列表
loadData(type='refresh') {
if(type=='refresh'){
......@@ -229,17 +241,26 @@
});
},
//取消订单
cancelOrder(orderId) {
cancelOrder(order) {
let superThis = this;
uni.showModal({
title: '提示',
content: '是否要取消该订单?',
success: function (res) {
if (res.confirm) {
eventSite({
event_english_name: 'cancel_order',
event_name: '取消订单',
action_type: '取消订单',
product_name: order.orderItemList[0].productBrand,
product_id: order.orderItemList[0].id,
operation_time: getCurrentTime(),
order_number: order.id,
})
uni.showLoading({
title: '请稍后'
})
cancelUserOrder({orderId:orderId}).then(response=>{
cancelUserOrder({orderId:order.id}).then(response=>{
uni.hideLoading();
superThis.loadData();
});
......@@ -256,17 +277,26 @@
});
},
//确认收货
receiveOrder(orderId){
receiveOrder(order){
let superThis = this;
uni.showModal({
title: '提示',
content: '是否要确认收货?',
success: function (res) {
if (res.confirm) {
eventSite({
event_english_name: 'confirm_receipt',
event_name: '确认收货',
action_type: '确认收货',
product_name: order.orderItemList[0].productBrand,
product_id: order.orderItemList[0].id,
operation_time: getCurrentTime(),
order_number: order.id,
})
uni.showLoading({
title: '请稍后'
})
confirmReceiveOrder({orderId:orderId}).then(response=>{
confirmReceiveOrder({orderId:order.id}).then(response=>{
uni.hideLoading();
superThis.loadData();
});
......
......@@ -216,6 +216,7 @@
</template>
<script>
import { eventSite, getCurrentTime } from '../../api/event';
import share from '@/components/share';
import {
fetchProductDetail
......@@ -297,6 +298,8 @@
couponList: []
};
},
onShow() {
},
async onLoad(options) {
let id = options.id;
this.shareList = defaultShareList;
......@@ -338,6 +341,14 @@
this.initProductDesc();
this.handleReadHistory();
this.initProductCollection();
eventSite({
event_english_name: 'open_product_details',
product_name: this.product.brandName,
product_id: this.product.id,
event_name: '打开商品详情',
action_type: '打开商品详情',
operation_time: getCurrentTime(),
})
});
},
//规格弹窗开关
......@@ -452,6 +463,14 @@
});
this.favorite = !this.favorite;
});
eventSite({
event_english_name: 'favorite',
event_name: '收藏',
product_name: this.product.brandName,
product_id: this.product.id,
action_type: '收藏',
operation_time: getCurrentTime(),
})
}
},
buy() {
......@@ -641,6 +660,14 @@
if (!this.checkForLogin()) {
return;
}
eventSite({
event_english_name: 'add_to_cart',
product_name: this.product.brandName,
product_id: this.product.id,
event_name: '加入购物车',
action_type: '加入购物车',
operation_time: getCurrentTime(),
})
let productSkuStock = this.getSkuStock();
let cartItem = {
price: this.product.price,
......
......@@ -34,6 +34,7 @@
</template>
<script>
import { eventSite, getCurrentTime } from '../../api/event';
import {
mapMutations
} from 'vuex';
......@@ -53,14 +54,30 @@
this.password = uni.getStorageSync('password') || '';
},
methods: {
handleEventSite(type) {
window.localStorage.user_name = this.username
eventSite({
event_english_name: 'login_logout_register',
event_name: '登录退出注册',
user_id: new Date().getTime(),
user_name: this.username,
mobile_number: this.username,
action_type: type === 1 ? '登录' : '注册',
timestamp: getCurrentTime(),
})
},
...mapMutations(['login']),
navBack() {
uni.navigateBack();
},
toRegist() {
this.handleEventSite(2)
uni.navigateTo({url:'/pages/public/register'});
},
async toLogin() {
if (this.username !== '') {
this.handleEventSite(1)
}
this.logining = true;
memberLogin({
username: this.username,
......
......@@ -37,6 +37,7 @@
</template>
<script>
import { eventSite, getCurrentTime } from '../../api/event';
import {
mapMutations
} from 'vuex';
......@@ -47,6 +48,17 @@
};
},
methods:{
handleEventSite() {
eventSite({
event_english_name: 'login_logout_register',
event_name: '登录退出注册',
user_id: new Date().getTime(),
user_name: window.localStorage.user_name,
mobile_number: window.localStorage.user_name,
action_type: '退出登录',
timestamp: getCurrentTime(),
})
},
...mapMutations(['logout']),
navTo(url){
......@@ -62,6 +74,7 @@
},
//退出登录
toLogout(){
this.handleEventSite()
uni.showModal({
content: '确定要退出登录么',
success: (e)=>{
......
// appConfig.js
//配置API请求的基础路径
export const API_BASE_URL = 'https://portal-api.macrozheng.com'
export const API_BASE_URL = 'https://mall-portal.ezijing.com'
// export const API_BASE_URL = 'https://saas-dml-pro.ezijing.com'
// https://project-api.ezijing.com/api/passport/account/get-user-info
//是否启用支付宝支付
export const USE_ALIPAY = false
......@@ -6,8 +6,9 @@ const http = new Request()
http.setConfig((config) => { /* 设置全局配置 */
config.baseUrl = API_BASE_URL /* 根域名不同 */
config.header = {
...config.header
}
...config.header,
},
config.withCredentials = true
return config
})
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论