mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 17:05:55 +08:00
微信登录版
This commit is contained in:
114
wechat_v2/pages/add4G/index.js
Normal file
114
wechat_v2/pages/add4G/index.js
Normal file
@@ -0,0 +1,114 @@
|
||||
// miniprogram/pages/add4G/index.js
|
||||
const { request } = require('../../API/request.js');
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
imei:'',
|
||||
remark:'',
|
||||
deviceName:'',
|
||||
firmwareVersion:'1.0',
|
||||
show:false,//控制下拉列表的显示隐藏,false隐藏、true显示
|
||||
selectData:[],//下拉列表的数据
|
||||
selectedIndex:0//选择的下拉列表下标
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.getCategoryList();
|
||||
},
|
||||
|
||||
async getCategoryList(){
|
||||
const res = await request('system/category/list','get');
|
||||
this.setData({
|
||||
selectData:res.rows
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
selectTap(){
|
||||
this.setData({
|
||||
show: !this.data.show
|
||||
});
|
||||
},
|
||||
optionTap(e){
|
||||
const { index } = e.currentTarget.dataset;
|
||||
this.setData({
|
||||
selectedIndex:index,
|
||||
show:false
|
||||
})
|
||||
},
|
||||
scand(){
|
||||
const that = this;
|
||||
wx.scanCode({
|
||||
scanType:['barCode', 'qrCode'],
|
||||
success(res){
|
||||
let imei = res.result.substring(res.result.lastIndexOf('/')+1);
|
||||
if (imei == '') {
|
||||
wx.showToast({
|
||||
title: 'imei错误',
|
||||
icon:'error',
|
||||
mask:true
|
||||
})
|
||||
return;
|
||||
}
|
||||
that.setData({
|
||||
imei:imei
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
inputRemark(e){
|
||||
this.setData({
|
||||
remark:e.detail.value
|
||||
})
|
||||
},
|
||||
inputDeviceName(e){
|
||||
this.setData({
|
||||
deviceName:e.detail.value
|
||||
})
|
||||
},
|
||||
inputImei(e){
|
||||
this.setData({
|
||||
imei:e.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
async 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{
|
||||
let options = {};
|
||||
options.deviceNum = imei;
|
||||
options.deviceName = deviceName;
|
||||
options.remark = remark;
|
||||
options.categoryId = selectData[selectedIndex].categoryId;
|
||||
|
||||
const res = await request('system/device/bindDevice','post',options);
|
||||
if (res.code === 200) {
|
||||
wx.showToast({
|
||||
title: '添加成功',
|
||||
mask:true
|
||||
});
|
||||
wx.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
5
wechat_v2/pages/add4G/index.json
Normal file
5
wechat_v2/pages/add4G/index.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-button": "@vant/weapp/button/index"
|
||||
}
|
||||
}
|
||||
67
wechat_v2/pages/add4G/index.wxml
Normal file
67
wechat_v2/pages/add4G/index.wxml
Normal file
@@ -0,0 +1,67 @@
|
||||
<!--miniprogram/pages/add4G/index.wxml-->
|
||||
<!-- <view class="top">
|
||||
<image src="/icons/Internet.png"></image>
|
||||
</view> -->
|
||||
<view class="title">添加4G设备</view>
|
||||
<view class="biaodan">
|
||||
|
||||
<view class="item">
|
||||
<view class="name">
|
||||
<text class="flag">*</text>
|
||||
<text>IMEI:</text>
|
||||
</view>
|
||||
<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">
|
||||
<van-button catchtap="submit" block color="linear-gradient(to right, #4bb0ff, #6149f6)" round>
|
||||
提 交
|
||||
</van-button>
|
||||
</view>
|
||||
</view>
|
||||
83
wechat_v2/pages/add4G/index.wxss
Normal file
83
wechat_v2/pages/add4G/index.wxss
Normal file
@@ -0,0 +1,83 @@
|
||||
/* miniprogram/pages/add4G/index.wxss */
|
||||
.top{
|
||||
margin: 60rpx auto 0rpx;
|
||||
}
|
||||
.title{
|
||||
height: 270rpx;
|
||||
font-size: 42rpx;
|
||||
text-align: center;
|
||||
margin-bottom: 45rpx;
|
||||
background-image: linear-gradient(120deg,#58bcff ,#2b63ff);
|
||||
color: #ffffff;
|
||||
padding:30rpx 0;
|
||||
box-shadow: 0 3rpx 10rpx #bfbfbf;
|
||||
line-height: 120rpx;
|
||||
}
|
||||
.btn {
|
||||
margin: 60rpx auto;
|
||||
width: 50vw;
|
||||
}
|
||||
|
||||
|
||||
.biaodan{
|
||||
width: 90vw;
|
||||
margin: -200rpx auto 0;
|
||||
padding: 15rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 0 10rpx #bfbfbf;
|
||||
border-radius: 15rpx;
|
||||
}
|
||||
.item{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 30rpx auto;
|
||||
}
|
||||
.name{
|
||||
width: 166rpx;
|
||||
text-align: end;
|
||||
}
|
||||
.flag{
|
||||
/* display:inline-block; */
|
||||
color:red;
|
||||
/* width:32rpx;
|
||||
text-align: center; */
|
||||
}
|
||||
.input{
|
||||
border: 2rpx solid #acacac;
|
||||
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 10rpx rgb(24, 120, 245);
|
||||
}
|
||||
.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);
|
||||
}
|
||||
Reference in New Issue
Block a user