增加登录日志埋点

This commit is contained in:
Waiting 2024-05-22 17:00:14 +08:00
parent 915ff6b184
commit d757f99b5d
9 changed files with 461 additions and 84 deletions

View File

@ -5,7 +5,8 @@ VITE_APP_TITLE='uniapp-vue3-project'
VITE_APP_ENV='development'
# 接口地址
VITE_APP_BASE_API='https://apidev.lakeapp.cn/'
#VITE_APP_BASE_API='https://apidev.lakeapp.cn/'
VITE_APP_BASE_API='https://api.lakeapp.cn/'
# 删除console
VITE_DROP_CONSOLE=false

View File

@ -1,12 +1,17 @@
<script setup lang='ts'>
<script lang='ts'>
import { mpUpdate, setCompanyId, setReferrerUserId, setRegisterStoreId } from '@/utils';
onLaunch(async (options) => {
const logManager = uni.getRealtimeLogManager();
const logger = logManager.tag('suke-mp');
export default {
onLaunch: async (options: any) => {
console.log('App Launch options ', options);
const miniProgram = uni.getAccountInfoSync().miniProgram;
const env = miniProgram.envVersion;
logger.info(`launch options ${env}: `, options);
//
if(env === 'release' || env === 'trial') {
async function getVersionStatus() {
@ -36,6 +41,11 @@ onLaunch(async (options) => {
// trial,develop
else {
// setCompanyId('1724629180555919361');
// setRegisterStoreId('1725026299888406529');
// setCompanyId('1471673498334113794');
// setRegisterStoreId('1471673498413805570');
setCompanyId('1150930317231112193');
setRegisterStoreId('1150930317436633090');
}
@ -87,17 +97,117 @@ onLaunch(async (options) => {
// #ifdef MP
mpUpdate();
// #endif
});
onShow(() => {
},
onShow: async () => {
console.log('App Show');
});
onHide(() => {
},
onHide: async () => {
console.log('App Hide');
});
},
// globalData : {
// test: '';
globalData: {
logger: logger
}
};
// onLaunch(async (options) => {
// console.log('App Launch options ', options);
// // globalData.logger.info('launch options : ', options);
//
// const miniProgram = uni.getAccountInfoSync().miniProgram;
// const env = miniProgram.envVersion;
//
// logger.info('launch options env : ', `${env} ${options}`);
// //
// if(env === 'release' || env === 'trial') {
// async function getVersionStatus() {
// return new Promise((resolve, reject) => {
// uni.request({
// url: 'https://api.lakeapp.cn/wechat/version_info',
// success(res) {
// console.log(res);
// resolve(res);
// },
// fail(exception) {
// reject(exception);
// }
// });
// }).then((res) => {
// const { version, audit } = res.data;
// // if(miniProgram.version === version && audit == 1) {
// if(audit == 1) {
// setCompanyId('1150930317231112193');
// setRegisterStoreId('1150930317436633090');
// }
// });
// }
//
// await getVersionStatus();
// }
//
// // trial,develop
// else {
// // setCompanyId('1724629180555919361');
// // setRegisterStoreId('1725026299888406529');
// setCompanyId('1471673498334113794');
// setRegisterStoreId('1471673498413805570');
// }
//
// if(options?.query) {
//
// // options.query.scene = 'companyId%3D1150930317231112193%26wxOpenId%3D111%26ticketId%3D123456%26storeId%3D1150930317436633090'
//
// //id
// if(options.query.referrerUserId) {
// setReferrerUserId(options.query.referrerUserId);
// }
//
// //id
// if(options.query.companyId) {
// setCompanyId(options.query.companyId);
// }
//
// //id
// if(options.query.storeId) {
// setRegisterStoreId(options.query.storeId);
// }
//
// if(options?.query.scene) {
// function getQueryParam(queryParams: string, key: string) {
// let regex = new RegExp('(?:[?&]|^)' + key + '=([^&]+)'),
// match = queryParams.match(regex);
// return match && match[1];
// }
//
// //id
// const params = decodeURIComponent(options?.query.scene);
// if(params.includes('companyId')) {
// setCompanyId(getQueryParam(params, 'companyId') || '');
// }
// if(params.includes('storeId')) {
// setRegisterStoreId(getQueryParam(params, 'storeId') || '');
// }
// if(options?.query.scene === 'edit_avatar_nickname') {
// setTimeout(() => {
// uni.reLaunch({
// url: '/pages/mine/subs/profile/index'
// });
// }, 500);
// }
// }
// }
//
// // #ifdef MP
// mpUpdate();
// // #endif
// });
// onShow(() => {
// console.log('App Show');
// });
// onHide(() => {
// console.log('App Hide');
// });
</script>
<style lang='scss'>

View File

@ -6,7 +6,10 @@
<view class='store-item' v-for='(item, index) in companyList' :key='index' @click='() => {
handleClick(index)
}'>
<view class='c-flex-row'>
<text>{{ item?.companyName || '' }}</text>
<image v-if='index===currentIndex' src='/static/images/ic_checkmark_red.png' />
</view>
</view>
</scroll-view>
<view class='close-btn primary-button' @click='close'>
@ -17,7 +20,7 @@
</template>
<script lang='ts' setup>
defineProps({
const props = defineProps({
companyList: {
type: Array,
default: () => []
@ -25,14 +28,19 @@ defineProps({
});
const popupRef = ref();
const currentIndex = ref(0);
let callback: Function;
const show = (fn: Function) => {
const show = (companyId: string, fn: Function) => {
if(companyId) {
currentIndex.value = props.companyList.findIndex(item => item.id === companyId);
}
callback = fn;
popupRef.value.open();
};
const handleClick = (index: number) => {
currentIndex.value = index;
callback(index);
close();
};
@ -68,6 +76,20 @@ defineExpose({
font-size: 35rpx;
color: #333333;
//padding: 20rpx 20rpx;
.c-flex-row {
text {
display: flex;
flex: 1;
}
image {
width: 30rpx;
height: 30rpx;
margin-right: 30rpx;
}
}
}
.store-item:after {
@ -81,6 +103,7 @@ defineExpose({
.close-btn {
background: #F5F5F5;
color: #333333;
justify-content: center;
}
}
</style>

View File

@ -50,6 +50,12 @@
},
{
"path": "register/index",
"style": {
"navigationBarTitleText": "用户注册"
}
},
{
"path": "register/reward",
"style": {
"navigationBarTitleText": "注册有礼"
}

View File

@ -0,0 +1,228 @@
<template>
<view class='content'>
<image class='bg-image' :src='assetsUrl("bg_register.png")' />
<image :src='assetsUrl("ic_register_gift_text.png")'
style='align-self: center;position: relative;width: 356rpx;height: 124rpx;margin-top: 70rpx' />
<view class='card-view'>
<view class='mobile-view c-flex-row' style='display: none'>
<image :src='assetsUrl("ic_register_mobile.png")' />
<input placeholder='请输入手机号' inputmode='number' maxLength='11' />
</view>
<view class='captcha-view c-flex-row' style='display: none'>
<view class='c-flex-row'>
<image :src='assetsUrl("ic_register_captcha.png")' />
<input placeholder='请输入验证码' inputmode='number' maxLength='6' />
</view>
<text @click.stop='startCountdown'>{{ countdown }}</text>
</view>
<text class='btn_register' style='display: none' @click.stop='register'>注册领券</text>
<image :src='companyConfigInfo.regqrcode||defaultImage' :show-menu-by-longpress='true' mode='aspectFill'
style='width: 439rpx;height: 439rpx;align-self: center' />
<text style='font-size: 26rpx;
margin-top: 10rpx;
align-self: center;color: #666666;'>长按扫码注册
</text>
<template v-if='couponBean&&couponBean.status==0'>
<view class='divider' />
<view class='coupon c-flex-column' @click.stop='goPath("/pages/mine/subs/coupon/index")'>
<view class='c-flex-row'>
<text class='coupon-name'>{{ couponBean.title }}</text>
<image :src='assetsUrl("ic_arrow_right_gray.png")' />
</view>
<text class='expired-time'>
有效期至{{ dayjs(Date.now()).add(couponBean.triggerEndDay, 'day').format('YYYY.MM.DD') }}
</text>
</view>
<view class='divider' />
<text style='font-size: 28rpx;
font-weight: bold;
color: #333333;margin-top: 20rpx'>福利详情
</text>
<text style='font-size: 28rpx;
color: #333333;margin-top: 14rpx'>1.优惠金额{{ couponBean.reduce }}\n
2.{{ couponBean.threshold }}{{ couponBean.reduce }}\n
3.赠送{{ couponBean.publicNum }}
</text>
</template>
<template v-else>
<text style='font-size: 28rpx;
font-weight: bold;
color: #333333;margin-top: 20rpx'>
微信扫一扫领取会员卡
</text>
<text style='font-size: 28rpx;
color: #333333;margin-top: 14rpx'>
1及时接受消费小票\n
2随时查询消费记录\n
3及时接收优惠信息
</text>
</template>
</view>
</view>
</template>
<script lang='ts' setup>
import { assetsUrl, defaultImage } from '@/utils/assets';
import { useUserStore } from '@/store';
import { goPath } from '@/utils';
import { getRegisterCoupon } from '@/api/user';
import dayjs from 'dayjs';
const userStore = useUserStore();
const { companyConfigInfo } = storeToRefs(userStore);
const countdown = ref('获取验证码');
const couponBean = ref();
onLoad(async (e) => {
couponBean.value = await getRegisterCoupon();
});
const startCountdown = () => {
if(countdown.value !== '获取验证码') {
return;
}
let time = 120;
let interval = setInterval(() => {
time--;
countdown.value = `${time}s 重新获取`;
if(time == 0) {
clearInterval(interval);
countdown.value = '获取验证码';
}
}, 1000);
};
const register = () => {
};
</script>
<style lang='scss' scoped>
.content {
position: relative;
height: 100vh;
}
.bg-image {
position: fixed;
height: 100vh;
width: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.card-view {
background: #FFFFFF;
border-radius: 10rpx;
margin: 0 40rpx;
padding: 50rpx;
top: 150rpx;
position: relative;
.mobile-view {
border-radius: 10rpx;
border: 1rpx solid #D8D8D8;
padding-left: 28rpx;
image {
width: 36rpx;
height: 36rpx;
}
input {
flex: 1;
height: 80rpx;
font-size: 30rpx;
color: #333333;
margin-left: 26rpx;
}
}
.captcha-view {
margin-top: 20rpx;
.c-flex-row {
border-radius: 10rpx;
border: 1rpx solid #D8D8D8;
padding-left: 28rpx;
flex: 1;
image {
width: 33rpx;
height: 26rpx;
}
input {
height: 80rpx;
font-size: 30rpx;
color: #333333;
margin-left: 26rpx;
}
}
text {
display: flex;
height: 80rpx;
background: #FFD436;
border-radius: 10rpx;
margin-left: 12rpx;
padding: 0 15rpx;
font-size: 28rpx;
align-items: center;
justify-content: center;
color: #FFFFFF;
}
}
.btn_register {
display: flex;
align-items: center;
justify-content: center;
height: 90rpx;
background: #F53636;
border-radius: 10rpx;
font-weight: 400;
font-size: 30rpx;
color: #FFFFFF;
margin-top: 46rpx;
}
.divider {
border-bottom-style: dashed;
border-color: #E98585;
border-width: 0.2rpx;
margin-top: 34rpx
}
.coupon {
margin-top: 30rpx;
.coupon-name {
display: flex;
font-size: 36rpx;
color: #D95554;
flex: 1;
}
image {
width: 13rpx;
height: 24rpx;
}
.expired-time {
font-size: 28rpx;
color: #333333;
margin-top: 2rpx;
}
}
}
</style>

View File

@ -85,7 +85,7 @@ const submenuList = [
{
title: '注册有礼',
icon: assetsUrl('ic_register_gift2.png'),
path: '/pages/common/register/index'
path: '/pages/common/register/reward'
},
{
title: '团购秒杀',
@ -139,7 +139,7 @@ onShow(async () => {
const switchCompany = () => {
fetchCompanyList((companyList: any[], userList: any[]) => {
companyDialogRef.value.show((index: number) => {
companyDialogRef.value.show(getCompanyId(),(index: number) => {
userStore.setUserInfo(userList[index]);
userStore.setCompanyInfo(companyList[index]);
});

View File

@ -4,6 +4,7 @@ import { getToken } from '@/utils/auth';
const loginPage = '/pages/common/login/index';
// 页面白名单
const whiteList = ['/', '/pages/common/login/index', '/pages/home/index','/pages/common/register/index',
'/pages/common/register/reward',
'/pages/mine/index','/pages/mine/subs/order/index'];
// 检查地址白名单

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -93,6 +93,7 @@ const useUserStore = defineStore('user', {
resetInfo() {
this.$reset();
},
// 获取用户信息
async getProfile() {
const result = await getUserProfile();
@ -103,6 +104,10 @@ const useUserStore = defineStore('user', {
this.companyConfigInfo = await getCompanyInfo();
},
checkUserRegisterStatus() {
},
userRegister(registerForm: RegisterParams) {
return new Promise(async (resolve, reject) => {
try {
@ -136,7 +141,7 @@ const useUserStore = defineStore('user', {
signature: wechatUserInfo?.signature,
iv: wechatUserInfo.iv
};
getApp().globalData?.logger.info('login params: ', userInfo);
const res = await login({
code: result.code,
userInfo: userInfo,
@ -144,6 +149,7 @@ const useUserStore = defineStore('user', {
// referrerUserId: '1727303781559697409'
// referrerUserId: getReferrerUserId()
});
getApp().globalData?.logger.info('login result: ', res);
if(res.user == undefined || res.user.id === null) {
const registerForm = {
@ -159,7 +165,9 @@ const useUserStore = defineStore('user', {
gender: res.user?.gender,
storeId: getRegisterStoreId()
};
getApp().globalData?.logger.info('register params: ', registerForm);
const registerResult = await this.userRegister(registerForm);
getApp().globalData?.logger.info('register result: ', registerResult);
if(registerResult != null) {
setToken(res.token);
await this.setUserInfo(registerResult as LoginResult);