没有登录则跳转到专门的登录页面。
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
var api = require('../../../config/api.js');
|
||||
var util = require('../../../utils/util.js');
|
||||
var user = require('../../../services/user.js');
|
||||
|
||||
var app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
@@ -26,7 +29,20 @@ Page({
|
||||
// 页面关闭
|
||||
|
||||
},
|
||||
startLogin: function () {
|
||||
wxLogin() {
|
||||
user.checkLogin().catch(() => {
|
||||
|
||||
user.loginByWeixin().then(res => {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}).catch((err) => {
|
||||
util.showErrorToast('微信登录失败');
|
||||
});
|
||||
|
||||
});
|
||||
},
|
||||
accountLogin: function () {
|
||||
var that = this;
|
||||
|
||||
if (that.data.password.length < 1 || that.data.username.length < 1) {
|
||||
|
||||
@@ -19,12 +19,14 @@
|
||||
<image class="code-img" src="https://dl.reg.163.com/cp?pd=yanxuan_web&pkid=SkeBZeG&random=1489903563234"></image>
|
||||
</view>
|
||||
|
||||
<button type="default" class="login-btn" bindtap="startLogin">登录</button>
|
||||
<button type="default" class="login-btn" bindtap="accountLogin">账号登录</button>
|
||||
|
||||
<view class="form-item-text">
|
||||
<navigator url="/pages/auth/register/register" class="register">注册账号</navigator>
|
||||
<navigator url="/pages/auth/reset/reset" class="reset">忘记密码</navigator>
|
||||
</view>
|
||||
|
||||
<button type="primary" class="login-btn" bindtap="wxLogin">微信直接登录</button>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
@@ -51,6 +51,47 @@ Page({
|
||||
|
||||
});
|
||||
},
|
||||
goOrder() {
|
||||
user.checkLogin().then(() => {
|
||||
wx.navigateTo({ url: "/pages/ucenter/order/order" });
|
||||
})
|
||||
.catch(() => {
|
||||
wx.navigateTo({ url: "/pages/auth/login/login" });
|
||||
});
|
||||
},
|
||||
goCoupon() {
|
||||
user.checkLogin().then(() => {
|
||||
wx.navigateTo({ url: "/pages/ucenter/coupon/coupon" });
|
||||
})
|
||||
.catch(() => {
|
||||
wx.navigateTo({ url: "/pages/auth/login/login" });
|
||||
});
|
||||
|
||||
},
|
||||
goCollect() {
|
||||
user.checkLogin().then(() => {
|
||||
wx.navigateTo({ url: "/pages/ucenter/collect/collect" });
|
||||
})
|
||||
.catch(() => {
|
||||
wx.navigateTo({ url: "/pages/auth/login/login" });
|
||||
});
|
||||
},
|
||||
goFootprint() {
|
||||
user.checkLogin().then(() => {
|
||||
wx.navigateTo({ url: "/pages/ucenter/footprint/footprint" });
|
||||
})
|
||||
.catch(() => {
|
||||
wx.navigateTo({ url: "/pages/auth/login/login" });
|
||||
});
|
||||
},
|
||||
goAddress() {
|
||||
user.checkLogin().then(() => {
|
||||
wx.navigateTo({ url: "/pages/ucenter/address/address" });
|
||||
})
|
||||
.catch(() => {
|
||||
wx.navigateTo({ url: "/pages/auth/login/login" });
|
||||
});
|
||||
},
|
||||
exitLogin: function () {
|
||||
wx.showModal({
|
||||
title: '',
|
||||
|
||||
@@ -8,64 +8,64 @@
|
||||
|
||||
<view class="user-menu">
|
||||
<view class="item">
|
||||
<navigator url="/pages/ucenter/order/order" class="a">
|
||||
<view class="a" bindtap="goOrder">
|
||||
<text class="icon order"></text>
|
||||
<text class="txt">我的订单</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<navigator url="/pages/ucenter/coupon/coupon" class="a">
|
||||
<view class="a" bindtap="goCoupon">
|
||||
<text class="icon coupon"></text>
|
||||
<text class="txt">优惠券</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="item no-border">
|
||||
<navigator url="url" class="a">
|
||||
<view class="a">
|
||||
<text class="icon gift"></text>
|
||||
<text class="txt">礼品卡</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="item">
|
||||
<navigator url="/pages/ucenter/collect/collect" class="a">
|
||||
<text class="icon address"></text>
|
||||
<view class="a" bindtap="goCollect">
|
||||
<text class="icon collect"></text>
|
||||
<text class="txt">我的收藏</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<navigator url="/pages/ucenter/footprint/footprint" class="a">
|
||||
<view class="a" bindtap="goFootprint">
|
||||
<text class="icon security"></text>
|
||||
<text class="txt">我的足迹</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="item no-border">
|
||||
<navigator url="url" class="a">
|
||||
<view class="a">
|
||||
<text class="icon kefu"></text>
|
||||
<text class="txt">会员福利</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="item">
|
||||
<navigator url="../address/address" class="a">
|
||||
<view class="a" bindtap="goAddress">
|
||||
<text class="icon address"></text>
|
||||
<text class="txt">地址管理</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="item">
|
||||
<navigator url="url" class="a">
|
||||
<view class="a">
|
||||
<text class="icon security"></text>
|
||||
<text class="txt">账号安全</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view> -->
|
||||
<!-- <view class="item no-border">
|
||||
<navigator url="url" class="a">
|
||||
<view class="a">
|
||||
<text class="icon kefu"></text>
|
||||
<text class="txt">联系客服</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view> -->
|
||||
<!-- <view class="item item-bottom">
|
||||
<navigator url="url" class="a">
|
||||
<view class="a">
|
||||
<text class="icon help"></text>
|
||||
<text class="txt">帮助中心</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
|
||||
@@ -101,6 +101,11 @@ page{
|
||||
background-size: 52.803rpx;
|
||||
}
|
||||
|
||||
.user-menu .icon.collect{
|
||||
background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/sprites/ucenter-sdf6a55ee56-f2c2b9c2f0.png) 0 -62.4997rpx no-repeat;
|
||||
background-size: 52.803rpx;
|
||||
}
|
||||
|
||||
.user-menu .icon.gift{
|
||||
background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/sprites/ucenter-sdf6a55ee56-f2c2b9c2f0.png) 0 -187.5rpx no-repeat;
|
||||
background-size: 52.803rpx;
|
||||
|
||||
@@ -37,8 +37,8 @@ function request(url, data = {}, method = "GET") {
|
||||
|
||||
if (res.data.errno == 401) {
|
||||
//需要登录后才可以操作
|
||||
wx.switchTab({
|
||||
url: '/pages/ucenter/index/index'
|
||||
wx.navigateTo({
|
||||
url: '/pages/auth/login/login'
|
||||
});
|
||||
} else {
|
||||
resolve(res.data);
|
||||
|
||||
Reference in New Issue
Block a user