Authored by lea guo

yohood原价购

import md5 from './vendors/md5';
import {GET} from './libs/request';
import {WeToast} from './vendors/toast/wetoast';
import { GET } from './libs/request';
import { WeToast } from './vendors/toast/wetoast';
import objectAssign from './vendors/object-assign';
import {API_HOST, MINI_APP_TYPE} from './libs/config';
import { API_HOST, MINI_APP_TYPE } from './libs/config';
import mta from './vendors/mta_analysis';
import {Event} from '/login/utils/index.js';
import {wxLogin} from '/login/utils/login/login';
import { Event } from '/login/utils/index.js';
import { wxLogin } from '/login/utils/login/login';
import appReport from './libs/appReport';
import iconfSwitch from './libs/switch';
import {isStringEmpty, getYHStorageSync} from './utils/util';
import { isStringEmpty, getYHStorageSync } from './utils/util';
import regeneratorRuntime from '/login/libs/regenerator-runtime/index';
import {
... ... @@ -17,13 +17,13 @@ import {
YB_ENTER_FOREGROUND,
YB_ENTER_BACKGROUND,
YB_AWAKE_MP,
YB_MY_LOGIN
YB_MY_LOGIN,
} from './libs/yas';
import router from './pages/zeroSell/router/router';
const event = new Event();
global.event = event;
App({
async onLaunch(options) {
let that = this;
... ... @@ -41,51 +41,51 @@ App({
that.getSimplePise();
this.checkNetworkType();
if (options && options.scene){
this.globalData.ch = options.scene
if (options && options.scene) {
this.globalData.ch = options.scene;
}
if (options && options.query && options.query.union_type){
this.updateUnionType(options.query.union_type)
if (options && options.query && options.query.union_type) {
this.updateUnionType(options.query.union_type);
}
wx.checkSession({
success: function () {
success: function() {
that.getWechatThirdSession();
that.getUserInfo();
that.getUnionID();
that.getUser_union_type();
},
fail: function () {
fail: function() {
wx.setStorage({
key: 'WXThird_session',
data: ''
data: '',
});
wx.setStorage({
key: 'userInfo',
data: {}
data: {},
});
wx.setStorage({
key: 'unionID',
data: ''
data: '',
});
wx.setStorage({
key: 'user_union_type',
data: ''
data: '',
});
}
},
});
this.getSessionkey();
let timestamp = new Date().getTime() + '';
this.globalData.sid = md5(timestamp);
if (options){
if (options) {
let channel = options.query.channel;
let channelType = options.query.type;
let params = { 'CHANNEL': channel, 'TYPE': channelType };
yasReport(YB_LAUNCH_APP, params, this);
let params = { CHANNEL: channel, TYPE: channelType };
yasReport(YB_LAUNCH_APP, params, this);
}
this.mtainit(options);
await wxLogin();
... ... @@ -101,74 +101,86 @@ App({
logged(userInfo);
}
} else {
event.once('user-login-success', (userInfo) => {
yasReport(YB_MY_LOGIN, {LOGIN_TYPE: 4});
event.once('user-login-success', userInfo => {
yasReport(YB_MY_LOGIN, { LOGIN_TYPE: 4 });
if (loginSuccess) {
loginSuccess(userInfo);
}
});
wx.navigateTo({
url: '/login/login-page/login-page',
})
});
}
});
},
//当应用程序进入前台显示状态时触发
//当应用程序进入前台显示状态时触发
onShow(options) {
iconfSwitch(this).then(data => {
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> app onshow switch');
this.globalData.hasSetSwitch = true;
iconfSwitch(this).then(
data => {
console.log(
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> app onshow switch',
);
this.globalData.hasSetSwitch = true;
if (data['javaapi'] && '0' === data['javaapi']) {
this.globalData.switch_javaApiEnable = false;
}
}, () => {
this.globalData.hasSetSwitch = true;
});
let that = this
},
() => {
this.globalData.hasSetSwitch = true;
},
);
let that = this;
let params = {};
yasReport(YB_ENTER_FOREGROUND, params, that)
if (!that.globalData.hasReportAwakeAction){
let pathParam = ""
if(options && options.query) {
yasReport(YB_ENTER_FOREGROUND, params, that);
if (!that.globalData.hasReportAwakeAction) {
let pathParam = '';
if (options && options.query) {
for (var Key in options.query) {
if (pathParam.length == 0) {
pathParam = Key + '=' + options.query[Key] + '';
} else {
pathParam = pathParam + '&' + '' + Key + '=' + options.query[Key] + '';
pathParam =
pathParam + '&' + '' + Key + '=' + options.query[Key] + '';
}
}
}
let path = '';
if (options && options.path) {
path = options.path
path = options.path;
}
if(pathParam!==""){
path = path + "?" + pathParam
if (pathParam !== '') {
path = path + '?' + pathParam;
}
params = {
PAGE_PATH: path
PAGE_PATH: path,
};
yasReport(YB_AWAKE_MP, params, this);
that.globalData.hasReportAwakeAction = true;
}
if (options && options.scene){
appReport({
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'RESUME',
param: {
'activeWay': options.scene + ''
}
}, this);
}else{
appReport({
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'RESUME',
param: {}
}, this);
if (options && options.scene) {
appReport(
{
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'RESUME',
param: {
activeWay: options.scene + '',
},
},
this,
);
} else {
appReport(
{
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'RESUME',
param: {},
},
this,
);
}
let scene = options ? options.scene : '';
... ... @@ -176,19 +188,22 @@ App({
},
//当应用程序进入后台状态时触发
onHide () {
onHide() {
let params = {};
yasReport(YB_ENTER_BACKGROUND, params);
appReport({
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'STOP',
param: {}
}, this);
appReport(
{
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'STOP',
param: {},
},
this,
);
},
getUserInfo: function () {
var value = getYHStorageSync('userInfo','app')
getUserInfo: function() {
var value = getYHStorageSync('userInfo', 'app');
if (value) {
this.globalData.userInfo = value;
}
... ... @@ -199,126 +214,128 @@ App({
return this.globalData.userInfo.mobile;
},
getUser_union_type: function () {
getUser_union_type: function() {
this.getUnionTypeWithUid(this.getUid());
},
/*
*union_type表示渠道号,在推广阶段通过商品详情页等传入。
* 接收到该参数时,赋值给全局变量时,持久化到本地。
* 在取值时,先从全局变量获取,若未获取到则从本地缓存中获取。
* 时效48小时
*/
getUnion_type: function () {
*union_type表示渠道号,在推广阶段通过商品详情页等传入。
* 接收到该参数时,赋值给全局变量时,持久化到本地。
* 在取值时,先从全局变量获取,若未获取到则从本地缓存中获取。
* 时效48小时
*/
getUnion_type: function() {
try {
var value = this.checkUnion_type(this.globalData.union_type, this.globalData.union_type_time);
var value = this.checkUnion_type(
this.globalData.union_type,
this.globalData.union_type_time,
);
if (!value) {
let union_type = getYHStorageSync('union_type','app');
let union_type_time = getYHStorageSync('union_type_time','app');
value = this.checkUnion_type(union_type, union_type_time);
let union_type = getYHStorageSync('union_type', 'app');
let union_type_time = getYHStorageSync('union_type_time', 'app');
value = this.checkUnion_type(union_type, union_type_time);
}
return value
return value;
} catch (e) {
// console.log(e)
}
},
checkUnion_type: function (union_type, union_type_time) {
if (!union_type)return '';
checkUnion_type: function(union_type, union_type_time) {
if (!union_type) return '';
let time_old = union_type_time;
let time_new = new Date().getTime() + '';
var dayDiff = parseInt ((parseInt(time_new) - parseInt(time_old)) / 1000 );
var dayDiff = parseInt((parseInt(time_new) - parseInt(time_old)) / 1000);
if (dayDiff > 2 * 24 * 3600) {
return '';
}
return union_type;
},
getUnionID: function () {
var value = getYHStorageSync('unionID','app')
getUnionID: function() {
var value = getYHStorageSync('unionID', 'app');
if (value) {
this.globalData.WXUnion_ID = value;
}
},
getWechatThirdSession: function () {
getWechatThirdSession: function() {
try {
var that = this
var value = this.globalData.WXThird_session
var that = this;
var value = this.globalData.WXThird_session;
if (!isStringEmpty(value)) {
that.globalData.WXThird_session = value;
}else{
value = getYHStorageSync('WXThird_session','app')
} else {
value = getYHStorageSync('WXThird_session', 'app');
}
return value
return value;
} catch (e) {
// console.log(e)
}
},
setUserInfo: function (cb) {
setUserInfo: function(cb) {
this.globalData.userInfo = objectAssign(this.globalData.userInfo, cb);
wx.setStorage({
key: "userInfo",
data: this.globalData.userInfo
})
key: 'userInfo',
data: this.globalData.userInfo,
});
if (this.globalData.userInfo.uid) {
this.getUnionTypeWithUid(this.globalData.userInfo.uid);
}
},
setSessionkey: function (sessionkey) {
setSessionkey: function(sessionkey) {
this.globalData.sessionkey = sessionkey;
wx.setStorage({
key: "sessionkey",
data: this.globalData.sessionkey
})
key: 'sessionkey',
data: this.globalData.sessionkey,
});
},
setWechatThirdSession: function (session) {
setWechatThirdSession: function(session) {
this.globalData.WXThird_session = session;
wx.setStorage({
key: "WXThird_session",
data: this.globalData.WXThird_session
})
key: 'WXThird_session',
data: this.globalData.WXThird_session,
});
},
setWXUnionID: function (unionID) {
setWXUnionID: function(unionID) {
this.globalData.WXUnion_ID = unionID;
wx.setStorage({
key: "unionID",
data: unionID
})
key: 'unionID',
data: unionID,
});
},
setOpenID:function(openID){
if(openID=='') return
setOpenID: function(openID) {
if (openID == '') return;
this.globalData.openID = openID;
wx.setStorage({
key: "openID",
data: openID
})
},
getOpenID: function () {
let openid = ''
if (!isStringEmpty(this.globalData.openID)){
openid = this.globalData.openID
}else{
openid = getYHStorageSync('open_id','app')
this.globalData.openID = openid
key: 'openID',
data: openID,
});
},
getOpenID: function() {
let openid = '';
if (!isStringEmpty(this.globalData.openID)) {
openid = this.globalData.openID;
} else {
openid = getYHStorageSync('open_id', 'app');
this.globalData.openID = openid;
}
return openid
return openid;
},
updateUid: function (uid) {
updateUid: function(uid) {
this.getUserInfo();
this.globalData.userInfo.uid = uid;
wx.setStorage({
key: "userInfo",
data: this.globalData.userInfo
})
key: 'userInfo',
data: this.globalData.userInfo,
});
this.getUnionTypeWithUid(uid);
},
... ... @@ -330,88 +347,87 @@ App({
systemInfo: null,
WXThird_session: '',
WXUnion_ID: '',
openID:'',
openID: '',
p2SecretKey: '',
sessionkey: '',
sid: '',
udid:'',
cid:'1',
mobileRegisterState:'',
udid: '',
cid: '1',
mobileRegisterState: '',
hasReportAwakeAction: false,
defraudurl:'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒',
defraudurl: 'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒',
miniapp_type: MINI_APP_TYPE,
union_type:'',//渠道号,大数据上传用
union_type: '', //渠道号,大数据上传用
union_type_time: '',
ch:'',
networkType:'0',
deviceInfo:{},
ch: '',
networkType: '0',
deviceInfo: {},
currentScene: 1001,
user_union_type: '',//用户相关unionType 要与union_type区分开
user_union_type_imageUrl: '',//联盟图片
user_nounion_type_imageUrl:'',//非联盟用户分享banner图片
user_union_type: '', //用户相关unionType 要与union_type区分开
user_union_type_imageUrl: '', //联盟图片
user_nounion_type_imageUrl: '', //非联盟用户分享banner图片
shareId: '',
shareInfo: {},
},
isLogin: function () {
isLogin: function() {
let uid = this.getUid();
return uid > 0;
},
getUid: function () {
getUid: function() {
let uid = this.globalData.userInfo.uid;
if(!uid || uid === 0){
if (!uid || uid === 0) {
let userInfo = this.getUserInfo();
uid = userInfo.uid || 0
uid = userInfo.uid || 0;
}
return uid;
},
getMiniappType:function(){
return MINI_APP_TYPE
getMiniappType: function() {
return MINI_APP_TYPE;
},
//获取加签的秘钥
getSimplePise: function () {
let that = this
let data = {
"udid": that.globalData.udid,
"method": 'resources.simple.pice'}
let method = "GET"
getSimplePise: function() {
let that = this;
let data = {
udid: that.globalData.udid,
method: 'resources.simple.pice',
};
let method = 'GET';
let header = {
'Content-Type': 'application/x-www-form-urlencoded'
}
'Content-Type': 'application/x-www-form-urlencoded',
};
wx.request({
url:API_HOST,
url: API_HOST,
data,
method,
header: header,
success: function (res) {
success: function(res) {
// console.log("res:", res)
if (res && res.data && res.data.data && res.data.data.sk){
if (res && res.data && res.data.data && res.data.data.sk) {
that.globalData.p2SecretKey = res.data.data.sk;
wx.setStorage({
key: "p2SecretKey",
data: res.data.data.sk
key: 'p2SecretKey',
data: res.data.data.sk,
});
}
},
fail: function (err) {
}
fail: function(err) {},
});
},
/*
获取用户相关union_type
*/
getUnionTypeWithUid: function (uid) {
getUnionTypeWithUid: function(uid) {
if (!uid) return;
let param = {
method: 'app.union.shareOrder.queryUnionTypeByUid',
uid,
}
};
let that = this;
GET(API_HOST, param)
.then(data => {
... ... @@ -422,14 +438,13 @@ App({
that.globalData.user_nounion_type_imageUrl = data.data.applyImageUrl;
}
})
.catch(error => {
});
.catch(error => {});
},
getShareInfo: function () {
getShareInfo: function() {
let param = {
share_id: this.globalData.shareId,
}
};
let that = this;
GET(API_HOST + '/operations/api/v5/webshare/getShare', param)
.then(data => {
... ... @@ -437,35 +452,31 @@ App({
that.globalData.shareInfo = data.data;
}
})
.catch(error => {
});
.catch(error => {});
},
fastloginSwitch: function () {
let that = this
fastloginSwitch: function() {
let that = this;
let param = {
method: 'app.passport.fastloginSwitch',
};
GET(API_HOST, param)
.then(json => {
})
.catch(error => {
});
.then(json => {})
.catch(error => {});
},
checkUDID:function(){
let that = this
checkUDID: function() {
let that = this;
try {
var value = getYHStorageSync('udid','app')
var value = getYHStorageSync('udid', 'app');
if (value) {
that.globalData.udid = value;
}else{
} else {
let udidValue = md5(that.getUUID());
that.globalData.udid = udidValue;
try {
wx.setStorageSync('udid', udidValue)
} catch (e) {
}
wx.setStorageSync('udid', udidValue);
} catch (e) {}
}
//获取签名秘钥
} catch (e) {
... ... @@ -474,15 +485,15 @@ App({
}
},
checkNetworkType:function(){
checkNetworkType: function() {
let that = this;
let net = '';
wx.getNetworkType({
success: function (res) {
success: function(res) {
// 返回网络类型, 有效值:
// wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
var networkType = res.networkType
var networkType = res.networkType;
if (networkType === 'wifi') {
net = '1';
} else if (networkType === '2g') {
... ... @@ -495,30 +506,43 @@ App({
net = '0';
}
},
complete:function(res){
appReport({
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'START',
param: {}
}, that);
}
})
complete: function(res) {
appReport(
{
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'START',
param: {},
},
that,
);
},
});
that.globalData.networkType = net;
},
getUUID: function () {
let value = "" + Date.now() + '-' + Math.floor(1e7 * Math.random()) + '-' + Math.random().toString(16).replace('.', '') + '-' + String(Math.random() * 31242).replace('.', '').slice(0, 8);
getUUID: function() {
let value =
'' +
Date.now() +
'-' +
Math.floor(1e7 * Math.random()) +
'-' +
Math.random()
.toString(16)
.replace('.', '') +
'-' +
String(Math.random() * 31242)
.replace('.', '')
.slice(0, 8);
return value;
},
loginCallBack: function (response) {
},
loginCallBack: function(response) {},
getSessionkey: function () {
getSessionkey: function() {
if (this.isLogin) {
var value = getYHStorageSync('sessionkey','app');
var value = getYHStorageSync('sessionkey', 'app');
if (value) {
this.globalData.sessionkey = value;
}
... ... @@ -527,18 +551,18 @@ App({
},
//更新渠道号同时更新时间戳,48小时失效
updateUnionType: function (union_type) {
if (union_type){
updateUnionType: function(union_type) {
if (union_type) {
let timeS = new Date().getTime() + '';
this.globalData.union_type = union_type;
this.globalData.union_type_time = timeS;
wx.setStorage({
key: "union_type_time",
key: 'union_type_time',
data: timeS,
});
wx.setStorage({
key: "union_type",
data: union_type
key: 'union_type',
data: union_type,
});
}
},
... ... @@ -547,11 +571,9 @@ App({
},
mtainit() {
mta.App.init({
"appID": "500570715",
"eventID": "500570797",
appID: '500570715',
eventID: '500570797',
});
},
WeToast
WeToast,
});
... ...
... ... @@ -7,7 +7,7 @@
"pages/zeroSell/error",
"pages/bindPhoneNumber/bindPhoneNumber",
"pages/choosecountry/choosecountry",
"pages/zeroSell/originalPrice",
"pages/zeroSell/originalPriceSell",
"login/login-page/login-page"
],
"window": {
... ...
... ... @@ -15,6 +15,15 @@ Component({
type: String,
value: '查看活动说明',
},
title: {
type: String,
value: '活动说明',
obsever: function(title) {
this.setData({
title,
});
},
},
},
/**
... ...
... ... @@ -41,6 +41,10 @@ const ACTION_BAR_STATUS = {
let app = getApp();
/**
* YOHOOD 原价购 抽奖
*/
Page(
Object.assign(
{
... ...
... ... @@ -4,7 +4,7 @@
<view class="lottery-info">
<view class="flow-tile-wrap">
<text>活动流程</text>
<help text="活动规则"></help>
<help url="https://activity.yoho.cn/feature/5901.html" text="活动规则" title="原价购活动说明"></help>
</view>
<image class="jion-tips-image" src="./images/lottery_flow_tip 16@3x.png"></image>
</view>
... ...
... ... @@ -33,7 +33,7 @@
"list": []
},
"miniprogram": {
"current": 5,
"current": 6,
"list": [
{
"id": 0,
... ... @@ -80,7 +80,7 @@
{
"id": 6,
"name": "YOHOOD LOTTERY",
"pathName": "pages/zeroSell/originalPrice",
"pathName": "pages/zeroSell/originalPriceSell",
"query": "actPrizeId=224",
"scene": null
},
... ...