添加注册页面,修改4G设备的添加页面

This commit is contained in:
qianlile
2021-08-24 18:32:04 +08:00
parent 7838cfcbe0
commit 7af68fee6b
16 changed files with 844 additions and 127 deletions

View File

@@ -2,8 +2,6 @@
// const baseURL = 'http://106.38.203.210:81/prod-api'; // const baseURL = 'http://106.38.203.210:81/prod-api';
const baseURL = 'http://106.12.9.213:80/prod-api'; const baseURL = 'http://106.12.9.213:80/prod-api';
const requestApi = ( url, params={} ) => { const requestApi = ( url, params={} ) => {
const token = wx.getStorageSync('token'); const token = wx.getStorageSync('token');
return new Promise((resolve,reject) => { return new Promise((resolve,reject) => {

View File

@@ -10,7 +10,8 @@
"pages/add/index", "pages/add/index",
"pages/4Gswitch/index", "pages/4Gswitch/index",
"pages/add4G/index", "pages/add4G/index",
"pages/addWiFi/index" "pages/addWiFi/index",
"pages/register/index"
], ],
"window": { "window": {
"backgroundColor": "#F6F6F6", "backgroundColor": "#F6F6F6",

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -1,11 +1,43 @@
// miniprogram/pages/add4G/index.js // miniprogram/pages/add4G/index.js
const addOptions = {
"categoryId": 0,
"categoryName": "",
"createBy": "",
"createTime": "",
"delFlag": "",
"deviceId": 0,
"deviceName": "",
"deviceNum": "",
"deviceTemp": 0,
"firmwareVersion": "",
"groupId": 0,
"ownerId": "",
"params": {},
"remark": "",
"searchValue": "",
"updateBy": "",
"updateTime": ""
}
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
imei:'',
remark:'',
deviceName:'',
firmwareVersion:'1.0',
show:false,//控制下拉列表的显示隐藏false隐藏、true显示
selectData:[
{ categoryId:1, categoryName:'WiFi通断器' },
{ categoryId:2, categoryName:'智能灯' },
{ categoryId:3, categoryName:'智能门锁' },
{ categoryId:4, categoryName:'智能水阀' },
{ categoryId:5, categoryName:'其它' },
],//下拉列表的数据
selectedIndex:0//选择的下拉列表下标
}, },
/** /**
@@ -14,53 +46,88 @@ Page({
onLoad: function (options) { onLoad: function (options) {
}, },
selectTap(){
/** this.setData({
* 生命周期函数--监听页面初次渲染完成 show: !this.data.show
*/ });
onReady: function () {
}, },
optionTap(e){
/** const { index } = e.currentTarget.dataset;
* 生命周期函数--监听页面显示 this.setData({
*/ selectedIndex:index,
onShow: function () { show:false
})
}, },
scand(){
/** const that = this;
* 生命周期函数--监听页面隐藏 wx.scanCode({
*/ scanType:['barCode', 'qrCode'],
onHide: function () { success(res){
that.setData({
}, imei:res.result
})
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
} }
}) })
},
inputRemark(e){
this.setData({
remark:e.detail.value
})
},
inputDeviceName(e){
this.setData({
deviceName:e.detail.value
})
},
inputImei(e){
this.setData({
imei:e.detail.value
})
},
submit(){
let imei = this.data.imei;
let remark = this.data.remark;
let deviceName = this.data.deviceName;
let firmwareVersion = this.data.firmwareVersion;
let selectedIndex = this.data.selectedIndex;
let selectData = this.data.selectData;
if ((imei.trim() === '') || (deviceName.trim() === '')) {
wx.showToast({
title: '输入必填数据',
icon:'error',
mask:true
})
return;
}else{
wx.showLoading({
title: '正在添加',
});
let options = addOptions;
options.firmwareVersion = firmwareVersion;
options.deviceNum = imei;
options.deviceName = deviceName;
options.remark = remark;
options.categoryId = selectData[selectedIndex].categoryId;
wx.request({
url: 'http://localhost/dev-api/system/device',
method:'POST',
data:options,
header:{
"Authorization":wx.getStorageSync('token')
},
complete(){
wx.hideLoading();
},
success(res){
console.log(res);
}
})
}
}
})

View File

