Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
ca188343
Commit
ca188343
authored
Mar 30, 2018
by
Junling Bu
Browse files
进一步调整登录逻辑。
parent
d566edc4
Changes
8
Show whitespace changes
Inline
Side-by-side
litemall-wx/app.js
View file @
ca188343
...
...
@@ -5,7 +5,14 @@ var user = require('./services/user.js');
App
({
onLaunch
:
function
()
{
},
onShow
:
function
(
options
)
{
user
.
checkLogin
().
then
(
res
=>
{
this
.
globalData
.
hasLogin
=
true
;
}).
catch
(()
=>
{
this
.
globalData
.
hasLogin
=
false
;
});
},
globalData
:
{
hasLogin
:
false
}
})
\ No newline at end of file
litemall-wx/config/api.js
View file @
ca188343
// 以下是业务服务器API地址
// 本机开发时使用
//
var WxApiRoot = 'http://localhost:8082/wx/';
var
WxApiRoot
=
'
http://localhost:8082/wx/
'
;
// 局域网测试使用
// var WxApiRoot = 'http://192.168.0.101:8082/wx/';
// 云平台部署时使用
var
WxApiRoot
=
'
http://122.152.206.172:8082/wx/
'
;
//
var WxApiRoot = 'http://122.152.206.172:8082/wx/';
// 以下是图片存储服务器API地址
// 本机开发时使用
...
...
litemall-wx/pages/auth/login/login.js
View file @
ca188343
...
...
@@ -33,6 +33,8 @@ Page({
user
.
checkLogin
().
catch
(()
=>
{
user
.
loginByWeixin
().
then
(
res
=>
{
app
.
globalData
.
hasLogin
=
true
;
wx
.
navigateBack
({
delta
:
1
})
...
...
@@ -69,6 +71,7 @@ Page({
that
.
setData
({
'
loginErrorCount
'
:
0
});
app
.
globalData
.
hasLogin
=
true
;
wx
.
setStorage
({
key
:
"
token
"
,
data
:
res
.
data
.
data
.
token
,
...
...
litemall-wx/pages/cart/cart.js
View file @
ca188343
var
util
=
require
(
'
../../utils/util.js
'
);
var
api
=
require
(
'
../../config/api.js
'
);
var
user
=
require
(
'
../../services/user.js
'
);
var
app
=
getApp
();
...
...
@@ -14,7 +15,8 @@ Page({
},
isEditCart
:
false
,
checkedAllStatus
:
true
,
editCartList
:
[]
editCartList
:
[],
hasLogin
:
false
},
onLoad
:
function
(
options
)
{
// 页面初始化 options为页面跳转所带来的参数
...
...
@@ -24,7 +26,14 @@ Page({
},
onShow
:
function
()
{
// 页面显示
if
(
app
.
globalData
.
hasLogin
){
this
.
getCartList
();
}
this
.
setData
({
hasLogin
:
app
.
globalData
.
hasLogin
});
},
onHide
:
function
()
{
// 页面隐藏
...
...
@@ -32,6 +41,9 @@ Page({
onUnload
:
function
()
{
// 页面关闭
},
goLogin
()
{
wx
.
navigateTo
({
url
:
"
/pages/auth/login/login
"
});
},
getCartList
:
function
()
{
let
that
=
this
;
util
.
request
(
api
.
CartList
).
then
(
function
(
res
)
{
...
...
litemall-wx/pages/cart/cart.wxml
View file @
ca188343
<view class="container">
<view class="no-login" wx:if="{{!hasLogin}}">
<view class="c">
<image src="http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/noCart-a8fe3f12e5.png" />
<text>还没有登录</text>
<button type="primary" bindtap="goLogin">去登录</button>
</view>
</view>
<view class='login' wx:else>
<view class="service-policy">
<view class="item">30天无忧退货</view>
<view class="item">48小时快速退款</view>
...
...
@@ -10,7 +18,7 @@
<text>去添加点什么吧</text>
</view>
</view>
<view class="cart-view" wx:
if="{{cartGoods.length > 0}}"
>
<view class="cart-view" wx:
else
>
<view class="list">
<view class="group-item">
<view class="goods">
...
...
@@ -47,4 +55,5 @@
<view class="checkout" bindtap="checkoutOrder" wx:if="{{!isEditCart}}">下单</view>
</view>
</view>
</view>
</view>
\ No newline at end of file
litemall-wx/pages/cart/cart.wxss
View file @
ca188343
...
...
@@ -31,6 +31,38 @@ page{
color: #666;
}
.no-login{
width: 100%;
height: auto;
margin: 0 auto;
}
.no-login .c{
width: 100%;
height: auto;
margin-top: 200rpx;
}
.no-login .c image{
margin: 0 auto;
display: block;
text-align: center;
width: 258rpx;
height: 258rpx;
}
.no-login .c text{
margin: 0 auto;
display: block;
width: 258rpx;
height: 59rpx;
line-height: 29rpx;
text-align: center;
font-size: 50rpx;
color: #999;
}
.no-cart{
width: 100%;
height: auto;
...
...
litemall-wx/pages/goods/goods.js
View file @
ca188343
...
...
@@ -268,12 +268,7 @@ Page({
},
openCartPage
:
function
()
{
user
.
checkLogin
().
then
(()
=>
{
wx
.
switchTab
({
url
:
'
/pages/cart/cart
'
});
})
.
catch
(()
=>
{
wx
.
navigateTo
({
url
:
"
/pages/auth/login/login
"
});
});
},
addFast
:
function
()
{
var
that
=
this
;
...
...
litemall-wx/pages/ucenter/index/index.js
View file @
ca188343
...
...
@@ -19,16 +19,12 @@ Page({
onShow
:
function
()
{
//获取用户的登录信息
user
.
checkLogin
().
then
(
res
=>
{
if
(
app
.
globalData
.
hasLogin
)
{
let
userInfo
=
wx
.
getStorageSync
(
'
userInfo
'
);
this
.
setData
({
userInfo
:
userInfo
,
});
}).
catch
(()
=>
{
});
}
},
onHide
:
function
()
{
...
...
@@ -39,58 +35,48 @@ Page({
// 页面关闭
},
goLogin
(){
user
.
checkLogin
().
catch
(()
=>
{
user
.
loginByWeixin
().
then
(
res
=>
{
this
.
setData
({
userInfo
:
res
.
data
.
userInfo
,
});
}).
catch
((
err
)
=>
{
util
.
showErrorToast
(
'
登陆失败
'
);
});
});
wx
.
navigateTo
({
url
:
"
/pages/auth/login/login
"
});
},
goOrder
()
{
user
.
checkLogin
().
then
(()
=>
{
if
(
app
.
globalData
.
hasLogin
)
{
wx
.
navigateTo
({
url
:
"
/pages/ucenter/order/order
"
});
}
)
.
catch
(()
=>
{
}
else
{
wx
.
navigateTo
({
url
:
"
/pages/auth/login/login
"
});
}
);
}
},
goCoupon
()
{
user
.
checkLogin
().
then
(()
=>
{
if
(
app
.
globalData
.
hasLogin
)
{
wx
.
navigateTo
({
url
:
"
/pages/ucenter/coupon/coupon
"
});
}
)
.
catch
(()
=>
{
}
else
{
wx
.
navigateTo
({
url
:
"
/pages/auth/login/login
"
});
}
)
;
};
},
goCollect
()
{
user
.
checkLogin
().
then
(()
=>
{
if
(
app
.
globalData
.
hasLogin
)
{
wx
.
navigateTo
({
url
:
"
/pages/ucenter/collect/collect
"
});
}
)
.
catch
(()
=>
{
}
else
{
wx
.
navigateTo
({
url
:
"
/pages/auth/login/login
"
});
}
)
;
};
},
goFootprint
()
{
user
.
checkLogin
().
then
(()
=>
{
if
(
app
.
globalData
.
hasLogin
)
{
wx
.
navigateTo
({
url
:
"
/pages/ucenter/footprint/footprint
"
});
}
)
.
catch
(()
=>
{
}
else
{
wx
.
navigateTo
({
url
:
"
/pages/auth/login/login
"
});
}
)
;
};
},
goAddress
()
{
user
.
checkLogin
().
then
(()
=>
{
if
(
app
.
globalData
.
hasLogin
)
{
wx
.
navigateTo
({
url
:
"
/pages/ucenter/address/address
"
});
}
)
.
catch
(()
=>
{
}
else
{
wx
.
navigateTo
({
url
:
"
/pages/auth/login/login
"
});
}
)
;
};
},
exitLogin
:
function
()
{
wx
.
showModal
({
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment