|
|
// index.js
|
|
|
import wx from '../../utils/wx';
|
|
|
import event from '../../common/event';
|
|
|
import { getLoginButtonType } from '../../common/login';
|
|
|
import { parse } from '../../vendors/query-stringify';
|
|
|
import {getLoginButtonType} from '../../common/login';
|
|
|
import {parse} from '../../vendors/query-stringify';
|
|
|
import accountModel from '../../models/account/index';
|
|
|
import Promise from '../../vendors/es6-promise';
|
|
|
import config from '../../common/config';
|
|
|
import Yas from '../../common/yas';
|
|
|
import helper from '../../utils/helper';
|
|
|
|
|
|
let app = getApp();
|
|
|
let yas;
|
...
|
...
|
@@ -15,17 +16,52 @@ let router = global.router; |
|
|
Page({
|
|
|
data: {
|
|
|
loginButtonType: '', // 获取登录button-type
|
|
|
channellist: [],
|
|
|
userInfo: {
|
|
|
phoneNum: '',
|
|
|
avatarUrl: '',
|
|
|
defaultAvatar: false,
|
|
|
nickName: ''
|
|
|
nickName: '',
|
|
|
wechat: ''
|
|
|
},
|
|
|
coinNum: 0,
|
|
|
isBound: false,
|
|
|
myQrCodeUrl: 'https://m.yohobuy.com/home/newQrcode?needLogin=1',
|
|
|
loginText: '点击登录'
|
|
|
loginText: '点击登录',
|
|
|
test_uid: [
|
|
|
349709, // 测试用
|
|
|
500030924,
|
|
|
500030922,
|
|
|
500030918,
|
|
|
500030916,
|
|
|
500030914,
|
|
|
500030912,
|
|
|
500030910,
|
|
|
500030908,
|
|
|
500030906,
|
|
|
500030904,
|
|
|
500030890,
|
|
|
500030888,
|
|
|
500030886,
|
|
|
500030884,
|
|
|
500030876,
|
|
|
500030830,
|
|
|
500030694,
|
|
|
500030690,
|
|
|
500030688
|
|
|
],
|
|
|
now_test_uid_index: 1,
|
|
|
containerHeight: '1006rpx',
|
|
|
h5PageUrl: [
|
|
|
{
|
|
|
title: '如何获得限购码?',
|
|
|
url: 'https://activity.yoho.cn/feature/247.html?nodownload=1'
|
|
|
}
|
|
|
],
|
|
|
limitCodes: {
|
|
|
codes: [],
|
|
|
invalidCodes: []
|
|
|
},
|
|
|
isShow: 0
|
|
|
},
|
|
|
onLoad: function() {
|
|
|
let that = this;
|
...
|
...
|
@@ -39,13 +75,14 @@ Page({ |
|
|
loginText: params.text || '点击登录'
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
},
|
|
|
onShow: function() {
|
|
|
setTimeout(() => {
|
|
|
app = app || getApp();
|
|
|
this.showBindUserInfo();
|
|
|
}, app ? 0 : 1000);
|
|
|
|
|
|
},
|
|
|
onReady: function() {
|
|
|
|
...
|
...
|
@@ -66,15 +103,19 @@ Page({ |
|
|
loginButtonType: getLoginButtonType()
|
|
|
});
|
|
|
|
|
|
if (app && app.getUid()) {
|
|
|
if (app && app.getUid() && app.getUserInfo().wechat) {
|
|
|
return Promise.all([
|
|
|
accountModel.getProfile(),
|
|
|
accountModel.getCoinTotal(),
|
|
|
accountModel.getLimitCodes()
|
|
|
]).then(res => {
|
|
|
let defaultAvatar = '../../static/images/icons/default-avatar.png';
|
|
|
let defaultAvatar = (app.globalData.userInfo.wechat &&
|
|
|
app.globalData.userInfo.wechat.avatarUrl) ||
|
|
|
'../../static/images/icons/default-avatar.png';
|
|
|
let resUserInfo = res[0].data || {};
|
|
|
|
|
|
console.log('resUserInfo:', resUserInfo);
|
|
|
console.log('limitInfo:', res[2]);
|
|
|
|
|
|
let user = Object.assign({}, this.data.userInfo, app.globalData.userInfo, {
|
|
|
nickName: resUserInfo.nickname,
|
...
|
...
|
@@ -85,12 +126,13 @@ Page({ |
|
|
|
|
|
app.setUserInfo(user);// 把用户信息写入storage
|
|
|
|
|
|
|
|
|
that.setData({
|
|
|
isBound: true,
|
|
|
userInfo: user,
|
|
|
coinNum: res[1].data && res[1].data.total || 0
|
|
|
});
|
|
|
|
|
|
that.setLimitCodeList(res[2]);
|
|
|
}).catch({});
|
|
|
}
|
|
|
},
|
...
|
...
|
@@ -110,5 +152,59 @@ Page({ |
|
|
});
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
setLimitCodeList: function(res) { // 处理限购码列表的数据
|
|
|
let that = this;
|
|
|
let invalidCodes = [];
|
|
|
let codes = [];
|
|
|
|
|
|
res.data.invalidLimitCodeProducts.forEach((item, index) => {
|
|
|
item.defaultUrl = helper.image(item.defaultUrl, 220, 138, 1);
|
|
|
invalidCodes.push(item);
|
|
|
});
|
|
|
|
|
|
res.data.limitCodeProducts.forEach((item, index) => {
|
|
|
item.defaultUrl = helper.image(item.defaultUrl, 220, 138, 1);
|
|
|
codes.push(item);
|
|
|
});
|
|
|
|
|
|
this.setData({
|
|
|
limitCodes: {
|
|
|
invalidCodes: invalidCodes,
|
|
|
codes: codes
|
|
|
},
|
|
|
isShow: 1
|
|
|
});
|
|
|
|
|
|
// 通过顶部和底部按钮的高度,计算中间限购码部分的高度
|
|
|
let sysInfo = wx.getSystemInfoSync();
|
|
|
let windowHeight = sysInfo.windowHeight;
|
|
|
|
|
|
let query = wx.createSelectorQuery();
|
|
|
|
|
|
query.select('.user-info-bar').boundingClientRect();
|
|
|
query.select('.out-login').boundingClientRect();
|
|
|
query.exec(result => {
|
|
|
let topHeight = result[0].height;
|
|
|
let bottomHeight = result[1].height;
|
|
|
let containerHeight = (windowHeight - topHeight - bottomHeight - 20 - 30) + 'px';
|
|
|
|
|
|
that.setData({
|
|
|
containerHeight: containerHeight
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
navigateToh5Page: function(e) {
|
|
|
console.log(e);
|
|
|
let type = e.currentTarget.dataset.type || 0;
|
|
|
|
|
|
let type_obj = this.data.h5PageUrl[type];
|
|
|
|
|
|
let url = type_obj.url + '&title=' + type_obj.title;
|
|
|
|
|
|
router.goUrl(url);
|
|
|
},
|
|
|
navigateToLimitListPage: function() {
|
|
|
router.go('home');
|
|
|
}
|
|
|
}); |
...
|
...
|
|