Authored by htoooth

add union type

... ... @@ -19,6 +19,8 @@ import {
stringify
} from './vendors/query-stringify';
import commonModel from './models/common';
let yas;
// app.js
... ... @@ -50,7 +52,10 @@ App({
}
this.globalData.systemInfo = sysInfo;
this.globalData.unionType = options.query.union_type || options.scene;
if (options && options.query && options.query.unionType) {
this.updateUnionType(options.query.unionType)
}
let timestamp = new Date().getTime() + '';
this.globalData.sid = MD5(timestamp);
... ... @@ -67,6 +72,7 @@ App({
this.getUserInfo();
this.getUnionID();
this.doLogin();
this.setUserUnionType(this.getUid());
}).catch(() => { // 微信登录过期
wx.setStorage({
key: 'thirdSession',
... ... @@ -81,6 +87,17 @@ App({
key: 'unionID',
data: ''
});
wx.setStorage({
key: "unionTypeTime",
data: '',
});
wx.setStorage({
key: "unionType",
data: ''
});
this.setUserInfo({});
this.setSessionKey('');
... ... @@ -205,6 +222,67 @@ App({
key: 'userInfo',
data: this.globalData.userInfo
});
this.setUserUnionType(this.globalData.userInfo.uid);
},
getUserUnionType() {
return this.globalData.userUnionType;
},
setUserUnionType(uid) {
if (!uid) {
return;
}
commonModel.getUnionTypeWithUid(uid).then(result => {
this.globalData.userUnionType = result.unionType;
});
},
updateUnionType(unionType) {
if (!unionType) {
return;
}
let timeS = new Date().getTime() + '';
this.globalData.unionType = unionType;
this.globalData.unionTypeTime = timeS;
wx.setStorage({
key: "unionTypeTime",
data: timeS,
});
wx.setStorage({
key: "unionType",
data: unionType
});
},
getUnionType() {
/*
*unionType表示渠道号,在推广阶段通过商品详情页等传入。
* 接收到该参数时,赋值给全局变量时,持久化到本地。
* 在取值时,先从全局变量获取,若未获取到则从本地缓存中获取。
* 时效7天
*/
try {
var value = this.checkUnionType(this.globalData.unionType, this.globalData.unionTypeTime);
if (!value) {
let unionType = wx.getStorageSync('unionType');
let unionTypeTime = wx.getStorageSync('unionTypeTime');
value = this.checkUnionType(unionType, unionTypeTime);
}
return value
} catch (e) {
// console.log(e)
}
},
checkUnionType(unionType, unionTypeTime) {
if (!unionType) return '';
let time_old = unionTypeTime;
let time_new = new Date().getTime() + '';
var dayDiff = parseInt((parseInt(time_new) - parseInt(time_old)) / 1000);
if (dayDiff > 7 * 24 * 3600) {
return '';
}
return unionType;
},
setSessionKey: function(sessionKey) {
this.globalData.sessionKey = sessionKey;
... ... @@ -278,4 +356,4 @@ App({
getMiniappType() {
return config.mini_app_type;
}
});
});
\ No newline at end of file
... ...
... ... @@ -12,7 +12,7 @@ export function getQRCodeSource(code) {
url: '/wechat/miniapp/getMiniAppRealParam',
data: param
}).then(data => {
if (data.code == 200) {
if (data.code === 200) {
if (data.data) {
return JSON.parse(data.data);
}
... ...
... ... @@ -13,4 +13,15 @@ export default {
}, params)
});
},
getUnionTypeWithUid(uid) {
let param = {
method: 'app.union.shareOrder.queryUnionTypeByUid',
uid,
}
return api.get({
data: param,
code: 200
});
}
};
... ...
... ... @@ -131,16 +131,16 @@ Page(Object.assign({
}]
},
},
onLoad: function(options) {
let limitProductCode = options.limitProductCode ? options.limitProductCode : '';
let originUid = parseInt(options.originUid ? options.originUid : '0', 10);
let originUnionID = options.originUnionID ? options.originUnionID : '';
onLoad: function(query) {
let limitProductCode = query.limitProductCode ? query.limitProductCode : '';
let originUid = parseInt(query.originUid ? query.originUid : '0', 10);
let originUnionID = query.originUnionID ? query.originUnionID : '';
let uid = app.getUid();
let scene = '';
if (options && options.scene && options.scene.length === 32) {
scene = options.scene;
if (query && query.scene && query.scene.length === 32) {
scene = query.scene;
}
this.setData({
... ... @@ -183,6 +183,10 @@ Page(Object.assign({
let originUid = parseInt(json.originUid ? json.originUid : '0', 10);
let originUnionID = json.originUnionID ? json.originUnionID : '';
if(json.unionType) {
app.updateUnionType(json.unionType);
}
this.setData({
limitProductCode,
originUid,
... ... @@ -217,7 +221,7 @@ Page(Object.assign({
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: `/pages/product/detail/detail?limitProductCode=${this.data.limitProductCode}&originUid=${app.getUid()}&originUnionID=${app.getUnionID()}`,
path: `/pages/product/detail/detail?limitProductCode=${this.data.limitProductCode}&originUid=${app.getUid()}&originUnionID=${app.getUnionID()}&unionType=${app.getUserUnionType()}`,
imageUrl: this.data.snapData.default_image,
success: function() {
},
... ... @@ -307,6 +311,7 @@ Page(Object.assign({
originUid: app.getUid(),
limitProductCode: this.data.limitProductCode,
originUnionID: app.getUnionID(),
unionType: app.getUserUnionType()
};
let product_qrCode = config.domains.api + `/wechat/miniapp/img-check.jpg?param=${JSON.stringify(params)}&miniapp_type=4&miniQrType=11`; // eslint-disable-line
... ...
... ... @@ -57,7 +57,8 @@ Page(Object.assign({
product_name: '',
product_qrCode: '',
product_skn: '',
limitProductCode: 0
limitProductCode: 0,
unionType: 0
},
test_uid: [349709, // 测试用
500030924,
... ... @@ -245,7 +246,7 @@ Page(Object.assign({
let path = `/pages/product/detail/detail?limitProductCode=${this.data.shareInfo.limitProductCode}`;
if (this.data.userInfo.isDrawline) {
path = `/pages/product/detail/detail?limitProductCode=${this.data.shareInfo.limitProductCode}&originUid=${app.getUid()}&originUnionID=${app.getUnionID()}`; // eslint-disable-line
path = `/pages/product/detail/detail?limitProductCode=${this.data.shareInfo.limitProductCode}&originUid=${app.getUid()}&originUnionID=${app.getUnionID()}&unionType=${app.getUserUnionType()}`; // eslint-disable-line
}
let params = {
FROM: res.from,
... ...
... ... @@ -32,7 +32,8 @@ Page(Object.assign({
product_name: '',
product_qrCode: '',
product_skn: '',
limitProductCode: ''
limitProductCode: '',
unionType: ''
},
bgStyle: [ // 排队图片
'../../static/images/limit/queue_bg_1.png',
... ... @@ -151,7 +152,7 @@ Page(Object.assign({
SHARE_RESUIL: 0,
TITLE: decodeURIComponent(this.data.shareInfo.product_name),
DESC: '我在有货限定频道发现一个不错的商品赶快来看看吧!',
PATH: `/pages/product/detail/detail?limitProductCode=${this.data.shareInfo.limitProductCode}&originUid=${app.getUid()}&originUnionID=${app.getUnionID()}`, // eslint-disable-line
PATH: `/pages/product/detail/detail?limitProductCode=${this.data.shareInfo.limitProductCode}&originUid=${app.getUid()}&originUnionID=${app.getUnionID()}&unionType=${app.getUserUnionType()}`, // eslint-disable-line
IMG: decodeURIComponent(this.data.shareInfo.default_image)
};
... ...
let app = getApp();
const windowWidth = app.globalData.systemInfo.windowWidth;
const windowHeight = app.globalData.systemInfo.windowHeight;
const rawScreenHeight = app.globalData.systemInfo.screenHeight;
let screenHeight = app.globalData.systemInfo.screenHeight;
const canvasWidth = 375;
... ... @@ -22,6 +23,7 @@ Page({
* 组件的初始数据
*/
data: {
rawScreenHeight,
screenHeight,
windowWidth,
windowHeight,
... ...
... ... @@ -43,7 +43,7 @@
</view>
</view>
<view class="snapshoot-canvas" style="width: {{windowWidth}}px;height:{{screenHeight}}px; background-color: white; margin-top: {{screenHeight}}px" >
<view class="snapshoot-canvas" style="width: {{windowWidth}}px;height:{{rawScreenHeight}}px; background-color: white; margin-top: {{rawScreenHeight}}px" >
<canvas canvas-id="productDetailCanvas" style="width: {{windowWidth}}px;height:{{screenHeight}}px;background-color: white"></canvas>
</view>
<!-- <view class="snapshoot-canvas" style="width: {{windowWidth}}px;height:{{screenHeight}}px; background-color: white; margin-top: {{-100}}px " >
... ...
... ... @@ -33,7 +33,7 @@
"list": []
},
"miniprogram": {
"current": 3,
"current": 7,
"list": [
{
"id": 0,
... ... @@ -91,7 +91,7 @@
"id": 7,
"name": "分享卡片进入小程序-好友助力-被分享者进入",
"pathName": "pages/product/detail/detail",
"query": "limitProductCode=2018062815591248&originUid=15075136",
"query": "limitProductCode=2018062815591248&originUid=15075136&unionType=108472",
"scene": "1037",
"referrerInfo": {
"appId": "wx084ab813d88c594b",
... ... @@ -144,13 +144,13 @@
"query": "scene=b26ea376ab62f4c11fdb8c6ce00dc85a",
"scene": "1012"
},
{
"id": 13,
"name": "webview",
"pathName": "pages/webview/webview",
"query": "url=http://ad.yoho.cn/html5/2018/question/index.html",
"scene": "1001"
}
{
"id": 13,
"name": "webview",
"pathName": "pages/webview/webview",
"query": "url=http://ad.yoho.cn/html5/2018/question/index.html",
"scene": "1001"
}
]
}
}
... ...