Browse Source

接口对接4个

master
j1ack 3 years ago
parent
commit
1f11322e10
  1. 6
      pages.json
  2. 122
      pages/login/forget.vue
  3. 42
      pages/login/index.vue
  4. 71
      pages/login/register.vue
  5. 97
      pages/me/about.vue
  6. 68
      pages/me/index.vue
  7. 1
      utils/api.js
  8. 3
      utils/axios.js
  9. 5
      utils/language/en_US.js

6
pages.json

@ -87,6 +87,12 @@
"navigationStyle": "custom"
}
},
{
"path": "pages/me/about",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/me/inviteFriends",
"style": {

122
pages/login/forget.vue

@ -2,7 +2,7 @@
<view class="main">
<navigation>{{ i18n.ForgotPassword }}</navigation>
<view class="body">
<u--form class="form" :model="userInfo" :rules="rules" ref="form1" errorType="toast">
<u--form class="form" :model="userInfo" :rules="rules" ref="uForm" errorType="toast">
<!-- 邮箱 -->
<u-form-item class="input-item" prop="email" ref="item1">
<u-icon class="icon"
@ -30,8 +30,8 @@
<u-icon class="icon"
:name="userInfo.password ? '../../static/login/Password_pr.png' : '../../static/login/Password_de.png'"
size="48rpx" width="48rpx"></u-icon>
<u-input class="input" type="password" v-model="userInfo.password" color="#fff" fontSize="32rpx" border="none"
:placeholder="i18n.passwordText">
<u-input class="input" type="password" v-model="userInfo.password" color="#fff" fontSize="32rpx"
border="none" :placeholder="i18n.passwordText">
</u-input>
</u-form-item>
<!-- 重复密码 -->
@ -39,13 +39,13 @@
<u-icon class="icon"
:name="userInfo.confirmPassword ? '../../static/login/Password_pr.png' : '../../static/login/Password_de.png'"
size="48rpx" width="48rpx"></u-icon>
<u-input class="input" type="password" v-model="userInfo.confirmPassword" color="#fff" fontSize="32rpx"
border="none" :placeholder="i18n.confirmPasswordText">
<u-input class="input" type="password" v-model="userInfo.confirmPassword" color="#fff"
fontSize="32rpx" border="none" :placeholder="i18n.confirmPasswordText">
</u-input>
</u-form-item>
</u--form>
<u-button class="button" color="#00E8A2" throttleTime="500" :disabled="!agreeFlag">{{ i18n.Save }}
<u-button class="button" color="#00E8A2" throttleTime="500" :disabled="!agreeFlag" @click="forgotPassword" :throttleTime="500">{{ i18n.Save }}
</u-button>
</view>
@ -54,8 +54,10 @@
</template>
<script>
import UButton from '../../uview-ui/components/u-button/u-button.vue'
export default {
import UButton from '../../uview-ui/components/u-button/u-button.vue'
import api from '@/utils/api'
import md5 from 'js-md5'
export default {
name: "ForgotPassword",
data() {
return {
@ -64,62 +66,92 @@ export default {
seconds: 60,
//
isCanGetCode: false,
//
isCanPassword: false,
userInfo: {
name: "",
email: "",
password: "",
confirmPassword: "",
code:"",
},
rules: {
email: {
type: "string",
required: true,
message: this.$t("login.emailInputMessage"),
message: this.$t("login").emailInputMessage,
trigger: ["blur", "change"],
},
code: {
type: "string",
required: true,
message: this.$t("login.verificationCodeMessage"),
message: this.$t("login").verificationCodeMessage,
trigger: ["blur", "change"]
},
password: {
type: "string",
required: true,
message: this.$t("login.passwordInputMessage"),
message: this.$t("login").passwordInputMessage,
trigger: ["blur", "change"]
},
confirmPassword: {
type: "string",
required: true,
message: this.$t("login").passwordInputMessage,
trigger: ["blur", "change"]
},
},
agreeFlag: false,
};
},
computed: {
i18n() {
return this.$t("login");
},
agreeFlag() {
return this.userInfo.email && this.userInfo.password && this.userInfo.confirmPassword && this.userInfo.code
}
},
watch: {
'userInfo.email': {
handler(newValue) {
this.isCanGetCode = uni.$u.test.email(newValue);
}
},
'userInfo.password': {
handler(newValue) {
const numberReg = /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])[A-Za-z0-9 _]{6,20}$/
this.isCanPassword = numberReg.test(newValue)
}
},
},
onLoad() {
// console.log(this.$t('login.emailInputMessage'));
},
onShow() { },
onShow() {},
methods: {
//
codeChange(text) {
this.tips = text;
if (text.length == 7) {
text = text.slice(0, 2); // cd
this.tips = text + "s";
}
if (text.length == 6) {
text = text.substring(0, 1)
this.tips = text + "s";
}
if (text.length == 4) {
this.tips = this.$t("login").Getcode
}
},
//
getCode() {
if (!this.userInfo.email) {
uni.$u.toast(this.$t("login.Emailempty"))
uni.$u.toast(this.$t("login").Emailempty)
return
}
if (!this.isCanGetCode) {
uni.$u.toast(this.$t("login.Emailincorrect"))
uni.$u.toast(this.$t("login").Emailincorrect)
return
}
if (this.$refs.uCode.canGetCode) {
@ -129,30 +161,62 @@ export default {
}
//
uni.showLoading({
title: this.$t("login.GettingVerificationCode")
title: this.$t("login").GettingVerificationCode
})
this.$api.sendEmailCode(data).then(res => {
if (res.code === 200) {
uni.hideLoading();
api.sendEmailCode(data).then(res => {
uni.hideLoading(this.$t("login").CodeHasSent);
// this.start()
uni.$u.toast(this.$t("login.CodeHasSent"));
uni.$u.toast(this.$t("login").CodeHasSent);
//
this.$refs.uCode.start();
} else {
uni.$u.toast(res.msg)
}
})
} else {
uni.$u.toast(this.$t("login.SendAfter"));
uni.$u.toast(this.$t("login").SendAfter);
}
},
//
forgotPassword() {
if (!this.isCanPassword) {
uni.$u.toast(this.$t("login").passwordRule)
return
}
//
if (this.userInfo.password !== this.userInfo.confirmPassword) {
uni.$u.toast(this.$t("login").passwordConfirm)
return
}
this.$refs.uForm.validate().then(res => {
let userInfo = {
email: this.userInfo.email,
password: md5(this.userInfo.password),
confirmPassword: md5(this.userInfo.confirmPassword),
code: this.userInfo.code,
}
api.forgotPassword(userInfo).then(res => {
setTimeout(() => {
uni.showToast({
title: this.$t("login").resSuccess
})
}, 600)
uni.reLaunch({
url: '/pages/login/index'
})
})
}).catch(errors => {
console.log('err')
})
},
},
components: { UButton }
}
components: {
UButton
}
}
</script>
<style lang="scss" scoped>
.main {
.main {
.body {
margin-top: 204rpx;
@ -212,5 +276,5 @@ export default {
}
}
}
</style>

42
pages/login/index.vue

@ -21,8 +21,8 @@
</u-form-item>
</u--form>
<navigator class="forget" url="./forget">{{ i18n.forgotText }}</navigator>
<u-button class="button" color="#00E8A2">{{ i18n.Login }}</u-button>
<view class="signUp" @click.native="$u.throttle(login, 500)">{{ i18n.notAccountText }}
<u-button class="button" color="#00E8A2" @click="login" :throttleTime="500">{{ i18n.Login }}</u-button>
<view class="signUp">{{ i18n.notAccountText }}
<navigator class="navigator" url="./register">{{ i18n.SignUp }}
</navigator>
</view>
@ -31,10 +31,14 @@
</template>
<script>
import api from '@/utils/api'
import md5 from 'js-md5'
export default {
name: 'login',
data() {
return {
//
isCanGetCode: false,
userInfo: {
name: '',
password: '',
@ -43,18 +47,25 @@
email: {
type: 'string',
required: true,
message: this.$t('login.emailInputMessage'),
message: this.$t('login').emailInputMessage,
trigger: ['blur', 'change'],
},
password: {
type: 'string',
required: true,
message: this.$t('login.passwordInputMessage'),
message: this.$t('login').passwordInputMessage,
trigger: ['blur', 'change']
},
},
}
},
watch: {
'userInfo.email': {
handler(newValue) {
this.isCanGetCode = uni.$u.test.email(newValue);
}
},
},
computed: {
i18n() {
return this.$t('login')
@ -65,22 +76,29 @@
},
onShow() {},
methods: {
//
//
login() {
if (!this.isCanGetCode) {
uni.$u.toast(this.$t("login").Emailincorrect)
return
}
this.$refs.uForm.validate().then(res => {
this.$api.login(this.userInfo).then(res => {
if (res.errCode === 'SUCCESS') {
let userInfo={
email:this.userInfo.email,
password:md5(this.userInfo.password),
}
api.login(userInfo).then(res => {
setTimeout(() => {
uni.showToast({
title: this.$t("login.loginSuccess")
title: this.$t("login").loginSuccess
})
}, 600)
uni.switchTab({
uni.reLaunch({
url: '/pages/home/index'
})
} else {
uni.$u.toast(res.msg)
}
//
uni.setStorageSync('ticket',res)
})
}).catch(errors => {
console.log('err')

71
pages/login/register.vue

@ -23,7 +23,7 @@
<u-input class="input" v-model="userInfo.code" color="#fff" fontSize="32rpx" border="none"
:placeholder="i18n.registerWelcomeText" maxlength="6">
</u-input>
<u-code startText="Get code" :seconds="seconds" ref="uCode" keep-running unique-key="login"
<u-code :startText="i18n.Getcode" :seconds="seconds" ref="uCode" keep-running unique-key="login"
@change="codeChange">
</u-code>
<u-button class="getVCodeBtn" color="#323045" @tap="getCode">{{tips}}</u-button>
@ -58,9 +58,9 @@
<!-- 邀请码 -->
<u-form-item class="input-item" prop="InvitationCode" ref="item1">
<u-icon class="icon"
:name="userInfo.InvitationCode ? '../../static/login/Invitation_pr.png' : '../../static/login/Invitation_de.png'"
:name="userInfo.inviteCode ? '../../static/login/Invitation_pr.png' : '../../static/login/Invitation_de.png'"
size="48rpx" width="48rpx"></u-icon>
<u-input class="input" v-model="userInfo.InvitationCode" color="#fff" fontSize="32rpx" border="none"
<u-input class="input" v-model="userInfo.inviteCode" color="#fff" fontSize="32rpx" border="none"
:placeholder="i18n.InvitationCodeText">
</u-input>
</u-form-item>
@ -73,7 +73,8 @@
i18n.Conditions
}}</span></view>
</view>
<u-button class="button" color="#00E8A2" throttleTime="500" :disabled="!agreeFlag" @click="register" :throttleTime="500">
<u-button class="button" color="#00E8A2" throttleTime="500" :disabled="!agreeFlag" @click="register"
:throttleTime="500">
{{ i18n.SignUp }}
</u-button>
<view class="signUp">{{ i18n.haveAccount }}
@ -89,6 +90,7 @@
<script>
import UButton from '../../uview-ui/components/u-button/u-button.vue'
import api from '@/utils/api'
import md5 from 'js-md5'
export default {
name: "register",
data() {
@ -98,11 +100,15 @@
seconds: 60,
//
isCanGetCode: false,
//
isCanPassword: false,
//
isCanPayPassword:false,
userInfo: {
password: "",
email: '',
payPassword: '',
inviteCode: '',
inviteCode: 'gyUafm',
code: '',
lang: '',
},
@ -131,7 +137,7 @@
message: this.$t("login").passwordInputMessage,
trigger: ["blur", "change"]
},
InvitationCode: {
inviteCode: {
type: "string",
required: true,
message: this.$t("login").InvitationCodeMessage,
@ -161,14 +167,37 @@
handler(newValue) {
this.isCanGetCode = uni.$u.test.email(newValue);
}
},
'userInfo.password': {
handler(newValue) {
const numberReg = /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])[A-Za-z0-9 _]{6,20}$/
this.isCanPassword = numberReg.test(newValue)
}
},
'userInfo.payPassword': {
handler(newValue) {
const numberReg = /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])[A-Za-z0-9 _]{6,20}$/
this.isCanPayPassword = numberReg.test(newValue)
}
},
},
onShow() {},
methods: {
//
codeChange(text) {
console.log(text)
this.tips = text;
if (text.length == 7) {
text = text.slice(0, 2); // cd
this.tips = text + "s";
}
if (text.length == 6) {
text = text.substring(0, 1)
this.tips = text + "s";
}
if (text.length == 4) {
this.tips = this.$t("login").Getcode
}
},
//
getCode() {
@ -202,20 +231,36 @@
},
//
register() {
if (!this.isCanPassword) {
uni.$u.toast(this.$t("login").passwordRule)
return
}
if (!this.isCanPayPassword) {
uni.$u.toast(this.$t("login").passwordRule)
return
}
//
if(this.userInfo.password!==this.userInfo.confirmPassword){
uni.$u.toast(this.$t("login").passwordConfirm)
return
}
this.$refs.uForm.validate().then(res => {
this.$api.register(this.userInfo).then(res => {
if (res.errCode === 'SUCCESS') {
let userInfo={
email:this.userInfo.email,
password:md5(this.userInfo.password),
payPassword:md5(this.userInfo.payPassword),
inviteCode:this.userInfo.inviteCode,
code:this.userInfo.code,
}
api.register(userInfo).then(res => {
setTimeout(() => {
uni.showToast({
title: this.$t("login").resSuccess
})
}, 600)
uni.switchTab({
uni.reLaunch({
url: '/pages/login/index'
})
} else {
uni.$u.toast(res.msg)
}
})
}).catch(errors => {
console.log('err')

97
pages/me/about.vue

@ -0,0 +1,97 @@
<template>
<view class="main">
<!-- nav -->
<navigation>{{ i18n.AboutUs }}</navigation>
<view class="body">
</view>
</view>
</template>
<script>
import api from '@/utils/api'
export default {
name: "AboutUs",
data() {
return {
};
},
computed: {
i18n() {
return this.$t("me");
},
},
onLoad() {
this.about();
},
onShow() { },
methods: {
//
about() {
api.aboutus().then(res => {
console.log(res)
})
},
},
}
</script>
<style lang="scss" scoped>
.main {
.body {
overflow: hidden;
margin-top: 200rpx;
padding: 0 48rpx;
.shareText {
margin-top: 104rpx;
font-size: 60rpx;
font-weight: 800;
text-align: center;
}
.scanText {
font-size: 32rpx;
text-align: center;
color: #A2A0A8;
}
.QRCode {
box-sizing: border-box;
margin: 66rpx auto;
width: 520rpx;
height: 520rpx;
background-image: url(../../static/me/bg_QR_code.png);
background-repeat: no-repeat;
background-size: 520rpx;
padding: 52rpx;
.QRCodeImg {
margin-left: 8rpx;
}
}
.myIdText {
font-size: 48rpx;
font-weight: 800;
text-align: center;
}
.button {
height: 112rpx;
margin: 72rpx 0;
border-radius: 32rpx;
color: #15141F !important;
font-weight: 700;
font-size: 32rpx;
}
}
}
</style>

68
pages/me/index.vue

@ -6,12 +6,12 @@
<u-image class="headImg" src="../../static/me/Ellipse 85.png" width="160rpx" height="160rpx"
radius="160rpx"></u-image>
<view class="idAndAccount">
<view class="id">ID:984934</view>
<view class="account">{{ i18n.account }}:348798457498579</view>
<view class="id">ID:{{userInfo.uid}}</view>
<view class="account">{{ i18n.account }}:{{userInfo.email}}</view>
</view>
</view>
<!-- 三个按钮 -->
<view class="btnDiv" >
<view class="btnDiv">
<!-- 充值 -->
<view class="item" id='recharge' @click="goto">
<view class="img" id='recharge'></view>
@ -32,17 +32,17 @@
<view class="balanceRow">
<!-- 可用余额 -->
<view class="item">
<view class="number">0</view>
<view class="number">{{userInfoBalance.balance}}</view>
<view class="title">{{ i18n.Balance }}</view>
</view>
<!-- 质押余额 -->
<view class="item">
<view class="number">0</view>
<view class="number">{{userInfoBalance.pledge}}</view>
<view class="title">{{ i18n.Pledge }}</view>
</view>
<!-- 合约余额 -->
<view class="item">
<view class="number">0</view>
<view class="number">{{userInfoBalance.contract}}</view>
<view class="title">{{ i18n.Contarct }}</view>
</view>
</view>
@ -70,40 +70,70 @@
</view>
<!-- 退出登录 -->
<u-button class="logOutButton" color="#323045" throttleTime="500">
<u-button class="logOutButton" color="#323045" throttleTime="500" @click="showLogOut=true">
<view class="title">{{ i18n.LogOut }}</view>
</u-button>
</view>
<!-- tabBar -->
<tab-bar :selectActive="5"></tab-bar>
<!-- 确认退出登录 -->
<u-modal :show="showLogOut" :showCancelButton="true" :confirmText="i18n.Confirm" :cancelText="i18n.Cancel"
:content="i18n.isLogOut" @confirm="logOut" @cancel="showLogOut=false"></u-modal>
</view>
</template>
<script>
export default {
import api from '@/utils/api'
export default {
name: 'me',
data() {
return {
// 退
showLogOut: false,
//
userInfo:{},
//
userInfoBalance:{},
}
},
onLoad() {
},
onShow() {
},
onHide() {
//
this.getUserInfo()
//
this.getUserInfoBalance();
},
onHide() {},
computed: {
i18n() {
return this.$t('me')
}
},
methods: {
//
getUserInfo() {
api.userInfo().then(res => {
this.userInfo=res
})
},
//
getUserInfoBalance() {
api.userAccount().then(res => {
this.userInfoBalance=res
})
},
// 退
logOut() {
api.loginOut().then(res => {
uni.setStorageSync('ticket',null)
uni.reLaunch({
url: '/pages/login/index'
})
})
},
goto(e) {
// console.log(e.target);
// console.log(e.target.id);
@ -141,6 +171,7 @@ export default {
url = '/pages/me/language'
break;
case 'AboutUs':
url = '/pages/me/about'
break;
default:
break;
@ -154,12 +185,11 @@ export default {
}
}
}
}
</script>
<style lang="scss" scoped>
.main {
.main {
padding-top: 88rpx;
padding-bottom: 198rpx; // TabBar
@ -205,7 +235,7 @@ export default {
border-radius: 16rpx;
font-size: 24rpx;
color: #FFBC1F;
text-align: center;
text-align: left;
padding-left: 20rpx;
&::before {
@ -374,5 +404,5 @@ export default {
}
}
</style>

1
utils/api.js

@ -81,6 +81,7 @@ const api = {
//--------------------------------- 个人中心 ---------------------------------
register: (params) => Vue.prototype.$axios.post('/api/index/register',params),//注册
login: (params) => Vue.prototype.$axios.post('/api/user/login',params),//登录
aboutus: (params) => Vue.prototype.$axios.post('/api/index/aboutus',params),//关于我们
loginOut: (params) => Vue.prototype.$axios.post('/api/user/loginOut',params),//退出登录
forgotPassword: (params) => Vue.prototype.$axios.post('/api/user/forgotPassword',params),//忘记密码
updatePassword: () => Vue.prototype.$axios.get('/api/user/updatePassword'),//修改登录密码

3
utils/axios.js

@ -40,7 +40,8 @@ service.interceptors.request.use(
}
const ticket = uni.getStorageSync('ticket')
if (ticket != '') {
if (ticket) {
config.data = {};
config.data['ticket'] = ticket
}
if (Vue.prototype.$showDialog) {

5
utils/language/en_US.js

@ -14,6 +14,8 @@ export default {
Login: 'Login',
SignUp: 'Sign Up',
ForgotPassword: 'Forgot password',
Getcode:'Get code',
passwordRule:'Please enter a password of 6-20 characters, which must contain at least 1 capital letter, 1 lowercase letter and 1 digit',
// login
welcomeText: 'Hi, Welcome Back!',
signInText: 'Sign in to your account.',
@ -27,6 +29,7 @@ export default {
checkTheTermsOfService: 'Please review and agree to the terms of service',
// register
passwordConfirm:"The login passwords entered repeatedly are inconsistent",
loginSuccess:"Login successful",
resSuccess:"Registration success",
Emailempty:"E-mail can not be empty",
@ -321,6 +324,7 @@ export default {
//me
me: {
isLogOut:'Are you sure you want to log out?',
account: 'account',
Recharge: 'Recharge',
Withdrawal: 'Withdrawal',
@ -354,6 +358,7 @@ export default {
PleaseEnterTheOldPassword: 'Please Enter the old password',
CreateNewLoginPassword: 'Create new Login password',
Confirm: 'Confirm',
Cancel: 'Cancel',
ModifyWithdrawalPassword: 'Modify Withdrawal Password',
CreateNewPassword: 'Create new password',

Loading…
Cancel
Save