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';
......@@ -14,15 +14,13 @@ export default {
this.globalData.baseUrl_api = config.baseUrl_api;
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 config from '@/config.js'
import aes from '@/common/aes.js'
function pcLogin(data) {
return request({
// url: '/login',
......@@ -16,6 +17,13 @@ function pcLogin(data) {
.then(getInfo)
}
function bindIdcCode(idcCode) {
return request({
url: `${config.baseUrl_api}/bind?idcCode=${idcCode}`,
method: 'post'
})
}
function h5Login(userName) {
return request({
url: `/h5Login`,
......@@ -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
uni.setStorageSync('perId', aes.encrypt(user.userId))
app.globalData.userInfo = user
})
}
......@@ -116,14 +123,14 @@ function getMyOwnMemberInfo() {
})
}
//for match
// for match
function getWxUserPhone(phoneRes) {
const currUser = uni.getStorageSync('currUser');
const currUser = uni.getStorageSync('currUser')
// getNowOpenId()
const nowOpenId = uni.getStorageSync('nowOpenId');
const nowOpenId = uni.getStorageSync('nowOpenId')
return request({
url: `/system/wx/updateMobile?openId=${nowOpenId}`,
method: "POST",
method: 'POST',
params: {
appId: appId,
userId: currUser.id,
......@@ -134,27 +141,36 @@ function getWxUserPhone(phoneRes) {
signature: phoneRes.signature
}
}).then((res) => {
let user = res.data;
const user = res.data
// uni.setStorageSync('token', 'Bearer '+ user.token);
uni.setStorageSync('token', user.token);
uni.setStorageSync('currUser', user);
uni.setStorageSync('token', user.token)
uni.setStorageSync('currUser', user)
return user
})
}
function checkUserAuth(path) {
const app = getApp()
if (app.globalData.isLogin) {
if (app.globalData.userInfo.perId) {
return true
} else {
uni.navigateTo({
url: '/pages/index/binding?path=' + encodeURIComponent(path)
url: '/myCenter/personInfo/index?path=' + encodeURIComponent(path)
})
return false
}
} else {
uni.navigateTo({
url: '/pages/index/login?path=' + encodeURIComponent(path)
})
return false;
return false
}
}
export {
pcLogin,getInfo,
pcLogin,
getInfo,
getCodeImg,
getSmsCode,
h5Login,
......@@ -163,5 +179,7 @@ export {
groupMemberRegister,
getMyOwnMemberInfo,
logout,
getWxUserPhone,checkUserAuth
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,
......
......@@ -13,7 +13,7 @@
</view>
<view class="rMainBox">
<uni-list :border="false" class="myList">
<!-- <uni-list-item :border="false" title="个人信息" showArrow :to="`./myInfo`">
<!-- <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>
......@@ -51,7 +51,7 @@
</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>
......@@ -127,12 +127,12 @@ function building() {
duration: 2000
});
}
function goPath(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
......@@ -211,6 +211,13 @@
}
},
{
"path": "personInfo/index",
"style": {
"navigationBarTitleText": "个人会员信息",
"enablePullDownRefresh": false
}
},
{
"path": "mytrain/mytrain",
"style": {
"navigationBarTitleText": "我的培训",
......@@ -263,7 +270,7 @@
"pagePath": "pages/webView/auth",
"text": "认证查询"
}, {
"pagePath": "pages/myCenter/myCenter",
"pagePath": "pages/myCenter/index",
"text": "我的"
}]
}
......
......@@ -9,7 +9,6 @@
<view>
<!-- 密码登录 -->
<view class="formbox">
<view>
<view class="round-input-item">
<image class="icon" :src="config.baseUrl_api+'/fs/static/login/tag01@2x.png'"></image>
......@@ -88,48 +87,48 @@
</template>
<script setup>
import {
import {
ref
} from 'vue'
} from 'vue'
import {
import {
onLoad
} from '@dcloudio/uni-app'
import config from '@/config.js'
import {
} from '@dcloudio/uni-app'
import config from '@/config.js'
import {
pcLogin,
getWxUserPhone,
getCodeImg,
getSmsCode,
loginByPhone
} from '@/common/login.js'
} from '@/common/login.js'
const popup = ref(null)
const agree = ref(true)
const loading = ref(false)
const showAgree = ref(false)
const form = ref({})
const codeUrl = ref('')
const inputstyle = ref({
const popup = ref(null)
const agree = ref(true)
const loading = ref(false)
const showAgree = ref(false)
const form = ref({})
const codeUrl = ref('')
const inputstyle = ref({
borderColor: 'transparent',
fontSize: '30rpx'
})
})
const app = getApp()
let path = '/pages/index/index';
onLoad((option) => {
let path = '/pages/index/index';
onLoad((option) => {
if (option.path) {
path = decodeURIComponent(option.path)
}
getCode()
})
})
function radioChange() {
function radioChange() {
popup.value.open()
agree.value = true
}
function decryptPhoneNumber(res) {
}
function decryptPhoneNumber(res) {
// console.log(res)
loading.value = true
......@@ -146,29 +145,29 @@ const app = getApp()
} else {
loading.value = false
}
}
}
function subscribe() {
function subscribe() {
uni.requestSubscribeMessage({
tmplIds: ['pvrlpWl1MDJfOghILwUsQtfcg96LWdstVOFLrDxGcdM'],
success: (res) => {
console.log('success:', res)
}
})
}
}
function showAgreement() {
function showAgreement() {
popup.value.open()
}
}
function getCode() {
function getCode() {
getCodeImg().then((res) => {
codeUrl.value = 'data:image/gif;base64,' + res.data.img
form.value.uuid = res.data.uuid
})
}
}
function handleLogin() {
function handleLogin() {
if (!form.value.username) {
uni.showToast({
title: '账号不能为空',
......@@ -197,7 +196,7 @@ const app = getApp()
url: path
})
})
}
}
</script>
<style scoped lang="scss">
......
......@@ -28,7 +28,7 @@
<view @click="goPath('/webView/vipSystem')">
<image />会员系统
</view>
<view @click="goPath('/myCenter/index')">
<view @click="goTab('/pages/myCenter/index')">
<image />我的
</view>
......@@ -37,29 +37,29 @@
</template>
<script setup>
import * as api from '@/common/api.js';
import * as loginServer from '@/common/login.js';
import config from '@/config.js'
import {
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 {
} from '@dcloudio/uni-app';
import {
ref,
getCurrentInstance
} from 'vue';
} from 'vue';
const {
const {
proxy
} = getCurrentInstance()
const app = getApp();
const svId = ref(null);
} = getCurrentInstance()
const app = getApp();
const svId = ref(null);
const messageList = ref([])
onShow(() => {
const messageList = ref([])
onShow(() => {
if (app.globalData.isLogin) {
init()
} else {
......@@ -67,32 +67,37 @@
init()
};
}
})
onLoad(option => {
})
onLoad(option => {
});
});
function goPath(path) {
function goPath(path) {
if(path)
uni.navigateTo({
url: path
});
}
}
function goTab(path){
uni.switchTab({
url: path
})
}
function init() {
function init() {
uni.showLoading({
title: '加载中'
});
uni.hideLoading();
}
}
function goItem(item) {
function goItem(item) {
if (item.path) {
let path = item.path
uni.navigateTo({
......@@ -105,7 +110,7 @@
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>
......@@ -85,15 +85,18 @@ import {
pcLogin,
loginByPhone
} 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({
const inputstyle = ref({
borderColor: 'transparent',
fontSize: '30rpx'
})
})
const form = ref({
username: null,
password: null,
......@@ -112,8 +115,12 @@ const countDown = ref({
})
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()
})
......@@ -152,7 +159,6 @@ function login() {
pcLogin(form.value)
.then((res) => {
app.globalData.isLogin = true
uni.redirectTo({
url: '/pages/index/index'
......@@ -178,9 +184,21 @@ function login() {
loginByPhone(form2.value.telNo,form2.value.code)
.then(() => {
app.globalData.isLogin = true
if(!app.globalData.userInfo.perId){
uni.redirectTo({
url: '/pages/index/index'
url: '/myCenter/personInfo/index?path=' + encodeURIComponent(path)
})
}else{
if(switchTab.indexOf(path)>-1){
uni.switchTab({
url: path
})
}else{
uni.redirectTo({
url: path
})
}
}
})
}
}
......
<template>
<view class="box">
<view class="box" v-if='isShow'>
<view class="topBg">
<view class="userInfoBox">
<view class="headImg">
......@@ -13,7 +13,7 @@
</view>
<view class="rMainBox">
<uni-list :border="false" class="myList">
<!-- <uni-list-item :border="false" title="个人信息" showArrow :to="`./myInfo`">
<!-- <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>
......@@ -42,8 +42,16 @@
</view>
</template>
</uni-list-item> -->
<uni-list-item :border="false" title="我的培训" showArrow clickable @click="goPath('/myCenter/mytrain/mytrain')">
<uni-list-item :border="false" title="个人会员" showArrow clickable
@click="goPath('/myCenter/personInfo/index')">
<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>
......@@ -51,7 +59,7 @@
</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>
......@@ -67,32 +75,40 @@
<script setup>
import * as my from '@/myCenter/center_api.js';
import * as loginServer from '@/common/login.js';
import { ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import {
onMounted,
ref
} from 'vue';
import {
onLoad,
onShow
} from '@dcloudio/uni-app';
const user = ref({});
const app = getApp();
const isShow = ref(false)
onMounted(() => {
init()
})
onShow(() => {
if (app.globalData.isLogin) {
init();
} else {
app.firstLoadCallback = () => {
init();
};
}
});
function init() {
console.log(app.globalData.isLogin)
if(app.globalData.userInfo){
if (app.globalData.isLogin) {
isShow.value = true
if (app.globalData.userInfo) {
const currUser = app.globalData.userInfo
user.value = currUser;
} else {
loginServer.getInfo().then(res=>{
loginServer.getInfo().then(res => {
const currUser = app.globalData.userInfo
user.value = currUser
})
}
} else {
uni.redirectTo({
url: '/pages/index/login?path=' + encodeURIComponent(getCurrentPages()[0].$page.fullPath)
})
}
}
function goBack() {
......@@ -127,74 +143,87 @@ function building() {
duration: 2000
});
}
function goPath(path) {
if(path)
function goPath(path) {
if (path)
uni.navigateTo({
url: path
});
}
}
</script>
<style scoped lang="scss">
.box {
.box {
width: 100vw;
overflow: hidden;
}
.rMainBox {
}
.rMainBox {
box-sizing: border-box;
padding: 20rpx 25rpx 0;
margin: 25rpx;
}
.userInfoBox {
}
.userInfoBox {
height: 200rpx;
}
.nameBox {
}
.nameBox {
position: absolute;
left: 180rpx;
top: 70rpx;
font-size: 30rpx;
}
.nameBox view {
}
.nameBox view {
color: #7b7f83;
font-size: 26rpx;
margin-top: 10rpx;
}
.goback {
}
.goback {
position: absolute;
color: #fff;
top: 100rpx;
left: 35rpx;
}
.forAdmin {
}
.forAdmin {
padding: 25rpx;
box-sizing: border-box;
}
.topBg {
}
.onlyCardBottom {
}
.topBg {}
.onlyCardBottom {
position: relative;
width: 660rpx;
margin: auto;
height: 90rpx;
.bbg {
height: 90rpx;
width: 660rpx;
}
.cardBottom {
width: 660rpx;
background: transparent;
height: 90rpx;
text {
font-size: 28rpx;
color: #925921;
}
.renewBtn {
background: #874f02;
color: #fff;
}
}
}
.headImg {
}
.headImg {
border-radius: 50%;
position: relative;
top: 50rpx;
......@@ -204,59 +233,67 @@ function building() {
border: 4px solid #ffffff;
background: #c4f9cb;
left: 40rpx;
button {
display: block;
padding: 0;
}
image {
width: 100rpx;
height: 100rpx;
display: block;
}
}
}
.slot-image {
.slot-image {
width: 50rpx;
position: relative;
top: -8rpx;
height: 50rpx;
margin-right: 30rpx;
}
}
.myList {
}
.funcBar {
.myList {}
.funcBar {
display: flex;
background: #fff;
width: 700rpx;
height: 140rpx;
justify-content: space-around;
}
.funcBar view {
}
.funcBar view {
display: flex;
align-items: center;
font-size: 36rpx;
}
.funcBar image {
}
.funcBar image {
width: 80rpx;
height: 80rpx;
}
.topbgimg {
}
.topbgimg {
width: 100vw;
position: absolute;
z-index: -1;
}
.reportItembox {
}
.reportItembox {
overflow: hidden;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.reportItem {
}
.reportItem {
background: #fff;
border-radius: 15rpx;
width: 340rpx;
margin-top: 25rpx;
.t {
border-bottom: 1px solid #e5e5e5;
height: 70rpx;
......@@ -265,15 +302,18 @@ function building() {
font-size: 30rpx;
padding-left: 36rpx;
}
.rbody {
display: flex;
padding: 36rpx;
box-sizing: border-box;
view {
font-size: 26rpx;
color: #888;
width: 40%;
}
text {
color: #00c176;
font-weight: bold;
......@@ -282,15 +322,18 @@ function building() {
margin-bottom: 20rpx;
}
}
}
.changephonepop {
}
.changephonepop {
width: 100%;
}
.changephonepop view {
}
.changephonepop view {
width: 100%;
margin: 0 0 30rpx;
}
.changephonepop view input {
}
.changephonepop view input {
width: 100%;
background: #f4f4f4;
font-size: 30rpx;
......@@ -298,11 +341,13 @@ function building() {
padding: 0 15rpx;
box-sizing: border-box;
line-height: 80rpx;
}
.changephonepop view.ffff {
}
.changephonepop view.ffff {
display: flex;
}
.changephonepop view button {
}
.changephonepop view button {
font-size: 24rpx;
margin-left: 10rpx;
white-space: nowrap;
......@@ -312,5 +357,5 @@ function building() {
color: #fff;
padding: 0;
border: none;
}
}
</style>
\ No newline at end of file
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!