@@ -2,16 +2,66 @@
<view class="top"> <view class="top">
<image src="/icons/Internet.png"></image> <image src="/icons/Internet.png"></image>
</view> </view>
<view>
<view class="biaodan">
<view class="title">添加4G设备</view> <view class="title">添加4G设备</view>
<label class='account'> <view class="item">
<view class="name">
<text class="flag">*</text>
<text>IMEI</text> <text>IMEI</text>
<input type='text' bind:input='inputIMEI' value='{{ imei }}' placeholder='请输入设备IMEI' /> </view>
</label> <view class="input">
<input value="{{ imei }}" bindinput='inputImei' placeholder="请输入设备IMEI" />
<image src="/icons/scand.png" catchtap="scand"></image>
</view>
</view>
<view class="item">
<view class="name">
<text class="flag">*</text>
<text>设备名称:</text>
</view>
<view class="input">
<input value="{{ deviceName }}" type="text" bind:input="inputDeviceName" placeholder="请输入设备名称" />
</view>
</view>
<view class="item">
<view class="name">
<text>固件版本:</text>
</view>
<view>{{ firmwareVersion }}</view>
</view>
<view class="item">
<view class="name">
<text class="flag">*</text>
<text>设备分类:</text>
</view>
<view class="input" catchtap='selectTap'>
<input placeholder="请选择" value='{{ selectData[selectedIndex].categoryName }}' disabled="true" />
<image src="/icons/down.png" class="{{ show && 'select_img_rotate' }}"></image>
<view class="select_box" style="height:{{ show?selectData.length*68:0 }}rpx">
<view class="select_item"
wx:for="{{ selectData }}" wx:key='this'
data-index='{{ index }}'
style='{{selectedIndex===index&&"background-color:skyblue;color:#fff"}}'
catchtap='optionTap'
>
{{ item.categoryName }}
</view>
</view>
</view>
</view>
<view class="item">
<view class="name">
<text>备注:</text>
</view>
<view class="input">
<input value="{{ remark }}" bindinput="inputRemark"/>
</view>
</view>
<view class="btn"> <view class="btn">
<van-button block color="linear-gradient(to right, #4bb0ff, #6149f6)" round> <van-button catchtap="submit" block color="linear-gradient(to right, #4bb0ff, #6149f6)" round>
提 交 提 交
</van-button> </van-button>
</view> </view>
</view> </view>

View File

@@ -1,34 +1,74 @@
/* miniprogram/pages/add4G/index.wxss */ /* miniprogram/pages/add4G/index.wxss */
.top{ .top{
margin: 100rpx auto 30rpx; margin: 60rpx auto 0rpx;
} }
.title{ .title{
font-size: 42rpx; font-size: 42rpx;
text-align: center; text-align: center;
margin-bottom: 30rpx; margin-bottom: 45rpx;
}
label{
display:flex;
align-items:center;
padding:30rpx 0;
border-bottom:2rpx solid #bfbfbf;
}
.icon{
width:40rpx;
height:40rpx;
display:flex;
align-items:center;
justify-content:center;
}
input{
padding:15rpx 30rpx;
flex:1
}
.account{
width:80vw;
margin:0 auto;
} }
.btn { .btn {
margin: 60rpx auto; margin: 60rpx auto;
width: 50vw; width: 50vw;
} }
.biaodan{
width: 90vw;
margin: 0 auto;
padding: 15rpx;
}
.item{
display: flex;
align-items: center;
margin: 30rpx auto;
}
.name{
width: 180rpx;
text-align: end;
}
.flag{
display:inline-block;
color:red;
width:32rpx;
text-align: center;
}
.input{
box-shadow: 0 0 3rpx 2rpx #bfbfbf;
flex: 1;
display: flex;
align-items: center;
position: relative;
}
.input>input{
padding: 15rpx 30rpx;
flex: 1;
}
.input>image{
width: 60rpx;
height: 60rpx;
transition:transform 0.3s;
}
.input:hover{
box-shadow: 0 0 3rpx 2rpx blue;
}
.select_box{
position: absolute;
width: 100%;
top: 100%;
background-color: #ffffff;
box-shadow: 0 0 3rpx 2rpx #bfbfbf;
transition:height 0.3s;
box-sizing: border-box;
height: 0;
overflow-y: auto;
z-index: 99;
}
.select_item{
padding: 15rpx 30rpx;
/* box-shadow: 0 0 3rpx 2rpx #bfbfbf; */
}
.select_img_rotate{
transform:rotate(180deg);
}

View File

