Commit 7c72d7a3 by 莫晓莉

登录注册

parent 0321957c
...@@ -16,8 +16,11 @@ export const sendCode = (data) => { ...@@ -16,8 +16,11 @@ export const sendCode = (data) => {
} }
//获取用户信息 //获取用户信息
export const getUserByToken = (data) => { export const getUserByToken = (data) => {
return request('getUserByToken', data) return request('getUserByToken', data)
} }
\ No newline at end of file
//获取项目类型
export const getProjectTypeList = (data) => {
return request('getProjectTypeList', data)
}
...@@ -9,20 +9,11 @@ ...@@ -9,20 +9,11 @@
</view> --> </view> -->
<view class="type-box"> <!-- <view class="type-box">
<view class="category-title"> <view class="category-title">
星级评价 <text style="color:red;">*</text> 星级评价 <text style="color:red;">*</text>
</view> </view>
<view class="cate-box"> <view class="cate-box">
<!-- <scroll-view scroll-x="true" class="category-area">
<block wx:for="{{ suggestInfo.typeList }}" wx:key="index">
<view bindtap="selectTypeTap" class="cate-item ">
<text class="name" >xx</text>
</view>
</block>
</scroll-view> -->
<view class="star" v-for="(item,index) in starsList" :key="item.id" v-bind:style="{ color: [item.selected ?'red':'#ccc']}" <view class="star" v-for="(item,index) in starsList" :key="item.id" v-bind:style="{ color: [item.selected ?'red':'#ccc']}"
:data-current="index" @tap="selStar">{{ item.content }}</view> :data-current="index" @tap="selStar">{{ item.content }}</view>
...@@ -32,7 +23,7 @@ ...@@ -32,7 +23,7 @@
</view> </view>
</view> </view>
</view> </view> -->
<view class="category-title"> <view class="category-title">
评价内容<text style="color:red;">*</text> 评价内容<text style="color:red;">*</text>
......
...@@ -146,20 +146,44 @@ ...@@ -146,20 +146,44 @@
//登录 //登录
login() { login() {
if (this.loginForm.phone==undefined) {
uni.showToast({
icon: 'none',
title: '请输入手机号'
});
return;
}
if (this.loginForm.code==undefined) {
uni.showToast({
icon: 'none',
title: '请输入验证码'
});
return;
}
if (this.loginForm.password==undefined) {
uni.showToast({
icon: 'none',
title: '请输入密码'
});
return;
}
login(this.loginForm).then(res => { login(this.loginForm).then(res => {
if (res.code == 200) { if (res.code == 200) {
var user={},token=''; var user={},token='';
user.name=res.data.name; user.name=res.data.data.name;
user.phone=res.data.phone; user.phone=res.data.data.phone;
user.phone=res.data.userId; user.userId=res.data.data.userId;
token=res.data.token; user.idCard=res.data.data.idCard;
token=res.data.data.token;
uni.showToast({ uni.showToast({
icon: 'success', icon: 'success',
title: '登录成功', title: '登录成功',
success: () => { success: () => {
uni.navigateTo({ uni.setStorageSync('token', token)
url: '../user/user?token='+token+"&user="+user, uni.setStorageSync('user', user)
}); uni.switchTab({
url: '../user/user',
})
} }
......
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
</view> </view>
</radio-group> </radio-group>
</view> </view>
<view class="login-item mt25" v-if="selectName==1"> <!-- <view class="login-item mt25" v-if="selectName==1">
<image class="login-icon" src="../../static/login/mine.png"></image> <image class="login-icon" src="../../static/login/mine.png"></image>
<input class="login-item-input" placeholder="请输入残疾证号" v-model="addForm.disableNumber" /> <input class="login-item-input" placeholder="请输入残疾证号" v-model="addForm.disableNumber" />
</view> </view> -->
<view class="login-item mt25"> <view class="login-item mt25">
<image class="login-icon" src="../../static/login/code.png"></image> <image class="login-icon" src="../../static/login/code.png"></image>
...@@ -101,7 +101,14 @@ ...@@ -101,7 +101,14 @@
methods: { methods: {
//是否持证 //是否持证
radioChange(e) { radioChange(e) {
this.selectName = e.detail.value this.selectName = e.detail.value;
if(this.selectName!=1){
uni.showToast({
icon: 'none',
title: '只有持证才可以注册'
});
return;
}
}, },
//获取验证码 //获取验证码
getCode() { getCode() {
...@@ -138,20 +145,64 @@ ...@@ -138,20 +145,64 @@
//注册 //注册
registerFun() { registerFun() {
if (this.addForm.name ==undefined) {
uni.showToast({
icon: 'none',
title: '请输入真实姓名'
});
return;
}
if (this.addForm.idCard==undefined) {
uni.showToast({
icon: 'none',
title: '请输入身份证号'
});
return;
}
if (this.addForm.phone==undefined) {
uni.showToast({
icon: 'none',
title: '请输入手机号'
});
return;
}
if (this.addForm.code==undefined) {
uni.showToast({
icon: 'none',
title: '请输入验证码'
});
return;
}
if (this.addForm.password==undefined) {
uni.showToast({
icon: 'none',
title: '请输入密码'
});
return;
}
if (this.addForm.okPassword==undefined) {
uni.showToast({
icon: 'none',
title: '请再次输入密码'
});
return;
}
register(this.addForm).then(res => { register(this.addForm).then(res => {
if (res.code == 200) { if (res.code == 200) {
uni.showToast({ uni.showToast({
icon: 'success', icon: 'success',
title: '注册成功', title: '注册成功',
success: () => { success: () => {
uni.setStorageSync('token', res.data.data.token) // uni.setStorageSync('token', res.data.data.token)
uni.setStorageSync('user', res.data.data) // uni.setStorageSync('user', res.data.data)
uni.navigateTo({
url: '../login/login',
});
//获取 //获取
getUserByToken().then(res=>{ // getUserByToken().then(res=>{
}) // })
} }
......
...@@ -63,7 +63,13 @@ ...@@ -63,7 +63,13 @@
<!-- <image class="remind-icon" mode="aspectFit" style="" src=""></image> --> <!-- <image class="remind-icon" mode="aspectFit" style="" src=""></image> -->
</view> </view>
<view class="flex1"> <view class="flex1">
<picker bindchange="cat1Change" value="" range="" range-key="name"> <!-- <picker bindchange="cat1Change" value="" range="" range-key="name">
<view class="flex-a-c" style="justify-content:flex-end;">
<view class="picker-content" style=''>公益服务</view>
<view class="trangle"></view>
</view>
</picker> -->
<picker bindchange="cat1Change" @change="cat1Change" :value="index" :range="projectTypeList" name="category">
<view class="flex-a-c" style="justify-content:flex-end;"> <view class="flex-a-c" style="justify-content:flex-end;">
<view class="picker-content" style=''>公益服务</view> <view class="picker-content" style=''>公益服务</view>
<view class="trangle"></view> <view class="trangle"></view>
...@@ -208,18 +214,34 @@ ...@@ -208,18 +214,34 @@
</template> </template>
<script> <script>
import {
getProjectTypeList
} from "@/api/login"
export default { export default {
data() { data() {
return { return {
arrayHurt: [{name:'一级'},{name: '二级'}, {name:'三级'}, {name:'四级'}], arrayHurt: [{name:'一级'},{name: '二级'}, {name:'三级'}, {name:'四级'}],
index: 0, index: 0,
projectTypeList:[],//项目类型
} }
}, },
onShow() {
this.getProjectTypeList();
},
methods: { methods: {
bindPickerChange: function(e) { bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为:' + e.detail.value) console.log('picker发送选择改变,携带值为:' + e.detail.value)
this.index = e.detail.value this.index = e.detail.value
}, },
getProjectTypeList(){
getProjectTypeList().then(res => {
if (res.code == 200) {
this.projectTypeList=res.data.data;
console.log(projectTypeList);
}
})
}
} }
} }
</script> </script>
......
...@@ -2,61 +2,59 @@ ...@@ -2,61 +2,59 @@
<view class=""> <view class="">
<view class="center"> <view class="center">
<view class="logo" @click="bindLogin" :hover-class="!hasLogin ? 'logo-hover' : ''"> <view class="logo" @click="bindLogin" :hover-class="!hasLogin ? 'logo-hover' : ''">
<!-- <image class="logo-img" :src="token ? userinfo.avatar : avatarUrl"></image> -->
<image class="logo-img" :src="avatarUrl"></image> <image class="logo-img" :src="avatarUrl"></image>
<view class="logo-title"> <view class="logo-title">
<text class="uer-name">Hi,{{hasLogin ? userName : '您未登录'}}</text> <text class="uer-name">Hi,{{token ? user.name : '您未登录'}}</text>
<text class="go-login navigat-arrow" v-if="!hasLogin">&#xe65e;</text> <text class="go-login navigat-arrow" v-if="!token">&#xe65e;</text>
</view> </view>
</view> </view>
<view class="center-list" v-for="item in navList" :key="item.id"> <!-- <view class="center-list" v-for="item in navList" :key="item.id">
<view class="center-list-item border-bottom" v-for="item2 in item.barList" :key="item2.id" @click="goDetailPage(item2)"> <view class="center-list-item border-bottom" v-for="item2 in item.barList" :key="item2.id" @click="goDetailPage(item2)">
<text class="list-icon">&#xe60b;</text> <text class="list-icon">&#xe60b;</text>
<text class="list-text">{{item2.name}}</text> <text class="list-text">{{item2.name}}</text>
<text class="navigat-arrow">&#xe65e;</text> <text class="navigat-arrow">&#xe65e;</text>
</view> </view>
<!-- <view class="center-list-item"> </view> -->
<text class="list-icon">&#xe65f;</text>
<text class="list-text">申请服务</text> <view class="center-list">
<text class="navigat-arrow">&#xe65e;</text> <view class="center-list-item border-bottom" @click="comment">
</view> -->
</view>
<!-- <view class="center-list">
<view class="center-list-item border-bottom">
<text class="list-icon">&#xe60f;</text> <text class="list-icon">&#xe60f;</text>
<text class="list-text">帐号管理</text> <text class="list-text">满意度评价</text>
<text class="navigat-arrow">&#xe65e;</text> <text class="navigat-arrow">&#xe65e;</text>
</view> </view>
<view class="center-list-item"> <view class="center-list-item" @click="apply">
<text class="list-icon">&#xe639;</text> <text class="list-icon">&#xe639;</text>
<text class="list-text">新消息通知</text> <text class="list-text">申请服务</text>
<text class="navigat-arrow">&#xe65e;</text> <text class="navigat-arrow">&#xe65e;</text>
</view> </view>
</view> </view>
<view class="center-list"> <view class="center-list">
<view class="center-list-item border-bottom"> <view class="center-list-item border-bottom" @click="commentHis">
<text class="list-icon">&#xe60b;</text> <text class="list-icon">&#xe60b;</text>
<text class="list-text">帮助与反馈</text> <text class="list-text">历史评价</text>
<text class="navigat-arrow">&#xe65e;</text> <text class="navigat-arrow">&#xe65e;</text>
</view> </view>
<view class="center-list-item"> <view class="center-list-item" @click="aplHis">
<text class="list-icon">&#xe65f;</text> <text class="list-icon">&#xe65f;</text>
<text class="list-text">服务条款及隐私</text> <text class="list-text">服务申请记录</text>
<text class="navigat-arrow">&#xe65e;</text> <text class="navigat-arrow">&#xe65e;</text>
</view> </view>
</view> </view>
<view class="center-list">
<view class="center-list-item">
<text class="list-icon">&#xe614;</text> <view class="center-list" >
<text class="list-text">关于应用</text> <!-- <view class="center-list-item" @click="logout" v-if="token"> -->
<view class="center-list-item" @click="logout">
<text class="list-icon">&#xe65f;</text>
<text class="list-text">退出登录</text>
<text class="navigat-arrow">&#xe65e;</text> <text class="navigat-arrow">&#xe65e;</text>
</view> </view>
</view> -->
<view class="btn-row">
<button v-if="hasLogin" class="primary" type="primary" @tap="bindLogout">退出登录</button>
</view> </view>
<!-- <view class="btn-row">
<button class="primary" type="primary" @tap="bindLogout">退出登录</button>
</view> -->
</view> </view>
</view> </view>
</template> </template>
...@@ -70,7 +68,7 @@ ...@@ -70,7 +68,7 @@
export default { export default {
data() { data() {
return { return {
avatarUrl: "../../static/img/logo.png", avatarUrl: "../../static/img/logo.png",//未登录时的头像
navList: [ navList: [
{ {
id: 1, id: 1,
...@@ -101,70 +99,87 @@ ...@@ -101,70 +99,87 @@
], ],
}, },
] ],
user:{},//用户信息
} }
}, },
computed: { computed: {
...mapState(['hasLogin', 'forcedLogin', 'userName']) ...mapState(['hasLogin', 'forcedLogin', 'userName'])
}, },
onLoad() {
var token=uni.getStorageSync('token');
var user=uni.getStorageSync('user');
console.log('token:',token);
this.user=user;
this.token=token;
},
onShow() {
// this.mylike();
},
methods: { methods: {
...mapMutations(['logout']), // ...mapMutations(['logout']),
bindLogin() { // bindLogin() {
uni.navigateTo({ // uni.navigateTo({
url: '../login/login', // url: '../login/login',
}); // });
}, // },
bindLogout() { // bindLogout() {
const loginType = uni.getStorageSync('login_type') // const loginType = uni.getStorageSync('login_type')
if (loginType === 'local') { // if (loginType === 'local') {
this.logout(); // this.logout();
if (this.forcedLogin) { // if (this.forcedLogin) {
uni.reLaunch({ // uni.reLaunch({
url: '../login/login', // url: '../login/login',
}); // });
} // }
return // return
} // }
uniCloud.callFunction({ // uniCloud.callFunction({
name: 'user-center', // name: 'user-center',
data: { // data: {
action: 'logout' // action: 'logout'
}, // },
success: (e) => { // success: (e) => {
console.log('logout success', e); // console.log('logout success', e);
if (e.result.code == 0) { // if (e.result.code == 0) {
this.logout(); // this.logout();
uni.removeStorageSync('uniIdToken') // uni.removeStorageSync('uniIdToken')
uni.removeStorageSync('username') // uni.removeStorageSync('username')
/** // /**
* 如果需要强制登录跳转回登录页面 // * 如果需要强制登录跳转回登录页面
*/ // */
if (this.forcedLogin) { // if (this.forcedLogin) {
uni.reLaunch({ // uni.reLaunch({
url: '../login/login', // url: '../login/login',
}); // });
} // }
} else { // } else {
uni.showModal({ // uni.showModal({
content: e.result.msg, // content: e.result.msg,
showCancel: false // showCancel: false
}) // })
console.log('登出失败', e); // console.log('登出失败', e);
} // }
}, // },
fail(e) { // fail(e) {
uni.showModal({ // uni.showModal({
content: JSON.stringify(e), // content: JSON.stringify(e),
showCancel: false // showCancel: false
}) // })
} // }
}) // })
// },
bindLogin() {
uni.navigateTo({
url: '../login/login',
});
}, },
// 路径跳转start // 路径跳转start
goDetailPage(e) { goDetailPage(e) {
...@@ -174,8 +189,69 @@ ...@@ -174,8 +189,69 @@
url: path url: path
}); });
} },
// 路径跳转end // 路径跳转end
// 退出登录
logout() {
this.user = '';
this.token = '';
this.appusername = '';
uni.removeStorageSync('user');
uni.removeStorageSync('token');
uni.reLaunch({
url: '../login/login',
});
},
// 判断是否登录
comment() {
if (!this.token) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
return false;
}
uni.navigateTo({
url: '../evaluate/evaluate'
});
},
apply() {
if (!this.token) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
return false;
}
uni.navigateTo({
url: '../service-apl/service-apl'
});
},
commentHis() {
if (!this.token) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
return false;
}
uni.navigateTo({
url: '../evaluate-history/evaluate-history'
});
},
aplHis() {
if (!this.token) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
return false;
}
uni.navigateTo({
url: '../service-apl-history/service-apl-history'
});
},
} }
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment