4b268e3f by 华明祺

登录

1 parent 9e55c13c
<script>
import {
h5Login
getInfo
} from '@/common/login.js';
import * as api from '@/common/api.js';
import config from '@/config.js';
......@@ -13,16 +13,14 @@ export default {
firstload = true
this.globalData.baseUrl_api = config.baseUrl_api;
let userName = uni.getStorageSync('userName')
if (userName) {
this.globalData.isLogin = true;
} else {
this.globalData.isLogin = false;
}
let userName = uni.getStorageSync('userName')
if (userName) {
this.globalData.isLogin = true;
getInfo()
} else {
this.globalData.isLogin = false;
}
},
onShow: function() {
console.log('App Show');
......
import request from './request'
import request from './request'
import config from '@/config.js'
import aes from '@/common/aes.js'
function pcLogin(data) {
return request({
// url: '/login',
// url: '/login',
url: `${config.baseUrl_api}/loginZtx`,
method: 'post',
headers: {
isToken: false
},
method: 'post',
headers: {
isToken: false
},
params: data
}).then((res) => {
uni.setStorageSync('token', 'Bearer ' + res.data.token)
})
.then(getInfo)
uni.setStorageSync('token', 'Bearer ' + res.data.token)
})
.then(getInfo)
}
function bindIdcCode(idcCode) {
return request({
url: `${config.baseUrl_api}/bind?idcCode=${idcCode}`,
method: 'post'
})
}
function h5Login(userName) {
......@@ -36,6 +44,7 @@ function h5LoginAuto() {
uni.redirectTo({
url: '/pages/index/login'
})
return Promise.reject()
}
}
......@@ -71,7 +80,7 @@ function loginByPhone(phonenumber, code) {
code
}
return request({
url: '/userLoginByPhone',
url: `${config.baseUrl_api}/userLoginByPhoneForPc`,
method: 'post',
params: data
}).then((res) => {
......@@ -82,15 +91,13 @@ function loginByPhone(phonenumber, code) {
// 获取用户详细信息
function getInfo() {
return request({
url: `${config.baseUrl_api}/getInfo`,
url: `${config.baseUrl_api}/getInfoForPc`,
method: 'get'
}).then(res => {
const app = getApp()
const user = res.data.user
const personInfo = res.data.personInfo
uni.setStorageSync('userName', user.userName)
uni.setStorageSync('perId', aes.encrypt(personInfo.perId))
app.globalData.deptType = user.dept.deptType
const user = res.data.user
uni.setStorageSync('userName', user.userName)
uni.setStorageSync('perId', aes.encrypt(user.userId))
app.globalData.userInfo = user
})
}
......@@ -114,54 +121,65 @@ function getMyOwnMemberInfo() {
app.globalData.memberInfo = res.data.memberInfo
app.globalData.isExam = res.data?.dept?.isExam
})
}
//for match
}
// for match
function getWxUserPhone(phoneRes) {
const currUser = uni.getStorageSync('currUser');
// getNowOpenId()
const nowOpenId = uni.getStorageSync('nowOpenId');
return request({
url: `/system/wx/updateMobile?openId=${nowOpenId}`,
method: "POST",
params: {
appId: appId,
userId: currUser.id,
encryptedData: phoneRes.encryptedData,
errMsg: phoneRes.errMsg,
iv: phoneRes.iv,
rawData: phoneRes.rawData,
signature: phoneRes.signature
}
}).then((res) => {
let user = res.data;
// uni.setStorageSync('token', 'Bearer '+ user.token);
uni.setStorageSync('token', user.token);
uni.setStorageSync('currUser', user);
return user
})
}
const currUser = uni.getStorageSync('currUser')
// getNowOpenId()
const nowOpenId = uni.getStorageSync('nowOpenId')
return request({
url: `/system/wx/updateMobile?openId=${nowOpenId}`,
method: 'POST',
params: {
appId: appId,
userId: currUser.id,
encryptedData: phoneRes.encryptedData,
errMsg: phoneRes.errMsg,
iv: phoneRes.iv,
rawData: phoneRes.rawData,
signature: phoneRes.signature
}
}).then((res) => {
const user = res.data
// uni.setStorageSync('token', 'Bearer '+ user.token);
uni.setStorageSync('token', user.token)
uni.setStorageSync('currUser', user)
return user
})
}
function checkUserAuth(path) {
const app = getApp()
if (app.globalData.isLogin) {
return true
} else {
uni.navigateTo({
url: '/pages/index/binding?path=' + encodeURIComponent(path)
})
return false;
}
}
const app = getApp()
if (app.globalData.isLogin) {
if (app.globalData.userInfo.perId) {
return true
} else {
uni.navigateTo({
url: '/myCenter/personInfo/index?path=' + encodeURIComponent(path)
})
return false
}
} else {
uni.navigateTo({
url: '/pages/index/login?path=' + encodeURIComponent(path)
})
return false
}
}
export {
pcLogin,getInfo,
pcLogin,
getInfo,
getCodeImg,
getSmsCode,
h5Login,
h5LoginAuto,
loginByPhone,
groupMemberRegister,
getMyOwnMemberInfo,
logout,
getWxUserPhone,checkUserAuth
getMyOwnMemberInfo,
logout,
getWxUserPhone,
checkUserAuth,
bindIdcCode
}
......
......@@ -8,9 +8,9 @@
// const baseUrl_api = 'https://newsystem.taekwondo.org.cn/stage-api/'
// train
const baseUrl_api = 'http://192.168.1.11:8787'
const trainUrl_api = 'http://192.168.1.25:8686'
//match
const baseUrl_api = 'http://192.168.1.98:8787'
const trainUrl_api = 'http://192.168.1.98:8686'
// match
// const baseUrl_api = 'http://192.168.1.132:8081'
export default {
baseUrl_api,
......
<template>
<view class="box">
<view class="topBg">
<view class="userInfoBox">
<view class="headImg">
<image mode="aspectFill" :src="avatarUrl"></image>
</view>
<view class="nameBox">
{{ user.nickName }}
<view>{{ user.phonenumber }}</view>
</view>
</view>
</view>
<view class="rMainBox">
<uni-list :border="false" class="myList">
<!-- <uni-list-item :border="false" title="个人信息" showArrow :to="`./myInfo`">
<view class="box">
<view class="topBg">
<view class="userInfoBox">
<view class="headImg">
<image mode="aspectFill" :src="avatarUrl"></image>
</view>
<view class="nameBox">
{{ user.nickName }}
<view>{{ user.phonenumber }}</view>
</view>
</view>
</view>
<view class="rMainBox">
<uni-list :border="false" class="myList">
<!-- <uni-list-item :border="false" title="个人信息" showArrow :to="`./myInfo`">
<template v-slot:header>
<view class="slot-box">
<image class="slot-image" src="/static/user_icon03.png" mode="widthFix"></image>
......@@ -43,25 +43,25 @@
</template>
</uni-list-item> -->
<uni-list-item :border="false" title="我的培训" showArrow clickable @click="goPath('/myCenter/mytrain/mytrain')">
<template v-slot:header>
<view class="slot-box">
<image class="slot-image" mode="widthFix"></image>
</view>
</template>
</uni-list-item>
<uni-list-item :border="false" title="我的培训" showArrow clickable @click="goPath('/myCenter/mytrain/mytrain')">
<template v-slot:header>
<view class="slot-box">
<image class="slot-image" mode="widthFix"></image>
</view>
</template>
</uni-list-item>
<!-- <uni-list-item :border="false" title="我的赛事" showArrow :to="`./match`">
<!-- <uni-list-item :border="false" title="我的赛事" showArrow :to="`./match`">
<template v-slot:header>
<view class="slot-box">
<image class="slot-image" src="/static/user_icon04.png" mode="widthFix"></image>
</view>
</template>
</uni-list-item> -->
</uni-list>
</view>
</uni-list>
</view>
</view>
</view>
</template>
<script setup>
......@@ -74,29 +74,29 @@ const user = ref({});
const app = getApp();
onShow(() => {
if (app.globalData.isLogin) {
init();
} else {
app.firstLoadCallback = () => {
init();
};
}
if (app.globalData.isLogin) {
init();
} else {
app.firstLoadCallback = () => {
init();
};
}
});
function init() {
console.log(app.globalData.isLogin)
if(app.globalData.userInfo){
const currUser = app.globalData.userInfo
user.value = currUser;
} else {
loginServer.getInfo().then(res=>{
const currUser = app.globalData.userInfo
user.value = currUser
})
}
console.log(app.globalData.isLogin)
if(app.globalData.userInfo){
const currUser = app.globalData.userInfo
user.value = currUser;
} else {
loginServer.getInfo().then(res=>{
const currUser = app.globalData.userInfo
user.value = currUser
})
}
}
function goBack() {
uni.navigateBack({});
uni.navigateBack({});
}
// function goQcode() {
// uni.scanCode({
......@@ -121,18 +121,18 @@ function goBack() {
// });
// }
function building() {
uni.showToast({
title: '暂未开放,敬请期待。',
icon: 'none',
duration: 2000
});
uni.showToast({
title: '暂未开放,敬请期待。',
icon: 'none',
duration: 2000
});
}
function goPath(path) {
if(path)
uni.navigateTo({
url: path
});
}
function goPath(path) {
if(path)
uni.navigateTo({
url: path
});
}
</script>
<style scoped lang="scss">
......
<template>
<view class="bg">
<view class="formbox" v-if="form.perId">
身份证号:{{form.idcCode}}
</view>
<view class="formbox" v-else>
<view>
<view class="round-input-item">
<uni-easyinput :styles="inputstyle" placeholder="身份证" v-model="form.idcCode" />
</view>
</view>
<view class="flex-item">
</view>
<view class="center-item">
<button @click="handleBind" class="btn-red">绑定个人会员</button>
</view>
</view>
</view>
</template>
<script setup>
import {
ref
} from 'vue'
import {
onLoad
} from '@dcloudio/uni-app'
import config from '@/config.js'
import {
bindIdcCode
} from '@/common/login.js'
const app=getApp()
const form = ref({})
let path = '/pages/myCenter/index';
onLoad((option) => {
if (option.path) {
path = decodeURIComponent(option.path)
}
form.value=app.globalData.userInfo
})
function handleBind() {
if (!form.value.idcCode) {
uni.showToast({
title: '身份证号不能为空',
icon: 'none'
})
return
}
bindIdcCode(form.value.idcCode)
.then((res) => {
uni.redirectTo({
url: path
})
})
}
</script>
<style scoped lang="scss">
.bg{background: linear-gradient(60deg,#ad1820 50%,#044a9f 50%);padding: 1px;height: 100vh;overflow: hidden;}
.formbox {
background: #fff;
width: 700rpx;
padding: 50rpx;box-sizing: border-box;
margin: auto;
border-radius: 20rpx;
}
.logoView {
/* margin: 20vh 0; */
}
.logo {
width: 420rpx;
height: 179rpx;
margin: 60rpx auto 60rpx;
display: block;
}
.h1 {
font-size: 36rpx;
color: #000000;
text-align: center;
}
.start {
margin: 0 auto 80rpx;
font-size: 30rpx;
color: #fff;
height: 80rpx;
width: 480rpx;
border-radius: 40rpx;
background: #44A92F;
}
.agreeArea {
text-align: center;
}
.agreeArea label {
font-size: 26rpx;
}
.agreeArea label text {
color: #00C176;
}
.tip {
margin: 30rpx 0 0;
font-size: 20rpx;
color: #181818;
}
.h3 {}
.round-input-item {
overflow: hidden;
background: RGBA(247, 247, 248, 1);
border-radius: 40rpx;
padding: 0 0 0 30rpx;
height: 80rpx;
margin-bottom: 30rpx;
display: flex;
align-items: center;
image {
width: 180rpx;
height: 80rpx;
&.icon {
width: 30rpx;
height: 30rpx;
margin-right: 16rpx;
}
}
input {
border-left: 1rpx solid RGBA(214, 216, 219, 1);
padding: 0 0 0 20rpx;
font-size: 30rpx;
}
input::-webkit-input-placeholder {
color: RGBA(158, 166, 174, 1);
font-size: 30rpx;
}
input::placeholder {
color: RGBA(158, 166, 174, 1);
font-size: 30rpx;
}
input::-moz-placeholder {
color: RGBA(158, 166, 174, 1);
font-size: 30rpx;
}
text {
font-size: 28rpx;
color: #014A9F; padding: 0 20rpx;
}
}
</style>
\ No newline at end of file
......@@ -33,7 +33,7 @@
}
},
{
"path": "pages/myCenter/myCenter",
"path": "pages/myCenter/index",
"style": {
"navigationBarTitleText": "我的",
"enablePullDownRefresh": false
......@@ -209,6 +209,13 @@
"navigationBarTitleText": "个人中心",
"enablePullDownRefresh": false
}
},
{
"path": "personInfo/index",
"style": {
"navigationBarTitleText": "个人会员信息",
"enablePullDownRefresh": false
}
},
{
"path": "mytrain/mytrain",
......@@ -263,7 +270,7 @@
"pagePath": "pages/webView/auth",
"text": "认证查询"
}, {
"pagePath": "pages/myCenter/myCenter",
"pagePath": "pages/myCenter/index",
"text": "我的"
}]
}
......
<template>
<view class="page">
<swiper>
<swiper-item>1</swiper-item>
<swiper-item>2</swiper-item>
<swiper-item>3</swiper-item>
</swiper>
<view class="girdBox">
<view @click="goPath('/training/trainList')">
<image />新闻资讯
</view>
<view @click="goPath('/match/index')">
<image />赛事报名
</view>
<view class="page">
<swiper>
<swiper-item>1</swiper-item>
<swiper-item>2</swiper-item>
<swiper-item>3</swiper-item>
</swiper>
<view class="girdBox">
<view @click="goPath('/training/trainList')">
<image />新闻资讯
</view>
<view @click="goPath('/match/index')">
<image />赛事报名
</view>
<view @click="goPath('/training/trainList')">
<image />培训报名
</view>
<view @click="goPath()">
<image />团体会员
</view>
<view @click="goPath()">
<image />地方协会
</view>
<view @click="goPath()">
<image />考点查询
</view>
<view @click="goPath('/webView/vipSystem')">
<image />会员系统
</view>
<view @click="goPath('/myCenter/index')">
<image />我的
</view>
<view @click="goPath('/training/trainList')">
<image />培训报名
</view>
<view @click="goPath()">
<image />团体会员
</view>
<view @click="goPath()">
<image />地方协会
</view>
<view @click="goPath()">
<image />考点查询
</view>
<view @click="goPath('/webView/vipSystem')">
<image />会员系统
</view>
<view @click="goTab('/pages/myCenter/index')">
<image />我的
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import * as api from '@/common/api.js';
import * as loginServer from '@/common/login.js';
import config from '@/config.js'
import {
onLoad,
onShow,
onReady,
onPullDownRefresh
} from '@dcloudio/uni-app';
import {
ref,
getCurrentInstance
} from 'vue';
const {
proxy
} = getCurrentInstance()
const app = getApp();
const svId = ref(null);
const messageList = ref([])
onShow(() => {
if (app.globalData.isLogin) {
init()
} else {
app.firstLoadCallback = () => {
init()
};
}
})
onLoad(option => {
});
function goPath(path) {
if(path)
uni.navigateTo({
url: path
});
}
import * as api from '@/common/api.js';
import * as loginServer from '@/common/login.js';
import config from '@/config.js'
import {
onLoad,
onShow,
onReady,
onPullDownRefresh
} from '@dcloudio/uni-app';
import {
ref,
getCurrentInstance
} from 'vue';
const {
proxy
} = getCurrentInstance()
const app = getApp();
const svId = ref(null);
const messageList = ref([])
onShow(() => {
if (app.globalData.isLogin) {
init()
} else {
app.firstLoadCallback = () => {
init()
};
}
})
onLoad(option => {
});
function goPath(path) {
if(path)
uni.navigateTo({
url: path
});
}
function goTab(path){
uni.switchTab({
url: path
})
}
function init() {
uni.showLoading({
title: '加载中'
});
uni.hideLoading();
function init() {
uni.showLoading({
title: '加载中'
});
uni.hideLoading();
}
}
function goItem(item) {
if (item.path) {
let path = item.path
uni.navigateTo({
url: item.path
});
function goItem(item) {
if (item.path) {
let path = item.path
uni.navigateTo({
url: item.path
});
} else {
uni.showToast({
title: `暂未开放`,
icon: 'none'
});
}
}
} else {
uni.showToast({
title: `暂未开放`,
icon: 'none'
});
}
}
</script>
<style scope lang="scss">
.page{width: 100vw;overflow: hidden;}
......
......@@ -5,10 +5,10 @@
<view class="retop">
<image class="logotop" :src="config.baseUrl_api+'/fs/static/login/logo@2x.png'"></image>
<view class="loginbox">
<view class="loginNav">
<!-- <view class="loginNav">
<view class="n1" :class="isActive==0?'active':''" @click="changeActive(0)">密码登录</view>
<view class="n2" :class="isActive==1?'active':''" @click="changeActive(1)">短信登录</view>
</view>
</view> -->
<!-- 密码登录 -->
<view class="formbox">
<form v-if="isActive==0">
......@@ -55,9 +55,9 @@
<view class="center-item">
<button @click="login" class="btn-red">登录</button>
</view>
<view class="center-item">
<!--<view class="center-item">
<text class="text-red" @click="goRegister">没有账号,去注册</text>
</view>
</view> -->
</view>
......@@ -84,16 +84,19 @@ import {
getSmsCode,
pcLogin,
loginByPhone
} from '@/common/login.js'
} from '@/common/login.js'
import {
onLoad
} from '@dcloudio/uni-app'
const isActive = ref(0)
const isActive = ref(1)
const agree = ref(false)
const isRember = ref(true)
const codeUrl = ref(null)
const inputstyle = ref({
borderColor: 'transparent',
fontSize: '30rpx'
})
const inputstyle = ref({
borderColor: 'transparent',
fontSize: '30rpx'
})
const form = ref({
username: null,
password: null,
......@@ -109,11 +112,15 @@ const form2 = ref({
const countDown = ref({
start: false,
second: 60
})
})
const app = getApp()
onMounted(() => {
const switchTab=['/pages/index/index','/pages/webView/auth','/pages/myCenter/index']
let path = '/pages/index/index';
onLoad((option) => {
if (option.path) {
path = decodeURIComponent(option.path)
}
getCode()
})
......@@ -151,8 +158,7 @@ function login() {
}
pcLogin(form.value)
.then((res) => {
.then((res) => {
app.globalData.isLogin = true
uni.redirectTo({
url: '/pages/index/index'
......@@ -177,10 +183,22 @@ function login() {
loginByPhone(form2.value.telNo,form2.value.code)
.then(() => {
app.globalData.isLogin = true
uni.redirectTo({
url: '/pages/index/index'
})
app.globalData.isLogin = true
if(!app.globalData.userInfo.perId){
uni.redirectTo({
url: '/myCenter/personInfo/index?path=' + encodeURIComponent(path)
})
}else{
if(switchTab.indexOf(path)>-1){
uni.switchTab({
url: path
})
}else{
uni.redirectTo({
url: path
})
}
}
})
}
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!