@@ -27,8 +27,6 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
// this.getProducts();
// this.query();
// timer = setInterval(() => { // timer = setInterval(() => {
this.getDevices(); this.getDevices();
// }, 2000); // }, 2000);
@@ -41,8 +39,18 @@ Page({
mask: true mask: true
}) })
const res = await requestApi('/system/device/list',{ method:'GET' }); const res = await requestApi('/system/device/list',{ method:'GET' });
console.log(res); wx.hideLoading();
const result = JSON.parse(res.result); const result = JSON.parse(res.result);
if (result.code !== 200) {
wx.showToast({
title: '请求失败',
icon:'error'
});
return;
}
wx.showToast({
title: '请求成功',
});
let onlineList = []; let onlineList = [];
let unlineList = []; let unlineList = [];
result.rows.forEach(v=>{ result.rows.forEach(v=>{
@@ -57,11 +65,9 @@ Page({
unlineList, unlineList,
DeviceList:result.rows DeviceList:result.rows
}) })
wx.hideLoading()
}, },
//获取天气 //获取天气
getWeather:async function(){ getWeather:async function(){
let that = this; let that = this;

View File

@@ -22,46 +22,81 @@ Page({
}, },
//获取验证码图片和uuid //获取验证码图片和uuid
async getCaptchaImage(){ // async getCaptchaImage(){
const res = await loginApi('/captchaImage',{ method:'get' }); // const res = await loginApi('/captchaImage',{ method:'get' });
const data = JSON.parse(res.result) // const data = JSON.parse(res.result)
this.setData({ // this.setData({
img:data.img, // img:data.img,
uuid:data.uuid // uuid:data.uuid
// })
// },
//测试接口
getCaptchaImage(){
const that = this;
wx.request({
url: 'http://localhost/dev-api/captchaImage',
success(res){
that.setData({
img:res.data.img,
uuid:res.data.uuid
})
console.log(res);
}
}) })
}, },
//登录 //登录
async submit(){ async submit(){
wx.showLoading({ // wx.showLoading({
title: '正在登录', // title: '正在登录',
}) // })
const res = await loginApi('/login',{ // const res = await loginApi('/login',{
// method:'POST',
// body:{
// code:this.data.value,
// uuid:this.data.uuid,
// password: this.data.password,
// username: this.data.username
// },
// json:true
// })
// wx.hideLoading();
// if (res.result.code !== 200) {
// wx.showToast({
// title: res.result.msg,
// icon:'error'
// });
// this.getCaptchaImage();
// return;
// }
// wx.setStorageSync('token', res.result.token);
// wx.switchTab({
// url: '/pages/index/index',
// })
wx.request({
url: 'http://localhost/dev-api/login',
method:'POST', method:'POST',
body:{ data:{
code:this.data.value, code:this.data.value,
uuid:this.data.uuid, uuid:this.data.uuid,
password: this.data.password, password: this.data.password,
username: this.data.username username: this.data.username
}, },
json:true success(res){
}) console.log(res);
wx.hideLoading(); wx.setStorageSync('token', res.data.token);
if (res.result.code !== 200) {
wx.showToast({
title: res.result.msg,
icon:'error'
});
this.getCaptchaImage();
return;
} }
wx.setStorageSync('token', res.result.token);
wx.switchTab({
url: '/pages/index/index',
}) })
}, },
//
register(){
wx.navigateTo({
url: '/pages/register/index',
})
},
inputUsername(e){ inputUsername(e){
this.setData({ username:e.detail }); this.setData({ username:e.detail });

View File

@@ -39,9 +39,15 @@
<image src='data:image/gif;base64,{{ img }}' /> <image src='data:image/gif;base64,{{ img }}' />
</view> </view>
</view> </view>
<view class="btns">
<view class="btn"> <view class="btn">
<van-button block bind:click="submit" round type="info">登 录</van-button> <van-button block bind:click="submit" round type="info">登 录</van-button>
</view> </view>
<view class="btn">
<van-button block bind:click="register" round type="default">注 册</van-button>
</view>
</view>
</view> </view>

View File

@@ -41,7 +41,12 @@
display: inline-block; display: inline-block;
height: 77rpx; height: 77rpx;
} }
.btn{ .btns{
margin: 45rpx auto; width: 100%;
width: 40vw; display: flex;
justify-content: space-around;
margin: 30rpx 0;
}
.btn{
width: 30vw;
} }

View File

@@ -0,0 +1,370 @@
// miniprogram/pages/register/index.js
const registerOptions = {
"admin": false,
"avatar": "",
"createBy": "",
"createTime": "",
"delFlag": "",
"dept": {
"ancestors": "",
"children": [
null
],
"createBy": "",
"createTime": "",
"delFlag": "",
"deptId": 0,
"deptName": "",
"email": "",
"leader": "",
"orderNum": "",
"params": {},
"parentId": 0,
"parentName": "",
"phone": "",
"remark": "",
"searchValue": "",
"status": "",
"updateBy": "",
"updateTime": ""
},
"deptId": 0,
"email": "",
"loginDate": "",
"loginIp": "",
"nickName": "李四",
"params": {},
"password": "",
"phonenumber": "",
"postIds": [
0
],
"remark": "",
"roleIds": [
2
],
"roles": [
{
"admin": false,
"createBy": "",
"createTime": "",
"dataScope": "2",
"delFlag": "",
"deptCheckStrictly": true,
"deptIds": [
0
],
"flag": true,
"menuCheckStrictly": true,
"menuIds": [
0
],
"params": {},
"remark": "",
"roleId": 2,
"roleKey": "common",
"roleName": "",
"roleSort": "2",
"searchValue": "",
"status": "",
"updateBy": "",
"updateTime": ""
}
],
"salt": "",
"searchValue": "",
"sex": "",
"status": "",
"updateBy": "",
"updateTime": "",
"userId": 0,
"userName": ""
}
const { loginApi } = require('../../API/request.js');
Page({
/**
* 页面的初始数据
*/
data: {
username:'',
password:'',
pwdAgain:'',
phonenumber:'',
email:'',
emailError:'',
radio:'0',
phoneError:'',
phoneValue:true,
emailValue:true,
nickName:'',
nickError:'',
nickValue:false,
nameValue:false,
nameError:'',
pwdValue:false,
pwdError:'',
pwdAgainValue:false,
pwdAgainError:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.setNavigationBarTitle({
title: '用户注册',
})
},
//测试接口,需修改
async register(){
if (!this.checkForm()) {
return;
}else{
wx.showLoading({
title: '正在注册',
})
let registerParams = registerOptions;
registerParams.password = this.data.password;
registerParams.userName = this.data.username;
registerParams.nickName = this.data.nickName;
registerParams.sex = this.data.radio;
registerParams.phonenumber = this.data.phonenumber;
registerParams.email = this.data.email;
wx.request({
url: 'http://localhost/dev-api/system/user/register',
method:'POST',
data:registerParams,
timeout:10000,
success(res){
wx.hideLoading();
if (res.data.code === 200) {
wx.showToast({
title: '注册成功',
icon:'success'
})
setTimeout(() => {
wx.redirectTo({
url: '/pages/login/index',
})
}, 1000);
}else{
wx.showToast({
title: res.data.msg,
icon:'error'
})
}
}
})
}
// const res = await loginApi('/system/user/register',{
// method:'POST',
// body:registerParams,
// json:true
// });
// console.log(formatDate());
},
//检查表单
checkForm(){
if (this.data.nickName === '') {
this.setData({
nickError:'昵称不能为空!'
})
}
if (this.data.username === '') {
this.setData({
nameError:'账号不能为空!'
})
}
if (this.data.password === '') {
this.setData({
pwdError:'密码不能为空!'
})
}
return (this.data.nickValue && this.data.nameValue && this.data.pwdValue && this.data.pwdAgainValue && this.data.phoneValue && this.data.emailValue)
},
onChooseSex(e){
this.setData({
radio:e.detail
})
},
// imputUsername(e){
// this.setData({
// username:e.detail
// })
// },
// imputPassword(e){
// this.setData({
// password:e.detail
// })
// },
endInputPwdAgain(e){
if ((e.detail.value.trim()!=='') && (e.detail.value === this.data.password)) {
this.setData({
pwdAgainValue:true,
pwdAgainError:''
})
}else{
this.setData({
pwdAgainValue:false,
pwdAgainError:'密码输入不一致'
})
}
},
endInputNick(e){
if (e.detail.value.trim() === '') {
this.setData({
nickValue:false,
nickError:'昵称不能为空!'
})
}else{
this.setData({
nickName:e.detail.value,
nickError:'',
nickValue:true
})
}
},
endInputName(e){
if (e.detail.value.trim() === '') {
this.setData({
nameValue:false,
nameError:'账号不能为空!'
})
}else{
this.setData({
username:e.detail.value,
nameError:'',
nameValue:true
})
}
},
endInputPwd(e){
if (e.detail.value.trim() === '') {
this.setData({
pwdValue:false,
pwdError:'密码不能为空!'
})
}else{
this.setData({
password:e.detail.value,
pwdError:'',
pwdValue:true
})
}
},
endInputPhone(e){
if (e.detail.value.trim() !== '') {
const reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
if(!reg.test(e.detail.value)){
this.setData({
phoneError:'请输入正确的手机号!',
phoneValue:false
});
return;
}else{
this.setData({
phoneError:'',
phoneValue:true,
phonenumber:e.detail.value
});
};
}else{
this.setData({
phoneError:'',
phoneValue:true,
phonenumber:''
});
}
},
endInputEmail(e){
if (e.detail.value.trim() !== '') {
const reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if(!reg.test(e.detail.value)){
this.setData({
emailError:'邮箱不合规范!',
emailValue:false
});
return;
}else{
this.setData({
emailError:'',
emailValue:true,
email:e.detail.value
});
};
}else{
this.setData({
emailError:'',
emailValue:true,
email:''
});
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

View File

@@ -0,0 +1,8 @@
{
"usingComponents": {
"van-field": "@vant/weapp/field/index",
"van-button": "@vant/weapp/button/index",
"van-radio": "@vant/weapp/radio/index",
"van-radio-group": "@vant/weapp/radio-group/index"
}
}

View File

@@ -0,0 +1,87 @@
<!--miniprogram/pages/register/index.wxml-->
<view class="form">
<view class="title">
<image src="/icons/user.png"></image>
<text>账号注册</text>
</view>
<view class="input">
<van-field
value="{{ nickName }}"
placeholder="请输入用户昵称"
bind:blur="endInputNick"
label='用户昵称'
title-width='120rpx'
error-message='{{ nickError }}'
required
/>
</view>
<view class="input">
<van-field
value="{{ username }}"
placeholder="请输入用户账号"
bind:blur="endInputName"
label='用户账号'
title-width='120rpx'
error-message='{{ nameError }}'
required
/>
</view>
<view class="input">
<van-field
value="{{ password }}"
placeholder="请输入密码"
bind:change="inputPassword"
bind:blur="endInputPwd"
error-message='{{ pwdError }}'
label='密码'
title-width='120rpx'
type='password'
required
/>
</view>
<view class="input">
<van-field
value="{{ pwdAgain }}"
placeholder="再次输入密码"
bind:blur="endInputPwdAgain"
error-message='{{ pwdAgainError }}'
label='确认密码'
title-width='120rpx'
type='password'
required
/>
</view>
<view class="checkbox">
<view class="check_title">性别 </view>
<van-radio-group value="{{ radio }}" bind:change="onChooseSex" direction="horizontal">
<van-radio name="0" icon-size="38rpx">男</van-radio>
<van-radio name="1" icon-size="38rpx">女</van-radio>
</van-radio-group>
</view>
<view class="input">
<van-field
value="{{ phoneNumber }}"
placeholder="请输入手机号"
bind:change="inputPhoneNumber"
bind:blur="endInputPhone"
label='手机号'
title-width='120rpx'
type='number'
error-message='{{ phoneError }}'
/>
</view>
<view class="input">
<van-field
value="{{ email }}"
placeholder="请输入邮箱"
bind:change="inputEmail"
bind:blur="endInputEmail"
label='邮箱'
error-message='{{ emailError }}'
title-width='120rpx'
/>
</view>
<view class="btn">
<van-button block bind:click="register" round type="info">注 册</van-button>
</view>
</view>

View File

@@ -0,0 +1,38 @@
/* miniprogram/pages/register/index.wxss */
.form{
width: 80vw;
margin: 50rpx auto;
padding: 30rpx;
box-shadow: 0 0 5rpx 3rpx rgb(202, 202, 202);
}
.title{
margin: 15rpx auto 30rpx;
font-size: 40rpx;
display: flex;
align-items: center;
}
.title>image{
width: 60rpx;
height: 60rpx;
margin-right: 15rpx;
}
.input{
margin: 15rpx 0;
/* box-shadow: 0 0 5rpx 5rpx #bfbfbf; */
border-bottom: 1rpx solid #bfbfbf;
}
.btn{
margin: 45rpx auto;
width: 40vw;
}
.checkbox{
display: flex;
margin: 15rpx 0;
padding: 15rpx 0;
}
.check_title{
/* font-size: 26rpx; */
width: 120rpx;
padding: 0 30rpx;
color: rgba(0, 0, 0, .6);
}

View File

@@ -69,6 +69,12 @@
{ {
"name": "pages/add4G/index", "name": "pages/add4G/index",
"pathName": "pages/add4G/index", "pathName": "pages/add4G/index",
"query": "",
"scene": null
},
{
"name": "pages/register/index",
"pathName": "pages/register/index",
"scene": null "scene": null
} }
] ]