用户接口对接
This commit is contained in:
22
App.vue
22
App.vue
@@ -2,21 +2,17 @@
|
||||
import encrypt from './common/js/aes.js'
|
||||
export default {
|
||||
onLaunch: function () {
|
||||
let cidAES = uni.getStorageSync('cidAES')
|
||||
let cidAES = uni.getStorageSync('cidAES') || 'nnvmhMk8626D8QHhJefm+W9rTAJWuBPRxcnRm4+9bWXdSLRIyTnTruoYfLxGK3Oy'
|
||||
uni.setStorageSync('cidAES', cidAES);
|
||||
if (!cidAES) {
|
||||
uni.getPushClientId({
|
||||
success: (res) => {
|
||||
console.log(res.cid);
|
||||
uni.setStorageSync('cid', res.cid);
|
||||
var cidAES = encrypt.Encrypt(res.cid, this.$config.key);
|
||||
uni.setStorageSync('cidAES', cidAES);
|
||||
},
|
||||
fail (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
document.addEventListener('plusready', () => {
|
||||
// 页面加载时触发
|
||||
let pinf = plus.push.getClientInfo();
|
||||
let cid = pinf.clientid;//客户端标识
|
||||
cidAES = encrypt.Encrypt(cid, this.$config.key);
|
||||
uni.setStorageSync('cidAES', cidAES);
|
||||
}, false);
|
||||
}
|
||||
|
||||
},
|
||||
onShow: function () {
|
||||
console.log('App Show')
|
||||
|
||||
@@ -1,22 +1,30 @@
|
||||
import request from '../js/request'
|
||||
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
* @param {*} params.type 0:登录 1:注册 3:忘记密码 4:更换手机号第二步获取验证码 5:更换手机号第一步获取验证码
|
||||
* @returns
|
||||
*/
|
||||
export function apiGetYms (params) {
|
||||
return request({
|
||||
url: '/shiningCloud/user/authCode',
|
||||
data: {
|
||||
phone: params.phone,
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
type: 0
|
||||
type: params.type
|
||||
},
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} type 0:ysm 1:pwd
|
||||
* 登录
|
||||
* @param {*} params.type 0:ysm 1:pwd
|
||||
* @returns
|
||||
*/
|
||||
export function apiLogin (params) {
|
||||
console.log(uni.getStorageSync('cidAES'));
|
||||
return request({
|
||||
url: '/shiningCloud/user/login',
|
||||
data: {
|
||||
@@ -27,4 +35,46 @@ export function apiLogin (params) {
|
||||
},
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function apiRegister (params) {
|
||||
return request({
|
||||
url: '/shiningCloud/user/register',
|
||||
data: {
|
||||
phone: params.phone,
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
code: params.code.trim(),
|
||||
},
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
// 第一次登录设置密码
|
||||
export function apiSetPsd (params) {
|
||||
return request({
|
||||
url: '/shiningCloud/user/setPsd',
|
||||
data: {
|
||||
userId: uni.getStorageSync('userInfo').userId,
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
password: params.password.trim()
|
||||
},
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
// 重置密码
|
||||
export function apiReSetPsd(params) {
|
||||
return request({
|
||||
url: '/shiningCloud/user/resetPsd',
|
||||
data: {
|
||||
phone: params.phone,
|
||||
code: params.code.trim(),
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
password: params.password.trim()
|
||||
},
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
@@ -24,8 +24,6 @@ export default (options = {}) => {
|
||||
},
|
||||
header: {
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
'Authorization': uni.getStorageSync('Authorization'),
|
||||
'Cookie': uni.getStorageSync('Cookie'),
|
||||
...options.header
|
||||
},
|
||||
method: options.method || 'GET',
|
||||
|
||||
@@ -125,6 +125,26 @@
|
||||
"mp-baidu" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
"h5" : {
|
||||
"devServer" : {
|
||||
"port" : 8088,
|
||||
"proxy" : {
|
||||
"/api" : {
|
||||
"https" : true,
|
||||
// "target" : "https://china.indpecker.com",
|
||||
"target" : "http://pqmcc.com:8040",
|
||||
"changOrigin" : true,
|
||||
"pathRewrite" : {
|
||||
"/api" : ""
|
||||
}
|
||||
}
|
||||
},
|
||||
"https" : false
|
||||
},
|
||||
"router" : {
|
||||
"base" : ""
|
||||
}
|
||||
},
|
||||
"mp-toutiao" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
|
||||
@@ -421,7 +421,7 @@
|
||||
"list": [
|
||||
{
|
||||
"name": "login", //模式名称
|
||||
"path": "pages/user/login", //启动页面,必选
|
||||
"path": "pages/user/changePhone", //启动页面,必选
|
||||
"query": "" //启动参数,在页面的onLoad函数里面得到。
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
<template>
|
||||
<Cn-page :loading='loading'>
|
||||
<view slot='body'>
|
||||
<view class='index'>
|
||||
用户协议 。。。。
|
||||
</view>
|
||||
</view>
|
||||
</Cn-page>
|
||||
<view>
|
||||
<view>
|
||||
<web-view src="http://112.4.156.196:8040/shiningCloud/business/userAgreement"></web-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
showFlag:0,
|
||||
pageNameFlag:1,
|
||||
pageName:'用户协议',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
</script>
|
||||
<style lang='scss'>
|
||||
.index {
|
||||
padding: 20rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
|
||||
@@ -3,34 +3,34 @@
|
||||
<view slot="body">
|
||||
<view class="index">
|
||||
<template v-if="step == 1">
|
||||
<uni-forms ref="form">
|
||||
<uni-forms ref="form" :rules="rules" :modelValue="formData">
|
||||
<uni-forms-item name="phone">
|
||||
<uni-easyinput disabled type="text" v-model="formData.phone" placeholder="请输入手机号" />
|
||||
<uni-easyinput disabled type="text" v-model="formData.phoneShow" placeholder="请输入手机号" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="code">
|
||||
<view class="login-box-input mt40">
|
||||
<view class="login-box-input">
|
||||
<uni-easyinput type="number" v-model="formData.code" placeholder="请输入验证码" />
|
||||
<view class="ml40"
|
||||
style="margin-left:40rpx;font-size: 28rpx; color: #666; width: 200rpx; text-align: center"
|
||||
v-if="waitTime > 0">{{ waitTime + 's后重新获取' }}</view>
|
||||
<button class="login-box-input-btn" v-else @click="getCode" size="mini">获取验证码</button>
|
||||
<button class="login-box-input-btn" v-else @click="getCode(5)" size="mini">获取验证码</button>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
<button type="default" class="submit-btn" @click="firstSubmit">下一步</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<uni-forms ref="form">
|
||||
<uni-forms ref="form" :rules="rules" :modelValue="formData">
|
||||
<uni-forms-item name="phone">
|
||||
<uni-easyinput type="number" v-model="formData.phone2" placeholder="请输入新手机号" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="code">
|
||||
<view class="login-box-input mt40">
|
||||
<view class="login-box-input">
|
||||
<uni-easyinput type="number" v-model="formData.code" placeholder="请输入验证码" />
|
||||
<view class="ml40"
|
||||
style="margin-left:40rpx;font-size: 28rpx; color: #666; width: 200rpx; text-align: center"
|
||||
v-if="waitTime > 0">{{ waitTime + 's后重新获取' }}</view>
|
||||
<button class="login-box-input-btn" v-else @click="getCode" size="mini">获取验证码</button>
|
||||
<button class="login-box-input-btn" v-else @click="getCode(4)" size="mini">获取验证码</button>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
@@ -50,7 +50,8 @@ export default {
|
||||
waitTime: 0,
|
||||
// 表单数据
|
||||
formData: {
|
||||
phone: '150****0083',
|
||||
phone: '',
|
||||
phoneShow: '',
|
||||
code: '',
|
||||
phone2: '',
|
||||
code2: '',
|
||||
@@ -72,19 +73,19 @@ export default {
|
||||
}
|
||||
]
|
||||
},
|
||||
password: {
|
||||
phone2: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: "请填写新密码"
|
||||
errorMessage: "请填写新手机号"
|
||||
}
|
||||
]
|
||||
},
|
||||
password2: {
|
||||
code2: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: "请填写确认密码"
|
||||
errorMessage: "请填写验证码"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -92,17 +93,39 @@ export default {
|
||||
};
|
||||
},
|
||||
onLoad () {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
getCode () {
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
getCode (type) {
|
||||
if (!this.formData.phone) {
|
||||
return this.$util.toast('请输入手机号!')
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '请稍等'
|
||||
})
|
||||
apiGetYms({
|
||||
phone: this.formData.phone,
|
||||
type,
|
||||
}).then(res => {
|
||||
uni.hideLoading()
|
||||
console.log(res);
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
}).catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err);
|
||||
})
|
||||
},
|
||||
init () {
|
||||
this.formData.phone = uni.getStorageSync('userInfo').phone
|
||||
// 150****0083
|
||||
this.formData.phoneShow = this.formData.phone.substr(0, 3) + '****' + this.formData.phone.substr(7)
|
||||
},
|
||||
firstSubmit () {
|
||||
this.step = 2
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<uni-easyinput type="number" v-model="formData.phone" placeholder="请输入手机号" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="code">
|
||||
<view class="login-box-input mt40">
|
||||
<view class="login-box-input">
|
||||
<uni-easyinput type="number" v-model="formData.code" placeholder="请输入验证码" />
|
||||
<view class="ml40"
|
||||
style="margin-left:40rpx;font-size: 28rpx; color: #666; width: 200rpx; text-align: center"
|
||||
@@ -24,8 +24,8 @@
|
||||
</uni-forms>
|
||||
<button type="default" class="submit-btn" @click="submit">提交</button>
|
||||
<view class="login-box-tips">
|
||||
<view style="color:#999">说明:密码长度为6-18位</view>
|
||||
</view>
|
||||
<view style="color:#999">说明:密码长度为6-18位</view>
|
||||
</view>
|
||||
<view class="login-box-tips">
|
||||
<view style="color:#999">点击提交即表示同意</view>
|
||||
<navigator url="/pages/mine/agreement" hover-class="none">《用户协议》</navigator>
|
||||
@@ -36,6 +36,8 @@
|
||||
</Cn-page>
|
||||
</template>
|
||||
<script>
|
||||
import { apiGetYms, apiReSetPsd } from '@/common/api/user'
|
||||
|
||||
export default {
|
||||
name: "jiaban",
|
||||
data () {
|
||||
@@ -89,20 +91,56 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
getCode () {
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
if (!this.formData.phone) {
|
||||
return this.$util.toast('请输入手机号!')
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '请稍等'
|
||||
})
|
||||
apiGetYms({
|
||||
phone: this.formData.phone,
|
||||
type: 3,
|
||||
}).then(res => {
|
||||
uni.hideLoading()
|
||||
console.log(res);
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
}).catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err);
|
||||
})
|
||||
},
|
||||
submit () {
|
||||
this.$refs.form.validate((valid) => {
|
||||
console.log(valid);
|
||||
if (valid) {
|
||||
if (this.formData.password.length < 6 || this.formData.password.length > 18) {
|
||||
return this.$util.toast('密码长度为6-18位')
|
||||
} else if (this.formData.password != this.formData.password2) {
|
||||
return this.$util.toast('两次密码不一致')
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '请稍等'
|
||||
})
|
||||
apiReSetPsd({
|
||||
phone: this.formData.phone,
|
||||
code: this.formData.code,
|
||||
password: this.formData.password,
|
||||
}).then(res => {
|
||||
uni.hideLoading()
|
||||
console.log(res);
|
||||
this.$util.toast('修改成功!')
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1000)
|
||||
}).catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err);
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<view slot="body">
|
||||
<view class="login">
|
||||
<view class="login-title">登录</view>
|
||||
<view class="login-des">{{ companyName }}</view>
|
||||
<view class="login-des">灿能物联</view>
|
||||
<view class="login-box">
|
||||
<!-- <image class="login-box-logo" mode="widthFix" src="/static/logo.png"></image> -->
|
||||
<image class="login-box-logo" mode="widthFix" src="/static/logo.png"></image>
|
||||
@@ -24,7 +24,7 @@
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="login-box-input mt100">
|
||||
<input class="login-box-input-main" v-model="pwdForm.account" placeholder="请输入账号" />
|
||||
<input class="login-box-input-main" v-model="pwdForm.phone" placeholder="请输入账号" />
|
||||
</view>
|
||||
<view class="login-box-input mt40">
|
||||
<input type="password" class="login-box-input-main" v-model="pwdForm.pwd" placeholder="请输入密码" />
|
||||
@@ -62,7 +62,7 @@ export default {
|
||||
loading: false,
|
||||
loginType: 'pwd',
|
||||
pwdForm: {
|
||||
account: '',
|
||||
phone: '',
|
||||
pwd: '',
|
||||
imgCode: '',
|
||||
},
|
||||
@@ -79,23 +79,31 @@ export default {
|
||||
},
|
||||
components: {},
|
||||
methods: {
|
||||
async getCode () {
|
||||
getCode () {
|
||||
if (!this.yzmForm.phone) {
|
||||
return this.$util.toast('请输入手机号!')
|
||||
}
|
||||
const res = await apiGetYms({
|
||||
uni.showLoading({
|
||||
title: '请稍等'
|
||||
})
|
||||
apiGetYms({
|
||||
phone: this.yzmForm.phone,
|
||||
type: 0,
|
||||
}).then(res => {
|
||||
uni.hideLoading()
|
||||
console.log(res);
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
}).catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err);
|
||||
})
|
||||
console.log(res);
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
login () {
|
||||
console.log(this.loginType);
|
||||
@@ -106,17 +114,12 @@ export default {
|
||||
}
|
||||
},
|
||||
pwdLogin () {
|
||||
console.log({
|
||||
phone: this.yzmForm.phone,
|
||||
key: this.yzmForm.pwd,
|
||||
type: 1,
|
||||
})
|
||||
if (!this.pwdForm.account && !this.pwdForm.pwd) {
|
||||
if (!this.pwdForm.phone && !this.pwdForm.pwd) {
|
||||
return this.$util.toast('请填写登录信息!')
|
||||
}
|
||||
apiLogin({
|
||||
phone: this.yzmForm.phone,
|
||||
key: this.yzmForm.pwd,
|
||||
phone: this.pwdForm.phone,
|
||||
key: this.pwdForm.pwd,
|
||||
type: 1,
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
<view slot="body">
|
||||
<view class="index">
|
||||
<template v-if="step == 1">
|
||||
<uni-forms ref="form">
|
||||
<uni-forms ref="form" :rules="rules" :modelValue="formData">
|
||||
<uni-forms-item name="phone">
|
||||
<uni-easyinput type="number" v-model="formData.phone" placeholder="请输入手机号" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item name="code">
|
||||
<view class="login-box-input mt40">
|
||||
<view class="login-box-input">
|
||||
<uni-easyinput type="number" v-model="formData.code" placeholder="请输入验证码" />
|
||||
<view class="ml40"
|
||||
style="margin-left:40rpx;font-size: 28rpx; color: #666; width: 200rpx; text-align: center"
|
||||
@@ -25,7 +25,7 @@
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<uni-forms ref="form">
|
||||
<uni-forms ref="form" :rules="rules" :modelValue="formData">
|
||||
<uni-forms-item name="password">
|
||||
<uni-easyinput type="text" v-model="formData.password" placeholder="请输入登录密码" />
|
||||
</uni-forms-item>
|
||||
@@ -43,6 +43,7 @@
|
||||
</Cn-page>
|
||||
</template>
|
||||
<script>
|
||||
import { apiRegister, apiGetYms, apiSetPsd } from '@/common/api/user'
|
||||
export default {
|
||||
name: "jiaban",
|
||||
data () {
|
||||
@@ -97,21 +98,64 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
getCode () {
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
if (!this.formData.phone) {
|
||||
return this.$util.toast('请输入手机号!')
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '请稍等'
|
||||
})
|
||||
apiGetYms({
|
||||
phone: this.formData.phone,
|
||||
type: 1,
|
||||
}).then(res => {
|
||||
uni.hideLoading()
|
||||
console.log(res);
|
||||
this.waitTime = 60
|
||||
this.inter = setInterval(() => {
|
||||
if (this.waitTime == 0) {
|
||||
clearInterval(this.inter)
|
||||
} else {
|
||||
this.waitTime--
|
||||
}
|
||||
}, 1000)
|
||||
}).catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err);
|
||||
})
|
||||
},
|
||||
firstSubmit () {
|
||||
this.step = 2
|
||||
|
||||
this.$refs.form.validate().then((valid, errors) => {
|
||||
apiRegister({
|
||||
phone: this.formData.phone,
|
||||
code: this.formData.code
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
this.$util.toast(res.msg)
|
||||
uni.setStorageSync('userInfo', res.data)
|
||||
this.step = 2
|
||||
})
|
||||
})
|
||||
},
|
||||
secondSubmit () {
|
||||
|
||||
this.$refs.form.validate().then((valid, errors) => {
|
||||
console.log(this.formData.password.length);
|
||||
if (this.formData.password.length < 6 || this.formData.password.length > 18) {
|
||||
return this.$util.toast('密码长度为6-18位')
|
||||
} else if (this.formData.password != this.formData.password2) {
|
||||
return this.$util.toast('两次密码不一致')
|
||||
}
|
||||
apiSetPsd({
|
||||
phone: this.formData.phone,
|
||||
password: this.formData.password,
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
this.$util.toast(res.msg)
|
||||
uni.setStorageSync('userInfo', res.data)
|
||||
uni.reLaunch({
|
||||
url: '/pages/user/login'
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user