Authored by htoooth

fix

@@ -19,5 +19,6 @@ @@ -19,5 +19,6 @@
19 "Page": true, 19 "Page": true,
20 "Component": true, 20 "Component": true,
21 "getCurrentPages": true, 21 "getCurrentPages": true,
  22 + "getDate": true
22 } 23 }
23 } 24 }
@@ -61,7 +61,7 @@ App({ @@ -61,7 +61,7 @@ App({
61 udid.get(); // 生成 UDID 61 udid.get(); // 生成 UDID
62 verify.gen(); // 此处返回是是 Promise,需要调用接口的业务,最好在 then 里边执行 62 verify.gen(); // 此处返回是是 Promise,需要调用接口的业务,最好在 then 里边执行
63 63
64 - wx.getLocation({}); 64 + // wx.getLocation({}); // 获取位置信息
65 wx.checkSession().then(() => { // 微信登录未过期 65 wx.checkSession().then(() => { // 微信登录未过期
66 this.getWechatThirdSession(); 66 this.getWechatThirdSession();
67 this.getUserInfo(); 67 this.getUserInfo();
@@ -261,6 +261,7 @@ App({ @@ -261,6 +261,7 @@ App({
261 clearUserSession: function() { 261 clearUserSession: function() {
262 this.setUserInfo({}); 262 this.setUserInfo({});
263 this.setSessionKey(''); 263 this.setSessionKey('');
  264 + this.setUnionID('');
264 }, 265 },
265 getReportUid() { 266 getReportUid() {
266 return this.globalData.userInfo.uid || this._getSync('userInfo').uid || ''; 267 return this.globalData.userInfo.uid || this._getSync('userInfo').uid || '';
1 { 1 {
2 "pages": [ 2 "pages": [
3 "pages/index/index", 3 "pages/index/index",
  4 + "pages/home/index",
4 "pages/account/chooseArea", 5 "pages/account/chooseArea",
5 "pages/account/bindMobile", 6 "pages/account/bindMobile",
6 "pages/product/detail/detail", 7 "pages/product/detail/detail",
@@ -12,7 +13,7 @@ @@ -12,7 +13,7 @@
12 "navigationBarTitleText": "限定发售", 13 "navigationBarTitleText": "限定发售",
13 "navigationBarTextStyle": "white", 14 "navigationBarTextStyle": "white",
14 "backgroundColor": "#fff", 15 "backgroundColor": "#fff",
15 - "onReachBottomDistance": 200 16 + "onReachBottomDistance": 250
16 }, 17 },
17 "debug": true 18 "debug": true
18 } 19 }
@@ -17,4 +17,4 @@ @@ -17,4 +17,4 @@
17 } 17 }
18 18
19 @import "./iconfont.wxss"; 19 @import "./iconfont.wxss";
20 -@import "./vendors/zanui/index.wxss";  
  20 +@import "./vendors/zanui/index.wxss";
@@ -98,8 +98,8 @@ function wechatUserIsBind(unionID, nickName) { @@ -98,8 +98,8 @@ function wechatUserIsBind(unionID, nickName) {
98 return accountModel.wechatUserIsBind(unionID, nickName).then(data => { 98 return accountModel.wechatUserIsBind(unionID, nickName).then(data => {
99 wx.hideLoading(); 99 wx.hideLoading();
100 if (data.data && 100 if (data.data &&
101 - data.data.is_bind &&  
102 - data.data.is_bind === 'Y') { // 已经绑定 101 + data.data.is_bind &&
  102 + data.data.is_bind === 'Y') { // 已经绑定
103 let userInfo = {}; 103 let userInfo = {};
104 104
105 userInfo.is_bind = data.data.is_bind; 105 userInfo.is_bind = data.data.is_bind;
@@ -113,7 +113,7 @@ function wechatUserIsBind(unionID, nickName) { @@ -113,7 +113,7 @@ function wechatUserIsBind(unionID, nickName) {
113 app.setSessionKey(userInfo.sessionKey); 113 app.setSessionKey(userInfo.sessionKey);
114 114
115 // 登录成功回调 115 // 登录成功回调
116 - event.emit('yas-login-type-report', { LOGIN_TYPE: 4 }); 116 + event.emit('yas-login-type-report', {LOGIN_TYPE: 4});
117 117
118 return Promise.resolve({ 118 return Promise.resolve({
119 code: 10003, 119 code: 10003,
@@ -226,62 +226,6 @@ function tapGoLogin() { @@ -226,62 +226,6 @@ function tapGoLogin() {
226 } 226 }
227 227
228 /** 228 /**
229 - * 用户手动点击登录<废弃>  
230 - * @returns {Promise.<T>}  
231 - */  
232 -function tapToLogin() {  
233 - let app = getApp();  
234 - let router = global.router;  
235 -  
236 - if (wx.getSetting) {  
237 - return wx.getSetting().then(res => {  
238 - if (res.authSetting['scope.userInfo']) {  
239 - return router.goUrl(`${config.MINI_APP_DOMAIN}/pages/account/bindMobile`);  
240 - } else {  
241 - return wx.showModal({  
242 - title: '',  
243 - content: '检测到您未打开微信用户信息授权,开启后即可进行登录',  
244 - confirmText: '去开启',  
245 - confirmColor: '#000000'  
246 - });  
247 - }  
248 - }).then(res => {  
249 - if (res.confirm) {  
250 - return wx.openSetting();  
251 - }  
252 -  
253 - if (res.cancel) {  
254 - return wx.navigateTo({  
255 - url: '/pages/account/bindMobile',  
256 - });  
257 - }  
258 - }).then(res => {  
259 - if (res.authSetting['scope.userInfo'] && res.authSetting['scope.userInfo'] === true) {  
260 - return getUnionID(app.getWechatThirdSession());  
261 - }  
262 - }).then(res => {  
263 - if (res.code === 10003) { // 已经绑定手机号  
264 - app._removeSync('disableAutoLogin');  
265 - app.setUserInfo(res.data);  
266 - app.setSessionKey(res.data.sessionKey);  
267 - event.emit('user-login-success');  
268 - }  
269 -  
270 - if (res.code === 10004) { // 手动授权登录未绑定强制绑定  
271 - return wx.navigateTo({  
272 - url: '/pages/account/bindMobile',  
273 - });  
274 - }  
275 - }).catch(() => {});  
276 - } else {  
277 - return wx.showModal({  
278 - title: '提示',  
279 - content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'  
280 - });  
281 - }  
282 -}  
283 -  
284 -/**  
285 * 验证sessionKey是否过期 229 * 验证sessionKey是否过期
286 * @returns {*} 230 * @returns {*}
287 */ 231 */
@@ -349,7 +293,7 @@ function getPhoneNumber(e) { @@ -349,7 +293,7 @@ function getPhoneNumber(e) {
349 } 293 }
350 294
351 event.emit('user-login-success'); 295 event.emit('user-login-success');
352 - event.emit('yas-user-register-success', { REG_TYPE: 5 });// 注册成功调用埋点事件 296 + event.emit('yas-user-register-success', {REG_TYPE: 5});// 注册成功调用埋点事件
353 wx.showToast({ 297 wx.showToast({
354 icon: 'none', 298 icon: 'none',
355 title: '手机号授权成功!\r\n为享受更多权益,已为您注册有货会员!', 299 title: '手机号授权成功!\r\n为享受更多权益,已为您注册有货会员!',
@@ -385,6 +329,8 @@ function getUserInfo(e) { @@ -385,6 +329,8 @@ function getUserInfo(e) {
385 }); 329 });
386 } 330 }
387 331
  332 + console.log(e.detail);
  333 +
388 wx.showLoading(); 334 wx.showLoading();
389 event.emit('enable-tap-login'); 335 event.emit('enable-tap-login');
390 336
@@ -408,6 +354,9 @@ function getUserInfo(e) { @@ -408,6 +354,9 @@ function getUserInfo(e) {
408 duration: 3000 354 duration: 3000
409 }); 355 });
410 } else if (res.code === 10004) { // 微信用户未绑定手机号 356 } else if (res.code === 10004) { // 微信用户未绑定手机号
  357 + event.emit('change-login-status', {
  358 + text: '绑定有货帐号'
  359 + });
411 wx.showToast({ 360 wx.showToast({
412 icon: 'none', 361 icon: 'none',
413 title: '该微信号未绑定yoho手机账号,请再次单击绑定手机号', 362 title: '该微信号未绑定yoho手机账号,请再次单击绑定手机号',
@@ -435,14 +384,20 @@ function getLoginButtonType() { @@ -435,14 +384,20 @@ function getLoginButtonType() {
435 return ''; // 已经是登录状态,合法用户 384 return ''; // 已经是登录状态,合法用户
436 } 385 }
437 386
438 - let isUnionID = app && app.globalData.unionID;// 如果有unionID情况 387 + let isUnionID = app && app.globalData.unionID && app.globalData.userInfo.head_img;// 如果有unionID情况
439 let isPhoneNumber = isUnionID ? !(app && app.getUid()) : false; // 如果有unionID且没有uid,可以获取手机号自动绑定登录 388 let isPhoneNumber = isUnionID ? !(app && app.getUid()) : false; // 如果有unionID且没有uid,可以获取手机号自动绑定登录
440 389
441 if (app._getSync('disableAutoLogin')) { // 手动退出,走手机号登录页面 390 if (app._getSync('disableAutoLogin')) { // 手动退出,走手机号登录页面
442 return 'tapGoLogin'; 391 return 'tapGoLogin';
443 } else if (!isUnionID) { 392 } else if (!isUnionID) {
  393 + event.emit('change-login-status', {
  394 + text: '点击登录'
  395 + });
444 return 'getUserInfo'; 396 return 'getUserInfo';
445 } else if (isPhoneNumber) { 397 } else if (isPhoneNumber) {
  398 + event.emit('change-login-status', {
  399 + text: '绑定有货帐号'
  400 + });
446 return 'getPhoneNumber'; 401 return 'getPhoneNumber';
447 } 402 }
448 403
@@ -454,7 +409,8 @@ module.exports = { @@ -454,7 +409,8 @@ module.exports = {
454 isNeedImgCheck, 409 isNeedImgCheck,
455 getVerifyCode, 410 getVerifyCode,
456 bindMobileAction, 411 bindMobileAction,
457 - tapToLogin, // <废弃> 412 +
  413 + // tapToLogin, // <废弃>
458 tapGoLogin, 414 tapGoLogin,
459 verifySessionKey, 415 verifySessionKey,
460 getPhoneNumber, 416 getPhoneNumber,
@@ -46,7 +46,7 @@ export default class yas { @@ -46,7 +46,7 @@ export default class yas {
46 46
47 // 开发环境不上报 47 // 开发环境不上报
48 if (this.devEnv) { 48 if (this.devEnv) {
49 - return console.log(params); 49 + // return console.log(params);
50 } 50 }
51 51
52 return wx.request({ 52 return wx.request({
  1 +// index.js
  2 +import wx from '../../utils/wx';
  3 +import event from '../../common/event';
  4 +import { getLoginButtonType } from '../../common/login';
  5 +import { parse } from '../../vendors/query-stringify';
  6 +import accountModel from '../../models/account/index';
  7 +import Promise from '../../vendors/es6-promise';
  8 +import config from '../../common/config';
  9 +import Yas from '../../common/yas';
  10 +
  11 +let app = getApp();
  12 +let yas;
  13 +let router = global.router;
  14 +
  15 +Page({
  16 + data: {
  17 + loginButtonType: '', // 获取登录button-type
  18 + channellist: [],
  19 + userInfo: {
  20 + phoneNum: '',
  21 + avatarUrl: '',
  22 + defaultAvatar: false,
  23 + nickName: ''
  24 + },
  25 + coinNum: 0,
  26 + isBound: false,
  27 + myQrCodeUrl: 'https://m.yohobuy.com/home/newQrcode?needLogin=1',
  28 + loginText: '点击登录'
  29 + },
  30 + onLoad: function() {
  31 + let that = this;
  32 +
  33 + yas = new Yas(app); // 实例化埋点
  34 + yas.pageOpenReport();
  35 + event.on('user-login-success', this.showBindUserInfo);
  36 + event.on('user-login-callback', this.loginCallback.bind(this));
  37 + event.on('change-login-status', params => {
  38 + that.setData({
  39 + loginText: params.text || '点击登录'
  40 + });
  41 + });
  42 + },
  43 + onShow: function() {
  44 + setTimeout(() => {
  45 + app = app || getApp();
  46 + this.showBindUserInfo();
  47 + }, app ? 0 : 1000);
  48 +
  49 + },
  50 + onReady: function() {
  51 +
  52 +
  53 + },
  54 + changeLoginStatus: function(params) {
  55 + console.log(params);
  56 + },
  57 + loginCallback: function(res) {
  58 + this.setData({
  59 + loginButtonType: getLoginButtonType()
  60 + });
  61 + },
  62 + showBindUserInfo: function() {
  63 + let that = this;
  64 +
  65 + this.setData({
  66 + loginButtonType: getLoginButtonType()
  67 + });
  68 +
  69 + if (app && app.getUid()) {
  70 + return Promise.all([
  71 + accountModel.getProfile(),
  72 + accountModel.getCoinTotal(),
  73 + ]).then(res => {
  74 + let defaultAvatar = '../../static/images/icons/default-avatar.png';
  75 + let resUserInfo = res[0].data || {};
  76 +
  77 + console.log('resUserInfo:', resUserInfo);
  78 +
  79 + let user = Object.assign({}, this.data.userInfo, app.globalData.userInfo, {
  80 + nickName: resUserInfo.nickname,
  81 + avatarUrl: resUserInfo.head_ico || defaultAvatar,
  82 + phoneNum: resUserInfo.mobile,
  83 + defaultAvatar: (resUserInfo.head_ico || defaultAvatar) === defaultAvatar,
  84 + });
  85 +
  86 + app.setUserInfo(user);// 把用户信息写入storage
  87 +
  88 +
  89 + that.setData({
  90 + isBound: true,
  91 + userInfo: user,
  92 + coinNum: res[1].data && res[1].data.total || 0
  93 + });
  94 + }).catch({});
  95 + }
  96 + },
  97 + outLogin: function() {
  98 + return wx.showModal({
  99 + title: '',
  100 + content: '确认退出?',
  101 + confirmText: '退出',
  102 + confirmColor: '#000'
  103 + }).then(res1 => {
  104 + if (res1.confirm) {
  105 + app.clearUserSession();
  106 +
  107 + // app._setSync('disableAutoLogin', true);
  108 + wx.reLaunch({
  109 + url: '/pages/index/index'
  110 + });
  111 + }
  112 + });
  113 + }
  114 +});
  1 +{
  2 + "navigationBarTitleText": "我的限购码",
  3 + "enablePullDownRefresh": false,
  4 + "backgroundColor": "#ebebeb",
  5 + "backgroundTextStyle": "light",
  6 + "usingComponents": {
  7 + "login-button": "/components/login/button"
  8 + }
  9 +}
  1 +<wxs src="../../wxs/helper.wxs" module="helper" />
  2 +
  3 +<view class="home-coupon-index">
  4 + <view class="user-info-bar">
  5 + <view wx:if="{{!isBound}}">
  6 + <image class="avatar" src="../../static/images/icons/avatar@2x.png"></image>
  7 + <text class="to-login">{{loginText}}</text>
  8 + <login-button class="login-area auto-btn" openType="{{loginButtonType}}"></login-button>
  9 + </view>
  10 + <view wx:if="{{isBound}}">
  11 + <image wx:if="{{userInfo.avatarUrl == ''}}" class="avatar" src="../../static/images/icons/avatar@2x.png"></image>
  12 + <image wx:if="{{userInfo.avatarUrl != '' && userInfo.defaultAvatar}}" class="avatar"
  13 + src="{{userInfo.avatarUrl}}"></image>
  14 + <image wx:if="{{userInfo.avatarUrl != '' && !userInfo.defaultAvatar}}" class="avatar"
  15 + src="{{helper.image(userInfo.avatarUrl, 108, 108)}}"></image>
  16 + <text class="phone">{{userInfo.nickName || userInfo.phoneNum}}</text>
  17 + <text class="coin">积分:<text class="num">{{coinNum}}</text></text>
  18 + </view>
  19 + </view>
  20 +
  21 + <view class="out-login" bindtap="outLogin" wx:if="{{userInfo.uid}}">退出登录</view>
  22 +</view>
  1 +/* stylelint-disable-next-line */
  2 +page {
  3 + height: 100%;
  4 + background-color: #f0f0f0;
  5 +}
  6 +
  7 +.home-coupon-index {
  8 + height: 100%;
  9 +}
  10 +
  11 +.channel-list {
  12 + padding-top: 20rpx;
  13 +}
  14 +
  15 +.channel-list .list-item {
  16 + width: 690rpx;
  17 + height: 176rpx;
  18 + background-color: #fff;
  19 + margin: 0 30rpx 20rpx;
  20 + border-radius: 6rpx;
  21 +}
  22 +
  23 +.channel-list .list-item .item-left {
  24 + float: left;
  25 + border-right: 1rpx solid #e0e0e0;
  26 + width: 469rpx;
  27 + height: 108rpx;
  28 + overflow: hidden;
  29 + margin: 35rpx 0 25rpx 0;
  30 +}
  31 +
  32 +.channel-list .list-item .item-left .ico {
  33 + width: 76rpx;
  34 + height: 76rpx;
  35 + margin: 15rpx 20rpx 0 30rpx;
  36 +}
  37 +
  38 +.channel-list .list-item .item-left .channel-name {
  39 + position: relative;
  40 + top: -25rpx;
  41 + font-size: 34rpx;
  42 + color: #444;
  43 +}
  44 +
  45 +.channel-list .list-item .item-left .partial {
  46 + top: -48rpx;
  47 +}
  48 +
  49 +.channel-list .list-item .item-left .vip-growth {
  50 + font-size: 28rpx;
  51 + color: #b0b0b0;
  52 + letter-spacing: -0.4rpx;
  53 + display: inline-block;
  54 + width: 100%;
  55 + position: relative;
  56 + top: -27px;
  57 + left: 126rpx;
  58 +}
  59 +
  60 +.channel-list .list-item .item-left .vip {
  61 + margin-right: 10px;
  62 +}
  63 +
  64 +.channel-list .list-item .item-right {
  65 + width: 220rpx;
  66 + height: 100%;
  67 + float: right;
  68 +}
  69 +
  70 +.channel-list .list-item .item-right .num {
  71 + font-size: 60rpx;
  72 + color: #222;
  73 + letter-spacing: -0.42px;
  74 + display: inline-block;
  75 + width: 100%;
  76 + text-align: center;
  77 + margin-top: 22rpx;
  78 + font-weight: bold;
  79 +}
  80 +
  81 +.channel-list .list-item .item-right .captions {
  82 + font-size: 28rpx;
  83 + color: #444;
  84 + letter-spacing: -0.4rpx;
  85 + width: 100%;
  86 + display: block;
  87 + text-align: center;
  88 + margin-top: 3rpx;
  89 +}
  90 +
  91 +.userinfo {
  92 + display: flex;
  93 + flex-direction: column;
  94 + align-items: center;
  95 +}
  96 +
  97 +.userinfo-avatar {
  98 + width: 128rpx;
  99 + height: 128rpx;
  100 + margin: 20rpx;
  101 + border-radius: 50%;
  102 +}
  103 +
  104 +.userinfo-nickname {
  105 + color: #aaa;
  106 +}
  107 +
  108 +.usermotto {
  109 + margin-top: 200px;
  110 +}
  111 +
  112 +.user-info-bar {
  113 + position: relative;
  114 + height: 200rpx;
  115 + background: #fff;
  116 +}
  117 +
  118 +.user-info-bar .avatar {
  119 + position: absolute;
  120 + height: 108rpx;
  121 + width: 108rpx;
  122 + top: 46rpx;
  123 + left: 30rpx;
  124 + border-radius: 100%;
  125 +}
  126 +
  127 +.user-info-bar .to-login {
  128 + font-family: PingFangSC-Regular, sans-serif;
  129 + display: inline-block;
  130 + position: absolute;
  131 + top: 60rpx;
  132 + left: 160rpx;
  133 + height: 80rpx;
  134 + line-height: 80rpx;
  135 + color: #444;
  136 + font-size: 32rpx;
  137 + letter-spacing: -0.44rpx;
  138 +}
  139 +
  140 +.user-info-bar .login-area {
  141 + position: absolute;
  142 + top: 0;
  143 + left: 0;
  144 + width: 550rpx;
  145 + height: 200rpx;
  146 +}
  147 +
  148 +.user-info-bar .login-area.auto-btn {
  149 + background-color: transparent;
  150 + border: none;
  151 +}
  152 +
  153 +.user-info-bar .login-area.auto-btn:after {
  154 + border: none;
  155 +}
  156 +
  157 +.user-info-bar .qr-area {
  158 + position: absolute;
  159 + top: 0;
  160 + right: 0;
  161 + width: 100rpx;
  162 + height: 200rpx;
  163 +}
  164 +
  165 +.user-info-bar .qrc {
  166 + position: absolute;
  167 + height: 48rpx;
  168 + width: 48rpx;
  169 + top: 76rpx;
  170 + right: 30rpx;
  171 +}
  172 +
  173 +.user-info-bar .phone {
  174 + position: absolute;
  175 + top: 54rpx;
  176 + left: 160rpx;
  177 + font-family: SanFranciscoText-Regular, sans-serif;
  178 + font-size: 32rpx;
  179 + line-height: 1;
  180 + color: #444;
  181 + letter-spacing: -0.44rpx;
  182 + width: 340rpx;
  183 + height: 32rpx;
  184 + overflow: hidden;
  185 + text-overflow: ellipsis;
  186 + white-space: nowrap;
  187 +}
  188 +
  189 +.user-info-bar .coin {
  190 + position: absolute;
  191 + top: 106rpx;
  192 + left: 160rpx;
  193 + font-family: PingFangSC-Regular, sans-serif;
  194 + font-size: 28rpx;
  195 + color: #b0b0b0;
  196 + letter-spacing: -0.39rpx;
  197 +}
  198 +
  199 +.user-info-bar .coin .num,
  200 +.user-info-bar .coupon .num {
  201 + font-family: PingFangSC-Regular, sans-serif;
  202 + font-size: 32rpx;
  203 + color: #444;
  204 + letter-spacing: -0.44rpx;
  205 +}
  206 +
  207 +.user-info-bar .coupon .num {
  208 + margin-left: 6rpx;
  209 +}
  210 +
  211 +.user-info-bar .coupon {
  212 + position: absolute;
  213 + top: 106rpx;
  214 + left: 336rpx;
  215 + font-family: PingFangSC-Regular, sans-serif;
  216 + font-size: 28rpx;
  217 + color: #b0b0b0;
  218 + letter-spacing: -0.39rpx;
  219 +}
  220 +
  221 +.home-coupon-index .out-login {
  222 + background-color: #fff;
  223 + font-family: PingFang-SC-Regular, sans-serif;
  224 + font-size: 34rpx;
  225 + color: #222;
  226 + margin: 40rpx 30rpx 20rpx;
  227 + height: 88rpx;
  228 + line-height: 88rpx;
  229 + text-align: center;
  230 +}
@@ -12,23 +12,24 @@ Page({ @@ -12,23 +12,24 @@ Page({
12 data: { 12 data: {
13 tabSelected: 0, 13 tabSelected: 0,
14 refreshText: '下拉刷新', 14 refreshText: '下拉刷新',
  15 + footText: '内容加载中...',
15 userInfo: {}, 16 userInfo: {},
16 tabBarArr: [ 17 tabBarArr: [
17 { 18 {
18 - icon: '../../static/images/icon_rmfs_n@3x.png',  
19 - iconSelected: '../../static/images/icon_rmfs_p@3x.png', 19 + icon: '../../static/images/limit/icon_rmfs_n@3x.png',
  20 + iconSelected: '../../static/images/limit/icon_rmfs_p@3x.png',
20 name: '热门发售', 21 name: '热门发售',
21 method: 'app.limitProduct.hotLimitProduct' 22 method: 'app.limitProduct.hotLimitProduct'
22 }, 23 },
23 { 24 {
24 - icon: '../../static/images/icon_jjfs_n@3x.png',  
25 - iconSelected: '../../static/images/icon_jjfs_p@3x.png', 25 + icon: '../../static/images/limit/icon_jjfs_n@3x.png',
  26 + iconSelected: '../../static/images/limit/icon_jjfs_p@3x.png',
26 name: '即将发售', 27 name: '即将发售',
27 method: 'app.limitProduct.soonToSaleLimitProduct' 28 method: 'app.limitProduct.soonToSaleLimitProduct'
28 }, 29 },
29 { 30 {
30 - icon: '../../static/images/icon_yjfs_n@3x.png',  
31 - iconSelected: '../../static/images/icon_yjfs_p@3x.png', 31 + icon: '../../static/images/limit/icon_yjfs_n@3x.png',
  32 + iconSelected: '../../static/images/limit/icon_yjfs_p@3x.png',
32 name: '已经发售', 33 name: '已经发售',
33 method: 'app.limitProduct.alreadySaleLimitProduct' 34 method: 'app.limitProduct.alreadySaleLimitProduct'
34 } 35 }
@@ -37,18 +38,12 @@ Page({ @@ -37,18 +38,12 @@ Page({
37 {}, {}, {} 38 {}, {}, {}
38 ], 39 ],
39 icon: { 40 icon: {
40 - clock: '../../static/images/clock_left.png' 41 + clock: '../../static/images/limit/clock_left.png'
41 } 42 }
42 }, 43 },
43 onLoad: function() { 44 onLoad: function() {
44 yas = new Yas(app); 45 yas = new Yas(app);
45 - console.log(app.getUserInfo());  
46 - if (app.getUserInfo().nickName) {  
47 - this.setData({  
48 - userInfo: app.getUserInfo(),  
49 - hasUserInfo: true  
50 - });  
51 - } 46 +
52 this.getList(0, 1, 20, false); 47 this.getList(0, 1, 20, false);
53 }, 48 },
54 onShow: function() { 49 onShow: function() {
@@ -62,6 +57,9 @@ Page({ @@ -62,6 +57,9 @@ Page({
62 57
63 this.getList(this.data.tabSelected, 1, 20, false).then(() => { 58 this.getList(this.data.tabSelected, 1, 20, false).then(() => {
64 wx.stopPullDownRefresh(); 59 wx.stopPullDownRefresh();
  60 + this.setData({
  61 + refreshText: '下拉刷新'
  62 + });
65 }); 63 });
66 64
67 }, 65 },
@@ -73,12 +71,11 @@ Page({ @@ -73,12 +71,11 @@ Page({
73 page += 1; 71 page += 1;
74 this.getList(this.data.tabSelected, page, 20, true); 72 this.getList(this.data.tabSelected, page, 20, true);
75 } 73 }
76 -  
77 }, 74 },
78 getUserInfo: function(e) { 75 getUserInfo: function(e) {
79 console.log(e); 76 console.log(e);
80 if (e.detail.errMsg === 'getUserInfo:ok') { 77 if (e.detail.errMsg === 'getUserInfo:ok') {
81 - // AccountModel.decodeUserInfo(); 78 + // AccountModel.decodeUserInfo();
82 } 79 }
83 app.setUserInfo(e.detail.userInfo); 80 app.setUserInfo(e.detail.userInfo);
84 this.setData({ 81 this.setData({
@@ -86,13 +83,15 @@ Page({ @@ -86,13 +83,15 @@ Page({
86 hasUserInfo: true 83 hasUserInfo: true
87 }); 84 });
88 }, 85 },
89 - tabChange: function(e) { 86 + tabChange: function(e) { // 切换TAB
90 let index = e.currentTarget.dataset.index; 87 let index = e.currentTarget.dataset.index;
91 88
92 if (index !== this.data.tabSelected) { 89 if (index !== this.data.tabSelected) {
93 this.setData({ 90 this.setData({
94 tabSelected: index 91 tabSelected: index
95 }); 92 });
  93 +
  94 + // 如果listData没有数据,或者数据为空,则调用接口
96 if (!this.data.listData[index].limitProductVoList || this.data.listData[index].limitProductVoList.length === 0) { 95 if (!this.data.listData[index].limitProductVoList || this.data.listData[index].limitProductVoList.length === 0) {
97 this.getList(index, 1, 20, false); 96 this.getList(index, 1, 20, false);
98 } 97 }
@@ -100,12 +99,20 @@ Page({ @@ -100,12 +99,20 @@ Page({
100 }, 99 },
101 100
102 /** 101 /**
103 - * index: tab的index,page:分页,limit: 每页数量, isBottom:是否是到达底部后触发 102 + * 获取限定发售列表
  103 + * index: tab的index,
  104 + * page:分页,
  105 + * limit: 每页数量,
  106 + * isBottom:是否是到达底部后触发
104 */ 107 */
105 - getList: function(index, page, limit, isBottom) { // 获取限定发售列表 108 + getList: function(index, page, limit, isBottom) {
106 let method = this.data.tabBarArr[index].method; 109 let method = this.data.tabBarArr[index].method;
107 let that = this; 110 let that = this;
108 111
  112 + this.setData({
  113 + footText: '内容加载中...'
  114 + });
  115 +
109 return LimitModel.getLimitSaleList({ 116 return LimitModel.getLimitSaleList({
110 method: method, 117 method: method,
111 page: page, 118 page: page,
@@ -113,16 +120,19 @@ Page({ @@ -113,16 +120,19 @@ Page({
113 }).then(res => { 120 }).then(res => {
114 console.log(res.data); 121 console.log(res.data);
115 if (res.data && res.data.limitProductVoList) { 122 if (res.data && res.data.limitProductVoList) {
  123 + // 获取到已有的data数据,对某部分数据进行赋值后再setData
116 let list = that.data.listData; 124 let list = that.data.listData;
117 125
118 if (isBottom) { 126 if (isBottom) {
119 list[index].page = page; 127 list[index].page = page;
120 - list[index].limitProductVoList = list[index].limitProductVoList.concat(res.data.limitProductVoList); 128 + list[index].limitProductVoList =
  129 + list[index].limitProductVoList.concat(res.data.limitProductVoList);
121 } else { 130 } else {
122 list[index] = res.data; 131 list[index] = res.data;
123 } 132 }
124 that.setData({ 133 that.setData({
125 - listData: list 134 + listData: list,
  135 + footText: '暂无更多内容'
126 }); 136 });
127 } 137 }
128 }); 138 });
@@ -133,6 +143,8 @@ Page({ @@ -133,6 +143,8 @@ Page({
133 let limitProductCode = e.currentTarget.dataset.code; 143 let limitProductCode = e.currentTarget.dataset.code;
134 144
135 router.go('productDetail', {limitProductCode}); 145 router.go('productDetail', {limitProductCode});
136 - 146 + },
  147 + navigateToHome: function(e) { // 跳转到我的限购码
  148 + router.go('userCenter');
137 } 149 }
138 }); 150 });
@@ -36,10 +36,10 @@ @@ -36,10 +36,10 @@
36 </block> 36 </block>
37 </block> 37 </block>
38 </view> 38 </view>
39 - <view class='list-foot-blank'>暂无内容</view> 39 + <view class='list-foot-blank'>{{footText}}</view>
40 </view> 40 </view>
41 <!--我的限购码按钮--> 41 <!--我的限购码按钮-->
42 - <view class='my-code-button'> 42 + <view class='my-code-button' bindtap='navigateToHome'>
43 我的限购码 43 我的限购码
44 </view> 44 </view>
45 </view> 45 </view>
@@ -68,6 +68,7 @@ page { @@ -68,6 +68,7 @@ page {
68 text-align: center; 68 text-align: center;
69 line-height: 88rpx; 69 line-height: 88rpx;
70 font-size: 30rpx; 70 font-size: 30rpx;
  71 + color: #ccc;
71 } 72 }
72 73
73 /* 列表外层容器 */ 74 /* 列表外层容器 */
@@ -4,4 +4,4 @@ Component({ @@ -4,4 +4,4 @@ Component({
4 }, 4 },
5 properties: { /* ... */ }, 5 properties: { /* ... */ },
6 methods: { /* ... */ } 6 methods: { /* ... */ }
7 -});  
  7 +});
@@ -4,4 +4,4 @@ Component({ @@ -4,4 +4,4 @@ Component({
4 }, 4 },
5 properties: { /* ... */ }, 5 properties: { /* ... */ },
6 methods: { /* ... */ } 6 methods: { /* ... */ }
7 -});  
  7 +});
@@ -42,6 +42,12 @@ @@ -42,6 +42,12 @@
42 "query": "from=开发调试" 42 "query": "from=开发调试"
43 }, 43 },
44 { 44 {
  45 + "id": -1,
  46 + "name": "个人中心首页",
  47 + "pathName": "pages/home/index",
  48 + "query": "f"
  49 + },
  50 + {
45 "id": 1, 51 "id": 1,
46 "name": "情详页", 52 "name": "情详页",
47 "pathName": "pages/product/detail/detail", 53 "pathName": "pages/product/detail/detail",
@@ -6,10 +6,10 @@ import Promise from '../vendors/es6-promise'; @@ -6,10 +6,10 @@ import Promise from '../vendors/es6-promise';
6 import config from '../common/config'; 6 import config from '../common/config';
7 7
8 // 跳转到小程序内 8 // 跳转到小程序内
9 -// router.go('https://miniapp.yohobuy.com/pages/index/index?xxxx=ghh&ytty=444'); 9 +// router.goUrl('https://miniapp.yohobuy.com/pages/index/index?xxxx=ghh&ytty=444');
10 10
11 // 跳转到小程序外 11 // 跳转到小程序外
12 -// router.go('https://miniapp.yohobuy.com/pages/index/index?app=yohobuy&xxxx=ghh&ytty=444'); 12 +// router.goUrl('https://miniapp.yohobuy.com/pages/index/index?app=yohobuy&xxxx=ghh&ytty=444');
13 13
14 const OPEN_BY_TYPE = { 14 const OPEN_BY_TYPE = {
15 GO_LIST: 'go.list', 15 GO_LIST: 'go.list',
@@ -3,5 +3,6 @@ import jump from './jump'; @@ -3,5 +3,6 @@ import jump from './jump';
3 export default { 3 export default {
4 home: {path: '/pages/index/index'}, 4 home: {path: '/pages/index/index'},
5 productDetail: {path: '/pages/product/detail/detail'}, 5 productDetail: {path: '/pages/product/detail/detail'},
  6 + userCenter: {path: '/pages/home/index'},
6 snapShare: {path: '/pages/snapshootShare/snapshootShare'}, 7 snapShare: {path: '/pages/snapshootShare/snapshootShare'},
7 }; 8 };
@@ -72,7 +72,55 @@ function round(num, precision) { @@ -72,7 +72,55 @@ function round(num, precision) {
72 return num.toFixed(precision); 72 return num.toFixed(precision);
73 } 73 }
74 74
  75 +// 如果图片没有imageView2,则默认添加imageView2
  76 +function imgView(imgSrc, w, h, mode, q) {
  77 + var imgUrl = imgSrc || '';
  78 + var indexOf = imgUrl.indexOf('?');
  79 +
  80 + if (!imgUrl) {
  81 + return '';
  82 + }
  83 +
  84 + if (imgUrl.indexOf('http://') === imgUrl.indexOf('https://')) {
  85 + return imgUrl;
  86 + }
  87 +
  88 + if (indexOf === -1) {
  89 + imgUrl += '?imageView2/{mode}/w/{width}/h/{height}';
  90 + return image(imgUrl, w, h, mode, q);
  91 + }
  92 +
  93 + if (indexOf > -1) {
  94 + return image(imgUrl, w, h, mode, q);
  95 + }
  96 +
  97 + return imgUrl;
  98 +}
  99 +
  100 +function dateFormat(times, format) {
  101 + // ios 日期格式为2017/05/06 12:10:30
  102 + var date = times ? getDate(times.replace(getRegExp('-', 'g'), '/')) : getDate();
  103 + var year = date.getFullYear();
  104 + var month = date.getMonth() + 1;
  105 + var day = date.getDate();
  106 +
  107 + var hour = date.getHours();
  108 + var minute = date.getMinutes();
  109 + var second = date.getSeconds();
  110 +
  111 + format = format || 'YYYY/MM/DD HH:mm:ss';
  112 + [year, month, day, hour, minute, second] = [year, month, day, hour, minute, second].map(function(n) {
  113 + n = n.toString();
  114 + return n[1] ? n : '0' + n;
  115 + });
  116 +
  117 + return format.replace('YYYY', year).replace('MM', month).replace('DD', day)
  118 + .replace('HH', hour).replace('mm', minute).replace('ss', second);
  119 +}
  120 +
75 module.exports = { 121 module.exports = {
  122 + dateFormat: dateFormat,
76 image: image, 123 image: image,
  124 + imgView: imgView,
77 round: round 125 round: round
78 }; 126 };