AlexZ33 / lessions

自己练习的各种demo和课程
12 stars 2 forks source link

二维码分享 #91

Open AlexZ33 opened 4 years ago

AlexZ33 commented 4 years ago

前端二维码生成f分享

AlexZ33 commented 4 years ago

关于打点

采用后端打点

module.exports = app => {
    return class QrcodeController extends app.Controller {
        async qrDownload() {
            const { ctx, logger} = this;
            const query = ctx.query;
            logger.info('Controller/qrcode/qrDownload:请求request: %s ', JSON.stringify(ctx.request));
            ctx.service.util.sendStatistic({
                data: JSON.stringify({
                    cur_page: 'qrcode_download', //页面
                    channel: query.c,
                    gameId: query.g,
                    package: query.p
                })
            })
            const userAgent = ctx.userAgent;
            if (userAgent.isiPhone || userAgent.isiPad || userAgent.isWeiXin) {
                return await ctx.render('tv/landing.js', {})
            }
            ctx.redirect(query.uri)
        }
    }
}

```javascript
  sendStatistic(para) {
            let uri = '打点地址';
            if (!para) {
             return;
            }
            let str = '',
            prop;
            for (prop in para) {
                if (hasOwnProperty.call(para, prop)) {
                    str += '&' + prop + '=' + para[prop];
                }
            }
            uri += str + '&_=' + (new Date()).getTime();
            return axios.get(uri)
        }