Authored by htoooth

fix

... ... @@ -19,5 +19,6 @@
"Page": true,
"Component": true,
"getCurrentPages": true,
"getDate": true
}
}
... ...
... ... @@ -61,7 +61,7 @@ App({
udid.get(); // 生成 UDID
verify.gen(); // 此处返回是是 Promise,需要调用接口的业务,最好在 then 里边执行
wx.getLocation({});
// wx.getLocation({}); // 获取位置信息
wx.checkSession().then(() => { // 微信登录未过期
this.getWechatThirdSession();
this.getUserInfo();
... ... @@ -261,6 +261,7 @@ App({
clearUserSession: function() {
this.setUserInfo({});
this.setSessionKey('');
this.setUnionID('');
},
getReportUid() {
return this.globalData.userInfo.uid || this._getSync('userInfo').uid || '';
... ...
{
"pages": [
"pages/index/index",
"pages/home/index",
"pages/account/chooseArea",
"pages/account/bindMobile",
"pages/product/detail/detail",
... ... @@ -12,7 +13,7 @@
"navigationBarTitleText": "限定发售",
"navigationBarTextStyle": "white",
"backgroundColor": "#fff",
"onReachBottomDistance": 200
"onReachBottomDistance": 250
},
"debug": true
}
... ...
... ... @@ -17,4 +17,4 @@
}
@import "./iconfont.wxss";
@import "./vendors/zanui/index.wxss";
\ No newline at end of file
@import "./vendors/zanui/index.wxss";
... ...
... ... @@ -98,8 +98,8 @@ function wechatUserIsBind(unionID, nickName) {
return accountModel.wechatUserIsBind(unionID, nickName).then(data => {
wx.hideLoading();
if (data.data &&
data.data.is_bind &&
data.data.is_bind === 'Y') { // 已经绑定
data.data.is_bind &&
data.data.is_bind === 'Y') { // 已经绑定
let userInfo = {};
userInfo.is_bind = data.data.is_bind;
... ... @@ -113,7 +113,7 @@ function wechatUserIsBind(unionID, nickName) {
app.setSessionKey(userInfo.sessionKey);
// 登录成功回调
event.emit('yas-login-type-report', { LOGIN_TYPE: 4 });
event.emit('yas-login-type-report', {LOGIN_TYPE: 4});
return Promise.resolve({
code: 10003,
... ... @@ -226,62 +226,6 @@ function tapGoLogin() {
}
/**
* 用户手动点击登录<废弃>
* @returns {Promise.<T>}
*/
function tapToLogin() {
let app = getApp();
let router = global.router;
if (wx.getSetting) {
return wx.getSetting().then(res => {
if (res.authSetting['scope.userInfo']) {
return router.goUrl(`${config.MINI_APP_DOMAIN}/pages/account/bindMobile`);
} else {
return wx.showModal({
title: '',
content: '检测到您未打开微信用户信息授权,开启后即可进行登录',
confirmText: '去开启',
confirmColor: '#000000'
});
}
}).then(res => {
if (res.confirm) {
return wx.openSetting();
}
if (res.cancel) {
return wx.navigateTo({
url: '/pages/account/bindMobile',
});
}
}).then(res => {
if (res.authSetting['scope.userInfo'] && res.authSetting['scope.userInfo'] === true) {
return getUnionID(app.getWechatThirdSession());
}
}).then(res => {
if (res.code === 10003) { // 已经绑定手机号
app._removeSync('disableAutoLogin');
app.setUserInfo(res.data);
app.setSessionKey(res.data.sessionKey);
event.emit('user-login-success');
}
if (res.code === 10004) { // 手动授权登录未绑定强制绑定
return wx.navigateTo({
url: '/pages/account/bindMobile',
});
}
}).catch(() => {});
} else {
return wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
});
}
}
/**
* 验证sessionKey是否过期
* @returns {*}
*/
... ... @@ -349,7 +293,7 @@ function getPhoneNumber(e) {
}
event.emit('user-login-success');
event.emit('yas-user-register-success', { REG_TYPE: 5 });// 注册成功调用埋点事件
event.emit('yas-user-register-success', {REG_TYPE: 5});// 注册成功调用埋点事件
wx.showToast({
icon: 'none',
title: '手机号授权成功!\r\n为享受更多权益,已为您注册有货会员!',
... ... @@ -385,6 +329,8 @@ function getUserInfo(e) {
});
}
console.log(e.detail);
wx.showLoading();
event.emit('enable-tap-login');
... ... @@ -408,6 +354,9 @@ function getUserInfo(e) {
duration: 3000
});
} else if (res.code === 10004) { // 微信用户未绑定手机号
event.emit('change-login-status', {
text: '绑定有货帐号'
});
wx.showToast({
icon: 'none',
title: '该微信号未绑定yoho手机账号,请再次单击绑定手机号',
... ... @@ -435,14 +384,20 @@ function getLoginButtonType() {
return ''; // 已经是登录状态,合法用户
}
let isUnionID = app && app.globalData.unionID;// 如果有unionID情况
let isUnionID = app && app.globalData.unionID && app.globalData.userInfo.head_img;// 如果有unionID情况
let isPhoneNumber = isUnionID ? !(app && app.getUid()) : false; // 如果有unionID且没有uid,可以获取手机号自动绑定登录
if (app._getSync('disableAutoLogin')) { // 手动退出,走手机号登录页面
return 'tapGoLogin';
} else if (!isUnionID) {
event.emit('change-login-status', {
text: '点击登录'
});
return 'getUserInfo';
} else if (isPhoneNumber) {
event.emit('change-login-status', {
text: '绑定有货帐号'
});
return 'getPhoneNumber';
}
... ... @@ -454,7 +409,8 @@ module.exports = {
isNeedImgCheck,
getVerifyCode,
bindMobileAction,
tapToLogin, // <废弃>
// tapToLogin, // <废弃>
tapGoLogin,
verifySessionKey,
getPhoneNumber,
... ...
... ... @@ -46,7 +46,7 @@ export default class yas {
// 开发环境不上报
if (this.devEnv) {
return console.log(params);
// return console.log(params);
}
return wx.request({
... ...
// index.js
import wx from '../../utils/wx';
import event from '../../common/event';
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';
let app = getApp();
let yas;
let router = global.router;
Page({
data: {
loginButtonType: '', // 获取登录button-type
channellist: [],
userInfo: {
phoneNum: '',
avatarUrl: '',
defaultAvatar: false,
nickName: ''
},
coinNum: 0,
isBound: false,
myQrCodeUrl: 'https://m.yohobuy.com/home/newQrcode?needLogin=1',
loginText: '点击登录'
},
onLoad: function() {
let that = this;
yas = new Yas(app); // 实例化埋点
yas.pageOpenReport();
event.on('user-login-success', this.showBindUserInfo);
event.on('user-login-callback', this.loginCallback.bind(this));
event.on('change-login-status', params => {
that.setData({
loginText: params.text || '点击登录'
});
});
},
onShow: function() {
setTimeout(() => {
app = app || getApp();
this.showBindUserInfo();
}, app ? 0 : 1000);
},
onReady: function() {
},
changeLoginStatus: function(params) {
console.log(params);
},
loginCallback: function(res) {
this.setData({
loginButtonType: getLoginButtonType()
});
},
showBindUserInfo: function() {
let that = this;
this.setData({
loginButtonType: getLoginButtonType()
});
if (app && app.getUid()) {
return Promise.all([
accountModel.getProfile(),
accountModel.getCoinTotal(),
]).then(res => {
let defaultAvatar = '../../static/images/icons/default-avatar.png';
let resUserInfo = res[0].data || {};
console.log('resUserInfo:', resUserInfo);
let user = Object.assign({}, this.data.userInfo, app.globalData.userInfo, {
nickName: resUserInfo.nickname,
avatarUrl: resUserInfo.head_ico || defaultAvatar,
phoneNum: resUserInfo.mobile,
defaultAvatar: (resUserInfo.head_ico || defaultAvatar) === defaultAvatar,
});
app.setUserInfo(user);// 把用户信息写入storage
that.setData({
isBound: true,
userInfo: user,
coinNum: res[1].data && res[1].data.total || 0
});
}).catch({});
}
},
outLogin: function() {
return wx.showModal({
title: '',
content: '确认退出?',
confirmText: '退出',
confirmColor: '#000'
}).then(res1 => {
if (res1.confirm) {
app.clearUserSession();
// app._setSync('disableAutoLogin', true);
wx.reLaunch({
url: '/pages/index/index'
});
}
});
}
});
... ...
{
"navigationBarTitleText": "我的限购码",
"enablePullDownRefresh": false,
"backgroundColor": "#ebebeb",
"backgroundTextStyle": "light",
"usingComponents": {
"login-button": "/components/login/button"
}
}
\ No newline at end of file
... ...
<wxs src="../../wxs/helper.wxs" module="helper" />
<view class="home-coupon-index">
<view class="user-info-bar">
<view wx:if="{{!isBound}}">
<image class="avatar" src="../../static/images/icons/avatar@2x.png"></image>
<text class="to-login">{{loginText}}</text>
<login-button class="login-area auto-btn" openType="{{loginButtonType}}"></login-button>
</view>
<view wx:if="{{isBound}}">
<image wx:if="{{userInfo.avatarUrl == ''}}" class="avatar" src="../../static/images/icons/avatar@2x.png"></image>
<image wx:if="{{userInfo.avatarUrl != '' && userInfo.defaultAvatar}}" class="avatar"
src="{{userInfo.avatarUrl}}"></image>
<image wx:if="{{userInfo.avatarUrl != '' && !userInfo.defaultAvatar}}" class="avatar"
src="{{helper.image(userInfo.avatarUrl, 108, 108)}}"></image>
<text class="phone">{{userInfo.nickName || userInfo.phoneNum}}</text>
<text class="coin">积分:<text class="num">{{coinNum}}</text></text>
</view>
</view>
<view class="out-login" bindtap="outLogin" wx:if="{{userInfo.uid}}">退出登录</view>
</view>
... ...
/* stylelint-disable-next-line */
page {
height: 100%;
background-color: #f0f0f0;
}
.home-coupon-index {
height: 100%;
}
.channel-list {
padding-top: 20rpx;
}
.channel-list .list-item {
width: 690rpx;
height: 176rpx;
background-color: #fff;
margin: 0 30rpx 20rpx;
border-radius: 6rpx;
}
.channel-list .list-item .item-left {
float: left;
border-right: 1rpx solid #e0e0e0;
width: 469rpx;
height: 108rpx;
overflow: hidden;
margin: 35rpx 0 25rpx 0;
}
.channel-list .list-item .item-left .ico {
width: 76rpx;
height: 76rpx;
margin: 15rpx 20rpx 0 30rpx;
}
.channel-list .list-item .item-left .channel-name {
position: relative;
top: -25rpx;
font-size: 34rpx;
color: #444;
}
.channel-list .list-item .item-left .partial {
top: -48rpx;
}
.channel-list .list-item .item-left .vip-growth {
font-size: 28rpx;
color: #b0b0b0;
letter-spacing: -0.4rpx;
display: inline-block;
width: 100%;
position: relative;
top: -27px;
left: 126rpx;
}
.channel-list .list-item .item-left .vip {
margin-right: 10px;
}
.channel-list .list-item .item-right {
width: 220rpx;
height: 100%;
float: right;
}
.channel-list .list-item .item-right .num {
font-size: 60rpx;
color: #222;
letter-spacing: -0.42px;
display: inline-block;
width: 100%;
text-align: center;
margin-top: 22rpx;
font-weight: bold;
}
.channel-list .list-item .item-right .captions {
font-size: 28rpx;
color: #444;
letter-spacing: -0.4rpx;
width: 100%;
display: block;
text-align: center;
margin-top: 3rpx;
}
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.userinfo-nickname {
color: #aaa;
}
.usermotto {
margin-top: 200px;
}
.user-info-bar {
position: relative;
height: 200rpx;
background: #fff;
}
.user-info-bar .avatar {
position: absolute;
height: 108rpx;
width: 108rpx;
top: 46rpx;
left: 30rpx;
border-radius: 100%;
}
.user-info-bar .to-login {
font-family: PingFangSC-Regular, sans-serif;
display: inline-block;
position: absolute;
top: 60rpx;
left: 160rpx;
height: 80rpx;
line-height: 80rpx;
color: #444;
font-size: 32rpx;
letter-spacing: -0.44rpx;
}
.user-info-bar .login-area {
position: absolute;
top: 0;
left: 0;
width: 550rpx;
height: 200rpx;
}
.user-info-bar .login-area.auto-btn {
background-color: transparent;
border: none;
}
.user-info-bar .login-area.auto-btn:after {
border: none;
}
.user-info-bar .qr-area {
position: absolute;
top: 0;
right: 0;
width: 100rpx;
height: 200rpx;
}
.user-info-bar .qrc {
position: absolute;
height: 48rpx;
width: 48rpx;
top: 76rpx;
right: 30rpx;
}
.user-info-bar .phone {
position: absolute;
top: 54rpx;
left: 160rpx;
font-family: SanFranciscoText-Regular, sans-serif;
font-size: 32rpx;
line-height: 1;
color: #444;
letter-spacing: -0.44rpx;
width: 340rpx;
height: 32rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.user-info-bar .coin {
position: absolute;
top: 106rpx;
left: 160rpx;
font-family: PingFangSC-Regular, sans-serif;
font-size: 28rpx;
color: #b0b0b0;
letter-spacing: -0.39rpx;
}
.user-info-bar .coin .num,
.user-info-bar .coupon .num {
font-family: PingFangSC-Regular, sans-serif;
font-size: 32rpx;
color: #444;
letter-spacing: -0.44rpx;
}
.user-info-bar .coupon .num {
margin-left: 6rpx;
}
.user-info-bar .coupon {
position: absolute;
top: 106rpx;
left: 336rpx;
font-family: PingFangSC-Regular, sans-serif;
font-size: 28rpx;
color: #b0b0b0;
letter-spacing: -0.39rpx;
}
.home-coupon-index .out-login {
background-color: #fff;
font-family: PingFang-SC-Regular, sans-serif;
font-size: 34rpx;
color: #222;
margin: 40rpx 30rpx 20rpx;
height: 88rpx;
line-height: 88rpx;
text-align: center;
}
... ...
... ... @@ -12,23 +12,24 @@ Page({
data: {
tabSelected: 0,
refreshText: '下拉刷新',
footText: '内容加载中...',
userInfo: {},
tabBarArr: [
{
icon: '../../static/images/icon_rmfs_n@3x.png',
iconSelected: '../../static/images/icon_rmfs_p@3x.png',
icon: '../../static/images/limit/icon_rmfs_n@3x.png',
iconSelected: '../../static/images/limit/icon_rmfs_p@3x.png',
name: '热门发售',
method: 'app.limitProduct.hotLimitProduct'
},
{
icon: '../../static/images/icon_jjfs_n@3x.png',
iconSelected: '../../static/images/icon_jjfs_p@3x.png',
icon: '../../static/images/limit/icon_jjfs_n@3x.png',
iconSelected: '../../static/images/limit/icon_jjfs_p@3x.png',
name: '即将发售',
method: 'app.limitProduct.soonToSaleLimitProduct'
},
{
icon: '../../static/images/icon_yjfs_n@3x.png',
iconSelected: '../../static/images/icon_yjfs_p@3x.png',
icon: '../../static/images/limit/icon_yjfs_n@3x.png',
iconSelected: '../../static/images/limit/icon_yjfs_p@3x.png',
name: '已经发售',
method: 'app.limitProduct.alreadySaleLimitProduct'
}
... ... @@ -37,18 +38,12 @@ Page({
{}, {}, {}
],
icon: {
clock: '../../static/images/clock_left.png'
clock: '../../static/images/limit/clock_left.png'
}
},
onLoad: function() {
yas = new Yas(app);
console.log(app.getUserInfo());
if (app.getUserInfo().nickName) {
this.setData({
userInfo: app.getUserInfo(),
hasUserInfo: true
});
}
this.getList(0, 1, 20, false);
},
onShow: function() {
... ... @@ -62,6 +57,9 @@ Page({
this.getList(this.data.tabSelected, 1, 20, false).then(() => {
wx.stopPullDownRefresh();
this.setData({
refreshText: '下拉刷新'
});
});
},
... ... @@ -73,12 +71,11 @@ Page({
page += 1;
this.getList(this.data.tabSelected, page, 20, true);
}
},
getUserInfo: function(e) {
console.log(e);
if (e.detail.errMsg === 'getUserInfo:ok') {
// AccountModel.decodeUserInfo();
// AccountModel.decodeUserInfo();
}
app.setUserInfo(e.detail.userInfo);
this.setData({
... ... @@ -86,13 +83,15 @@ Page({
hasUserInfo: true
});
},
tabChange: function(e) {
tabChange: function(e) { // 切换TAB
let index = e.currentTarget.dataset.index;
if (index !== this.data.tabSelected) {
this.setData({
tabSelected: index
});
// 如果listData没有数据,或者数据为空,则调用接口
if (!this.data.listData[index].limitProductVoList || this.data.listData[index].limitProductVoList.length === 0) {
this.getList(index, 1, 20, false);
}
... ... @@ -100,12 +99,20 @@ Page({
},
/**
* index: tab的index,page:分页,limit: 每页数量, isBottom:是否是到达底部后触发
* 获取限定发售列表
* index: tab的index,
* page:分页,
* limit: 每页数量,
* isBottom:是否是到达底部后触发
*/
getList: function(index, page, limit, isBottom) { // 获取限定发售列表
getList: function(index, page, limit, isBottom) {
let method = this.data.tabBarArr[index].method;
let that = this;
this.setData({
footText: '内容加载中...'
});
return LimitModel.getLimitSaleList({
method: method,
page: page,
... ... @@ -113,16 +120,19 @@ Page({
}).then(res => {
console.log(res.data);
if (res.data && res.data.limitProductVoList) {
// 获取到已有的data数据,对某部分数据进行赋值后再setData
let list = that.data.listData;
if (isBottom) {
list[index].page = page;
list[index].limitProductVoList = list[index].limitProductVoList.concat(res.data.limitProductVoList);
list[index].limitProductVoList =
list[index].limitProductVoList.concat(res.data.limitProductVoList);
} else {
list[index] = res.data;
}
that.setData({
listData: list
listData: list,
footText: '暂无更多内容'
});
}
});
... ... @@ -133,6 +143,8 @@ Page({
let limitProductCode = e.currentTarget.dataset.code;
router.go('productDetail', {limitProductCode});
},
navigateToHome: function(e) { // 跳转到我的限购码
router.go('userCenter');
}
});
... ...
... ... @@ -36,10 +36,10 @@
</block>
</block>
</view>
<view class='list-foot-blank'>暂无内容</view>
<view class='list-foot-blank'>{{footText}}</view>
</view>
<!--我的限购码按钮-->
<view class='my-code-button'>
<view class='my-code-button' bindtap='navigateToHome'>
我的限购码
</view>
</view>
... ...
... ... @@ -68,6 +68,7 @@ page {
text-align: center;
line-height: 88rpx;
font-size: 30rpx;
color: #ccc;
}
/* 列表外层容器 */
... ...
... ... @@ -4,4 +4,4 @@ Component({
},
properties: { /* ... */ },
methods: { /* ... */ }
});
\ No newline at end of file
});
... ...
... ... @@ -4,4 +4,4 @@ Component({
},
properties: { /* ... */ },
methods: { /* ... */ }
});
\ No newline at end of file
});
... ...
... ... @@ -42,6 +42,12 @@
"query": "from=开发调试"
},
{
"id": -1,
"name": "个人中心首页",
"pathName": "pages/home/index",
"query": "f"
},
{
"id": 1,
"name": "情详页",
"pathName": "pages/product/detail/detail",
... ...
... ... @@ -6,10 +6,10 @@ import Promise from '../vendors/es6-promise';
import config from '../common/config';
// 跳转到小程序内
// router.go('https://miniapp.yohobuy.com/pages/index/index?xxxx=ghh&ytty=444');
// router.goUrl('https://miniapp.yohobuy.com/pages/index/index?xxxx=ghh&ytty=444');
// 跳转到小程序外
// router.go('https://miniapp.yohobuy.com/pages/index/index?app=yohobuy&xxxx=ghh&ytty=444');
// router.goUrl('https://miniapp.yohobuy.com/pages/index/index?app=yohobuy&xxxx=ghh&ytty=444');
const OPEN_BY_TYPE = {
GO_LIST: 'go.list',
... ...
... ... @@ -3,5 +3,6 @@ import jump from './jump';
export default {
home: {path: '/pages/index/index'},
productDetail: {path: '/pages/product/detail/detail'},
userCenter: {path: '/pages/home/index'},
snapShare: {path: '/pages/snapshootShare/snapshootShare'},
};
... ...
... ... @@ -72,7 +72,55 @@ function round(num, precision) {
return num.toFixed(precision);
}
// 如果图片没有imageView2,则默认添加imageView2
function imgView(imgSrc, w, h, mode, q) {
var imgUrl = imgSrc || '';
var indexOf = imgUrl.indexOf('?');
if (!imgUrl) {
return '';
}
if (imgUrl.indexOf('http://') === imgUrl.indexOf('https://')) {
return imgUrl;
}
if (indexOf === -1) {
imgUrl += '?imageView2/{mode}/w/{width}/h/{height}';
return image(imgUrl, w, h, mode, q);
}
if (indexOf > -1) {
return image(imgUrl, w, h, mode, q);
}
return imgUrl;
}
function dateFormat(times, format) {
// ios 日期格式为2017/05/06 12:10:30
var date = times ? getDate(times.replace(getRegExp('-', 'g'), '/')) : getDate();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
format = format || 'YYYY/MM/DD HH:mm:ss';
[year, month, day, hour, minute, second] = [year, month, day, hour, minute, second].map(function(n) {
n = n.toString();
return n[1] ? n : '0' + n;
});
return format.replace('YYYY', year).replace('MM', month).replace('DD', day)
.replace('HH', hour).replace('mm', minute).replace('ss', second);
}
module.exports = {
dateFormat: dateFormat,
image: image,
imgView: imgView,
round: round
};
... ...