master
tangyi 2022-03-03 15:51:49 +08:00
parent 60ff17aad1
commit b4f22b7916
5 changed files with 430 additions and 162 deletions

View File

@ -4,27 +4,22 @@ import VueAxios from 'vue-axios'
import App from './App.vue' import App from './App.vue'
import router from './router' import router from './router'
// Vue.config.productionTip = false // Vue.config.productionTip = false
Vue.prototype.host = 'https://ypzy.emingren.com'
Vue.prototype.HOME = '/api' Vue.prototype.HOME = '/api'
axios.interceptors.request.use(config => { axios.interceptors.request.use(config => {
console.log(config.url) if (config.url!="/api/api/user/login-by-Phone"&&config.url!="/api/api/common/send-sms-captcha") {
// config.headers.Authorization = "Basic c2FiZXI6c2FiZXJfc2VjcmV0"
// if (config.url!="/hysc/auth/token") {
// if (!localStorage.token) {
// router.replace('/');
// return config
// }
// }
// config.headers.common['Blade-Auth'] =localStorage.token
// if (config.url!="/hysc/auth/token") { if (!localStorage.userData) {
// if (!localStorage.token) { window.alert("请登陆")
router.replace('/');
// router.replace('/'); return config
// return config }else{
// } config.headers.Authorization = "Bearer "+JSON.parse(localStorage.userData).token
// } }
}
return config return config

View File

@ -2,7 +2,7 @@ import Vue from 'vue'
import VueRouter from 'vue-router' import VueRouter from 'vue-router'
import login from '../views/login.vue' import login from '../views/login.vue'
import verification from '../views/login/verification.vue' import verification from '../views/login/verification.vue'
import index from '../views/index/index.vue'
Vue.use(VueRouter) Vue.use(VueRouter)
const routes = [ const routes = [
@ -16,6 +16,11 @@ const routes = [
name: 'verification', name: 'verification',
component: verification component: verification
}, },
{
path: '/index',
name: 'index',
component: index
},
] ]
const router = new VueRouter({ const router = new VueRouter({

222
src/views/index/index.vue Normal file
View File

@ -0,0 +1,222 @@
<template>
<div class="content main-content">
<!-- 头部 -->
<div :class="{ header: true, 'scroll white': isScrollTop }">
<div class="back"></div>
<div class="header-title">首页</div>
</div>
<!-- 轮播图 -->
<div class="banner-wrap">
<div class="swiper-container" ref="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
<img :src="host + bannerSrc" alt="" />
</div>
</div>
<div class="swiper-pagination" ref="swiper-pagination"></div>
</div>
</div>
<!-- 领取咨询卡 -->
<div
class="index-receive"
@click="goPage('/information')"
v-if="consult_amount == 0"
>
<img src="../../assets/images/home/index/receive.jpg" alt="" />
<span>完善信息立即领取免费咨询卡(1小时)</span>
</div>
<!-- 专家 -->
<div class="index-expert section">
<div class="index-title">
<h2>专家<em>团队</em></h2>
<span @click="goPage('/expert')"></span>
</div>
<ul class="index-expert-list">
<li v-for="(item, index) in expertData" :key="index">
<div class="expert-img">
<img :src="item.avatar" alt="" />
</div>
<div class="expert-name">
{{ item.name }}<span>{{ item.keywords_list[1] }}</span>
</div>
<div class="expert-honor">
<span>{{ item.keywords_list[0] }}</span>
<span>{{ item.keywords_list[1] }}</span>
</div>
</li>
</ul>
</div>
<!-- 计划 -->
<div class="index-plan">
<ul class="index-plan-list">
<li v-for="(item, index) in planData" :key="index">
<img src="../../assets/images/home/index/plan-01.png" alt="" />
<p>{{ item.title }}</p>
</li>
</ul>
</div>
<!-- 测评 -->
<div class="index-evaluation section">
<div class="index-title">
<h2>专业<em>测评</em></h2>
<span @click="goPage('/evaluation')"></span>
</div>
<ul class="index-evaluation-list">
<li
@click="cpUrl()"
v-for="(item, index) in evaluationData"
:key="index"
>
<div class="evaluation-img">
<img
src="../../assets/images/home/index/evaluation-01.png"
alt=""
/>
</div>
<p>{{ item.title }}</p>
<div class="evaluation-btn" @click="goPage()"></div>
</li>
</ul>
</div>
<!-- 直播 -->
<div class="index-live section">
<div class="index-title">
<h2>有谱<em>直播</em></h2>
<span @click="goPage()"></span>
</div>
<ul class="index-live-list">
<li><img src="../../assets/images/home/index/live-01.png" alt="" /></li>
<li><img src="../../assets/images/home/index/live-02.png" alt="" /></li>
</ul>
</div>
<!-- 头条 -->
<div class="index-headlines section">
<div class="index-title">
<h2>有谱<em>头条</em></h2>
<span @click="goPage()"></span>
</div>
<ul class="index-headlines-list">
<li v-for="(item, index) in headlinesData" :key="index">
<p>{{ item.title }}</p>
<span>{{ item.time }}</span>
</li>
</ul>
</div>
</div>
</template>
<script>
export default {
name: "index",
data() {
return {
isScrollTop: false,
isReceive: 0, //
bannerSrc: "",
expertData: [
{
name: "赵晓",
imgSrc: "",
year: "从业5年",
honor: [{ title: "硕士" }, { title: "中科院" }],
},
{
name: "赵晓",
imgSrc: "",
year: "从业3年",
honor: [{ title: "硕士" }, { title: "中科院" }],
},
{
name: "赵晓",
imgSrc: "",
year: "从业8年",
honor: [{ title: "硕士" }, { title: "中科院" }],
},
],
planData: [
{ imgSrc: "", title: "强基计划" },
{ imgSrc: "", title: "综合评价" },
{ imgSrc: "", title: "专项计划" },
],
evaluationData: [
{ imgSrc: "", title: "霍兰德职业兴趣测评" },
{ imgSrc: "", title: "MBIT职业性格测试" },
],
headlinesData: [
{ title: "全国各省市最好大学+王牌专业盘点", time: "2022年2月12日" },
{
title: "批次、批次线、大类招生到底是什么20个名词帮 你快速了解",
time: "2022年2月12日",
},
{
title: "教育部公布2021年度全国高等学校名单共计3012所",
time: "2022年2月12日",
},
{
title: "人民日报权威解读:热门专业和相似专业如何区分!",
time: "2022年2月12日",
},
{
title:
"比普通批低100多分从高一准备到高三报考2022 年强基计划最新报考指南",
time: "2022年2月12日",
},
],
};
},
created() {
this.isScroll = true;
window.addEventListener("scroll", this.eventScrollTop);
this.consult_amount = JSON.parse(localStorage.userData).consult_amount;
},
mounted() {
this.getBanner();
this.getExpertData();
},
computed: {},
methods: {
cpUrl() {},
getBanner() {
let that = this;
this.axios
.post(this.HOME + "/api/dictionary/get-slide-list", {
position: "h5_home_banner",
})
.then(function (res) {
that.bannerSrc = res.data.data[0].src;
});
},
eventScrollTop() {
let scrollTop =
document.body.scrollTop || document.documentElement.scrollTop;
if (scrollTop >= 5) {
if (this.isScroll) {
this.isScroll = false;
this.isScrollTop = true;
}
} else {
if (!this.isScroll) {
this.isScroll = true;
this.isScrollTop = false;
}
}
},
//
getExpertData() {
let that = this;
this.axios
.post(this.HOME + "/api/consumer/expert-list", {
page: "1",
size: "3",
})
.then(function (res) {
console.log(res.data.data);
that.expertData = res.data.data.list;
});
},
},
};
</script>
<style scoped>
</style>

View File

@ -133,6 +133,7 @@ export default {
}, },
// //
phoneLogin() { phoneLogin() {
let that = this;
var reg_tel = var reg_tel =
/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/; /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
if (this.phoneNumber == "") { if (this.phoneNumber == "") {
@ -144,12 +145,17 @@ export default {
return false; return false;
} }
this.axios this.axios
.post(this.HOME+"/api/common/send-sms-captcha", { .post(this.HOME + "/api/common/send-sms-captcha", {
phone:this.phoneNumber, phone: this.phoneNumber,
type: "login", type: "login",
}) })
.then(function () { .then(function () {
this.$router("/") that.$router.push({
path: "/verification",
query: {
phone: that.phoneNumber,
},
});
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);

View File

@ -1,151 +1,191 @@
<template> <template>
<div class="content"> <div class="content">
<!-- 头部 --> <!-- 头部 -->
<div :class="{'header':true,'scroll white':isScrollTop,'white':true}"> <div :class="{ header: true, 'scroll white': isScrollTop, white: true }">
<div class="back" @click="$router.go(-1)"><img src="../../assets/images/home/expert/back.png" alt=""></div> <div class="back" @click="$router.go(-1)">
<div class="header-title">手机验证码</div> <img src="../../assets/images/home/expert/back.png" alt="" />
</div> </div>
<div class="header-title">手机验证码</div>
<div class="verification pull-content list-section"> </div>
<div class="verification-txt">
<p>输入验证码</p> <div class="verification pull-content list-section">
<span>验证码已发送至 +86 {{phoneData}}</span> <div class="verification-txt">
<div class="result"> <p>输入验证码</p>
<div class="security-code-wrap"> <span>验证码已发送至 +86 {{ phoneData }}</span>
<label for="code"> <div class="result">
<ul class="security-code-container"> <div class="security-code-wrap">
<li class="field-wrap" v-for="(item, index) in number" :key="index"> <label for="code">
<i class="char-field">{{value[index] || placeholder}}</i> <ul class="security-code-container">
</li> <li
</ul> class="field-wrap"
</label> v-for="(item, index) in number"
<input ref="input" class="input-code" @keyup="handleInput($event)" v-model="value" id="code" name="code" type="tel" :maxlength="number" autocorrect="off" autocomplete="off" autocapitalize="off"> :key="index"
</div> >
</div> <i class="char-field">{{ value[index] || placeholder }}</i>
<span v-show="!show">{{count}}</span> </li>
<div v-show="show" @click="getCode()" class="getCode"></div> </ul>
</div> </label>
<input
</div> ref="input"
</div> class="input-code"
@keyup="handleInput($event)"
v-model="value"
id="code"
name="code"
type="tel"
:maxlength="number"
autocorrect="off"
autocomplete="off"
autocapitalize="off"
/>
</div>
</div>
<span v-show="!show">{{ count }}</span>
<div v-show="show" @click="getCode()" class="getCode"></div>
</div>
</div>
</div>
</template> </template>
<script> <script>
export default { export default {
name: "login-verification", name: "login-verification",
props: { props: {
number: { number: {
type: Number, type: Number,
default: 4 default: 6,
}, },
placeholder: { placeholder: {
type: String, type: String,
default: '-' default: "-",
} },
}, },
data() { data() {
return { return {
isScrollTop: false, isScrollTop: false,
phoneData: '', // phoneData: "", //
verification: '', // verification: "", //
value: '', value: "",
show: false, // show: false, //
count: '', // count: "", //
timer: null, timer: null,
} };
}, },
beforeCreate() { beforeCreate() {},
created() {
}, this.isScroll = true;
created() { window.addEventListener("scroll", this.eventScrollTop);
this.isScroll = true; this.phoneData = this.$route.query.number;
window.addEventListener("scroll", this.eventScrollTop); const TIME_COUNT = 60;
this.phoneData = this.$route.query.number; if (!this.timer) {
const TIME_COUNT = 60; this.count = TIME_COUNT;
if (!this.timer) { this.show = false;
this.count = TIME_COUNT; this.timer = setInterval(() => {
this.show = false; if (this.count > 0 && this.count <= TIME_COUNT) {
this.timer = setInterval(() => { this.count--;
if (this.count > 0 && this.count <= TIME_COUNT) { } else {
this.count--; this.show = true;
} else { clearInterval(this.timer);
this.show = true; this.timer = null;
clearInterval(this.timer); }
this.timer = null; }, 1000);
} }
}, 1000) },
} mounted() {},
}, computed: {},
mounted() { methods: {
hideKeyboard() {
//
var that = this;
document.activeElement.blur(); // ios
this.$refs.input.blur(); // android
}, this.axios
computed: { .post(this.HOME + "/api/user/login-by-Phone", {
phone: this.$route.query.phone,
}, sms_code: this.value,
methods: { })
hideKeyboard() { .then(function (res) {
// localStorage.userData = JSON.stringify(res.data.data);
document.activeElement.blur() // ios if (res.data.code == 0) {
this.$refs.input.blur() // android that.$router.push({
}, path: "/index", });
handleSubmit() { } else {
this.$emit('input', this.value) window.alert(res.msg);
}, }
handleInput() { })
this.$refs.input.value = this.value .catch(function (error) {
if (this.value.length >= this.number) { console.log(error);
this.hideKeyboard() });
} },
this.handleSubmit() handleSubmit() {
}, this.$emit("input", this.value);
// 60s },
getCode(){ handleInput() {
const TIME_COUNT = 60; this.$refs.input.value = this.value;
if (!this.timer) { if (this.value.length >= this.number) {
this.count = TIME_COUNT; this.hideKeyboard();
this.show = false; }
this.timer = setInterval(() => { this.handleSubmit();
if (this.count > 0 && this.count <= TIME_COUNT) { },
this.count--; // 60s
} else { getCode() {
this.show = true; const TIME_COUNT = 60;
clearInterval(this.timer); if (!this.timer) {
this.timer = null; this.count = TIME_COUNT;
} this.show = false;
}, 1000) this.timer = setInterval(() => {
} if (this.count > 0 && this.count <= TIME_COUNT) {
}, this.count--;
// } else {
eventScrollTop() { this.show = true;
let scrollTop = document.body.scrollTop || document.documentElement.scrollTop; clearInterval(this.timer);
if (scrollTop >= 5) { this.timer = null;
if (this.isScroll) { }
this.isScroll = false; }, 1000);
this.isScrollTop = true; this.axios
} .post(this.HOME + "/api/common/send-sms-captcha", {
} else { phone: this.$route.query.phone,
if (!this.isScroll) { type: "login",
this.isScroll = true; })
this.isScrollTop = false; .then(function () {})
} .catch(function (error) {
} console.log(error);
} });
},
destroyed() { }
window.removeEventListener("scroll", this.eventScrollTop); },
}, //
//keep-alive eventScrollTop() {
activated() { let scrollTop =
this.isScroll = true; document.body.scrollTop || document.documentElement.scrollTop;
window.addEventListener("scroll", this.eventScrollTop) if (scrollTop >= 5) {
}, if (this.isScroll) {
//keep-alive this.isScroll = false;
deactivated() { this.isScrollTop = true;
window.removeEventListener("scroll", this.eventScrollTop); }
} } else {
} if (!this.isScroll) {
this.isScroll = true;
this.isScrollTop = false;
}
}
},
},
destroyed() {
window.removeEventListener("scroll", this.eventScrollTop);
},
//keep-alive
activated() {
this.isScroll = true;
window.addEventListener("scroll", this.eventScrollTop);
},
//keep-alive
deactivated() {
window.removeEventListener("scroll", this.eventScrollTop);
},
};
</script> </script>
<style scoped> <style scoped>
</style> </style>