提交 dc95fce6 编写于 作者: D dexiaoly
......@@ -16,6 +16,15 @@
}
}
,{
"path" : "pages/login/index",
"style" :
{
"navigationBarTitleText": "登陆",
"enablePullDownRefresh": false
}
}
],
"easycom": {
// 下载安装的方式需要前面的"@/",npm安装的方式无需"@/"
......
......@@ -135,18 +135,21 @@
VIPlevel:'VIP1',//vip等级
name:'无名氏',
user_id:'0',
head_img:'../../static/logo.png'
head_img:'../../static/logo.png',
token:'',
}
},
onLoad() {
this.userinfo()
this.balance = this.CutMoney(this.balance)
this.integral = this.CutMoney(this.integral)
},
onPullDownRefresh() {
//下拉刷新
this.name = "成功啦"
this.userinfo()
setTimeout(function () {
uni.stopPullDownRefresh();
}, 1000);
......@@ -159,6 +162,48 @@
},
methods: {
userinfo(){
let _this = this
uni.getStorage({
key: 'token',
success: function (res) {
this.token = res.data
uni.request({
url: 'http://127.0.0.1:8000/userinfo/',
header: {
'Authorization': 'JWT '+this.token //自定义请求头信息
},
success: (res) => {
if(res.statusCode == 401){
uni.redirectTo({
url: '../login/index'
});
}
else{
_this.name = res.data.username
_this.user_id = res.data.id
console.log(res.data);
}
},
fail(e) {
console.log(e);
}
});
},
fail(e) {
uni.redirectTo({
url: '../login/index',
fail(e) {
console.log(e)
}
});
}
});
},
GoPage(urls){
//用于页面跳转
uni.navigateTo({
......@@ -168,8 +213,6 @@
}
})
},
CutMoney(price){
//返回小数点后面小字体
let splitPrice = price.split(".");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册