作者 朱振飞

注册优化

<template>
<view class="content">
<view class="studentMsg">
<view class="item">
<view class="title">姓名</view>
<input type="text" v-model="username" class="inpt" placeholder="请输入姓名" placeholder-style="color:rgba(189,196,206,1);font-size:28rpx;">
</view>
<view class="item">
<view class="title">邮箱</view>
<input type="text" v-model="email" class="inpt" placeholder="请输入邮箱" placeholder-style="color:rgba(189,196,206,1);font-size:28rpx;">
</view>
<view class="item" style="border-bottom:none">
<view class="title">头像</view>
<image @click="upload" class="photo" :src="isUpload ? image : '../../static/touxiang_img@2x.png'"></image>
</view>
</view>
<view class="schoolTitle">高中信息</view>
<view class="studentMsg">
<view class="item" @click="selhigh">
<view class="title">高中</view>
<view class="selectBtn">{{isHighShow? name : '请选择就读高中'}}<image class="icon" src="../../static/zhuandao_icon@2x.png"></image></view>
</view>
<view class="item">
<view class="title">毕业年份</view>
<!-- <view class="selectBtn">请选择毕业年份<image class="icon" src="../../static/zhuandao_icon@2x.png"></image></view> -->
<view @click="selDate" style="display: flex;justify-content: space-between;align-items: center;">
<picker mode="date" :value="date" start="2000-01-01" @change="bindTimeChange">
<view class="selectBtn">{{isDateShow? date : '请选择毕业年份'}}</view>
</picker>
<image class="icon" src="../../static/zhuandao_icon@2x.png"></image>
</view>
</view>
<view class="item" @click="subPopupShow">
<view class="title">选考科目</view>
<view class="selectBtn">{{subid.toString()!='' ? subname.toString() : "请选择选考科目"}}<image class="icon" src="../../static/zhuandao_icon@2x.png"></image></view>
</view>
<view class="item" style="border-bottom:none" @click="stylePopupShow">
<view class="title">升学方式</view>
<view class="selectBtn">{{isupnameshow? upname : "请选择升学方式"}}<image class="icon" src="../../static/zhuandao_icon@2x.png"></image></view>
</view>
</view>
<view class="schoolTitle">大学信息</view>
<view class="studentMsg">
<view class="item" @click="selcollege">
<view class="title">就读大学</view>
<view class="selectBtn">{{isNameShow? collegename : '请选择就读大学'}}<image class="icon" src="../../static/zhuandao_icon@2x.png"></image></view>
</view>
<view class="item">
<view class="title">所属学院</view>
<view class="selectBtn" @click="tocollege">{{iscollgegshow? academyname : '请选择所属学院' }}<image class="icon" src="../../static/zhuandao_icon@2x.png"></image></view>
</view>
<view class="item" style="border-bottom:none" @click="tomajor">
<view class="title">就读专业</view>
<view class="selectBtn">{{ismajorshow? academyname : '请选择所属专业' }}<image class="icon" src="../../static/zhuandao_icon@2x.png"></image></view>
</view>
</view>
<view class="okBtn" @click="collegeregister">注册</view>
<view class="subPopup" v-if="isSubPopupShow">
<view class="selectCard">
<view class="buttonBox">
<view class="closeBtn" @click="subPopupHide">取消</view>
<view class="confimBtn" @click="subPopupHide">确定</view>
</view>
<view class="subBox">
<view class="subject" @click="selsub" :class="{active:subid.indexOf(item.id)!=-1}" v-for="(item,index) in sublist" :key="index" :data-id="item.id" :data-name="item.name">{{item.name}}</view>
</view>
</view>
</view>
<view class="stylePopup" v-if="isStylePopupShow">
<view class="styleCard">
<view class="buttonBox">
<view class="closeBtn" @click="stylePopupHide">取消</view>
<view class="confimBtn" @click="stylePopupHide">确定</view>
</view>
<view class="subBox">
<view class="subject" :class="{active:upid==item.id}" @click="selup" v-for="(item,index) in uplist" :key="index" :data-id="item.id" :data-name="item.name">{{item.name}}</view>
</view>
</view>
</view>
</view>
<view class="content">
<view class="studentMsg">
<view class="item">
<view class="title">姓名</view>
<input type="text" v-model="username" class="inpt" placeholder="请输入姓名" placeholder-style="color:rgba(189,196,206,1);font-size:28rpx;" />
</view>
<view class="item">
<view class="title">邮箱</view>
<input type="text" v-model="email" class="inpt" placeholder="请输入邮箱" placeholder-style="color:rgba(189,196,206,1);font-size:28rpx;" />
</view>
<view class="item" style="border-bottom:none">
<view class="title">头像</view>
<image @click="upload" class="photo" :src="isUpload ? uploadImg : '../../static/touxiang_img@2x.png'"></image>
</view>
</view>
<view class="schoolTitle">高中信息</view>
<view class="studentMsg">
<view class="item" @click="selhigh">
<view class="title">高中</view>
<view class="selectBtn">
{{ isHighShow ? name : '请选择就读高中' }}
<image class="icon" src="../../static/zhuandao_icon@2x.png"></image>
</view>
</view>
<view class="item">
<view class="title">毕业年份</view>
<!-- <view class="selectBtn">请选择毕业年份<image class="icon" src="../../static/zhuandao_icon@2x.png"></image></view> -->
<view @click="selDate" style="display: flex;justify-content: space-between;align-items: center;">
<picker mode="date" :value="date" start="2000-01-01" @change="bindTimeChange">
<view class="selectBtn">{{ isDateShow ? date : '请选择毕业年份' }}</view>
</picker>
<image class="icon" src="../../static/zhuandao_icon@2x.png"></image>
</view>
</view>
<view class="item" @click="subPopupShow">
<view class="title">选考科目</view>
<view class="selectBtn">
{{ subid.toString() != '' ? subname.toString() : '请选择选考科目' }}
<image class="icon" src="../../static/zhuandao_icon@2x.png"></image>
</view>
</view>
<view class="item" style="border-bottom:none" @click="stylePopupShow">
<view class="title">升学方式</view>
<view class="selectBtn">
{{ isupnameshow ? upname : '请选择升学方式' }}
<image class="icon" src="../../static/zhuandao_icon@2x.png"></image>
</view>
</view>
</view>
<view class="schoolTitle">大学信息</view>
<view class="studentMsg">
<view class="item" @click="selcollege">
<view class="title">就读大学</view>
<view class="selectBtn">
{{ isNameShow ? collegename : '请选择就读大学' }}
<image class="icon" src="../../static/zhuandao_icon@2x.png"></image>
</view>
</view>
<view class="item">
<view class="title">所属学院</view>
<view class="selectBtn" @click="tocollege">
{{ iscollgegshow ? academyname : '请选择所属学院' }}
<image class="icon" src="../../static/zhuandao_icon@2x.png"></image>
</view>
</view>
<view class="item" style="border-bottom:none" @click="tomajor">
<view class="title">就读专业</view>
<view class="selectBtn">
{{ ismajorshow ? academyname : '请选择所属专业' }}
<image class="icon" src="../../static/zhuandao_icon@2x.png"></image>
</view>
</view>
</view>
<view class="okBtn" @click="collegeregister">注册</view>
<view class="subPopup" v-if="isSubPopupShow">
<view class="selectCard">
<view class="buttonBox">
<view class="closeBtn" @click="subPopupHide">取消</view>
<view class="confimBtn" @click="subPopupHide">确定</view>
</view>
<view class="subBox">
<view
class="subject"
@click="selsub"
:class="{ active: subid.indexOf(item.id) != -1 }"
v-for="(item, index) in sublist"
:key="index"
:data-id="item.id"
:data-name="item.name"
>
{{ item.name }}
</view>
</view>
</view>
</view>
<view class="stylePopup" v-if="isStylePopupShow">
<view class="styleCard">
<view class="buttonBox">
<view class="closeBtn" @click="stylePopupHide">取消</view>
<view class="confimBtn" @click="stylePopupHide">确定</view>
</view>
<view class="subBox">
<view
class="subject"
:class="{ active: upid == item.id }"
@click="selup"
v-for="(item, index) in uplist"
:key="index"
:data-id="item.id"
:data-name="item.name"
>
{{ item.name }}
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import app from "../../App.vue"
import app from '../../App.vue';
export default {
data(){
return{
isSubPopupShow:false,
isStylePopupShow:false,
username:'',
image:'',
isUpload:false,
date: '请选择毕业年份',
isDateShow: false,
uplist:[],
upid:'1',
subid:[],
sublist:[],
collegename:'请选择就读大学',
isNameShow:false,
isHighShow:false,
name:'请选择就读高中',
subname:[],
issubnameshow:false,
upname:'请选择升学方式',
isupnameshow:false,
school_id:'',
uni_id:'',
academyname:'请选择所属学院',
iscollgegshow:false,
majorname:'请选择所属专业',
ismajorshow:false,
email:'',
majorid:'',
academyid:'',
chuanimg:''
}
},
methods:{
selDate(){
this.isDateShow=true
},
subPopupShow(){
this.isSubPopupShow=true
},
subPopupHide(){
this.isSubPopupShow=false
},
stylePopupShow(){
this.isStylePopupShow=true
},
stylePopupHide(){
this.isStylePopupShow=false
},
// toSchoolmate(){
data() {
return {
isSubPopupShow: false,
isStylePopupShow: false,
username: '',
image: '',
isUpload: false,
date: '请选择毕业年份',
isDateShow: false,
uplist: [],
upid: '1',
subid: [],
sublist: [],
collegename: '请选择就读大学',
isNameShow: false,
isHighShow: false,
name: '请选择就读高中',
subname: [],
issubnameshow: false,
upname: '请选择升学方式',
isupnameshow: false,
school_id: '',
uni_id: '',
academyname: '请选择所属学院',
iscollgegshow: false,
majorname: '请选择所属专业',
ismajorshow: false,
email: '',
majorid: '',
academyid: '',
chuanimg: '',
baseUrl: app.globalData.imageBaseUrl,
uploadImg: ''
};
},
methods: {
selDate() {
this.isDateShow = true;
},
subPopupShow() {
this.isSubPopupShow = true;
},
subPopupHide() {
this.isSubPopupShow = false;
},
stylePopupShow() {
this.isStylePopupShow = true;
},
stylePopupHide() {
this.isStylePopupShow = false;
},
// wx.navigateTo({
// url: "/pages/schoolmate/schoolmate?type="+2
// })
// },
upload(){
var that = this;
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: function (res) {
const tempFilePaths = res.tempFilePaths;
that.image = tempFilePaths[0];
app.upload('image',res.tempFilePaths[0],"post").then((res)=>{
// let newimage=that.image
that.image=res.url;
that.chuanimg=res.kurl
console.log(res)
console.log(that.image)
console.log(res.url)
// newimage.push(res.url)
that.isUpload=true
}).catch((err)=>{
console.log(err)
})
// console.log("tempFilePaths[0]",tempFilePaths[0]) //能够打印出选中的图片
// console.log(res)
// that.head_image=tempFilePaths[0]
// that.iconcheck = 1;//点击后图片更改状态由0变成1
},
error : function(e){
console.log(e);
}
});
},
bindTimeChange: function(e) {
this.date = e.target.value
},
getUpType(){
var that = this
var url = "university/getAllUp"
var params = {}
app.post(url,params,"get").then((res)=>{
console.log(res)
that.uplist=res
}).catch((err)=>{
console.log(err)
})
},
getAllSub(){
var that=this
var url = "university/listSubject"
var params ={}
app.post(url,params,"get").then((res)=>{
that.sublist=res
console.log(res)
}).catch((err)=>{
console.log(err)
})
},
selup(e){
this.isupnameshow=true
console.log(e.currentTarget.dataset)
this.upid=e.currentTarget.dataset.id
this.upname=e.currentTarget.dataset.name
},
selsub(e){
Array.prototype.remove = function(val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
};
this.issubnameshow=true
if(this.subid.indexOf(e.currentTarget.dataset.id)!=-1){
this.subid.remove(e.currentTarget.dataset.id)
this.subname.remove(e.currentTarget.dataset.name)
}else{
this.subid.push(e.currentTarget.dataset.id)
this.subname.push(e.currentTarget.dataset.name)
}
console.log(this.subid)
upload() {
var that = this;
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: function(res) {
const tempFilePaths = res.tempFilePaths;
that.image = tempFilePaths[0];
app.upload('image', res.tempFilePaths[0], 'post')
.then(res => {
that.image = res.url;
that.chuanimg = res.kurl;
that.uploadImg = that.baseUrl + res.kurl;
that.isUpload = true;
})
.catch(err => {
console.log(err);
});
},
error: function(e) {
console.log(e);
}
});
},
bindTimeChange: function(e) {
this.date = e.target.value;
},
getUpType() {
var that = this;
var url = 'university/getAllUp';
var params = {};
app.post(url, params, 'get')
.then(res => {
console.log(res);
that.uplist = res;
})
.catch(err => {
console.log(err);
});
},
getAllSub() {
var that = this;
var url = 'university/listSubject';
var params = {};
app.post(url, params, 'get')
.then(res => {
that.sublist = res;
console.log(res);
})
.catch(err => {
console.log(err);
});
},
selup(e) {
this.isupnameshow = true;
console.log(e.currentTarget.dataset);
this.upid = e.currentTarget.dataset.id;
this.upname = e.currentTarget.dataset.name;
},
selsub(e) {
Array.prototype.remove = function(val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
};
this.issubnameshow = true;
if (this.subid.indexOf(e.currentTarget.dataset.id) != -1) {
this.subid.remove(e.currentTarget.dataset.id);
this.subname.remove(e.currentTarget.dataset.name);
} else {
this.subid.push(e.currentTarget.dataset.id);
this.subname.push(e.currentTarget.dataset.name);
}
console.log(this.subid);
},
selcollege() {
this.isNameShow = true;
uni.navigateTo({
url: './selectCollege'
});
},
selhigh() {
this.isHighShow = true;
uni.navigateTo({
url: './selectSchool'
});
},
tocollege() {
this.iscollgegshow = true;
var school_id = this.uni_id;
console.log(school_id);
uni.navigateTo({
url: './selectAcademy?uni_id=' + school_id
});
},
tomajor() {
this.ismajorshow = true;
},
selcollege(){
this.isNameShow=true
uni.navigateTo({
url:'./selectCollege'
})
},
selhigh(){
this.isHighShow=true
uni.navigateTo({
url:'./selectSchool'
})
},
tocollege(){
this.iscollgegshow=true
var school_id = this.uni_id
console.log(school_id)
uni.navigateTo({
url:'./selectAcademy?uni_id='+school_id
})
},
tomajor(){
this.ismajorshow=true
uni.navigateTo({
url:'./selectMajor'
})
},
collegeregister(){
var that = this
if(that.username==''){
uni.showToast({
title:"姓名不能为空",
icon:"none"
})
return false
}
var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/ ;
if(!reg.test(that.email)){
uni.showToast({
title:"请输入正确邮箱",
icon:"none"
})
return false
}
if(that.image==''){
uni.showToast({
title:"请选择头像",
icon:"none"
})
return false
}
if(that.name=='请选择就读高中'){
uni.showToast({
title:"请选择高中",
icon:"none"
})
return false
}
if(that.date=='请选择毕业年份'){
uni.showToast({
title:"请选择毕业年份",
icon:"none"
})
return false
}
if(that.subname=='请选择选考科目'){
uni.showToast({
title:"请选择选考科目",
icon:"none"
})
return false
}
if(that.upname=='请选择升学方式'){
uni.showToast({
title:"请选择升学方式",
icon:"none"
})
return false
}
if(that.collegename=='请选择就读大学'){
uni.showToast({
title:"请选择就读大学",
icon:"none"
})
return false
}
if(that.academyname=='请选择所属学院'){
uni.showToast({
title:"请选择所属学院",
icon:"none"
})
return false
}
if(that.majorname=='请选择所属专业'){
uni.showToast({
title:"请选择所属专业",
icon:"none"
})
return false
}
var url = "register/register"
var token = uni.getStorageSync('token')
var params = {
token:token,
level:2,
nickname:that.username,
head_image:that.chuanimg,
school_id:that.school_id,
email:that.email,
endtime:that.date,
subject_ids:that.subid.toString(),
up_id:that.upid,
university_id:that.uni_id,
graduated_id:that.majorid,
college_id:that.academyid
}
app.post(url,params,"post").then((res)=>{
console.log(res)
// console.log(res)
uni.showToast({
title:"注册成功",
icon:"none"
})
setTimeout(() => {
uni.navigateTo({
url: "/pages/schoolmate/schoolmate?type="+2
})
}, 1500);
}).catch((err)=>{
console.log(err)
if(err.code==0){
uni.showToast({
title:err.msg,
icon:'none'
})
}
})
}
},
onLoad(){
this.getUpType()
this.getAllSub()
}
}
uni.navigateTo({
url: './selectMajor'
});
},
collegeregister() {
var that = this;
if (that.username == '') {
uni.showToast({
title: '姓名不能为空',
icon: 'none'
});
return false;
}
var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
if (!reg.test(that.email)) {
uni.showToast({
title: '请输入正确邮箱',
icon: 'none'
});
return false;
}
if (that.image == '') {
uni.showToast({
title: '请选择头像',
icon: 'none'
});
return false;
}
if (that.name == '请选择就读高中') {
uni.showToast({
title: '请选择高中',
icon: 'none'
});
return false;
}
if (that.date == '请选择毕业年份') {
uni.showToast({
title: '请选择毕业年份',
icon: 'none'
});
return false;
}
if (that.subname == '请选择选考科目') {
uni.showToast({
title: '请选择选考科目',
icon: 'none'
});
return false;
}
if (that.upname == '请选择升学方式') {
uni.showToast({
title: '请选择升学方式',
icon: 'none'
});
return false;
}
if (that.collegename == '请选择就读大学') {
uni.showToast({
title: '请选择就读大学',
icon: 'none'
});
return false;
}
if (that.academyname == '请选择所属学院') {
uni.showToast({
title: '请选择所属学院',
icon: 'none'
});
return false;
}
if (that.majorname == '请选择所属专业') {
uni.showToast({
title: '请选择所属专业',
icon: 'none'
});
return false;
}
var url = 'register/register';
var token = uni.getStorageSync('token');
var params = {
token: token,
level: 2,
nickname: that.username,
head_image: that.chuanimg,
school_id: that.school_id,
email: that.email,
endtime: that.date,
subject_ids: that.subid.toString(),
up_id: that.upid,
university_id: that.uni_id,
graduated_id: that.majorid,
college_id: that.academyid
};
app.post(url, params, 'post')
.then(res => {
console.log(res);
// console.log(res)
uni.showToast({
title: '注册成功',
icon: 'none'
});
setTimeout(() => {
uni.navigateTo({
url: '/pages/schoolmate/schoolmate?type=' + 2
});
}, 1500);
})
.catch(err => {
console.log(err);
if (err.code == 0) {
uni.showToast({
title: err.msg,
icon: 'none'
});
}
});
}
},
onLoad() {
this.getUpType();
this.getAllSub();
}
};
</script>
<style lang="less">
.content{
padding: 32rpx;
background:rgba(249,249,249,1);
font-size: 28rpx;
.studentMsg{
background-color: #fff;
padding: 0rpx 32rpx;
border-radius:20rpx;
.item{
height: 114rpx;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1rpx solid rgba(238,238,238,1);
font-size: 28rpx;
.title{
// line-height: 114px;
padding: 30rpx 0;
// box-sizing: border-box;
}
.selectBtn{
color:rgba(189,196,206,1);
line-height: 114rpx;
}
.icon{
width: 13rpx;
height: 24rpx;
margin-left: 8rpx;
}
.inpt{
height: 114rpx;
text-align: right;
// width: 250rpx;
}
.photo{
width: 64rpx;
height: 64rpx;
margin-top: 20rpx;
border-radius: 50%;
}
}
}
.schoolTitle{
font-size:32rpx;
color:rgba(45,85,117,1);
margin-top: 44rpx;
margin-bottom: 12rpx;
}
.okBtn{
width:686rpx;
height:80rpx;
background:rgba(45,85,117,1);
opacity:1;
border-radius:8rpx;
font-size: 28rpx;
color: #fff;
line-height: 80rpx;
text-align: center;
margin-top: 56rpx;
}
.subPopup{
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 999;
.selectCard{
width: 750rpx;
height: 426rpx;
background:rgba(255,255,255,1);
// opacity:1;
border-radius:20px 20px 0px 0px;
position: absolute;
bottom: 0;
.buttonBox{
display: flex;
justify-content: space-between;
padding: 28rpx 30rpx;
font-size: 28rpx;
.closeBtn{
color:rgba(140,145,152,1);
}
.confimBtn{
color:rgba(45,85,117,1);
}
}
.subBox{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 16rpx 32rpx;
.active{
background:rgba(129,195,191,1);
border:2rpx solid rgba(129,195,191,1);
color: #fff;
}
}
.subject{
width:28%;
height:56rpx;
background: #fff;
border:1rpx solid rgba(6,18,30,1);
opacity:1;
border-radius:40rpx;
text-align: center;
line-height: 56rpx;
color:rgba(6,18,30,1);
font-size: 28rpx;
margin-bottom: 36rpx;
}
}
}
.stylePopup{
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 999;
.styleCard{
width: 750rpx;
height: 228rpx;
background:rgba(255,255,255,1);
// opacity:1;
border-radius:20px 20px 0px 0px;
position: absolute;
bottom: 0;
.buttonBox{
display: flex;
justify-content: space-between;
padding: 28rpx 30rpx;
font-size: 28rpx;
.closeBtn{
color:rgba(140,145,152,1);
}
.confimBtn{
color:rgba(45,85,117,1);
}
}
.subBox{
display: flex;
flex-wrap: wrap;
justify-content: space-around;
padding: 16rpx 32rpx;
.active{
background:rgba(129,195,191,1);
border:2rpx solid rgba(129,195,191,1);
color: #fff;
}
}
.subject{
width:28%;
height:56rpx;
background: #fff;
border:1rpx solid rgba(6,18,30,1);
opacity:1;
border-radius:40rpx;
text-align: center;
line-height: 56rpx;
color:rgba(6,18,30,1);
font-size: 28rpx;
margin-bottom: 36rpx;
}
}
}
.content {
padding: 32rpx;
background: rgba(249, 249, 249, 1);
font-size: 28rpx;
.studentMsg {
background-color: #fff;
padding: 0rpx 32rpx;
border-radius: 20rpx;
.item {
height: 114rpx;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1rpx solid rgba(238, 238, 238, 1);
font-size: 28rpx;
.title {
// line-height: 114px;
padding: 30rpx 0;
// box-sizing: border-box;
}
.selectBtn {
color: rgba(189, 196, 206, 1);
line-height: 114rpx;
}
.icon {
width: 13rpx;
height: 24rpx;
margin-left: 8rpx;
}
.inpt {
height: 114rpx;
text-align: right;
// width: 250rpx;
}
.photo {
width: 64rpx;
height: 64rpx;
margin-top: 20rpx;
border-radius: 50%;
}
}
}
.schoolTitle {
font-size: 32rpx;
color: rgba(45, 85, 117, 1);
margin-top: 44rpx;
margin-bottom: 12rpx;
}
.okBtn {
width: 686rpx;
height: 80rpx;
background: rgba(45, 85, 117, 1);
opacity: 1;
border-radius: 8rpx;
font-size: 28rpx;
color: #fff;
line-height: 80rpx;
text-align: center;
margin-top: 56rpx;
}
.subPopup {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 999;
.selectCard {
width: 750rpx;
height: 426rpx;
background: rgba(255, 255, 255, 1);
// opacity:1;
border-radius: 20px 20px 0px 0px;
position: absolute;
bottom: 0;
.buttonBox {
display: flex;
justify-content: space-between;
padding: 28rpx 30rpx;
font-size: 28rpx;
.closeBtn {
color: rgba(140, 145, 152, 1);
}
.confimBtn {
color: rgba(45, 85, 117, 1);
}
}
.subBox {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 16rpx 32rpx;
.active {
background: rgba(129, 195, 191, 1);
border: 2rpx solid rgba(129, 195, 191, 1);
color: #fff;
}
}
.subject {
width: 28%;
height: 56rpx;
background: #fff;
border: 1rpx solid rgba(6, 18, 30, 1);
opacity: 1;
border-radius: 40rpx;
text-align: center;
line-height: 56rpx;
color: rgba(6, 18, 30, 1);
font-size: 28rpx;
margin-bottom: 36rpx;
}
}
}
.stylePopup {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 999;
.styleCard {
width: 750rpx;
height: 228rpx;
background: rgba(255, 255, 255, 1);
// opacity:1;
border-radius: 20px 20px 0px 0px;
position: absolute;
bottom: 0;
.buttonBox {
display: flex;
justify-content: space-between;
padding: 28rpx 30rpx;
font-size: 28rpx;
.closeBtn {
color: rgba(140, 145, 152, 1);
}
.confimBtn {
color: rgba(45, 85, 117, 1);
}
}
.subBox {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
padding: 16rpx 32rpx;
.active {
background: rgba(129, 195, 191, 1);
border: 2rpx solid rgba(129, 195, 191, 1);
color: #fff;
}
}
.subject {
width: 28%;
height: 56rpx;
background: #fff;
border: 1rpx solid rgba(6, 18, 30, 1);
opacity: 1;
border-radius: 40rpx;
text-align: center;
line-height: 56rpx;
color: rgba(6, 18, 30, 1);
font-size: 28rpx;
margin-bottom: 36rpx;
}
}
}
}
</style>
\ No newline at end of file
</style>
... ...
... ... @@ -72,7 +72,6 @@
wxGetUserInfo(e) {
let that = this;
console.log(e)
// type:1 高中生 2 大学生
let type = e.currentTarget.dataset.type;
console.log(type)
... ... @@ -107,6 +106,7 @@
console.log(r)
that.session_key = r.session_key;
that.openid = r.openid;
console.log(that.session_key);
console.log(that.openid)
... ... @@ -132,7 +132,6 @@
encryptedData: that.encrypted_data,
iv: that.iv
}
console.log(param)
app.post(url, param, "get").then(r => {
uni.setStorageSync('token', r.userInfo.token);
... ...
... ... @@ -121,6 +121,9 @@ export default {
text-align: center;
margin-right: 14rpx;
margin-bottom: 16rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
}
... ...
... ... @@ -174,6 +174,8 @@ export default {
color:rgba(6,18,30,1);
height: 100vh;
font-size: 28rpx;
display: flex;
flex-direction: column;
// padding: 0 32rpx;
.selectCity{
display: flex;
... ... @@ -195,6 +197,9 @@ export default {
.list{
font-size: 28rpx;
padding: 12rpx 32rpx;
flex: 1;
margin-bottom: 100rpx;
overflow-y: scroll;
.item{
padding: 28rpx 0;
border-bottom: 1rpx solid rgba(238,238,238,1);
... ...
... ... @@ -170,6 +170,9 @@ export default {
background:rgba(249,249,249,1);
color:rgba(6,18,30,1);
height: 100vh;
display: flex;
flex-direction: column;
// padding: 0 32rpx;
.selectCity{
display: flex;
... ... @@ -191,6 +194,9 @@ export default {
.list{
font-size: 28rpx;
padding: 12rpx 32rpx;
box-sizing: border-box;
overflow-y: scroll;
margin-bottom: 100rpx;
.item{
padding: 28rpx 0;
border-bottom: 1rpx solid rgba(238,238,238,1);
... ...
... ... @@ -70,10 +70,12 @@
word:'',
schoollist:[],
isnulldata:false,
token:''
token:'',
isRegister: 0,
}
},
onLoad(options){
this.code2Token();
this.token=uni.getStorageSync('token')
console.log(options);
// this.getschoollist();
... ... @@ -89,7 +91,22 @@
uni.redirectTo({
url: url
})
},
code2Token(){
let that = this;
uni.login({
success(res) {
let url = 'common/codeToToken'
app.post(url,{
code: res.code
}).then(r=>{
console.log()
uni.setStorageSync('token',r.userInfo.token);
uni.setStorageSync('isRegister',r.userInfo.is_register);
that.isRegister = r.userInfo.is_register;
})
}
})
},
// 获取大学列表
... ... @@ -167,9 +184,21 @@
})
}, 1500);
}else{
wx.navigateTo({
url:'./searchSchool'
})
if(this.isRegister == 0){
uni.showToast({
title: '请完善信息后操作',
icon: 'none'
})
setTimeout(() => {
uni.navigateTo({
url:'../register/register?istoken='+1
})
}, 1500);
}else{
wx.navigateTo({
url:'./searchSchool'
})
}
}
},
... ...
<template>
<view class="content">
<view class="top">
<view class="search">
<image class="icon" src="../../static/sousuo_icon@2x.png"></image>
<input type="text" placeholder="请输入搜索内容" class="input" placeholder-style="color:rgba(189,196,206,1);font-size:28rpx;" style="font-size:28rpx;" v-model="word">
</view>
<view class="searchBtn" @click="getschoollist">搜索</view>
</view>
<view class="type">
<view class="paiming" :class="{'active':active1}" @click="paimingShow">排名</view>
<view class="diqu" :class="{'active':active2}" @click="diquShow">地区</view>
<view class="paimingPopup" v-if="isPaimingShow">
<view class="title" @click="selectalllevel">全部</view>
<view class="item" @click="paimingHide" v-for="(item,index) in levelList" :key="index">{{item.name}}</view>
<!-- <view class="item" @click="paimingHide">{{item.name}}</view> -->
</view>
<view class="diquPopup" v-if="isDiquShow">
<view class="title" @click="selectallprovince">全部地区</view>
<view class="cont">
<view class="colum">
<view class="item" @click="selectprovince" v-for="(item,index) in provinceList" :key="index" :data-id="item.code">{{item.name}}</view>
</view>
<view class="colum">
<view class="item" @click="selectcity" v-for="(item,index) in cityList" :key="index" :data-id="item.code">{{item.name}}</view>
</view>
</view>
</view>
</view>
<view class="contentBox">
<view class="item" v-for="(item,index) in schoolList" :key="index" @click="godetail(item)">
<view class="title">{{item.name}}</view>
<image class="icon" :src="item.icon_image"></image>
</view>
</view>
</view>
<view class="content">
<view class="conet_top">
<view class="top">
<view class="search">
<image class="icon" src="../../static/sousuo_icon@2x.png"></image>
<input
type="text"
placeholder="请输入搜索内容"
class="input"
placeholder-style="color:rgba(189,196,206,1);font-size:28rpx;"
style="font-size:28rpx;"
v-model="word"
/>
</view>
<view class="searchBtn" @click="getschoollist">搜索</view>
</view>
<view class="type">
<view class="paiming" :class="{ active: active1 }" @click="paimingShow">排名</view>
<view class="diqu" :class="{ active: active2 }" @click="diquShow">地区</view>
<view class="paimingPopup" v-if="isPaimingShow">
<view class="title" @click="selectalllevel">全部</view>
<view class="item" @click="paimingHide" v-for="(item, index) in levelList" :key="index">{{ item.name }}</view>
<!-- <view class="item" @click="paimingHide">{{item.name}}</view> -->
</view>
<view class="diquPopup" v-if="isDiquShow">
<view class="title" @click="selectallprovince">全部地区</view>
<view class="cont">
<view class="colum">
<view class="item" @click="selectprovince" v-for="(item, index) in provinceList" :key="index" :data-id="item.code">{{ item.name }}</view>
</view>
<view class="colum">
<view class="item" @click="selectcity" v-for="(item, index) in cityList" :key="index" :data-id="item.code">{{ item.name }}</view>
</view>
</view>
</view>
</view>
</view>
<view class="contentBox">
<view class="item" v-for="(item, index) in schoolList" :key="index" @click="godetail(item)">
<view class="title">{{ item.name }}</view>
<image class="icon" :src="item.icon_image"></image>
</view>
</view>
</view>
</template>
<script>
import app from "../../App.vue";
import app from '../../App.vue';
export default {
data(){
return{
isPaimingShow:false,
isDiquShow:false,
active1:false,
// isDiquShow:false,
active2:false,
province_id:"",
city_id:'',
level_id:'',
provinceList:[],
cityList:[],
schoolList:[],
word:'',
page:'1',
levelList:[]
}
},
methods:{
paimingShow(event){
this.isPaimingShow=true;
this.isDiquShow=false
this.active1=true,
this.active2=false
},
paimingHide(){
this.isPaimingShow=false;
this.active1=false,
this.active2=false
},
diquShow(){
this.isDiquShow=true;
this.isPaimingShow=false;
this.active2=true,
this.active1=false
},
diquHide(){
this.isDiquShow=false,
this.active1=false,
this.active2=false
},
//获取全部地区(省)
getAllProvince(){
var url ="city/getAllProvince"
var params ={}
app.post(url,params,"get").then((res)=>{
this.provinceList=res
console.log(res)
}).catch((err)=>{
console.log(err)
})
},
//市
getAllCity(){
var url = "city/getCity"
var params = {
province_id:this.province_id
}
app.post(url,params,"get").then((res)=>{
console.log(res)
this.cityList=res
}).catch((err)=>{
console.log(err)
})
},
//点击选中的省
selectprovince(e){
this.province_id=e.currentTarget.dataset.id
this.getAllCity()
},
//点击全部省
selectallprovince(){
this.getschoollist()
this.isDiquShow=false
},
//点击选中全部市
selectallcity(){
this.getschoollist()
this.isDiquShow=false
},
//点击选中的市
selectcity(e){
this.city_id=e.currentTarget.dataset.id
this.getschoollist()
this.isDiquShow=false
},
// getAllSchool(){
// var url="city/getUniversityByCity"
// var params ={
// city_id:this.city_id
// }
// app.post(url,params,"get").then((res)=>{
// console.log(res)
// this.schoolList=res
// }).catch((err)=>{
// console.log(err)
// })
// },
// 获取大学列表
getschoollist(){
let that = this;
var url = 'university/getUniversityList';
var params = {
page:that.page,
size:10,
word:that.word,
level_id:that.level_id,
province_id:that.province_id
}
app.post(url, params,"post").then((res) => {
console.log(res);
that.schoolList=res
}).catch((err) => {
})
},
//获取全部排名
getAllLevel(){
let that = this;
var url = 'university/getUniversityLevel'
var params={}
app.post(url,params,"get").then((res)=>{
that.levelList=res
}).catch((err)=>{
console.log(err)
})
},
//点击全部排名
selectalllevel(){
this.isPaimingShow=false
this.getschoollist()
data() {
return {
isPaimingShow: false,
isDiquShow: false,
active1: false,
// isDiquShow:false,
active2: false,
province_id: '',
city_id: '',
level_id: '',
provinceList: [],
cityList: [],
schoolList: [],
word: '',
page: '1',
levelList: []
};
},
methods: {
paimingShow(event) {
this.isPaimingShow = true;
this.isDiquShow = false;
(this.active1 = true), (this.active2 = false);
},
paimingHide() {
this.isPaimingShow = false;
(this.active1 = false), (this.active2 = false);
},
diquShow() {
this.isDiquShow = true;
this.isPaimingShow = false;
(this.active2 = true), (this.active1 = false);
},
diquHide() {
(this.isDiquShow = false), (this.active1 = false), (this.active2 = false);
},
//获取全部地区(省)
getAllProvince() {
var url = 'city/getAllProvince';
var params = {};
app.post(url, params, 'get')
.then(res => {
this.provinceList = res;
console.log(res);
})
.catch(err => {
console.log(err);
});
},
},
// 进入学校详情页
godetail(item){
let id=item.id;
//市
getAllCity() {
var url = 'city/getCity';
var params = {
province_id: this.province_id
};
app.post(url, params, 'get')
.then(res => {
console.log(res);
this.cityList = res;
})
.catch(err => {
console.log(err);
});
},
//点击选中的省
selectprovince(e) {
this.province_id = e.currentTarget.dataset.id;
this.getAllCity();
},
//点击全部省
selectallprovince() {
this.getschoollist();
this.isDiquShow = false;
},
//点击选中全部市
selectallcity() {
this.getschoollist();
this.isDiquShow = false;
},
//点击选中的市
selectcity(e) {
this.city_id = e.currentTarget.dataset.id;
this.getschoollist();
this.isDiquShow = false;
},
// getAllSchool(){
// var url="city/getUniversityByCity"
// var params ={
// city_id:this.city_id
// }
// app.post(url,params,"get").then((res)=>{
// console.log(res)
// this.schoolList=res
// }).catch((err)=>{
// console.log(err)
// })
// },
// 获取大学列表
getschoollist() {
let that = this;
var url = 'university/getUniversityList';
var params = {
page: that.page,
size: 10,
word: that.word,
level_id: that.level_id,
province_id: that.province_id
};
app.post(url, params, 'post')
.then(res => {
console.log(res);
that.schoolList = res;
})
.catch(err => {});
},
//获取全部排名
getAllLevel() {
let that = this;
var url = 'university/getUniversityLevel';
var params = {};
app.post(url, params, 'get')
.then(res => {
that.levelList = res;
})
.catch(err => {
console.log(err);
});
},
//点击全部排名
selectalllevel() {
this.isPaimingShow = false;
this.getschoollist();
},
// 进入学校详情页
godetail(item) {
let id = item.id;
uni.navigateTo({
url:'./schoolDetails?id='+id
})
},
},
onLoad(){
this.getAllProvince()
this.getschoollist()
this.getAllLevel()
}
}
url: './schoolDetails?id=' + id
});
}
},
onLoad() {
this.getAllProvince();
this.getschoollist();
this.getAllLevel();
}
};
</script>
<style lang="less">
.content{
background-color: rgba(249,249,249,1);
.top{
padding: 18rpx 32rpx;
display: flex;
background-color: #fff;
}
.search{
// background-color: #fff;
display: flex;
// text-align: center;
align-items: center;
width:596rpx;
height:64rpx;
background:rgba(238,238,238,1);
opacity:1;
border-radius:40rpx;
padding: 0 28rpx;
box-sizing: border-box;
.icon{
width: 30rpx;
height: 30rpx;
}
.input{
height: 64rpx;
width: 500rpx;
text-align: center;
}
}
.searchBtn{
color:rgba(6,18,30,1);
font-size: 28rpx;
line-height: 64rpx;
margin-left: 20rpx;
}
.type{
display: flex;
color:rgba(6,18,30,1);
font-size: 24rpx;
background-color: #fff;
padding: 24rpx 32rpx;
margin-top: 2rpx;
.paiming,.diqu{
margin-right: 72rpx;
}
.paimingPopup,.diquPopup{
width: 750rpx;
height: 600rpx;
position: absolute;
top: 184rpx;
left: 0;
background-color: #fff;
padding: 22rpx 32rpx;
box-sizing: border-box;
z-index: 999;
box-shadow:0px 4px 4px rgba(0,0,0,0.06);
border-top: 1rpx solid rgba(249,249,249,1);
.item{
margin-bottom: 22rpx;
// height: 74rpx;
width: 170rpx;
}
.title{
margin-bottom: 20rpx;
}
.cont{
display: flex;
// flex-direction: column;
flex-wrap: wrap;
justify-content: start;
.colum{
overflow: auto;
height: 500rpx;
width: 30%;
}
}
}
.active{
color: #05849D;
}
}
.contentBox{
padding: 24rpx 32rpx;
.item{
width:686rpx;
height:160rpx;
background:rgba(255,255,255,1);
opacity:1;
border-radius:8rpx;
display: flex;
font-size: 28rpx;
color:rgba(61,68,77,1);
justify-content: space-between;
padding: 0 40rpx;
box-sizing: border-box;
margin-bottom: 24rpx;
.title{
line-height: 160rpx;
}
.icon{
width: 120rpx;
height: 120rpx;
margin-top: 20rpx;
}
}
}
page{
height: 100%;
width: 100%;
}
.content {
background-color: rgba(249, 249, 249, 1);
height: 100%;
display: flex;
flex-direction: column;
.top {
padding: 18rpx 32rpx;
display: flex;
background-color: #fff;
}
.search {
display: flex;
align-items: center;
width: 596rpx;
height: 64rpx;
background: rgba(238, 238, 238, 1);
opacity: 1;
border-radius: 40rpx;
padding: 0 28rpx;
box-sizing: border-box;
.icon {
width: 30rpx;
height: 30rpx;
}
.input {
height: 64rpx;
width: 500rpx;
text-align: center;
}
}
.searchBtn {
color: rgba(6, 18, 30, 1);
font-size: 28rpx;
line-height: 64rpx;
margin-left: 20rpx;
}
.type {
display: flex;
color: rgba(6, 18, 30, 1);
font-size: 24rpx;
background-color: #fff;
padding: 24rpx 32rpx;
margin-top: 2rpx;
.paiming,
.diqu {
margin-right: 72rpx;
}
.paimingPopup,
.diquPopup {
width: 750rpx;
height: 600rpx;
position: absolute;
top: 184rpx;
left: 0;
background-color: #fff;
padding: 22rpx 32rpx;
box-sizing: border-box;
z-index: 999;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.06);
border-top: 1rpx solid rgba(249, 249, 249, 1);
.item {
margin-bottom: 22rpx;
// height: 74rpx;
width: 170rpx;
}
.title {
margin-bottom: 20rpx;
}
.cont {
display: flex;
// flex-direction: column;
flex-wrap: wrap;
justify-content: start;
.colum {
overflow: auto;
height: 500rpx;
width: 30%;
}
}
}
.active {
color: #05849d;
}
}
.contentBox {
padding: 24rpx 32rpx;
box-sizing: border-box;
flex: 1;
overflow-y: scroll;
.item {
width: 686rpx;
height: 160rpx;
background: rgba(255, 255, 255, 1);
opacity: 1;
border-radius: 8rpx;
display: flex;
font-size: 28rpx;
color: rgba(61, 68, 77, 1);
justify-content: space-between;
padding: 0 40rpx;
box-sizing: border-box;
margin-bottom: 24rpx;
.title {
line-height: 160rpx;
}
.icon {
width: 120rpx;
height: 120rpx;
margin-top: 20rpx;
}
}
}
}
</style>
\ No newline at end of file
</style>
... ...
... ... @@ -12,8 +12,6 @@
<!-- <view class="typeitem" @click="schoolShow" :class="{'active':active2}">学校</view> -->
<view class="typeitem" @click="majorShow" :class="{'active':active3}">专业</view>
<view class="typeitem" @click="styleShow" :class="{'active':active4}">升学方式</view>
<view class="diquPopup" v-if="isDiquShow">
<view class="cont">
... ... @@ -30,7 +28,6 @@
<view class="colum" style="overflow: auto;height: 600rpx;">
<view class="title" @click="selectschool" :data-id="null">全部学校</view>
<view class="item" @click="selectschool" v-for="(item,index) in schoolList" :key="index" :data-id="item.id">{{item.name}}</view>
</view>
</view>
... ... @@ -47,9 +44,7 @@
<view class="majorPopup" v-if="isMajorShow">
<view class="cont" style="display:flex;flex-direction: column;overflow: auto;height: 600rpx;">
<view class="title" @click="selectgraduated" :data-id="null">全部</view>
<view class="item" style="width:330rpx" @click="selectgraduated" v-for="(item,index) in graduatedList" :key="index" :data-id="item.id">{{item.name}}</view>
</view>
</view>
<view class="stylePopup" v-if="isStyleShow">
... ... @@ -169,7 +164,6 @@ data(){
page:'1',
size:'10',
word:''
},
graduatedList:[],
... ... @@ -379,8 +373,11 @@ methods:{
},
//点击选中的省
selectprovince(e){
this.province_id=e.currentTarget.dataset.id
this.getAllCity()
if(this.province_id!=e.currentTarget.dataset.id){
this.province_id=e.currentTarget.dataset.id;
this.schoolList = [];
this.getAllCity()
}
},
//点击全部省
... ... @@ -396,8 +393,13 @@ methods:{
},
//点击选中的市
selectcity(e){
this.city_id=e.currentTarget.dataset.id
this.getAllSchool()
if(this.city_id!=e.currentTarget.dataset.id){
this.city_id=e.currentTarget.dataset.id
this.schoolList = [];
this.getAllSchool()
}
},
todetile(e){
if(uni.getStorageSync('token')==''){
... ...