Commit e6d1d1d5 by sunchao

登陆注册

parent d3eab360
<script>
import initApp from "@/util/router.js";
import {interceptor} from '@/util/interceptor.ts';
export default {
onLaunch: function() {
console.log('App Launch')
initApp()
},
onShow: function() {
console.log('App Show')
......
import request from "../util/request";
import {baseURL,apiURL,sfpURL} from "../environments/environment";
import {baseURL,apiURL,cffpURL} from "../environments/environment";
export default {
//查看token是否已经失效
......@@ -17,6 +17,17 @@ export default {
}
return request(`${baseURL}/api/authorize/obtainToken`, "POST", params)
},
//获取验证码
verificationCode(params){
return request(`${baseURL}/api/verificationCode`, "POST", params)
},
//登录接口
loginVerification(params){
return request(`${cffpURL}/user/loginVerification`, "POST", params)
},
//注册接口
register(params){
return request(`${cffpURL}/user/register`, "POST", params)
}
}
export default {
mobileNoValid(no) {
const MOBILE_REGEXP = /^(1)\d{10}$/;
return MOBILE_REGEXP.test(no);
},
// 封装报错弹窗
errorDialog(type,content){
// type 1 必填项校验 2 规则校验
uni.showModal({
title: type===1 ? '必填项校验' : '规则校验',
content:content,
showCancel:false,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
}
\ No newline at end of file
<template>
<view>
课程列表
</view>
</template>
<script>
export default{
data(){
return;
},
name:'courselist',
}
</script>
<style>
</style>
\ No newline at end of file
......@@ -10,14 +10,19 @@
</view>
<form>
<view class="inputItem" v-if="loginType==='register'">
<input class="uni-input" name="invitationCode" placeholder="输入邀请码(非必填)" />
<input class="uni-input" name="invitationCode" placeholder="输入邀请码(非必填)" v-model="invitation_code"/>
</view>
<view class="inputItem">
<input class="uni-input" name="mobileNo" placeholder="输入手机号" />
<view class="inputItem" v-if="loginType!=='agentlogin'">
<input class="uni-input" name="mobileNo" placeholder="输入手机号" v-model="form.mobile" maxlength="11"
/>
</view>
<view class="inputItem" v-if="loginType === 'codelogin' || loginType==='register'">
<input class="uni-input" name="code" placeholder="输入验证码" />
<text @click="sendMessage()">{{sedCode}}</text>
<view class="inputItem" v-if="loginType==='agentlogin'">
<input class="uni-input" name="mobileNo" placeholder="输入账号" v-model="account" maxlength="11"
/>
</view>
<view class="inputItem" v-if="loginType === 'codelogin' || loginType==='register' || loginType === 'resetpw'">
<input class="uni-input" name="code" placeholder="输入验证码" v-model="form.code" type="number"/>
<text @click="sendMessage()" :class="{'grey':disabledSendBtn}">{{sendCodeHtml}}</text>
</view>
<view class="inputItem" v-if="loginType === 'pwlogin' || loginType==='register'">
<input class="uni-input" type="text" name="password" placeholder="输入密码" v-if="!passwordFlag"/>
......@@ -25,26 +30,40 @@
<text v-if="passwordFlag" @click="passwordFlag=false">显示密码</text>
<text v-if="!passwordFlag" @click="passwordFlag=true">不显示密码</text>
</view>
<!--重置密码-->
<view v-if="loginType === 'resetpw'">
<view class="inputItem" >
<input class="uni-input" type="text" password name="password" placeholder="密码(6-20位字母数字组合)" />
</view>
<view class="inputItem" >
<input class="uni-input" type="text" password name="password" placeholder="再次确认密码" />
</view>
</view>
</form>
<view class="agree">
<view class="agree" v-if="loginType!='resetpw'">
<icon :type="radioUnselect" size="26"/><text>已阅读并同意</text><a href="#">银盾保险经纪服务协议</a><text></text><a href="">隐私政策</a>
</view>
<view class="login_btn">
<view class="login_btn" @click="loginInCheck()()" v-if="loginType!='resetpw'">
{{loginType=='register'?'注册':'登录'}}
{{loginType}}
</view>
<view class="login_btn" v-if="loginType=='resetpw'">
保存
</view>
<view class="login_type">
<text @click="getLogin()">{{(loginType=='pwlogin' || loginType=='register')?'验证码登录':'密码登录'}}</text>
<view class="login_type" v-if="loginType!='resetpw'">
<text @click="getLoginType()">{{(loginType=='pwlogin' || loginType=='register')?'验证码登录':'密码登录'}}</text>
<text @click="register()">{{loginType=='codelogin'?'立即注册':'忘记密码'}}</text>
</view>
<view>
<view v-if="loginType!='resetpw'">
<view class="other_login">
<text class="text_line"></text>
<text style="margin: 0 40rpx;position: relative;top: 10rpx;">其他登录</text>
<text class="text_line"></text>
</view>
<view class="login_type">
<text>游客</text>
<text>代理商</text>
<text @click="loginType='visitor';loginIn(1)">游客</text>
<text @click="loginType = 'agentlogin';loginTypeName = '管理账号登录';">代理商</text>
</view>
</view>
</view>
......@@ -53,6 +72,9 @@
</template>
<script>
import api from '../../api/api';
import common from '../../common/common';
export default {
data() {
return {
......@@ -60,39 +82,147 @@
loginType: 'codelogin',
passwordFlag:false,
loginTypeName:'验证码登录',
countdown:60,
sedCode:'获取验证码'
remainTimes:60,
sendCodeHtml:'获取验证码',
//用户输入信息
form:{
mobile:null,
code:null,
password:null,
},
disabledSendBtn:false,
invitation_code:null,
account:null
}
},
methods: {
formReset: function(e) {
console.log('清空数据')
},
getLogin(){
getLoginType(){
this.loginType==='codelogin'?this.loginType='pwlogin':this.loginType='codelogin';
this.loginTypeName = this.loginType =='codelogin'?'验证码登录':'密码登录';
this.loginType==='codelogin'?this.form.password=null:this.form.code=null;
},
register(){
this.loginType = 'register';
this.loginTypeName = '注册';
this.loginType==='register'?this.loginType='resetpw':this.loginType='register';
this.loginTypeName = this.loginType =='register'?'注册':'重置密码';
},
sendMessage(){
this.delayTime()
const params = {
mobileNo:this.form.mobile,
type:"1"
}
if(common.mobileNoValid(this.form.mobile) && !this.disabledSendBtn){
api.verificationCode(params).then((res)=>{
console.log(res)
if(res['success']){
this.delayTime()
}
})
}else{
common.errorDialog(2,'手机号校验错误')
}
},
delayTime() {
if (this.countdown == 0) {
this.isValid = false;
this.sedCode = "重新发送";
this.countdown = 60;
} else {
this.isValid = true;
this.sedCode = this.countdown + "s";
this.countdown--;
setTimeout(() => {
this.delayTime();
}, 1000);
}
}
this.disabledSendBtn = true;
this.timer = setInterval(() => {
this.remainTimes--;
this.sendCodeHtml = `${this.remainTimes}(S)`;
if (this.remainTimes <= 0) {
this.sendCodeHtml = '获取验证码';
this.remainTimes = 60;
this.disabledSendBtn = false;
clearInterval(this.timer);
}
}, 1000);
},
loginIn(loginType){
console.log(loginType)
const params = {
loginType:loginType,
...this.form
}
console.log(params)
api.loginVerification(params).then((res)=>{
if(res['success']){
uni.setStorageSync('isLogin',1)
uni.navigateTo({
url:'/pages/index/index'
})
}else{
uni.showToast({
title: res['message'],
duration: 2000,
icon: 'none'
})
}
})
},
registerIn(){
const params = {
invitation_code:this.invitation_code,
...this.form
}
console.log(params)
api.register(params).then((res)=>{
if(res['success']){
uni.setStorageSync('isLogin',1)
uni.navigateTo({
url:'/pages/index/index'
})
}else{
uni.showToast({
title: res['message'],
duration: 2000,
icon: 'none'
})
}
})
},
loginInCheck(){
//只有代理商登录不需要填写手机号
if(this.loginType !== 'agentlogin'){
if(!this.form.mobile){
common.errorDialog(1,'请输入手机号');
return false;
}
if(!common.mobileNoValid(this.form.mobile)){
common.errorDialog(2,'手机号格式填写错误');
return false;
}
if(this.loginType === 'codelogin'){
if(!this.form.code){
common.errorDialog(1,'请输入验证码');
return false;
}
this.loginIn(3)
}
if(this.loginType === 'password'){
if(!this.form.code){
common.errorDialog(1,'请输入密码');
return false;
}
this.loginIn(2)
}
if(this.loginType === 'register'){
}
}
if(this.loginType === 'agentlogin'){
if(!this.account){
if(!this.form.code){
common.errorDialog(1,'请输入密码');
return false;
}
}
this.loginIn(4)
}
}
},
mounted() {
}
}
</script>
......@@ -134,16 +264,16 @@
}
.uni-input:after{
content: " ";
position: absolute;
left: 0;
bottom: 0;
right: 0;
height: 1px;
border-bottom: 1px solid rgba(0,0,0,.1);
color: #CECECE;
transform-origin: 0 100%;
transform: scaleY(.5);
z-index: 2;
position: absolute;
left: 0;
bottom: 0;
right: 0;
height: 1px;
border-bottom: 1px solid rgba(0,0,0,.1);
color: #CECECE;
transform-origin: 0 100%;
transform: scaleY(.5);
z-index: 2;
}
text{
position: absolute;
......@@ -151,6 +281,9 @@
top: 20rpx;
color: #20279B;
}
.grey{
color: #CECECE;
}
}
}
.agree{
......
const dev = {
base_url:'https://mdev.zuihuibi.cn',
api_url:'https://mdev.zuihuibi.cn/api',
sfp_url:'https://mdev.zuihuibi.cn/api/sfp'
cffp_url:'https://mdev.zuihuibi.cn/api/cffp'
}
const stage = {
base_url:'https://mstage.zuihuibi.cn',
api_url:'https://mstage.zuihuibi.cn/api',
sfp_url:'https://mstage.zuihuibi.cn/api/sfp'
cffp_url:'https://mstage.zuihuibi.cn/api/cffp'
}
const prod = {
base_url:'https://m.zuihuibi.cn',
api_url:'https://m.zuihuibi.cn/api',
sfp_url:'https://m.zuihuibi.cn/api/sfp'
cffp_url:'https://m.zuihuibi.cn/api/cffp'
}
const config = {
......@@ -30,10 +30,10 @@ let env = 'dev';
let baseURL = config[env].base_url;
let apiURL = config[env].api_url;
let sfpURL = config[env].sfp_url;
let cffpURL = config[env].cffp_url;
export{
baseURL,
apiURL,
sfpURL
cffpURL
}
\ No newline at end of file
import App from './App'
import App from './App';
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
......
......@@ -76,5 +76,25 @@
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "3"
"vueVersion" : "3",
"h5" : {
"router" : {
"base" : "/cffp/",
"mode" : "history"
},
"devServer" : {
"proxy" : {
"/api" : {
"port" : 3000, // 端口号
"target" : "https://mdev.zuihuibi.cn", //请求的目标域名
"changeOrigin" : true, //是否跨域
"secure" : false, //设置支持https协议的代理
"logLevel" : "debug",
"pathRewrite" : {
"^/api" : ""
}
}
}
}
}
}
{
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"topWindow": false,
"navigationBarTitleText": "CFFP"
}
},
{
"path": "components/login/login",
"style": {
"topWindow": false,
"navigationBarTitleText": "CFFP"
}
}
},
// {
// "path": "pages/index/index",
// "style": {
// "topWindow": false,
// "navigationBarTitleText": "CFFP"
// }
// },
],
// "tabBar": {
// "color": "#7A7E83", // tab 上的文字默认颜色
// "selectedColor": "#3cc51f", // tab 上的文字选中时的颜色
// "borderStyle": "black", // tabbar 上边框的颜色,可选值 black/white
// "backgroundColor": "#ffffff", // tab 的背景色
// "list": [{ // 最少2个、最多5 tab
// "pagePath": "pages/index/index", // 页面路径,必须在 pages 中先定义
// "iconPath": "static/tabbar/home.png", // 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px
// "selectedIconPath": "static/tabbar/home-active.png", // 选中时的图片路径
// "text": "首页" // tab 上按钮文字
// }, { // 最少2个、最多5 tab
// "pagePath": "pages/index/index", // 页面路径,必须在 pages 中先定义
// "iconPath": "static/tabbar/home.png", // 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px
// "selectedIconPath": "static/tabbar/home-active.png", // 选中时的图片路径
// "text": "SFP智能财策" // tab 上按钮文字
// },{ // 最少2个、最多5 tab
// "pagePath": "pages/index/index", // 页面路径,必须在 pages 中先定义
// "iconPath": "static/tabbar/home.png", // 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px
// "selectedIconPath": "static/tabbar/home-active.png", // 选中时的图片路径
// "text": "CFFP认证" // tab 上按钮文字
// },{
// "pagePath": "pages/my/my",
// "iconPath": "static/tabbar/my.png",
// "selectedIconPath": "static/tabbar/my-active.png",
// "text": "我的"
// }]
// },
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
......@@ -15,5 +56,15 @@
"backgroundColor": "#F8F8F8",
"navigationStyle": "custom"
},
"uniIdRouter": {}
"uniIdRouter": {},
"condition" : { //模式配置,仅开发期间生效
"current": 0, //当前激活的模式(list 的索引项)
"list": [
{
"name": "", //模式名称
"path": "", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
}
]
}
}
......@@ -4,21 +4,34 @@
<view class="text-area">
<text class="title">{{title}}</text>
</view>
<courselist></courselist>
</view>
</template>
<script>
import courselist from '../../components/courselist/courselist.vue'
export default {
data() {
return {
title: 'Hello'
title: '首页'
}
},
comments:{
courselist
},
onLoad() {
},
methods: {
},
onShow() {
if(!uni.getStorageSync('isLogin')){
uni.navigateTo({
url:'/components/login/login'
})
}
}
}
</script>
......
<template>
</template>
<script>
</script>
<style>
</style>
\ No newline at end of file
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
if (typeof Promise !== "undefined" && !Promise.prototype.finally) {
Promise.prototype.finally = function(callback) {
const promise = this.constructor;
......@@ -35,6 +51,136 @@ if (uni.restoreGlobal) {
console[type].apply(console, [...args, filename]);
}
}
const whiteApiList = [`/api/authorize/obtainToken`, `/api/authorize/checkToken`];
const interceptor = () => {
uni.addInterceptor("request", {
invoke(args) {
formatAppLog("log", "at util/interceptor.ts:13", "\u8BF7\u6C42\u62E6\u622A\u5668", args);
uni.showLoading({
title: "\u52A0\u8F7D\u4E2D..."
});
if (!uni.getStorageSync("uni-token") && !whiteApiList.includes(args.url)) {
formatAppLog("log", "at util/interceptor.ts:20", "-----------");
return new Promise((resolve, reject) => {
uni.request({
url: "/api/authorize/obtainToken",
method: "POST",
data: { ticket: "uni-app" },
success: (res) => {
if (res.statusCode === 200) {
uni.setStorageSync("uni-token", res.data["data"]["token"]);
window.location.href = window.location.href + "?t_reload=" + new Date().getTime();
}
formatAppLog("log", "at util/interceptor.ts:31", res);
},
fail(err) {
reject(err);
}
});
uni.hideLoading();
return false;
});
}
args.header = {
"content-type": args.method === "POST" ? "application/json" : "application/x-www-form-urlencoded",
"X-Authorization": uni.getStorageSync("uni-token")
};
},
success(args) {
uni.hideLoading();
},
fail(err) {
formatAppLog("log", "at util/interceptor.ts:56", "interceptor-fail", err);
formatAppLog("log", "at util/interceptor.ts:57", "\u8BF7\u6C42\u5931\u8D25");
uni.hideLoading();
},
complete(res) {
uni.hideLoading();
}
});
};
var request = (url, method, params) => {
interceptor();
return new Promise((resolve, reject) => {
uni.request({
url,
method,
data: __spreadValues({}, params),
success(res) {
resolve(res.data);
},
fail(err) {
reject(err);
},
complete() {
uni.hideLoading();
}
});
});
};
const dev = {
base_url: "https://mdev.zuihuibi.cn",
api_url: "https://mdev.zuihuibi.cn/api",
sfp_url: "https://mdev.zuihuibi.cn/api/sfp"
};
const stage = {
base_url: "https://mstage.zuihuibi.cn",
api_url: "https://mstage.zuihuibi.cn/api",
sfp_url: "https://mstage.zuihuibi.cn/api/sfp"
};
const prod = {
base_url: "https://m.zuihuibi.cn",
api_url: "https://m.zuihuibi.cn/api",
sfp_url: "https://m.zuihuibi.cn/api/sfp"
};
const config = {
dev,
stage,
prod
};
let env = "dev";
let baseURL = config[env].base_url;
var api = {
checkToken() {
const params = {
token: uni.getStorageSync("uni-token"),
ticket: "uni-app"
};
return request(`${baseURL}/api/authorize/checkToken`, "POST", params);
},
obtainToken() {
const params = {
ticket: "uni-app"
};
return request(`${baseURL}/api/authorize/obtainToken`, "POST", params);
},
verificationCode(params) {
return request(`${baseURL}/api/verificationCode`, "POST", params);
},
loginVerification(params) {
return request(`${baseURL}/api/verificationCode`, "POST", params);
}
};
var common = {
mobileNoValid(no) {
const MOBILE_REGEXP = /^(1)\d{10}$/;
return MOBILE_REGEXP.test(no);
},
errorDialog(type, content) {
uni.showModal({
title: type === 1 ? "\u5FC5\u586B\u9879\u6821\u9A8C" : "\u89C4\u5219\u6821\u9A8C",
content,
showCancel: false,
success: function(res) {
if (res.confirm) {
formatAppLog("log", "at common/common.ts:15", "\u7528\u6237\u70B9\u51FB\u786E\u5B9A");
} else if (res.cancel) {
formatAppLog("log", "at common/common.ts:17", "\u7528\u6237\u70B9\u51FB\u53D6\u6D88");
}
}
});
}
};
var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
......@@ -48,39 +194,64 @@ if (uni.restoreGlobal) {
loginType: "codelogin",
passwordFlag: false,
loginTypeName: "\u9A8C\u8BC1\u7801\u767B\u5F55",
countdown: 60,
sedCode: "\u83B7\u53D6\u9A8C\u8BC1\u7801"
remainTimes: 60,
sendCodeHtml: "\u83B7\u53D6\u9A8C\u8BC1\u7801",
form: {
mobile: null,
code: null,
password: null,
invitation_code: null
},
disabledSendBtn: false
};
},
methods: {
formReset: function(e) {
formatAppLog("log", "at components/login/login.vue:69", "\u6E05\u7A7A\u6570\u636E");
formatAppLog("log", "at components/login/login.vue:96", "\u6E05\u7A7A\u6570\u636E");
},
getLogin() {
this.loginType === "codelogin" ? this.loginType = "pwlogin" : this.loginType = "codelogin";
this.loginTypeName = this.loginType == "codelogin" ? "\u9A8C\u8BC1\u7801\u767B\u5F55" : "\u5BC6\u7801\u767B\u5F55";
},
register() {
this.loginType = "register";
this.loginTypeName = "\u6CE8\u518C";
this.loginType === "register" ? this.loginType = "resetpw" : this.loginType = "register";
this.loginTypeName = this.loginType == "register" ? "\u6CE8\u518C" : "\u91CD\u7F6E\u5BC6\u7801";
},
sendMessage() {
this.delayTime();
},
delayTime() {
if (this.countdown == 0) {
this.isValid = false;
this.sedCode = "\u91CD\u65B0\u53D1\u9001";
this.countdown = 60;
debugger;
const params = {
mobileNo: this.form.mobile,
type: "1"
};
if (common.mobileNoValid(this.form.mobile) && !this.disabledSendBtn) {
api.verificationCode(params).then((res) => {
formatAppLog("log", "at components/login/login.vue:114", res);
if (res["success"]) {
this.delayTime();
}
});
} else {
this.isValid = true;
this.sedCode = this.countdown + "s";
this.countdown--;
setTimeout(() => {
this.delayTime();
}, 1e3);
common.errorDialog(2, "\u624B\u673A\u53F7\u6821\u9A8C\u9519\u8BEF");
}
},
delayTime() {
this.disabledSendBtn = true;
this.timer = setInterval(() => {
this.remainTimes--;
this.sendCodeHtml = `${this.remainTimes}(S)`;
if (this.remainTimes <= 0) {
this.sendCodeHtml = "\u83B7\u53D6\u9A8C\u8BC1\u7801";
this.remainTimes = 60;
this.disabledSendBtn = false;
clearInterval(this.timer);
}
}, 1e3);
}
},
mounted() {
api.obtainToken().then((res) => {
formatAppLog("log", "at components/login/login.vue:141", res);
});
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
......@@ -107,24 +278,33 @@ if (uni.restoreGlobal) {
})
])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("view", { class: "inputItem" }, [
vue.createElementVNode("input", {
vue.withDirectives(vue.createElementVNode("input", {
class: "uni-input",
name: "mobileNo",
placeholder: "\u8F93\u5165\u624B\u673A\u53F7"
})
placeholder: "\u8F93\u5165\u624B\u673A\u53F7",
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $data.form.mobile = $event),
maxlength: "11"
}, null, 512), [
[vue.vModelText, $data.form.mobile]
])
]),
$data.loginType === "codelogin" || $data.loginType === "register" ? (vue.openBlock(), vue.createElementBlock("view", {
$data.loginType === "codelogin" || $data.loginType === "register" || $data.loginType === "resetpw" ? (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
class: "inputItem"
}, [
vue.createElementVNode("input", {
vue.withDirectives(vue.createElementVNode("input", {
class: "uni-input",
name: "code",
placeholder: "\u8F93\u5165\u9A8C\u8BC1\u7801"
}),
placeholder: "\u8F93\u5165\u9A8C\u8BC1\u7801",
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => $data.form.code = $event),
type: "number"
}, null, 512), [
[vue.vModelText, $data.form.code]
]),
vue.createElementVNode("text", {
onClick: _cache[0] || (_cache[0] = ($event) => $options.sendMessage())
}, vue.toDisplayString($data.sedCode), 1)
onClick: _cache[2] || (_cache[2] = ($event) => $options.sendMessage()),
class: vue.normalizeClass({ "grey": $data.disabledSendBtn })
}, vue.toDisplayString($data.sendCodeHtml), 3)
])) : vue.createCommentVNode("v-if", true),
$data.loginType === "pwlogin" || $data.loginType === "register" ? (vue.openBlock(), vue.createElementBlock("view", {
key: 2,
......@@ -147,15 +327,39 @@ if (uni.restoreGlobal) {
})) : vue.createCommentVNode("v-if", true),
$data.passwordFlag ? (vue.openBlock(), vue.createElementBlock("text", {
key: 2,
onClick: _cache[1] || (_cache[1] = ($event) => $data.passwordFlag = false)
onClick: _cache[3] || (_cache[3] = ($event) => $data.passwordFlag = false)
}, "\u663E\u793A\u5BC6\u7801")) : vue.createCommentVNode("v-if", true),
!$data.passwordFlag ? (vue.openBlock(), vue.createElementBlock("text", {
key: 3,
onClick: _cache[2] || (_cache[2] = ($event) => $data.passwordFlag = true)
onClick: _cache[4] || (_cache[4] = ($event) => $data.passwordFlag = true)
}, "\u4E0D\u663E\u793A\u5BC6\u7801")) : vue.createCommentVNode("v-if", true)
])) : vue.createCommentVNode("v-if", true),
vue.createCommentVNode("\u91CD\u7F6E\u5BC6\u7801"),
$data.loginType === "resetpw" ? (vue.openBlock(), vue.createElementBlock("view", { key: 3 }, [
vue.createElementVNode("view", { class: "inputItem" }, [
vue.createElementVNode("input", {
class: "uni-input",
type: "text",
password: "",
name: "password",
placeholder: "\u5BC6\u7801(6-20\u4F4D\u5B57\u6BCD\u6570\u5B57\u7EC4\u5408)"
})
]),
vue.createElementVNode("view", { class: "inputItem" }, [
vue.createElementVNode("input", {
class: "uni-input",
type: "text",
password: "",
name: "password",
placeholder: "\u518D\u6B21\u786E\u8BA4\u5BC6\u7801"
})
])
])) : vue.createCommentVNode("v-if", true)
]),
vue.createElementVNode("view", { class: "agree" }, [
$data.loginType != "resetpw" ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "agree"
}, [
vue.createElementVNode("icon", {
type: _ctx.radioUnselect,
size: "26"
......@@ -164,17 +368,28 @@ if (uni.restoreGlobal) {
vue.createElementVNode("a", { href: "#" }, "\u94F6\u76FE\u4FDD\u9669\u7ECF\u7EAA\u670D\u52A1\u534F\u8BAE"),
vue.createElementVNode("text", null, "\u548C"),
vue.createElementVNode("a", { href: "" }, "\u9690\u79C1\u653F\u7B56")
]),
vue.createElementVNode("view", { class: "login_btn" }, vue.toDisplayString($data.loginType == "register" ? "\u6CE8\u518C" : "\u767B\u5F55"), 1),
vue.createElementVNode("view", { class: "login_type" }, [
])) : vue.createCommentVNode("v-if", true),
$data.loginType != "resetpw" ? (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
class: "login_btn",
onClick: _cache[5] || (_cache[5] = ($event) => _ctx.loginIn())
}, vue.toDisplayString($data.loginType == "register" ? "\u6CE8\u518C" : "\u767B\u5F55") + " " + vue.toDisplayString($data.loginType), 1)) : vue.createCommentVNode("v-if", true),
$data.loginType == "resetpw" ? (vue.openBlock(), vue.createElementBlock("view", {
key: 2,
class: "login_btn"
}, " \u4FDD\u5B58 ")) : vue.createCommentVNode("v-if", true),
$data.loginType != "resetpw" ? (vue.openBlock(), vue.createElementBlock("view", {
key: 3,
class: "login_type"
}, [
vue.createElementVNode("text", {
onClick: _cache[3] || (_cache[3] = ($event) => $options.getLogin())
onClick: _cache[6] || (_cache[6] = ($event) => $options.getLogin())
}, vue.toDisplayString($data.loginType == "pwlogin" || $data.loginType == "register" ? "\u9A8C\u8BC1\u7801\u767B\u5F55" : "\u5BC6\u7801\u767B\u5F55"), 1),
vue.createElementVNode("text", {
onClick: _cache[4] || (_cache[4] = ($event) => $options.register())
onClick: _cache[7] || (_cache[7] = ($event) => $options.register())
}, vue.toDisplayString($data.loginType == "codelogin" ? "\u7ACB\u5373\u6CE8\u518C" : "\u5FD8\u8BB0\u5BC6\u7801"), 1)
]),
vue.createElementVNode("view", null, [
])) : vue.createCommentVNode("v-if", true),
$data.loginType != "resetpw" ? (vue.openBlock(), vue.createElementBlock("view", { key: 4 }, [
vue.createElementVNode("view", { class: "other_login" }, [
vue.createElementVNode("text", { class: "text_line" }),
vue.createElementVNode("text", { style: { "margin": "0 40rpx", "position": "relative", "top": "10rpx" } }, "\u5176\u4ED6\u767B\u5F55"),
......@@ -184,7 +399,7 @@ if (uni.restoreGlobal) {
vue.createElementVNode("text", null, "\u6E38\u5BA2"),
vue.createElementVNode("text", null, "\u4EE3\u7406\u5546")
])
])
])) : vue.createCommentVNode("v-if", true)
])
]);
}
......
......@@ -78,6 +78,9 @@
top: 0.625rem;
color: #20279B;
}
.wrapper .content uni-form .inputItem .grey {
color: #CECECE;
}
.wrapper .content .agree {
font-size: 0.875rem;
color: #666;
......
......@@ -75,6 +75,7 @@
}
}
},
"arguments": "{\"path\":\"components/login/login\"}",
"uniStatistics": {
"enable": false
},
......
......@@ -10,7 +10,7 @@ export const interceptor = () => {
// 请求拦截器
invoke(args) {
// console.log('请求拦截器',args);
console.log('请求拦截器',args);
// 加载loading
uni.showLoading({
title: '加载中...'
......@@ -28,7 +28,7 @@ export const interceptor = () => {
uni.setStorageSync('uni-token',res.data['data']['token']);
window.location.href = window.location.href + '?' + 't_reload=' + new Date().getTime();
}
// console.log(res)
console.log(res)
},fail(err) {
reject(err);
},
......
//只要是未登录状态,想要跳转到名单内的路径时,直接跳到登录页
// 页面白名单,不受拦截
const whiteList = [
'/components/login/login',
'/pages/index/index'
]
export default function initApp(){
uni.addInterceptor('navigateTo', {
// 页面跳转前进行拦截, invoke根据返回值进行判断是否继续执行跳转
invoke (e) {
if(!hasPermission(e.url)){
uni.reLaunch({
url: '/components/login/login'
})
return false
}
return true
},
success (e) {
}
})
uni.addInterceptor('switchTab', {
// tabbar页面跳转前进行拦截
invoke (e) {
if(!hasPermission(e.url)){
uni.reLaunch({
url: '/components/login/login'
})
return false
}
return true
},
success (e) {
}
})
}
function hasPermission (url) {
let islogin = uni.getStorageSync("isLogin");//在这可以使用token、vuex
islogin = Boolean(Number(islogin));//返回布尔值
// 在白名单中或有登录判断条件可以直接跳转
if(whiteList.indexOf(url) !== -1 || islogin) {
return true
}
return false
}
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