Authored by 李奇

Merge remote-tracking branch 'origin/master' into feature/store

# Conflicts:
#	src/app.js
#	src/pages/order/orderConfirm/orderConfirm.js
#	src/pages/orderDetail/index.js
#	src/pages/orderList/index.js
Showing 47 changed files with 1038 additions and 352 deletions
... ... @@ -3,6 +3,7 @@ import * as globalData from '../constants/globalData';
import {login as loginModel} from '../models';
import config from '../config';
import user from '../utils/user';
import event from '../utils/event';
export const setUdid = (udid) => {
udid = !udid ? user.getYHStorageSync('udid', 'app') : udid;
... ... @@ -93,7 +94,7 @@ export const getWechatThirdSession = () => {
// }));
// }
// })
// })
// })
// }
// }
... ... @@ -106,7 +107,7 @@ export const wechatUserIsBind = (unionID, nickName, userAvatarUrl) => {
nickname: nickName
}).then(ret => {
ret = ret && ret.data || {};
// 已绑定
if (ret.is_bind && ret.is_bind === 'Y') {
let userInfo = {
... ... @@ -122,7 +123,7 @@ export const wechatUserIsBind = (unionID, nickName, userAvatarUrl) => {
if (!getState().globalData.userInfo.avatarUrl){
dispatch(getUnionID(srd_session));
}
user.sendWeChatUserData(userInfo.uid,nickName,userAvatarUrl);
return resolve({
... ... @@ -151,7 +152,7 @@ export const getUnionID = (srd_session) => {
success: (res) => {
let userInfo = res.userInfo;
let nickName = userInfo.nickName;
//保存用户信息
dispatch(setUserInfo(userInfo));
// if (userInfo.uid) {
... ... @@ -179,7 +180,7 @@ export const getUnionID = (srd_session) => {
}
})
})
}
}
... ... @@ -206,7 +207,7 @@ export const wechatLogin = function() {
// dispatch(getUnionID(responseData.srd_session));
dispatch(setWxUnionId(responseData.unionid));
user.sendWeChatUserDataWithUnionId(responseData.unionid, getState().globalData.userInfo.nickName, getState().globalData.userInfo.avatarUrl)
dispatch(wechatUserIsBind(responseData.unionid, '', ''));
dispatch(wechatUserIsBind(responseData.unionid, '', ''));
}
}
})
... ... @@ -237,7 +238,7 @@ export const decodePhoneNumber = (iv, encryptedData, inviteCode) => {
}).then(ret => {
ret = ret && ret.data || {};
if (ret.phoneNumber !== '' && ret.countryCode != '') {
return dispatch(BindMiniAppByAuto(data.data.phoneNumber, data.data.countryCode, inviteCode));
return dispatch(BindMiniAppByAuto(data.data.phoneNumber, data.data.countryCode, inviteCode));
}
});
}
... ... @@ -255,7 +256,7 @@ export const BindMiniAppByAuto = (mobile, countryCode, inviteCode) => {
}
let globalData = getState().globalData;
let param = {
area: countryCode,
mobile: mobile,
... ... @@ -349,7 +350,7 @@ export const loginAndRegisterTapped = () => {
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
})
})
}
}
... ... @@ -362,7 +363,7 @@ export const decodeUnionId = (srd_session, result) => {
let res = result.detail;
let userInfo = res.userInfo;
let nickName = userInfo.nickName;
//保存用户信息
dispatch(setUserInfo(userInfo));
... ... @@ -471,6 +472,9 @@ export const bindAction = (phoneNumb, verifyCode, areaCode, inviteCode, callback
inviteCode
}).then(ret => {
if (ret && ret.code === 200 && ret.data && ret.data.uid > 0) {
if (ret.data.nFlag === 'Y') {
event.emit('report-new-user-created');
}
let userInfo = {
ssouid: ret.data.ssouid,
uid: ret.data.uid,
... ... @@ -511,6 +515,9 @@ export const bindAction = (phoneNumb, verifyCode, areaCode, inviteCode, callback
}).then(ret => {
Taro.hideToast()
if (ret.code === 200 && (ret.data.uid !== null) && ret.data.uid > 0 && ret.data.uid !== undefined) {//验证正确
if (ret.data.nFlag === 'Y') {
event.emit('report-new-user-created');
}
userInfo = {
ssouid: ret.data.ssouid,
uid: ret.data.uid,
... ... @@ -519,7 +526,7 @@ export const bindAction = (phoneNumb, verifyCode, areaCode, inviteCode, callback
session_key: ret.data.session_key,
...userInfo
}
dispatch(setSessionkey(ret.data.session_key));
dispatch(setUserInfo(userInfo));
... ...
... ... @@ -12,9 +12,15 @@ import { loginAction, checkUidAndSessionKey, getGlobalData } from './libs/login/
import { app_report } from './libs/services/appReport';
import {WeToast} from './vendors/toast/wetoast';
import {getYHStorageSync} from './utils/util'
import Yas from './utils/yas'
import Analytics from './reports/analytics.js'
global.analytics = new Analytics();
const store = createStore();
let yas;
@connect(({ globalData, user }) => ({
globalData
}), (dispatch) => {
... ... @@ -28,6 +34,7 @@ class App extends Component {
constructor(props) {
super(props)
this.WeToast = WeToast
this.hasAwaken = false;
// this.globalData = {
// userInfo: null,
// }
... ... @@ -115,6 +122,7 @@ class App extends Component {
};
componentWillMount () {
yas = new Yas(this);
wx.setStorageSync('show_bind', false);
let {setSystemInfo, wechatLogin, setSessionkey} = this.props;
let options = this.$router.params;
... ... @@ -127,6 +135,10 @@ class App extends Component {
ch: options.scene
}
this.props.globalData.systemInfo = systemInfo;
this.props.globalData.sid = sid;
this.props.globalData.ch = options.scene;
systemInfo.screenHeight = !systemInfo.screenHeight ? systemInfo.windowHeight : systemInfo.screenHeight;
systemInfo.screenWidth = !systemInfo.screenWidth ? systemInfo.windowWidth : systemInfo.screenWidth;
... ... @@ -148,7 +160,6 @@ class App extends Component {
Taro.setStorage({ key: 'unionid', data: '' });
Taro.setStorage({ key: 'user_union_type', data: '' });
}
console.log(result);
}).catch(error => {
console.log(error);
});
... ... @@ -175,6 +186,14 @@ class App extends Component {
console.log(error);
});
let loginReport = () => {
yas.report('YB_MY_LOGIN', {LOGIN_TYPE: 4});
};
event.one('report-new-user-created', () => {
yas.report('YB_REGISTER_SUCCESS', {LOGIN_TYPE: 5});
});
event.one('user-is-login', (loginedCallBack, loginSuccess) => {
let userInfo = Taro.getStorageSync('userInfo');
if (userInfo && userInfo.uid) {
... ... @@ -187,6 +206,7 @@ class App extends Component {
}
} else {
event.one('my-user-login-success', () => {
loginReport();
if (loginSuccess) {
loginSuccess();
}
... ... @@ -211,6 +231,7 @@ class App extends Component {
}
} else {
event.one('my-user-login-success', () => {
loginReport();
if (loginSuccess) {
loginSuccess();
}
... ... @@ -227,6 +248,7 @@ class App extends Component {
}
} else {
event.one('my-user-login-success', () => {
loginReport();
if (loginSuccess) {
loginSuccess();
}
... ... @@ -236,7 +258,6 @@ class App extends Component {
});
}
}
console.log(result);
}).catch(error => {
let userInfo = Taro.getStorageSync('userInfo');
if (userInfo && userInfo.uid && userInfo.session_key) {
... ... @@ -245,6 +266,7 @@ class App extends Component {
}
} else {
event.one('my-user-login-success', () => {
loginReport();
if (loginSuccess) {
loginSuccess();
}
... ... @@ -256,6 +278,7 @@ class App extends Component {
});
} else {
event.one('my-user-login-success', () => {
loginReport();
if (loginSuccess) {
loginSuccess();
}
... ... @@ -327,17 +350,52 @@ class App extends Component {
}
}
});
}
event.on('report-main-event', params => {
yas.report('YB_MAIN_EVENT', params);
});
yas.report('YB_LAUNCH_APP');
}
componentDidHide () {
app_report('start', "LIFECYCLE", "STOP", {}, this);
}
yas.report('YB_ENTER_BACKGROUND');
}
componentDidShow() {
let options = this.$router.params;
let activeWay = options && options.scene;
let par = activeWay ? { activeWay } : {}
let par = activeWay ? {activeWay} : {}
app_report('start', 'LIFECYCLE', 'RESUME', par, this);
yas.report('YB_ENTER_FOREGROUND');
if (!this.hasAwaken) {
let pathParam = '';
if (options && options.query) {
for (let Key in options.query) {
if (!pathParam.length) {
pathParam = Key + '=' + options.query[Key] + '';
} else {
pathParam = pathParam + '&' + '' + Key + '=' + options.query[Key] + '';
}
}
}
let path = '';
if (options && options.path) {
path = options.path;
}
if (pathParam !== '') {
path = path + '?' + pathParam;
}
const params = {
PAGE_PATH: path
};
this.hasAwaken = true;
yas.report('YB_AWAKE_MP', params);
}
}
componentCatchError () {}
... ...
... ... @@ -26,7 +26,7 @@ export default class filterMenu extends Component {
curOrder: ''
};
}
static defaultProps = {
tabs: [],
hasFilter: false,
... ... @@ -45,7 +45,7 @@ export default class filterMenu extends Component {
}
this.props.changeType(params);
}
onChangeTab(item) {
let {filterMenu, fromPage} = this.props;
let order = '';
... ... @@ -69,6 +69,7 @@ export default class filterMenu extends Component {
}
params.indexType = item;
params.curType = filterMenu.curType;
this.props.onSetCurrentTab && this.props.onSetCurrentTab(item);
}
this.props.changeType(params);
event.emit('reset-page-loading', { filterMenu: Object.assign(...filterMenu, params)});
... ... @@ -82,7 +83,7 @@ export default class filterMenu extends Component {
console.log('screen: ', screen);
if (screen && screen.query) {
screen.query = decodeURI(screen.query);
}
}
router.go('filter', {
...screen
});
... ... @@ -136,4 +137,4 @@ export default class filterMenu extends Component {
</View>
)
}
}
\ No newline at end of file
}
... ...
... ... @@ -12,12 +12,19 @@ export default class ProductList extends Component {
newList: []
};
}
static defaultProps = {
list: []
list: [],
report: ''
}
goToDetail(product) {
goToDetail(product, idx) {
let {onReport} = this.props;
if (onReport && typeof onReport === 'function') {
onReport(product, idx);
}
router.go('productDetail', {
id: product.id
});
... ... @@ -37,7 +44,7 @@ export default class ProductList extends Component {
newList.map((item, index) => {
return (
<View className= "product-item" key = { index }>
<View onClick={this.goToDetail.bind(this, item)} hover-class="none">
<View onClick={this.goToDetail.bind(this, item, index + 1)} hover-class="none">
<Text className="product-price">{item.price ? '¥' + item.price : ''}</Text>
<Image src={getImgUrl(item.default_images, 376, 376)} mode="aspectFit" className="product-img"/>
<Text className="product-name">{item.product_name}</Text>
... ... @@ -49,4 +56,4 @@ export default class ProductList extends Component {
</View>
)
}
}
\ No newline at end of file
}
... ...
... ... @@ -3,6 +3,7 @@ import { Swiper, SwiperItem, Image } from '@tarojs/components';
import {getImgUrl} from '../../utils';
import './index.scss';
import router from '../../router/index';
import event from '../../utils/event';
export default class Focus extends Component {
constructor(props) {
... ... @@ -12,7 +13,10 @@ export default class Focus extends Component {
}
static defaultProps = {
floor: []
floor: [],
floorId: 0,
floorName: '',
floorIdx: 0
}
componentWillMount() {}
... ... @@ -29,7 +33,22 @@ export default class Focus extends Component {
componentDidHide() {}
goToResource(item) {
goToResource(item, idx) {
const {
floorId,
floorName,
floorIdx
} = this.props;
const params = {
F_ID: floorId,
F_NAME: floorName,
F_INDEX: floorIdx,
F_URL: item.url,
I_INDEX: idx
};
event.emit('report-main-event', params);
router.goUrl(item.url);
}
... ... @@ -37,7 +56,7 @@ export default class Focus extends Component {
let {floor} = this.props;
return (
<View className='swiper-bg'>
<View className='swiper-bg'>
<Swiper
className='index-swiper'
>
... ... @@ -45,7 +64,7 @@ export default class Focus extends Component {
floor.map((item, index) => {
return (
<SwiperItem key={index}>
<Image onClick={this.goToResource.bind(this, item)} src={getImgUrl(item.src, 670, 280)} mode="aspectFill" />
<Image onClick={this.goToResource.bind(this, item, index + 1)} src={getImgUrl(item.src, 670, 280)} mode="aspectFill" />
</SwiperItem>
)
})
... ... @@ -55,4 +74,4 @@ export default class Focus extends Component {
</View>
)
}
}
\ No newline at end of file
}
... ...
... ... @@ -3,6 +3,7 @@ import {View, Text, ScrollView, Image} from '@tarojs/components';
import {getImgUrl} from '../../utils';
import './index.scss';
import router from '../../router/index';
import event from '../../utils/event';
export default class HotSeries extends Component {
constructor(props) {
... ... @@ -17,8 +18,23 @@ export default class HotSeries extends Component {
isShow: false
}
goToList(item) {
router.go('productList', {
goToList(item, idx) {
const {
floorId,
floorName,
floorIdx
} = this.props;
const params = {
F_ID: floorId,
F_NAME: floorName,
F_INDEX: floorIdx,
F_URL: `/pages/searchList/index?name=${item.series_name}&series=${item.series_id}`,
I_INDEX: idx
};
event.emit('report-main-event', params);
router.go('productList', {
series: item.series_id,
name: item.series_name
});
... ... @@ -39,10 +55,10 @@ export default class HotSeries extends Component {
upperThreshold='20'
>
{
floor.map(item => {
floor.map((item, index) => {
return (
<View className="item" key={item.series_id}>
<Image onClick={this.goToList.bind(this, item)} src={getImgUrl(item.image_url, 140, 140)} mode="aspectFill" className="item-img" />
<Image onClick={this.goToList.bind(this, item, index + 1)} src={getImgUrl(item.image_url, 140, 140)} mode="aspectFill" className="item-img" />
<View className="item-name">{item.series_name}</View>
</View>
)
... ...
... ... @@ -43,7 +43,7 @@ export default class Resources extends Component {
return (
<View className="resources">
{
floors.map(floor => {
floors.map((floor, idx) => {
return (
<View
className={
... ... @@ -52,14 +52,21 @@ export default class Resources extends Component {
key={floor.template_id}>
{
floor.template_name === 'focus' &&
<Focus floor={floor.data}></Focus>
<Focus floor={floor.data}
floorIdx={idx + 1}
floorName={floor.template_name}
floorId={floor.template_id}></Focus>
}
{
floor.template_name === 'hotSeries' &&
<HotSeries isShow={isShow} floor={floor.data} title={floor.template_intro}></HotSeries>
<HotSeries isShow={isShow} floor={floor.data}
floorIdx={idx + 1}
floorName={floor.template_name}
floorId={floor.template_id}
title={floor.template_intro}></HotSeries>
}
{
floor.template_name === 'category' && floor.data.length > 0 &&
floor.data.map((item, index) => {
return (
... ...
... ... @@ -52,7 +52,8 @@ export default class SelectSize extends Component {
}
productDetailModel.createPaymentinfo(this.state.selectedskup).then(data => {
if (data && data.code === 200) {
let {product_id} = this.props;
let {product_id, onConfirmSelect} = this.props;
onConfirmSelect && onConfirmSelect(this.state.selectedskup);
this.state.canBuy && Taro.navigateTo({
url: `/pages/order/orderConfirm/orderConfirm?skup=${this.state.selectedskup}&&product_id=${product_id}`,
})
... ... @@ -69,9 +70,9 @@ export default class SelectSize extends Component {
})
})
}
onTouchMove() {
}
render() {
... ... @@ -109,7 +110,7 @@ export default class SelectSize extends Component {
rightStyle = 'right-border'
} else if (index === sizeLength - 1) {
rightStyle = 'right-border'
}
}
return (
<View key={item.size_id} className={curSelect === item.size_id ? `actived ${sizeStyle}` : `${sizeStyle} ${topStyle} ${rightStyle}`} onClick={this.onChangeSize.bind(this, item)}>
<View className={item.storage_num > 0 ? 'size' : 'size gray'}>{item.size_name}</View>
... ...
... ... @@ -9,7 +9,8 @@ export default {
yohoApi: 'http://api-test3.dev.yohocorp.com',
yohoLogin: 'http://java-yoho-wechat.test3.ingress.dev.yohocorp.com',
activityHost: 'http://yoho-activity-platform.test3.ingress.dev.yohocorp.com',
reportHost: 'https://app.yoho.cn/collect/v3'
reportHost: 'https://app.yoho.cn/collect/v3',
yasHost: 'https://analysis.yohobuy.com/yas_mobile'
},
apiParams: {
client_type: 'miniapp',
... ... @@ -18,12 +19,12 @@ export default {
// miniapp_version: '0.0.1',
source_type: 'wechat',
user_source: 'wechat',
business_line: 'miniapp',
business_line: 'miniappUFO',
},
unionType: '', // 渠道号
// MINI_APP_DOMAIN: 'miniapp.yohobuy.com',
appid: appid,
business_line: 'miniapp', // 业务线
business_line: 'miniappUFO', // 业务线
mini_app_type: '63',
},
production: {
... ... @@ -33,7 +34,8 @@ export default {
yohoApi: 'https://api.yoho.cn',
yohoLogin: 'https://api.yoho.cn',
activityHost: 'https://action.yoho.cn',
reportHost: 'https://app.yoho.cn/collect/v3'
reportHost: 'https://app.yoho.cn/collect/v3',
yasHost: 'https://analysis.yohobuy.com/yas_mobile'
},
apiParams: {
client_type: 'miniapp',
... ... @@ -42,12 +44,12 @@ export default {
// miniapp_version: '1.0.0',
source_type: 'wechat',
user_source: 'wechat',
business_line: 'miniapp',
business_line: 'miniappUFO',
},
unionType: '', // 渠道号
// MINI_APP_DOMAIN: 'miniapp.yohobuy.com',
appid: appid,
business_line: 'yohobuy', // 业务线
business_line: 'miniappUFO', // 业务线
mini_app_type: '63',
}
}[process.env.NODE_ENV];
... ...
... ... @@ -9,6 +9,19 @@ const USER_LOGIN_SUCCESS = 'user-login-success';
const MY_USER_LOGIN_SUCCESS = 'my-user-login-success';
const USER_CHANGE_LOGIN_STATUS = 'change-login-status';
const reportAnalytics = (report_key, monitor_id, error) => {
try {
const analytics = global.analytics;
wx.reportMonitor(monitor_id, 1);
analytics.report(report_key, {
error: (error && error.message) || (error && error.errMsg),
monitor_id
});
} catch(err) {
console.error(err);
}
}
export const loginAction = (callBack, isReject) => {
return wx.login({
success(res) {
... ... @@ -24,11 +37,23 @@ export const loginAction = (callBack, isReject) => {
if (callBack) {
callBack(error);
}
const analytics = global.analytics;
reportAnalytics(analytics.keys.WX_LOGIN_ERROR, '0', error);
});
} else {
if (callBack) {
callBack(res);
}
const analytics = global.analytics;
reportAnalytics(analytics.keys.WX_LOGIN_ERROR, '0', res);
}
},
fail(error) {
callBack(error);
if (callBack) {
callBack(error);
}
const analytics = global.analytics;
reportAnalytics(analytics.keys.WX_LOGIN_ERROR, '0', error);
}
})
};
... ... @@ -83,8 +108,8 @@ export const decodeUnionId = (srd_session, result) => {
// 网络上传头像,union_id,昵称
login.sendWeChatUserDataWithUnionId(data.union_id, nickName, avatarUrl).catch(error => {
});
return {
union_id: union_id,
return {
union_id: union_id,
userInfo: res.userInfo
};
});
... ... @@ -158,11 +183,16 @@ export const wechatUserIsBind = (union_id, userInfo = {}) => {
});
} else {
console.log('login ------------ globalData: ', globalData);
const analytics = global.analytics;
reportAnalytics(analytics.keys.SIGNIN_BY_OPENID_ERROR, '3', { message: 'is_bind is N' });
return Promise.resolve({
code: 10004,
message: '微信用户未绑定手机号'
});
}
}).catch(error => {
const analytics = global.analytics;
reportAnalytics(analytics.keys.SIGNIN_BY_OPENID_ERROR, '3', error);
});
}
... ... @@ -185,7 +215,7 @@ const getStorageWithValueForKey = (key) => {
wx.getStorage({
key: key,
success: function(res) {
},
})
}
... ... @@ -222,8 +252,8 @@ export const getUserInfo = (e) => {
const fromPage = e.currentTarget.dataset.from;
if (e.detail.errMsg === 'getUserInfo:ok') {
loginAction((error, loginData) => {
if (error) {
event.emit(checkEventName(USER_GET_PHONENUMBER_ERROR, fromPage), error.message);
if (error) {
event.emit(checkEventName(USER_GET_PHONENUMBER_ERROR, fromPage), error.message || error.errMsg);
return;
}
console.log('loginData: ', loginData);
... ... @@ -260,6 +290,8 @@ export const getUserInfo = (e) => {
event.emit(checkEventName(USER_GET_PHONENUMBER_ERROR, fromPage), error.message);
});
}).catch(error => {
const analytics = global.analytics;
reportAnalytics(analytics.keys.DECODE_USERINFO_ERROR, '4', error);
event.emit(checkEventName(USER_LOGIN_CALLBACK, fromPage), error);
event.emit(checkEventName(USER_GET_PHONENUMBER_ERROR, fromPage), error.message);
});
... ... @@ -291,6 +323,8 @@ export const getUserInfo = (e) => {
}
event.emit(checkEventName(USER_LOGIN_CALLBACK, fromPage), message);
}).catch(error => {
const analytics = global.analytics;
reportAnalytics(analytics.keys.GET_USER_INFO_ERROR, '1', error);
event.emit(checkEventName(USER_LOGIN_CALLBACK, fromPage), error);
event.emit(checkEventName(USER_GET_PHONENUMBER_ERROR, fromPage), error.message);
});
... ... @@ -298,10 +332,12 @@ export const getUserInfo = (e) => {
}, true);
} else {
loginAction((error, loginAction) => {
let errMsg = error.message;
let errMsg = e.detail.errMsg;
if (e.detail.errMsg === 'getUserInfo:fail auth deny') {
errMsg = '获取用户授权失败,请使用手机号登录';
}
const analytics = global.analytics;
reportAnalytics(analytics.keys.GET_USER_INFO_ERROR, '1', e.detail);
event.emit(checkEventName(USER_GET_PHONENUMBER_ERROR, fromPage), errMsg);
}, false);
}
... ... @@ -324,6 +360,9 @@ export const getPhoneNumber = (e) => {
}
throw new Error('手机号获取失败,请重新获取');
}).then(result => {
if(result.nFlag === 'Y') {
event.emit('report-new-user-created');
}
if (result.is_register !== undefined && result.is_register === 0) {
const newUserInfo = {
is_bind: result.is_bind,
... ... @@ -372,8 +411,12 @@ export const getPhoneNumber = (e) => {
}
}).catch(error => {
event.emit(checkEventName(USER_GET_PHONENUMBER_ERROR, fromPage), error.message);
const analytics = global.analytics;
reportAnalytics(analytics.keys.DECODE_USERINFO_ERROR, '5', error);
});
} else {
const analytics = global.analytics;
reportAnalytics(analytics.keys.GET_PHONENUMBER_ERROR, '2', e.detail);
event.emit(checkEventName(USER_GET_PHONENUMBER_ERROR, fromPage), e.detail.errMsg);
}
}
... ... @@ -414,4 +457,4 @@ const getStorageUserInfo = () => {
export const getCountryArea = () => {
return login.getCountryArea();
}
\ No newline at end of file
}
... ...
import Taro from '@tarojs/taro';
import getPrivateKey from './getPrivateKey'
import config from '../../config.js'
import trimObject from './utils/trimObject.js'
... ... @@ -5,7 +6,6 @@ import queryString from './utils/query-string/query-string.js'
const crypto = require('./utils/cryptojs/cryptojs.js');
import MD5 from './utils/md5/md5.js'
import udid from './utils/udid.js'
const request = (methods = 'GET') => {
return async (options = {}) => {
try {
... ... @@ -150,8 +150,36 @@ const sendRequest = (resolve, reject, options) => {
method: options.methods,
success: function(res) {
const statusCode = res.statusCode;
const errMsg = res.errMsg;
const errMsg = res.message;
const data = res.data;
// 活动平台限流
if(res.statusCode === 503 && url.indexOf(config.domains.activityHost) > -1) {
Taro.showToast({
title: '目前参与人数过多请下拉刷新',
icon: 'none',
duration: 2000
});
return reject({ code: 503, message: '目前参与人数过多请下拉刷新' });
}
if (res.statusCode === 401) {
try {
const analytics = global.analytics;
wx.reportMonitor('6', 1);
let param = {
method: resultParams.method || '',
path: options.path || ''
}
analytics.report(analytics.keys.REQUEST_401_ERROR, {
error: `reqeust 401: ${JSON.stringify(param)} `,
monitor_id: '6',
info: {
uid: resultParams && resultParams.uid,
}
});
} catch(error) { console.error(error) }
}
if (resultParams.method === 'app.passport.verify') {
resolve(res);
} else {
... ... @@ -167,6 +195,16 @@ const sendRequest = (resolve, reject, options) => {
fail: function (err) {
const code = err.code ? err.code : 800;
const message = err.message ? err.message : '';
// 活动平台限流
if (code === 503 && url.indexOf(config.domains.activityHost) > -1) {
Taro.showToast({
title: '目前参与人数过多请下拉刷新',
icon: 'none',
duration: 2000
});
return reject({ code: 503, message: '目前参与人数过多请下拉刷新' });
}
reject({ code, message });
},
complete: options.complete, // 无论成功还是失败, 都会调用,可以用于取消 loading 等
... ... @@ -263,7 +301,6 @@ const _reportData = async (reportType, pt, pn, param, appObject) => {
device,
sid: sid
}
console.log(report_params);
return report_params
};
... ...
... ... @@ -2,7 +2,6 @@ import api from '../utils/api';
export default {
resource(code) {
console.log(code);
return api.get({
url: '/resources',
data: {
... ...
... ... @@ -7,6 +7,9 @@ import {getImgUrl} from '../../utils';
import './index.scss';
import getPrivateKey from '../../libs/request/getPrivateKey.js'
import router from '../../router/index.js'
import Yas from '../../utils/yas';
let yas;
export default class Classify extends Component {
constructor() {
... ... @@ -22,6 +25,10 @@ export default class Classify extends Component {
navigationBarTitleText: '分类'
}
componentWillMount() {
yas = new Yas(this.$scope);
}
async componentDidMount () {
const pk = await getPrivateKey();
Taro.setStorage({ key: 'verifyKey', data: pk });
... ... @@ -33,7 +40,12 @@ export default class Classify extends Component {
}
})
}
componentDidShow() {
yas.pageOpenReport();
yas.report('YB_MAIN_TAB_C', {TAB_ID: 2});
}
changeTab(item) {
this.setState({
actived: item
... ... @@ -97,7 +109,7 @@ export default class Classify extends Component {
})
}
</View>
}
}
</ScrollView>
)
}
... ...
... ... @@ -9,6 +9,9 @@ import { setFilter } from '../../actions/filterData';
import event from '../../utils/event.js'
import './index.scss';
import wx from '../../libs/wx';
import Yas from '../../utils/yas';
let yas;
@connect(({ filterData, filterMenu }) => ({
filterData,
... ... @@ -32,6 +35,14 @@ export default class Search extends Component {
navigationBarTitleText: '筛选'
}
componentWillMount() {
yas = new Yas(this.$scope);
yas.pageOpenReport();
}
componentDidShow() {
}
componentDidMount () {
console.log(this.$router);
let { params } = this.$router;
... ...
... ... @@ -10,7 +10,10 @@ import { connect } from '@tarojs/redux';
import { loginAction, decodeUnionId, wechatUserIsBind } from '../../libs/login/login.js'
import getPrivateKey from '../../libs/request/getPrivateKey.js'
import router from '../../router/index.js'
import Yas from '../../utils/yas';
import event from '../../utils/event';
let yas;
@connect(({ filterMenu }) => ({
filterMenu
... ... @@ -39,7 +42,9 @@ export default class Index extends Component {
productList: {},
stopLoading: {},
floors: []
}
};
this.currentTab = 0;
}
config = {
... ... @@ -48,7 +53,7 @@ export default class Index extends Component {
backgroundTextStyle: "dark",
onReachBottomDistance: 50
};
onPullDownRefresh() {
let filterMenu = this.props.filterMenu;
this.getProductData(filterMenu).then(isFinish => {
... ... @@ -60,13 +65,12 @@ export default class Index extends Component {
}).catch(error => {
Taro.stopPullDownRefresh();
});
}
async getResource() {
const pk = await getPrivateKey();
Taro.setStorage({ key: 'verifyKey', data: pk });
console.log(contentCode.index);
return commonModel.resource(contentCode.index).then(res => {
if (res && res.code === 200) {
this.setState({
... ... @@ -90,6 +94,10 @@ export default class Index extends Component {
}
}
componentWillMount() {
yas = new Yas(this.$scope);
}
componentDidMount() {
let obj = {
page: {},
... ... @@ -112,6 +120,11 @@ export default class Index extends Component {
});
}
componentDidShow() {
yas.pageOpenReport();
yas.report('YB_MAIN_TAB_C', {TAB_ID: 1});
}
componentWillReceiveProps(nextProps, oldProps) {
let curType = nextProps.filterMenu.indexType;
let oldCurType = oldProps && oldProps.filterMenu && oldProps.filterMenu.indexType;
... ... @@ -129,8 +142,7 @@ export default class Index extends Component {
let { page, productList, stopLoading } = this.state;
obj = obj || filterMenu;
let type = obj.indexType;
console.log(type);
const pk = await getPrivateKey();
Taro.setStorage({ key: 'verifyKey', data: pk });
commonModel.search({
... ... @@ -140,7 +152,7 @@ export default class Index extends Component {
}).then(ret => {
if (ret && ret.code === 200) {
let list = ret.data && ret.data.product_list || [];
if (list.length === 0) {
this.setState({
stopLoading: Object.assign(stopLoading, { [type]: true })
... ... @@ -171,7 +183,7 @@ export default class Index extends Component {
}
}
// gotoNative() {
// Taro.navigateTo({
... ... @@ -192,7 +204,7 @@ export default class Index extends Component {
// }
// <Text onClick={this.gotoNative}>跳转原生页面</Text>
// <Button openType="getUserInfo" onGetUserInfo = { this.login } > 登录 < /Button>
goToSearch() {
router.go('search');
}
... ... @@ -206,6 +218,25 @@ export default class Index extends Component {
})
}
setCurrentTab(type) {
console.log(this)
this.currentTab = type;
}
reportClick(item, idx) {
const params = {
F_ID: '20181224',
F_NAME: '商品列表',
F_INDEX: '3',
F_URL: `/pages/productDetail/index?id=${item.id}`,
I_INDEX: idx,
PRD_ID: item.id,
TAB_ID: this.currentTab
};
event.emit('report-main-event', params);
}
render() {
let {tabs, productList, isRefresh, floors} = this.state;
let {filterMenu} = this.props;
... ... @@ -224,14 +255,16 @@ export default class Index extends Component {
lowerThreshold='20'
onScrollToLower={this.onScrollToLower}>
<Resources isRefresh={ isRefresh } floors = { floors } code={ contentCode.index}></Resources>
<FilterMenu filterMenu={filterMenu} tabs={tabs} tabClass="border" fromPage="index"></FilterMenu>
<FilterMenu filterMenu={filterMenu} tabs={tabs} tabClass="border"
onSetCurrentTab={this.setCurrentTab.bind(this)}
fromPage="index"></FilterMenu>
{
list &&
<ProductList list={list}></ProductList>
<ProductList list={list} onReport={this.reportClick.bind(this)}></ProductList>
}
<Image className="goYohoBuy" onClick={this.goYohoBuyMinApp.bind(this)} src={goYohoBuy} mode="aspectFill" />
</View>
</View>
... ...
... ... @@ -10,6 +10,7 @@ import './index.scss';
import event from '../../utils/event.js'
import { getUserInfo, getPhoneNumber, checkUnionIdIsBind, getGlobalData } from '../../libs/login/login.js'
import router from '../../router/index.js';
import Yas from '../../utils/yas';
const USER_GET_PHONENUMBER_ERROR = 'user-get-phonenumber-error';
const USER_LOGIN_CALLBACK = 'user-login-callback';
... ... @@ -17,6 +18,8 @@ const USER_LOGIN_SUCCESS = 'user-login-success';
const MY_USER_LOGIN_SUCCESS = 'my-user-login-success';
const USER_CHANGE_LOGIN_STATUS = 'change-login-status';
let yas;
@connect(({ globalData }) => ({
globalData
}), (dispatch) => {
... ... @@ -50,6 +53,11 @@ export default class Login extends Component {
navigationBarTitleText: '登录'
}
componentWillMount() {
yas = new Yas(this.$scope);
yas.pageOpenReport();
}
componentDidMount () {
const union_id = wx.getStorageSync('unionid');
this.setState({
... ... @@ -80,7 +88,7 @@ export default class Login extends Component {
addPrefix(prefix, eventName) {
return `${prefix}-${eventName}`;
}
eventOnAll() {
const prefix = 'phonenumber';
event.one(this.addPrefix(prefix, USER_GET_PHONENUMBER_ERROR), (errMsg) => {
... ... @@ -114,7 +122,7 @@ export default class Login extends Component {
let timeStamp = Date.parse(new Date());
this.setState({
graphicsCodeUrl: config.domains.yohoApi + '/passport/img-check' + '?business_line=miniapp' + '&udid=' + udid + '&fromPage=' + 'bindPhoneNumber' + '&timeStamp=' + timeStamp
graphicsCodeUrl: config.domains.yohoApi + '/passport/img-check' + '?business_line=miniappUFO' + '&udid=' + udid + '&fromPage=' + 'bindPhoneNumber' + '&timeStamp=' + timeStamp
});
}
... ... @@ -131,7 +139,7 @@ export default class Login extends Component {
}
})
}
chooseCountry() {
router.go('selectCountry');
}
... ... @@ -235,7 +243,7 @@ export default class Login extends Component {
elem.dataVal = dataVal;
this.setState({graphicsCodeElement});
}
async bindBtnAction() {
let {phoneNum, verifyCode} = this.state;
... ... @@ -258,7 +266,7 @@ export default class Login extends Component {
return;
}
let result = await this.props.bindAction(this.state.phoneNum, this.state.verifyCode, this.state.countryArea, this.state.inviteCode);
if (result && result.message) {
... ... @@ -339,7 +347,6 @@ export default class Login extends Component {
render () {
let { tipText, verifyBtnText, countryArea, graphicsCodeElement, graphicsCodeSwitch, graphicsCodeUrl, hasUnionID, is_bind } = this.state;
let showBind = wx.getStorageSync('show_bind');
console.log(hasUnionID);
return (
<View className="login-page">
... ... @@ -349,7 +356,7 @@ export default class Login extends Component {
<View className="phonenum-container">
<View onClick={this.chooseCountry} className="country-area">
<Text className="phone-title" >{`+${countryArea}`}</Text>
<Image className="arrow-down-icon" src={arrowDown}></Image>
<Image className="arrow-down-icon" src={arrowDown}></Image>
</View>
<Input
className="phoneNumberContent"
... ... @@ -390,12 +397,12 @@ export default class Login extends Component {
</View>
</View>
}
<Button onClick={this.bindBtnAction} className={disabledClass ? 'bind-btn disabled' : 'bind-btn'} >完成</Button>
<Button
className="verify-btn"
openType={hasUnionID ? ( showBind ? 'getPhoneNumber' : '') :'getUserInfo'}
onGetPhoneNumber={this.getPhoneNumber}
<Button
className="verify-btn"
openType={hasUnionID ? ( showBind ? 'getPhoneNumber' : '') :'getUserInfo'}
onGetPhoneNumber={this.getPhoneNumber}
onGetUserInfo={this.getUserInfo}
onClick={this.checkUnionIdIsBind}
data-from="phonenumber">自动验证</Button>
... ...
import MessageService from '../MessageService.js'
import { formatTimeByDefined } from '../../../utils'
import event from '../../../utils/event.js'
import Yas from '../../../utils/yas';
let yas;
Page({
... ... @@ -23,6 +26,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
yas = new Yas(this);
let api = new MessageService();
this.setData({
api: api
... ... @@ -73,7 +77,6 @@ Page({
.then(data => {
if (data) {
let msgList = data.list;
console.log(msgList);
const list = msgList.map(item => {
let createTime = formatTimeByDefined(item.createTime, 'Y.M.D h:m:s');
item.createTime = createTime;
... ... @@ -109,16 +112,11 @@ Page({
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
yas.pageOpenReport();
yas.report('YB_MAIN_TAB_C', {TAB_ID: 3});
event.emit('judge-user-is-login', this.isJudgeLogined, this.isLoginCallback);
},
... ... @@ -135,27 +133,6 @@ Page({
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
... ... @@ -168,4 +145,4 @@ Page({
onShareAppMessage: function () {
}
})
\ No newline at end of file
})
... ...
import MessageService from '../MessageService.js'
import { formatTimeByDefined } from '../../../utils'
import Yas from '../../../utils/yas';
let yas;
Page({
... ... @@ -20,7 +23,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options);
yas = new Yas(this);
let title = options.title;
let messgeType = options.type;
this.setData({
... ... @@ -28,6 +31,7 @@ Page({
});
this.fetchMessageList(messgeType);
yas.pageOpenReport();
},
// 消息列表
... ... @@ -78,53 +82,7 @@ Page({
messageInfo.isLoading = false;
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
});
... ...
// dist/pages/myassets/index.js
import MyAssetsService from './myassetsService.js'
import { formatTimeByDefined } from '../../utils/index.js'
import Yas from '../../utils/yas';
let yas;
Page({
/**
... ... @@ -21,10 +25,12 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
yas = new Yas(this);
yas.pageOpenReport();
let api = new MyAssetsService();
this.setData({ api: api });
this.fetchIncomeList();
// this.setData({api: new MyAssetsService()});
},
/**
... ... @@ -92,13 +98,13 @@ Page({
* 开始progress
*/
startProgress: function (summary) {
// 设置倒计时 定时器 每100毫秒执行一次,计数器count+1 ,耗时6秒绘一圈
if (summary && summary.totalIncome > 0) {
// this.countTimer = setInterval(() => {
// if (this.data.count <= 60) {
/* 绘制彩色圆环进度条
/* 绘制彩色圆环进度条
注意此处 传参 step 取值范围是0到2,
所以 计数器 最大值 60 对应 2 做处理,计数器count=60的时候step=2
*/
... ... @@ -137,7 +143,7 @@ Page({
} else {
detail = that.data.data
}
if (detail.length > 0) {
detail.filter((item) => {
item.createTime = formatTimeByDefined(item.createTime, 'Y-M-D h:m:s');
... ... @@ -145,7 +151,7 @@ Page({
})
}
console.log(summary);
let cPage = data.page;
if (cPage == 1){
//绘制背景
... ... @@ -153,7 +159,7 @@ Page({
//开始progress
that.startProgress(summary);
}
let isLast = false;
// that.setData(data);
if (that.data.currentPage <= data.pagetotal) {
... ... @@ -168,7 +174,7 @@ Page({
summary: summary
});
}
// console.log(data);
})
},
... ... @@ -194,41 +200,5 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
});
... ...
import event from '../../utils/event.js'
import { getLoginButtonType } from '../../libs/login/login.js'
import Yas from '../../utils/yas';
let yas;
Page({
... ... @@ -16,6 +19,8 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
yas = new Yas(this);
yas.pageOpenReport();
let that = this;
event.one('user-login-success', () => {
// 返回上一页
... ... @@ -120,4 +125,4 @@ Page({
onShareAppMessage: function () {
}
})
\ No newline at end of file
})
... ...
... ... @@ -8,7 +8,10 @@
import orderService from '../orderService'
import {getImgUrl} from '../../../utils';
import router from '../../../router/index.js'
import {prePay} from '../../order/wxpay.js'
import { prePay } from '../../order/wxpay.js'
import Yas from '../../../utils/yas';
let yas;
const api = new orderService();
Page({
... ... @@ -25,7 +28,8 @@ Page({
storeId: 0
},
onLoad: async function (option) {
console.log(option)
yas = new Yas(this);
yas.pageOpenReport();
this.setData({
isStore: Number(option.is_store) || 0,
storeId: option.store_id || 0,
... ... @@ -134,14 +138,16 @@ Page({
wx.showLoading({
title: '',
})
debugger;
data = await api.buyerSubmit(skup, channelNo, addressId, () => wx.hideLoading());
}
if (data && data.orderCode) {
//todo:待处理微信数据分析上报,订单生成
// wx.reportAnalytics(eventName, data)
let orderCode = data.orderCode;
let productId = data.productId ? data.productId : '';
let params = {
RPD_SKUP: skup,
ORD_NUM: orderCode + ''
};
yas.report('YB_SC_ORD', params);
prePay(productId, orderCode, 0);
}
} catch (error) {
... ...
... ... @@ -7,6 +7,9 @@
import orderService from '../orderService'
import router from '../../../router/index.js'
import Yas from '../../../utils/yas';
let yas;
Page({
... ... @@ -21,6 +24,8 @@ Page({
},
onLoad: function (option) {
yas = new Yas(this);
yas.pageOpenReport();
if(option){
let productId = option.product_id
let orderCode = option.orderCode
... ... @@ -36,6 +41,9 @@ Page({
}
},
onShow() {
},
fetchRecommend(product_id) {
let api = new orderService()
... ...
... ... @@ -5,10 +5,15 @@ import { getImgUrl, formatTimeByMin } from '../../utils/index.js';
import { showDialog } from '../../components/order/orderActionUtil.js';
import { prePay } from '../order/wxpay.js'
import router from '../../router/index.js'
import Yas from '../../utils/yas';
const BUY_AGAIN = 'buy_again';
const NOW_BUY = 'now_buy';
const SHOW_EXPRESS = 'show_express';
let interval;
let yas;
Page({
/**
... ... @@ -26,6 +31,8 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
yas = new Yas(this);
yas.pageOpenReport();
let orderCode = options.orderCode
let api = new OrderDetailService();
let orderActionApi = new OrderActionService();
... ... @@ -47,7 +54,6 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
... ...
import logisticsService from './logisticsService.js'
import Yas from '../../../utils/yas';
let yas;
Page({
... ... @@ -16,6 +19,8 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
yas = new Yas(this);
yas.pageOpenReport();
let orderCode = options.orderCode ? options.orderCode : '';
this.fetchLogisticsInfo(orderCode);
},
... ... @@ -47,13 +52,13 @@ Page({
})
},
onCopyOrderCode: function() {
let orderCode = String(this.data.wayBillCode) || '';
wx.setClipboardData({
data: orderCode,
success (res) {
}
})
},
... ... @@ -106,4 +111,4 @@ Page({
onShareAppMessage: function () {
}
})
\ No newline at end of file
})
... ...
import OrderListService from './orderListService.js';
import event from '../../utils/event.js';
import { getImgUrl } from '../../utils/index.js';
import Yas from '../../utils/yas';
let yas;
Page({
/**
... ... @@ -41,9 +45,11 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
yas = new Yas(this);
yas.pageOpenReport();
let that = this;
let api = new OrderListService();
wx.getSystemInfo({
success: function (res) {
that.setData({
... ... @@ -58,10 +64,10 @@ Page({
});
event.one('refresh-order', () => {
// console.log("======refresh-order")
debugger
let currentType = that.data.activeIndex + 2;
console.log('currentType: ', currentType);
this.fetchOrderList(currentType, 1);
this.fetchOrderList(currentType,1);
});
},
bindChange: function (e) {
... ... @@ -75,7 +81,7 @@ Page({
if(!tab.data){
this.fetchOrderList(currentType, 1);
}
// console.log("bindChange:" + current + "===" + currentType);
},
... ... @@ -91,49 +97,48 @@ Page({
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
/**
... ... @@ -172,14 +177,14 @@ Page({
tab.showLoadMoreView = false;
that.data.tabs[index] = tab;
that.setData({ tabs: that.data.tabs });
});
},
/**
* 按钮操作
*/
actionButtonClick: function (event) {
let action = event.detail;
let action = event.detail;
},
onLoadMore: function () {
... ... @@ -197,5 +202,5 @@ Page({
return false;
}
})
... ...
... ... @@ -20,12 +20,15 @@ import collectOff from '../../static/images/collect-off.png';
import './index.scss';
import event from '../../utils/event'
import { getQRCodeSource } from '../../libs/miniQRCodeRoute'
import Yas from '../../utils/yas';
const SHARE_FRIENDS = 'user-share-friends';
const SHARE_MOMENTS = 'user-share-moments';
const SHARE_CANCEL = 'user-canel-share';
const SHARE_CANCEL_MOMENTS = 'user-canel-share-moments';
let yas;
@connect(({ productDetail }) => ({
productDetail
}), (dispatch) => ({
... ... @@ -94,6 +97,8 @@ export default class ProductDetail extends Component {
}
componentWillMount() {
yas = new Yas(this.$scope);
yas.pageOpenReport();
let options = this.$router.params;
if (options && options.q) {
let url = decodeURIComponent(options.q);
... ... @@ -183,7 +188,7 @@ export default class ProductDetail extends Component {
loadElement(options) {
let productId = options.id
if (options && options.scene && options.scene.length > 0) {
var scene = decodeURIComponent(options.scene)
var arr = scene ? scene.split("&") : [];
... ... @@ -221,13 +226,13 @@ export default class ProductDetail extends Component {
let data = ret.data || {};
let productInfo = data && data.product_info || {};
let goodsList = productInfo.goods_list && productInfo.goods_list.length > 0 && productInfo.goods_list[0] || {};
let imageSize = goodsList.image_list.length;
let imageSize = goodsList.image_list.length;
let default_image = imageSize > 0 ? goodsList.image_list[0]['image_url'] : '';
var product_qrCode = ''
let param = {
id: productInfo.product_id
}
}
product_qrCode = config.domains.yohoApi + '/wechat/miniapp/img-check.jpg?param=' + encodeURIComponent(JSON.stringify(param)) + '&miniQrType=23&miniapp_type=63';
console.log('====================================');
... ... @@ -297,7 +302,7 @@ export default class ProductDetail extends Component {
}
});
}
onChangeSwiper(e) {
this.setState(prevState => ({
swiperNum: `${e.detail.current + 1} | ${prevState.imageSize}`
... ... @@ -315,9 +320,10 @@ export default class ProductDetail extends Component {
that.handleCollectAction(id, isFavorite);
})
}
handleCollectAction(productId, isFavorite) {
if (isFavorite) {//添加收藏
yas.report('YB_GDS_COLLECT_C', {PRD_ID: productId});
productDetailModel.addFavorite(productId).then(ret => {
if (ret && ret.code === 200) {
this.setState({
... ... @@ -340,7 +346,7 @@ export default class ProductDetail extends Component {
onShareAppMessage(res) {
console.log(res);
if (res.from === 'menu') {
// 用户点击右上角分享
return {
... ... @@ -388,6 +394,14 @@ export default class ProductDetail extends Component {
showSnapshot(false);
}
confirmSelect(skup) {
const params = {
PRD_SKUP: skup
};
yas.report('YB_GDS_ADD_TO_CART_C', params);
}
onClickBuy() {
let {showSizeBox} = this.props;
... ... @@ -432,7 +446,7 @@ export default class ProductDetail extends Component {
wx.navigateToMiniProgram({
appId: 'wx084ab813d88c594b',
success(res) {
}
})
}
... ... @@ -572,12 +586,12 @@ export default class ProductDetail extends Component {
{
this.props.productDetail.showSnapshot &&
<snapshoot-share isShow={this.props.productDetail.showSnapshot} shareData={snapshootShareData} bindhiddenSnaphotSheet='hiddenSnaphotSheet'></snapshoot-share>
<snapshoot-share isShow={this.props.productDetail.showSnapshot} shareData={snapshootShareData} bindhiddenSnaphotSheet='hiddenSnaphotSheet'></snapshoot-share>
}
{
this.props.productDetail.showSizeBox &&
<SelectSize sizeList={goodsList.size_list} product_id={id}></SelectSize>
<SelectSize sizeList={goodsList.size_list} product_id={id} onConfirmSelect={this.confirmSelect.bind(this)}></SelectSize>
}
{
... ...
... ... @@ -4,6 +4,9 @@ import { SearchItem, SearchBar, PageTitle } from '../../components';
import {search as searchModel} from '../../models';
import './index.scss';
import router from '../../router/index';
import Yas from '../../utils/yas';
let yas;
export default class Search extends Component {
constructor() {
... ... @@ -21,6 +24,11 @@ export default class Search extends Component {
navigationBarTitleText: '搜索'
}
componentWillMount() {
yas = new Yas(this.$scope);
yas.pageOpenReport();
}
componentDidMount () {
const list = Taro.getStorageSync('latelySearch');
console.log(list);
... ... @@ -41,7 +49,6 @@ export default class Search extends Component {
this.setState({
latelySearch: list || []
})
}
onScroll(e) {
... ... @@ -66,7 +73,7 @@ export default class Search extends Component {
if (e.detail.value === '') {
return;
}
this.saveLateSearch(e);
this.saveLateSearch(e);
router.go('productList', {
query: e.detail.value
});
... ...
... ... @@ -8,6 +8,9 @@ import { clearFilter } from '../../actions/filterData';
import './index.scss';
import goYohoBuy from '../../assets/images/goYohoBuy@3x.png';
import event from '../../utils/event.js';
import Yas from '../../utils/yas';
let yas;
@connect(({ filterMenu, filterData }) => ({
filterMenu,
... ... @@ -44,6 +47,14 @@ export default class SearchList extends Component {
};
}
componentWillMount() {
yas = new Yas(this.$scope);
yas.pageOpenReport();
}
componentDidShow() {
}
componentDidMount() {
let params = this.$router.params || {};
console.log(params);
... ... @@ -123,7 +134,7 @@ export default class SearchList extends Component {
console.log(stopLoading);
this.setState({
page: page,
stopLoading
stopLoading
}, () => {
this.getProductData(props.filterMenu);
});
... ... @@ -303,12 +314,12 @@ export default class SearchList extends Component {
}
return hash;
}
goYohoBuyMinApp() {
wx.navigateToMiniProgram({
appId: 'wx084ab813d88c594b',
success(res) {
}
})
}
... ... @@ -356,9 +367,9 @@ export default class SearchList extends Component {
<FilterMenu filterMenu={ filterMenu } tabs = { this.state.tabs } fromPage = "search" hasFilter = { this.state.hasFilter } screen={params} > </FilterMenu>
< /View>
<ProductList list={productList[type]}></ProductList>
<Image className="goYohoBuy" onClick={this.goYohoBuyMinApp.bind(this)} src={goYohoBuy} mode="aspectFill" />
<Image className="goYohoBuy" onClick={this.goYohoBuyMinApp.bind(this)} src={goYohoBuy} mode="aspectFill" />
</ScrollView>
)
}
}
\ No newline at end of file
}
... ...
// login/select-country/select-country.js
import { getCountryArea, getGlobalData } from '../../libs/login/login.js';
import Yas from '../../utils/yas';
let yas;
Page({
/**
... ... @@ -13,9 +17,13 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
yas = new Yas(this);
yas.pageOpenReport();
this.getCountryArea();
},
onShow: function () {
},
async getCountryArea() {
try {
let country = await getCountryArea();
... ... @@ -35,4 +43,4 @@ Page({
delta: 1
});
},
})
\ No newline at end of file
})
... ...
import AddressService from '../addressService.js'
import user from '../../../../utils/user';
import Yas from '../../../../utils/yas';
var modeEdit = "modeEdit";
var modeSelect = "modeSelect";
... ... @@ -8,6 +9,7 @@ var modeAdd = "modeAdd"
var app = getApp();
const APP_ADDRESS_PROVINCES = "app.address.provinces";
let yas;
Page({
... ... @@ -33,6 +35,8 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
yas = new Yas(this);
yas.pageOpenReport();
let timestamp = options.timestamp;
let value = user.getYHStorageSync(timestamp, 'addressEditer');
let addressTitle = (value && (value.currentEditMode === 'modeEdit')) ? '编辑地址' : '添加地址';
... ... @@ -53,6 +57,9 @@ Page({
}
},
onShow() {
},
editPageOnLoad: function (level,id) {
let params = {
fromPage: 'addressEditer',
... ... @@ -69,8 +76,8 @@ Page({
let newEditeAddressPage = that.data.editeAddressPage;
let key = 'address_' + level;
newEditeAddressPage[key] = value;
//比对_area_code 解决 “其他” 被选中后,后台自动过滤掉address文字的返回但是_area_code没过滤的情况,导致我们显示上就没有选中 “其他”
//比对_area_code 解决 “其他” 被选中后,后台自动过滤掉address文字的返回但是_area_code没过滤的情况,导致我们显示上就没有选中 “其他”
if (level == 3) {
let list = value;
for (var i = 0; i < list.length; i++) {
... ... @@ -95,7 +102,7 @@ Page({
},
onInputChanged: function (e) {
let id = e.target.dataset.id;
let val = e.detail.value;
if (id == "txtConsignee") {
... ... @@ -122,7 +129,7 @@ Page({
editeAddressPage
});
},
onDeleteButtonTapped: function () {
let that = this;
wx.showModal({
... ... @@ -148,7 +155,7 @@ Page({
})
})
.catch(error => {
})
}
}
... ... @@ -287,7 +294,7 @@ Page({
});
});
});
},
},
editData: function (level){
let newEditeAddressPage = this.data.editeAddressPage;
... ...
import AddressService from './addressService.js'
import Yas from '../../../utils/yas';
// import {
// logEvent,
// YB_PAGE_OPEN_L,
// } from '../../libs/analytics.js'
var modeEdit = "modeEdit";
var modeSelect = "modeSelect";
... ... @@ -12,6 +9,7 @@ var modeAdd = "modeAdd"
var app = getApp();
let PV_ID = new Date().getTime() + '';
let yas;
Page({
data: {
... ... @@ -43,6 +41,8 @@ Page({
addType: 'none' // normal or wechat
},
onLoad:function(options){
yas = new Yas(this);
yas.pageOpenReport();
// 生命周期函数--监听页面加载
this.data.currentMode = modeEdit;
if (options.currentMode == modeEdit || options.currentMode == modeSelect || options.currentMode == modeChange){
... ... @@ -76,7 +76,7 @@ Page({
// FROM_PAGE_NAME: this.data.from_page_name,
// FROM_PAGE_PARAM: this.data.from_page_param,
// PV_ID: PV_ID,
// PAGE_PATH: url
// PAGE_PATH: url
// };
// logEvent(YB_PAGE_OPEN_L, params);
... ... @@ -85,7 +85,7 @@ Page({
let addType = options.addType ? options.addType : 'none';
this.setData({
currentMode: this.data.currentMode,
address_id,
address_id,
addType,
})
... ... @@ -112,7 +112,7 @@ Page({
prePage[prePage.length - 2].selectComplete(null);
}
}
},
onPullDownRefresh: function() {
// 页面相关事件处理函数--监听用户下拉动作
... ... @@ -140,7 +140,7 @@ Page({
wx.navigateBack({
delta: 1
})
}
else if (this.data.currentMode == modeChange) {
var that = this;
... ...
import MessageService from './collectionService.js'
import Yas from '../../../utils/yas';
let yas;
Page({
... ... @@ -19,7 +22,8 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
yas = new Yas(this);
yas.pageOpenReport();
},
fetchCollectionList: function (reload) {
... ... @@ -120,4 +124,4 @@ Page({
onShareAppMessage: function () {
}
})
\ No newline at end of file
})
... ...
... ... @@ -14,6 +14,9 @@ import './index.scss';
import event from '../../utils/event.js';
import { getImgUrl } from '../../utils/index.js'
import router from '../../router/index.js'
import Yas from '../../utils/yas';
let yas;
@connect(({ globalData }) => ({
globalData
... ... @@ -61,6 +64,10 @@ export default class UserCenter extends Component {
navigationBarTitleText: '我的'
}
componentWillMount(){
yas = new Yas(this.$scope);
}
componentDidShow() {
let { globalData } = this.props;
console.log('进入个人中心页面')
... ... @@ -71,32 +78,10 @@ export default class UserCenter extends Component {
});
this.showUserInfo();
}
//测试接口,将获取到的unionID等参数,上报给服务端以便于调试
// checkUnionIDExist(openID, unionID, srdSession, method) {
// let param = {
// ops: method,
// openId: openID,
// unionId: unionID,
// srdSession: srdSession
// }
// GET(API_HOST + "/wechat/miniapp/collect/", param)
// .then(data => {
// callbackFunc({
// succeed: true,
// message: ''
// });
// })
// .catch(error => {
// callbackFunc({
// succeed: false,
// message: error.message
// });
// });
// }
yas.pageOpenReport();
yas.report('YB_MAIN_TAB_C', {TAB_ID: 4});
}
getWechatThirdSession() {
let value = this.props.globalData.WXThird_session;
... ... @@ -329,7 +314,7 @@ export default class UserCenter extends Component {
}
{
isLogin &&
<View className="user-name" > { userInfo.nickName } < /View>
<View className="user-name" > { userInfo.nickName } < /View>
}
</View>
{
... ... @@ -337,7 +322,7 @@ export default class UserCenter extends Component {
return (
<View className= { item.mt ? 'entry-item mt' : 'entry-item' } key={ item.text} onClick={this.naviagteToPage.bind(this, item)} >
<View className="label" > { item.text } < /View>
<View className="num">
<View className="num">
<Text className="num-text">{isLogin ? item.num : ''}</Text>
<Image src={ arrowRightIcon } className="arrow-right-icon"> </Image>
</View >
... ...
... ... @@ -2,16 +2,11 @@ import {
parse,
stringify
} from '../../libs/request/utils/query-string/query-string.js';
// import config from '../../common/config';
// import udid from '../../common/udid';
// import event from '../../common/event';
// import {
// verify
// } from '../../common/api';
import Yas from '../../utils/yas';
import event from '../../utils/event.js';
// import {
// getQRCodeSource
// } from '../../common/miniQRCodeRoute';
let yas;
Page({
... ... @@ -29,6 +24,8 @@ Page({
*/
onLoad: function (options) {
console.log(options);
yas = new Yas(this);
yas.pageOpenReport();
options.url = decodeURIComponent(options.url || '');
if (options && options.scene && options.scene.length > 0) {
... ... @@ -60,6 +57,9 @@ Page({
}
},
onShow: function() {
},
/**
* 获取 UID
*/
... ...
<!--page/subPackage/pages/zeroSell/components/action-bar.wxml-->
<form bindsubmit='submitFormId' report-submit='true'>
<view class="action-bar">
<view class="action-item action-list" bindtap="goList">
<button form-type="submit" class="action-item action-list fix-button" bindtap="goList">
<image class="action-image" src="../images/list_icon@2x.png"></image>
</view>
</button>
<block wx:if="{{status === 1}}">
<view class="action-item over">即将开始</view>
... ... @@ -16,13 +16,13 @@
</block>
<block wx:elif="{{status === 3}}">
<view class="action-item confirm" bindtap="goMyList">
我的抽奖码({{num}})
</view>
<button form-type="submit" class="action-item confirm fix-button" bindtap="goMyList">
我的抽奖码({{num}})
</button>
<view class="action-item ok" bindtap="goShare">
获取更多抽奖码
</view>
<button form-type="submit" class="action-item ok fix-button" bindtap="goShare">
获取更多抽奖码
</button>
</block>
<block wx:elif="{{status === 4}}">
... ... @@ -45,6 +45,8 @@
<view class="action-item over">活动已结束</view>
</block>
</view>
</form>
<zero-alert wx:if="{{show}}">
<view class="code-alert">
... ... @@ -59,9 +61,6 @@
<button class="foot-item" plain="true" hover-class="none" form-type="submit" bindtap="cancelAlert">取消</button>
</view>
</form>
<!-- <view class="foot-item info" bindtap="goShare">去分享</view>
<view class="foot-item" bindtap="cancelAlert">取消</view> -->
</zero-alert>
<zero-alert wx:if="{{error}}">
... ... @@ -75,4 +74,4 @@
</view>
</zero-alert>
<fellow-alert show="{{fellow}}" bindok="cancelAlert"></fellow-alert>
\ No newline at end of file
<fellow-alert show="{{fellow}}" bindok="cancelAlert"></fellow-alert>
... ...
... ... @@ -17,6 +17,17 @@
background-color: white;
}
.action-item.fix-button {
display: inline-block;
border-radius: 0;
border: none;
}
.action-item.fix-button:after {
border-radius: 0;
border: none;
}
.action-list {
flex: 0;
position: relative;
... ... @@ -31,7 +42,7 @@
left: 50%;
/* transform: translateY(-50%); */
transform: translate(-50%, -50%);
}
.ok {
... ...
// page/subPackage/pages/zeroSell/components/prize-item.js
import router from '../router/router'
import commonService from '../service/commonService'
const PRODUCT_STATUS = {
UNKNOWN: 0, // 活动关闭
}
const common = new commonService();
Component({
/**
* 组件的属性列表
... ... @@ -40,7 +43,9 @@ Component({
show: false
})
},
goDetail() {
goDetail(e) {
if (e.target.dataset.code) return;
if (this.properties.item.status === PRODUCT_STATUS.UNKNOWN) {
wx.showModal({
title: 'OOPS',
... ... @@ -52,6 +57,11 @@ Component({
actPrizeId: this.properties.item.act_prize_id
});
}
},
submitFormId(e) {
return common.addWechatFormId({
formId: e.detail.formId,
});
}
},
... ...
<!--page/subPackage/pages/zeroSell/components/prize-item.wxml-->
<form bindsubmit='submitFormId' report-submit='true'>
<view class="prize-item" bindtap="goDetail">
<image class="product-image" src="{{item.cover_img}}"></image>
<image class="product-image" src="{{item.cover_img}}"></image>
<view class="content">
<view class="code">抽奖码 <text style="color: black;">{{item.prize_code}}</text></view>
<view class="product-name" >{{item.name}}</view>
<block wx:if="{{item.status === 4}}">
<view class="btn" catchtap="goFellow">查看中奖信息</view>
</block>
... ... @@ -21,11 +21,11 @@
</block>
<block wx:else>
<view class="btn" catchtap="goShare">获得更多抽奖码</view>
<button form-type="submit" class="btn fix-button" bindtap="goShare" data-code="true">获得更多抽奖码</button>
</block>
</view>
</view>
</form>
<fellow-alert show="{{show}}" bindok="onOk"></fellow-alert>
\ No newline at end of file
<fellow-alert show="{{show}}" bindok="onOk"></fellow-alert>
... ...
... ... @@ -42,3 +42,13 @@
color: white;
background-color: #222;
}
.btn.fix-button {
line-height: inherit;
border-radius: 0;
font-size: 24rpx;
}
.btn.fix-button:after {
border-radius: 0;
}
... ...
... ... @@ -16,7 +16,8 @@ import {
} from '../../vendors/zanui/index';
import router from './router/router'
import {wrapperName} from './helper'
import { formatImageUrl } from '../../utils/util'
import { formatImageUrl, getYHStorageSync } from '../../utils/util'
import event from '../../utils/event'
import { jumpByUrl } from '../../libs/urlRoute';
import {getGlobalData, getUid, getStorageUserInfo, isLogin, setUserInfo} from '../../utils/index'
import {login as loginModel} from '../../models'
... ... @@ -241,6 +242,7 @@ Page(Object.assign({
recommends: r2.code === 200 ? r2.data : [],
avatars: (r3).map(i => {
i.user_name = wrapperName(i.user_name);
i.user_thumb = formatImageUrl(i.user_thumb, 60, 60);
return i;
}),
... ... @@ -373,7 +375,7 @@ Page(Object.assign({
_getUser() {
const userInfo = getStorageUserInfo();
if (isLogin() && (!userInfo || !userInfo.nickName)) {
... ... @@ -442,10 +444,22 @@ Page(Object.assign({
router.go('index');
},
goLogin() {
event.emit('user-is-login', {logged: this.logged, loginSuccess: this.loginSuccess});
},
logged() {
},
loginSuccess() {
},
getUserInfo: function(e) {
var that = this;
if (e.detail.errMsg === 'getUserInfo:ok') {
decodeUnionId(app.getWechatThirdSession(), e, function(response) {
decodeUnionId(that.getWechatThirdSession(), e, function(response) {
if (response.isHaveUnionID) {
that.setData({
hasUnionID: true,
... ... @@ -513,6 +527,10 @@ Page(Object.assign({
})
}
},
getWechatThirdSession() {
return getYHStorageSync('WXThird_session','app') || '';
},
//跳转到登录页面
loginAndRegisterTapped(needBind) {
let that = this;
... ... @@ -532,7 +550,7 @@ Page(Object.assign({
success: (res) => {
// console.log(res.authSetting["scope.userInfo"])
if (res.authSetting["scope.userInfo"] !== null && res.authSetting["scope.userInfo"] !== undefined && res.authSetting["scope.userInfo"] === true) {
getUnionID(app.getWechatThirdSession(), function(response) {
getUnionID(that.getWechatThirdSession(), function(response) {
// console.log(response)
})
}
... ... @@ -549,7 +567,7 @@ Page(Object.assign({
wx.navigateTo({
url: '/pages/bindPhoneNumber/bindPhoneNumber'
});
}
}
}
})
} else {
... ...
... ... @@ -7,9 +7,9 @@
<view style="height: 20rpx;"></view>
</view>
<counter count="{{participantCount}}" num="{{product.limit}}" status="{{product.status}}"></counter>
<counter wx:if="{{false}}" count="{{participantCount}}" num="{{product.limit}}" status="{{product.status}}"></counter>
<prize-progress step="{{step}}"></prize-progress>
<prize-progress step="{{step}}" wx:if="{{false}}"></prize-progress>
<view class="help">
<help></help>
</view>
... ... @@ -36,7 +36,7 @@
</view>
<block wx:if="{{product.status === 2}}">
<button class="action-item confirm" open-type="{{!hasUnionID ? 'getUserInfo':'getPhoneNumber'}}" bindgetphonenumber="getPhoneNumber" bindgetuserinfo='getUserInfo'>0元参加抽奖</button>
<button class="action-item confirm" bindtap="goLogin">0元参加抽奖</button>
</block>
<block wx:else>
... ... @@ -58,8 +58,3 @@
<import src="../../vendors/toast/wetoast.wxml"/>
<template is="wetoast" data="{{...__wetoast__}}"/>
<zero-alert wx:if="{{showAuth}}" >
<view class="auth-content">OOPS 用户尚未授权登录</view>
<button class="auth-foot action-item confirm" open-type="{{!hasUnionID ? 'getUserInfo':'getPhoneNumber'}}" bindgetphonenumber="getPhoneNumber" bindgetuserinfo='getUserInfo'>授权登录</button>
</zero-alert>
... ...
import { toPromiseWX } from './wx'
const networkPromise = toPromiseWX('getNetworkType');
const ANALYTICS_KEYS = {
WX_LOGIN_ERROR: 'wx_login_error',
GET_USER_INFO_ERROR: 'get_userinfo_error',
GET_PHONENUMBER_ERROR: 'get_phonenumber_error',
SIGNIN_BY_OPENID_ERROR: 'signin_by_openid_error',
DECODE_USERINFO_ERROR: 'decode_userinfo_error',
SHOW_BIND_PHONE_NUMBER_PAGE: 'show_bind_phone_number_page',
REQUEST_401_ERROR: 'request_401_error',
REQUEST_508_ERROR: 'request_508_error',
SET_STORAGE_ERROR: 'set_storage_error',
GET_STORAGE_ERROR: 'get_storage_error'
}
export default class Analytics {
constructor() {
this._udid = this._getUdid();
this.keys = ANALYTICS_KEYS;
this._systemInfo = wx.getSystemInfoSync();
}
_getUdid() {
return wx.getStorageSync('udid');
}
_getTime(date) {
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
}
_getTimeStamp(date) {
return date.getTime();
}
async _getInfo(dataInfo = {}) {
let res = await networkPromise();
let info = { ...dataInfo };
if (res.networkType) {
info.network = res.networkType;
}
let systemInfo = this._systemInfo;
if (systemInfo) {
info.os_version = systemInfo.system;
info.device_model = systemInfo.model;
info.device_brand = systemInfo.brand;
info.sdk_version = systemInfo.SDKVersion;
}
return info;
}
async report(key, data) {
try {
let date = new Date();
let newData = Object.assign({
time: this._getTime(date),
timestamp: this._getTimeStamp(date),
udid: this._udid,
}, data);
let info = await this._getInfo(data.info);
newData.info = JSON.stringify(info);
wx.reportAnalytics(key, newData);
} catch (error) {
}
}
}
\ No newline at end of file
... ...
export const toPromise = (platform) => {
return (method) => {
return (option) => {
return new Promise ((resolve, reject) => {
platform[method]({
...option,
success: (res) => { resolve(res) },
fail: (err) => { reject(err) }
})
})
}
}
}
export const toPromiseWX = toPromise(wx);
\ No newline at end of file
... ...
export default {
'pages/index/index': {
pathName: 'home'
},
'pages/search/index': {
pathName: 'search'
},
'pages/searchList/index': {
multiEntry: true,
multiName: {
'series': 'seriesList',
'brand': 'brandList',
'query': 'searchList'
}
},
'pages/filter/index': {
pathName: 'filter'
},
'pages/productDetail/index': {
pathName: 'productDetail',
paramKey: 'id'
},
'pages/sell/index': {
pathName: 'sell'
},
'pages/classify/index': {
pathName: 'classify'
},
'pages/message/message/message': {
pathName: 'message'
},
'pages/message/messageDetail/messageDetail': {
pathName: 'messageDetail'
},
'pages/userCenter/index': {
pathName: 'userCenter'
},
'pages/login/index': {
pathName: 'login'
},
'pages/orderList/index': {
pathName: 'orderList'
},
'pages/nativeTest/nativeTest': {
pathName: 'nativeTest'
},
'pages/userCenter/collection/collection': {
pathName: 'collection'
},
'pages/userCenter/addressManager/addressManager': {
pathName: 'addressManager'
},
'pages/userCenter/addressManager/addressEditer/addressEditer': {
pathName: 'addressEditer'
},
'pages/userCenter/addressManager/addressEditer/addressPicker': {
pathName: 'addressPicker'
},
'pages/order/orderConfirm/orderConfirm': {
pathName: 'orderConfirm'
},
'pages/order/orderSuccess/orderSuccess': {
pathName: 'orderSuccess'
},
'pages/order/orderProtocol/orderProtocol': {
pathName: 'orderProtocol'
},
'pages/nativeLogin/nativeLogin': {
pathName: 'nativeLogin'
},
'pages/myassets/index': {
pathName: 'myassets'
},
'pages/orderDetail/index': {
pathName: 'orderDetail',
paramKey: 'orderCode'
},
'pages/orderList/orderlistcell': {
pathName: 'orderlistcell'
},
'pages/orderDetail/logistics/logistics': {
pathName: 'logistics'
},
'pages/webview/webview': {
pathName: 'webview'
},
'pages/select-country/select-country': {
pathName: 'selectCountry'
},
"pages/zeroSell/index": {
pathName: 'zeroSellIndex'
},
"pages/zeroSell/detail": {
pathName: 'zeroSellDetail'
},
"pages/zeroSell/myList": {
pathName: 'zeroSellMyList'
},
"pages/zeroSell/snapshootShare": {
pathName: 'snapshootShare'
},
"pages/zeroSell/h5Page": {
pathName: 'zeroSellH5'
}
}
... ...
... ... @@ -59,7 +59,7 @@ class EventEmitter {
return true;
}
one(type, listener,) {
one(type, listener) {
let events;
if (typeof listener !== 'function')
throw new Error('"listener" argument must be a function');
... ...
... ... @@ -3,7 +3,8 @@ import {GET, POST} from '../libs/request/request';
import {API_HOST, SERVICE_HOST} from '../libs/config';
import {Encrypt} from '../libs/aes'
import {isStringEmpty} from './util'
import { logEvent,
import event from '../utils/event';
import { logEvent,
YB_MY_LOGIN,
YB_PAGE_OPEN_L,
YB_REGISTER_SUCCESS,
... ... @@ -20,7 +21,7 @@ let listenerList = [];//存放订阅者回调函数
/**获取用户UnionID相关逻辑**/
/*****************************************/
/*
/*
调用wx.login后,用获取到的jscode调用该接口,返回openid/unionid/srdSession。
(注:如果是全新的用户,不会返回unionid,需要申请用户授权后再调用getUnionID函数。
*/
... ... @@ -54,16 +55,16 @@ function wechatLoginAction(callbackFunc) {
//如果unionID不存在(未使用过任何有货微信产品的全新用户),调用getUnionID函数,再次获取unionID
//对于已经授权过的用户,拿到unionid之后获取一次userinfo更新个人信息.
let params = { LOGIN_TYPE: 4, PV_ID: PV_ID, };
logEvent(YB_MY_LOGIN, params);
// logEvent(YB_MY_LOGIN, params);
//当unionId为空或者头像为空时,调用微信接口获取用户信息
if (!isStringEmpty(responseData.unionid)) {
getUnionID(responseData.srd_session, callbackFunc);
app.setWXUnionID(data.data.unionid);
sendWeChatUserDataWithUnionId(data.data.unionid, app.globalData.userInfo.nickName, app.globalData.userInfo.avatarUrl)
wechatUserIsBind(data.data.unionid, "", "", callbackFunc);
wechatUserIsBind(data.data.unionid, "", "", callbackFunc);
}
}
}
})
.catch(error => {
callbackFunc({
... ... @@ -172,7 +173,7 @@ function sendWeChatUserDataWithUnionId(unionId,nickName,userAvatarUrl) {
// console.log(error)
});
}
/*
判断该微信用户是否已经绑定了有货账号,如果已绑定则返回uid等用户信息
... ... @@ -234,7 +235,7 @@ function wechatUserIsBind(unionID, nickName,userAvatarUrl, callbackFunc) {
根据用户是否授权,分别走两套发送、校验验证码的接口:
已授权:app.bind.sendThridBindCode、app.passport.bindMiniapp
未授权:app.message.sendSms、app.passport.autoSignin
未授权:app.message.sendSms、app.passport.autoSignin
**/
/*******************************************************************/
... ... @@ -348,6 +349,9 @@ function checkVerifyCode(phoneNumb, verifyCode, areaCode, inviteCode, callbackFu
.then(data => {
wx.hideToast()
if (data.code === 200 && (data.data.uid !== null) && data.data.uid > 0 && data.data.uid !== undefined) {//验证正确
if(data.data.nFlag === 'Y') {
event.emit('report-new-user-created');
}
let userInfo = {}
userInfo.ssouid = data.data.ssouid;
userInfo.uid = data.data.uid;
... ... @@ -361,7 +365,7 @@ function checkVerifyCode(phoneNumb, verifyCode, areaCode, inviteCode, callbackFu
let logParams = {
YB_REGISTER_SUCCESS: 5,
};
logEvent(YB_REGISTER_SUCCESS, logParams);
// logEvent(YB_REGISTER_SUCCESS, logParams);
callbackFunc({
succeed: true,
message: "登录成功",
... ... @@ -452,6 +456,10 @@ function autoSignin(mobile, verifyCode, areaCode, inviteCode, callbackFunc) {
.then(data => {
if (data.code ===200 && data.data&& data.data.uid>0){
if(data.data.nFlag === 'Y') {
event.emit('report-new-user-created');
}
let userInfo = {}
userInfo.ssouid = data.data.ssouid;
userInfo.uid = data.data.uid;
... ... @@ -462,7 +470,7 @@ function autoSignin(mobile, verifyCode, areaCode, inviteCode, callbackFunc) {
let logParams = {
YB_REGISTER_SUCCESS: 5,
};
logEvent(YB_REGISTER_SUCCESS, logParams);
// logEvent(YB_REGISTER_SUCCESS, logParams);
}
callbackFunc({
succeed: true,
... ... @@ -554,11 +562,16 @@ function BindMiniAppByAuto(mobile, countryCode, inviteCode, callbackFunc){
app.setSessionkey(data.data.session_key)
app.updateUid(data.data.uid)
sendWeChatUserData(data.data.uid, app.globalData.userInfo.nickName, app.globalData.userInfo.avatarUrl);
if(data.data && data.data.nFlag === 'Y') {
event.emit('report-new-user-created');
}
if (data.data.is_register !== undefined && data.data.is_register !== null && data.data.is_register === 0) {
let logParams = {
YB_REGISTER_SUCCESS: 5,
};
logEvent(YB_REGISTER_SUCCESS, logParams);
// logEvent(YB_REGISTER_SUCCESS, logParams);
callbackFunc({
succeed: true,
message: "登录成功",
... ... @@ -621,7 +634,7 @@ function listen(callbackFunc){
}
function trigger(succeed){
let that = this
let that = this
for (var i = 0, fn; fn = listenerList[i++];) {
fn.apply(that, arguments);
}
... ...
import udid from './udid';
import Taro from '@tarojs/taro';
import config from '../config';
import rules from '../router/rules';
import { MD5 } from './crypto';
import { parse, stringify } from 'querystringify';
import { getGlobalData } from '../libs/login/login.js'
import pathReport from '../router/path-report';
export default class yas {
constructor(app) {
let self = this;
this.app = app;
this.pvid = MD5(`${new Date().getTime()}${udid.get()}`).toString();
this.deviceInfo = {
os: '', // 系统类型
dm: '', // 设备型号
res: '', // 屏幕大小
osv: '', // 系统版本
ak: 'yohoufo_mp',
ch: '',
udid: udid.get()
};
// 获取设备信息
Taro.getSystemInfo({
success(res) {
self.language = res.language;
if (res.platform === 'devtools') {
// self.devEnv = true; //判断开发环境
}
Object.assign(self.deviceInfo, {
os: res.platform,
dm: res.model,
res: `${res.screenWidth}*${res.screenHeight}`,
osv: res.system,
});
}
});
}
uploadData(params) {
let self = this;
let sid = '';
let globalData = getGlobalData() || {};
sid = self.app.globalData && self.app.globalData.sid || globalData.sid || '';
return Taro.request({
url: config.domains.yasHost,
data: { _mlogs: JSON.stringify(params) },
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
'x-yoho-sid': MD5(sid).toString(),
},
});
}
report(event, info = {}) {
let self = this;
for (let key in info) {
if (info[key]) {
info[key] = decodeURIComponent(info[key]);
}
}
const pageNameMap = {};
for (let i in rules) {
if (rules.hasOwnProperty(i) && rules[i].path) {
pageNameMap[rules[i].path] = i;
}
}
if (event === 'YB_SHARE_RESULT_L') {
info.PAGE_NAME = pageNameMap['/' + info.PATH];
}
let userInfo = info || {};
let statusInfo = { ln: this.language };
let user = Taro.getStorageSync('userInfo') || {};
userInfo.UNION_ID = user.unionid || user.union_id || Taro.getStorageSync('unionid') || '';
userInfo.APP_ID = config.appid || '';
if (!userInfo.PV_ID) {
userInfo.PV_ID = info.PV_ID;
}
return new Promise(resolve => {
Taro.getNetworkType({
success(res) {
switch (res.networkType) {
case 'wifi':
statusInfo.net = '1';
break;
case '2g':
statusInfo.net = '2';
break;
case '3g':
statusInfo.net = '3';
break;
case '4g':
statusInfo.net = '4';
break;
default:
statusInfo.net = '0';
break;
}
},
complete() {
let globalData = getGlobalData() || {};
let userData = globalData.userInfo || {};
if (!Object.keys(userData).length) {
userData = Taro.getStorageSync('userInfo') || {};
}
let ch = self.app.globalData && self.app.globalData.ch || globalData.ch || '';
let uid = userData.uid || '';
self.deviceInfo.ch = ch;
return resolve(self.uploadData({
status: statusInfo,
device: self.deviceInfo,
events: [{
param: userInfo,
ts: new Date().getTime(),
op: event,
uid: uid,
sid: self.app.globalData && self.app.globalData.sid ||globalData.sid || ''
}]
}));
}
});
});
}
_pageName(options, path) {
let hasConf = pathReport[path];
// 多入口页面依据参数设定上报页面名称
if (hasConf && hasConf.multiEntry) {
let pathName = '';
Object.keys((hasConf.multiName || {})).forEach(key => {
if (options[key]) {
pathName = hasConf.multiName[key];
return false;
}
});
return pathName;
}
return hasConf ? hasConf.pathName : '';
}
_pageParam(options = {}, fromPath) {
if (!options) return '';
let hasConf = pathReport[fromPath];
if (hasConf && hasConf.multiEntry) {
let param = '';
Object.keys((hasConf.multiName || {})).forEach(key => {
if (options[key]) {
param = options[key];
return false;
}
});
return param;
}
if (pathReport[fromPath] && pathReport[fromPath].paramKey) {
return `${decodeURIComponent(options[pathReport[fromPath].paramKey])}` || '';
}
return stringify(options, '');
}
pageOpenReport(pvid, extra) {
let self = this;
let pages = getCurrentPages();
let currentPage = pages[pages.length - 1];
let path = `${currentPage.route}`,
options = currentPage.options || {}; // 拷贝options对象,用于获取当前页面参数
let info = { PV_ID: pvid || this.pvid };
// from page relevant
let fromPage, fromPath, fromOptions;
if (pages.length > 1) {
fromPage = pages[pages.length - 2];
fromPath = `${fromPage.route}`;
fromOptions = fromPage.options || {};
}
Object.assign(info, {
PAGE_PATH: path,
PAGE_PARAM: self._pageParam(options, path),
PAGE_NAME: self._pageName(options, path),
FROM_PAGE_NAME: self._pageName(options, fromPath),
FROM_PAGE_PARAM: self._pageParam(fromOptions, fromPath)
});
this.report('YB_PAGE_OPEN_L', Object.assign(info, extra || {}));
}
}
... ...