Commit 7c72d7a3 by 莫晓莉

登录注册

parent 0321957c
......@@ -16,8 +16,11 @@ export const sendCode = (data) => {
}
//获取用户信息
export const getUserByToken = (data) => {
return request('getUserByToken', data)
}
//获取项目类型
export const getProjectTypeList = (data) => {
return request('getProjectTypeList', data)
}
......@@ -9,20 +9,11 @@
</view> -->
<view class="type-box">
<!-- <view class="type-box">
<view class="category-title">
星级评价 <text style="color:red;">*</text>
</view>
<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']}"
:data-current="index" @tap="selStar">{{ item.content }}</view>
......@@ -32,7 +23,7 @@
</view>
</view>
</view>
</view> -->
<view class="category-title">
评价内容<text style="color:red;">*</text>
......
......@@ -146,20 +146,44 @@
//登录
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 => {
if (res.code == 200) {
var user={},token='';
user.name=res.data.name;
user.phone=res.data.phone;
user.phone=res.data.userId;
token=res.data.token;
user.name=res.data.data.name;
user.phone=res.data.data.phone;
user.userId=res.data.data.userId;
user.idCard=res.data.data.idCard;
token=res.data.data.token;
uni.showToast({
icon: 'success',
title: '登录成功',
success: () => {
uni.navigateTo({
url: '../user/user?token='+token+"&user="+user,
});
uni.setStorageSync('token', token)
uni.setStorageSync('user', user)
uni.switchTab({
url: '../user/user',
})
}
......
......@@ -25,10 +25,10 @@
</view>
</radio-group>
</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>
<input class="login-item-input" placeholder="请输入残疾证号" v-model="addForm.disableNumber" />
</view>
</view> -->
<view class="login-item mt25">
<image class="login-icon" src="../../static/login/code.png"></image>
......@@ -101,7 +101,14 @@
methods: {
//是否持证
radioChange(e) {
this.selectName = e.detail.value
this.selectName = e.detail.value;
if(this.selectName!=1){
uni.showToast({
icon: 'none',
title: '只有持证才可以注册'
});
return;
}
},
//获取验证码
getCode() {
......@@ -138,20 +145,64 @@
//注册
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 => {
if (res.code == 200) {
uni.showToast({
icon: 'success',
title: '注册成功',
success: () => {
uni.setStorageSync('token', res.data.data.token)
uni.setStorageSync('user', res.data.data)
// uni.setStorageSync('token', res.data.data.token)
// uni.setStorageSync('user', res.data.data)
uni.navigateTo({
url: '../login/login',
});
//获取
getUserByToken().then(res=>{
// getUserByToken().then(res=>{
})
// })
}
......
......@@ -63,7 +63,13 @@
<!-- <image class="remind-icon" mode="aspectFit" style="" src=""></image> -->
</view>
<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="picker-content" style=''>公益服务</view>
<view class="trangle"></view>
......@@ -208,18 +214,34 @@
</template>
<script>
import {
getProjectTypeList
} from "@/api/login"
export default {
data() {
return {
arrayHurt: [{name:'一级'},{name: '二级'}, {name:'三级'}, {name:'四级'}],
index: 0,
projectTypeList:[],//项目类型
}
},
onShow() {
this.getProjectTypeList();
},
methods: {
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为:' + 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>
......
......@@ -2,61 +2,59 @@
<view class="">
<view class="center">
<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>
<view class="logo-title">
<text class="uer-name">Hi,{{hasLogin ? userName : '您未登录'}}</text>
<text class="go-login navigat-arrow" v-if="!hasLogin">&#xe65e;</text>
<text class="uer-name">Hi,{{token ? user.name : '您未登录'}}</text>
<text class="go-login navigat-arrow" v-if="!token">&#xe65e;</text>
</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)">
<text class="list-icon">&#xe60b;</text>
<text class="list-text">{{item2.name}}</text>
<text class="navigat-arrow">&#xe65e;</text>
</view>
<!-- <view class="center-list-item">
<text class="list-icon">&#xe65f;</text>
<text class="list-text">申请服务</text>
<text class="navigat-arrow">&#xe65e;</text>
</view> -->
</view>
<!-- <view class="center-list">
<view class="center-list-item border-bottom">
<view class="center-list">
<view class="center-list-item border-bottom" @click="comment">
<text class="list-icon">&#xe60f;</text>
<text class="list-text">帐号管理</text>
<text class="list-text">满意度评价</text>
<text class="navigat-arrow">&#xe65e;</text>
</view>
<view class="center-list-item">
<view class="center-list-item" @click="apply">
<text class="list-icon">&#xe639;</text>
<text class="list-text">新消息通知</text>
<text class="list-text">申请服务</text>
<text class="navigat-arrow">&#xe65e;</text>
</view>
</view>
<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-text">帮助与反馈</text>
<text class="list-text">历史评价</text>
<text class="navigat-arrow">&#xe65e;</text>
</view>
<view class="center-list-item">
<view class="center-list-item" @click="aplHis">
<text class="list-icon">&#xe65f;</text>
<text class="list-text">服务条款及隐私</text>
<text class="list-text">服务申请记录</text>
<text class="navigat-arrow">&#xe65e;</text>
</view>
</view>
<view class="center-list">
<view class="center-list-item">
<text class="list-icon">&#xe614;</text>
<text class="list-text">关于应用</text>
<view class="center-list" >
<!-- <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>
</view>
</view> -->
<view class="btn-row">
<button v-if="hasLogin" class="primary" type="primary" @tap="bindLogout">退出登录</button>
</view>
<!-- <view class="btn-row">
<button class="primary" type="primary" @tap="bindLogout">退出登录</button>
</view> -->
</view>
</view>
</template>
......@@ -70,7 +68,7 @@
export default {
data() {
return {
avatarUrl: "../../static/img/logo.png",
avatarUrl: "../../static/img/logo.png",//未登录时的头像
navList: [
{
id: 1,
......@@ -101,81 +99,159 @@
],
},
]
],
user:{},//用户信息
}
},
computed: {
...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: {
...mapMutations(['logout']),
// ...mapMutations(['logout']),
// bindLogin() {
// uni.navigateTo({
// url: '../login/login',
// });
// },
// bindLogout() {
// const loginType = uni.getStorageSync('login_type')
// if (loginType === 'local') {
// this.logout();
// if (this.forcedLogin) {
// uni.reLaunch({
// url: '../login/login',
// });
// }
// return
// }
// uniCloud.callFunction({
// name: 'user-center',
// data: {
// action: 'logout'
// },
// success: (e) => {
// console.log('logout success', e);
// if (e.result.code == 0) {
// this.logout();
// uni.removeStorageSync('uniIdToken')
// uni.removeStorageSync('username')
// /**
// * 如果需要强制登录跳转回登录页面
// */
// if (this.forcedLogin) {
// uni.reLaunch({
// url: '../login/login',
// });
// }
// } else {
// uni.showModal({
// content: e.result.msg,
// showCancel: false
// })
// console.log('登出失败', e);
// }
// },
// fail(e) {
// uni.showModal({
// content: JSON.stringify(e),
// showCancel: false
// })
// }
// })
// },
bindLogin() {
uni.navigateTo({
url: '../login/login',
});
},
bindLogout() {
const loginType = uni.getStorageSync('login_type')
if (loginType === 'local') {
this.logout();
if (this.forcedLogin) {
uni.reLaunch({
url: '../login/login',
// 路径跳转start
goDetailPage(e) {
let path = e.url;
// let url ='/pages/'+path+'/'+path;
uni.navigateTo({
url: path
});
}
return
}
uniCloud.callFunction({
name: 'user-center',
data: {
action: 'logout'
},
success: (e) => {
console.log('logout success', e);
if (e.result.code == 0) {
this.logout();
uni.removeStorageSync('uniIdToken')
uni.removeStorageSync('username')
/**
* 如果需要强制登录跳转回登录页面
*/
if (this.forcedLogin) {
// 路径跳转end
// 退出登录
logout() {
this.user = '';
this.token = '';
this.appusername = '';
uni.removeStorageSync('user');
uni.removeStorageSync('token');
uni.reLaunch({
url: '../login/login',
});
}
} else {
uni.showModal({
content: e.result.msg,
showCancel: false
})
console.log('登出失败', e);
}
},
fail(e) {
uni.showModal({
content: JSON.stringify(e),
showCancel: false
})
// 判断是否登录
comment() {
if (!this.token) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
return false;
}
})
uni.navigateTo({
url: '../evaluate/evaluate'
});
},
// 路径跳转start
goDetailPage(e) {
let path = e.url;
// let url ='/pages/'+path+'/'+path;
apply() {
if (!this.token) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
return false;
}
uni.navigateTo({
url: path
url: '../service-apl/service-apl'
});
},
commentHis() {
if (!this.token) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
return false;
}
// 路径跳转end
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>
......
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