mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 00:45:55 +08:00
删除无用文件夹
This commit is contained in:
189
wechat/pages/4Gswitch/index.js
Normal file
189
wechat/pages/4Gswitch/index.js
Normal file
@@ -0,0 +1,189 @@
|
||||
// miniprogram/pages/4Gswitch/index.js
|
||||
|
||||
const { request } = require('../../API/request')
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
deviceInfo:{},
|
||||
deviceId:null,
|
||||
lightStatus:null
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.setNavigate();
|
||||
try {
|
||||
this.getLastPageData();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
this.isShared(options);
|
||||
|
||||
},
|
||||
|
||||
checkLogin(){
|
||||
const isLogin = wx.getStorageSync('isLogin') || false;
|
||||
const that = this;
|
||||
if (!isLogin) {
|
||||
wx.showModal({
|
||||
cancelColor: '#ff0000',
|
||||
cancelText: '取消',
|
||||
confirmColor: '#6149f6',
|
||||
confirmText: '登录',
|
||||
content: '检测到您还未登录,是否授权登录?',
|
||||
showCancel: true,
|
||||
title: '登录授权',
|
||||
success: (result) => {
|
||||
if (result.confirm) {
|
||||
wx.showLoading({
|
||||
title: '正在登录'
|
||||
});
|
||||
wx.getUserProfile({
|
||||
desc:'用以展示您的头像和昵称等信息',
|
||||
success(res){
|
||||
console.log(res);
|
||||
wx.setStorageSync('userInfo',JSON.parse(res.rawData));
|
||||
wx.setStorageSync('isLogin',true);
|
||||
},
|
||||
complete(){
|
||||
wx.hideLoading();
|
||||
},
|
||||
fail(err){
|
||||
if (err.errMsg == 'getUserProfile:fail auth deny') {
|
||||
wx.showToast({
|
||||
title: '授权取消',
|
||||
icon:'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}else if(result.cancel){
|
||||
wx.switchTab({
|
||||
url: '/pages/my/my',
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
setNavigate(){
|
||||
wx.setNavigationBarTitle({
|
||||
title: '4G开关',
|
||||
});
|
||||
wx.setNavigationBarColor({
|
||||
backgroundColor: '#4271f1',
|
||||
frontColor: '#ffffff',
|
||||
});
|
||||
},
|
||||
|
||||
getLastPageData(){
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
const that = this;
|
||||
eventChannel.on('getDeviceInfo',async (data)=>{
|
||||
that.setData({
|
||||
deviceId:data
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
async getDeviceDetail(){
|
||||
let deviceId = this.data.deviceId;
|
||||
const res = await request(`system/device/getDeviceInfoByDeviceId?deviceId=${deviceId}`,'get');
|
||||
console.log(res);
|
||||
if (res.code === 200) {
|
||||
this.setData({
|
||||
deviceInfo:res.data,
|
||||
lightStatus:res.data.lightStatus
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async lightPower(){
|
||||
let lightStatus = this.data.lightStatus;
|
||||
let deviceInfo = this.data.deviceInfo;
|
||||
if (!deviceInfo.isOnline) {
|
||||
wx.showToast({
|
||||
title: '设备离线',
|
||||
icon:'error',
|
||||
mask:true
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(lightStatus){
|
||||
var res = await request('system/device/control','post',{
|
||||
deviceNum:deviceInfo.deviceNum,
|
||||
cmd:'off'
|
||||
})
|
||||
}else if(!lightStatus){
|
||||
var res = await request('system/device/control','post',{
|
||||
deviceNum:deviceInfo.deviceNum,
|
||||
cmd:'on'
|
||||
})
|
||||
}
|
||||
if (res.code === 200) {
|
||||
this.setData({ lightStatus:!lightStatus })
|
||||
}
|
||||
},
|
||||
|
||||
//打开分享的页面
|
||||
async isShared(options){
|
||||
if (options.hasOwnProperty('deviceInfo')) {
|
||||
this.checkLogin();
|
||||
const deviceInfo = JSON.parse(options.deviceInfo);
|
||||
this.setData({
|
||||
deviceInfo
|
||||
})
|
||||
const res = await request('system/device/bindDevice','post',{
|
||||
deviceNum:deviceInfo.deviceNum,
|
||||
deviceName:deviceInfo.deviceName,
|
||||
categoryId:deviceInfo.categoryId,
|
||||
remark:deviceInfo.remark
|
||||
});
|
||||
const result = await request(`system/status/new/${deviceInfo.deviceId}`,'GET');
|
||||
this.setData({
|
||||
power:result.data.lightStatus,
|
||||
isOnline:result.data.isOnline
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
lookDetail(e){
|
||||
wx.navigateTo({
|
||||
url: '/pages/deviceDetail/index',
|
||||
success: (result) => {
|
||||
result.eventChannel.emit('getDeviceInfo',e.currentTarget.dataset.info);
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
this.getDeviceDetail();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function (e) {
|
||||
return {
|
||||
title:"我分享了一个设备。",
|
||||
path:`/pages/4Gswitch/index?deviceInfo=${JSON.stringify(e.target.dataset.info)}&&isShare=1`,
|
||||
imageUrl:'/icons/smart.jpg'
|
||||
}
|
||||
}
|
||||
})
|
||||
3
wechat/pages/4Gswitch/index.json
Normal file
3
wechat/pages/4Gswitch/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
32
wechat/pages/4Gswitch/index.wxml
Normal file
32
wechat/pages/4Gswitch/index.wxml
Normal file
@@ -0,0 +1,32 @@
|
||||
<!--miniprogram/pages/4Gswitch/index.wxml-->
|
||||
<view class="name">
|
||||
<text style="margin-right:15rpx">{{ deviceInfo.deviceName }}</text>
|
||||
<view>
|
||||
<van-tag mark type="success">{{ deviceInfo.categoryName }}</van-tag>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view>
|
||||
<view class="outside" style="{{(lightStatus == true) ?'background-image: radial-gradient(#6149f6 10%,#b0e6ff 100%)':'background-color: #dadada;'}}">
|
||||
<view class="inside" bindtap="lightPower">
|
||||
<image wx:if="{{ lightStatus == false }}" class="switch" src="/icons/switch_off.png"></image>
|
||||
<image wx:if="{{ lightStatus == true }}" class="switch" src="/icons/switch_on.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="power">
|
||||
<text>开关状态:</text>
|
||||
<text wx:if="{{ lightStatus == true }}" style="color:#0000ff">开</text>
|
||||
<text wx:if="{{ lightStatus == false }}" style="color:#ff0000">关</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom">
|
||||
<view class="bottom-item">
|
||||
<image src="/icons/share.png"></image>
|
||||
<text>分享</text>
|
||||
<button class="share" open-type="share" data-info = "{{ deviceInfo }}"></button>
|
||||
</view>
|
||||
<view class="bottom-item" bindtap="lookDetail" data-info="{{ deviceInfo }}">
|
||||
<image src="/icons/detail.png"></image>
|
||||
<text>详情</text>
|
||||
</view>
|
||||
</view>
|
||||
77
wechat/pages/4Gswitch/index.wxss
Normal file
77
wechat/pages/4Gswitch/index.wxss
Normal file
@@ -0,0 +1,77 @@
|
||||
/* miniprogram/pages/4Gswitch/index.wxss */
|
||||
page{
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.name{
|
||||
width: 60%;
|
||||
margin: 15vh auto 30rpx;
|
||||
text-align: center;
|
||||
font-size: 42rpx;
|
||||
}
|
||||
.outside{
|
||||
margin: 50rpx auto;
|
||||
width: 60vw;
|
||||
height: 60vw;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
/* border: 1rpx solid #666; */
|
||||
}
|
||||
.inside{
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
border-radius: 50%;
|
||||
background-color: #ffffff;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
box-shadow: 0 0 8rpx #bfbfbf;
|
||||
}
|
||||
.inside:active{
|
||||
transform: translateY(5rpx);
|
||||
}
|
||||
.switch{
|
||||
width: 25%;
|
||||
height: 25%;
|
||||
}
|
||||
.power{
|
||||
width: 60%;
|
||||
margin: 30rpx auto;
|
||||
text-align: center;
|
||||
font-size: larger;
|
||||
}
|
||||
.bottom{
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100rpx;
|
||||
display: flex;
|
||||
}
|
||||
.bottom-item{
|
||||
position: relative;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #4271f1;
|
||||
border: 1rpx solid #bfbfbf;
|
||||
color: #ffffff;
|
||||
}
|
||||
.bottom-item>image{
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
margin: 0 10rpx;
|
||||
}
|
||||
.bottom-item:active{
|
||||
background-color: #0044ff;
|
||||
}
|
||||
.share{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
}
|
||||
28
wechat/pages/add/add.js
Normal file
28
wechat/pages/add/add.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// pages/add/add.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
addFourG(){
|
||||
wx.navigateTo({
|
||||
url: '/pages/add4G/index',
|
||||
})
|
||||
},
|
||||
addWifi(){
|
||||
wx.showToast({
|
||||
title: '暂不支持',
|
||||
icon:'error'
|
||||
})
|
||||
},
|
||||
})
|
||||
3
wechat/pages/add/add.json
Normal file
3
wechat/pages/add/add.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
37
wechat/pages/add/add.wxml
Normal file
37
wechat/pages/add/add.wxml
Normal file
@@ -0,0 +1,37 @@
|
||||
<!--miniprogram/pages/add/index.wxml-->
|
||||
<view class="top">
|
||||
<image src="/icons/Internet.png" />
|
||||
</view>
|
||||
<view class="title">添加设备</view>
|
||||
<view class="main">
|
||||
<view class="name">设备分类 >>></view>
|
||||
<view class="content">
|
||||
<view class="item">
|
||||
<view class="type">
|
||||
<image src="/icons/4g.png"></image>
|
||||
<text>4G开关</text>
|
||||
</view>
|
||||
<view class="add" bindtap="addFourG">
|
||||
<image src="/icons/add_1.png" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="item">
|
||||
<view class="type">
|
||||
<image src="/icons/room.png"></image>
|
||||
<text>智慧宿舍</text>
|
||||
</view>
|
||||
<view class="add">
|
||||
<image src="/icons/add_1.png" />
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="item">
|
||||
<view class="type">
|
||||
<image src="/icons/wifi1.png"></image>
|
||||
<text>WiFi空气盒子</text>
|
||||
</view>
|
||||
<view class="add" bindtap="addWifi">
|
||||
<image src="/icons/add_1.png" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
67
wechat/pages/add/add.wxss
Normal file
67
wechat/pages/add/add.wxss
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
.top{
|
||||
width:100vw;
|
||||
height: 40vw;
|
||||
}
|
||||
.top>image{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.title{
|
||||
/* margin: 30rpx auto; */
|
||||
padding: 30rpx 0;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 42rpx;
|
||||
background-color: rgb(64, 130, 252);
|
||||
color: #ffffff;
|
||||
}
|
||||
.name{
|
||||
background-color: #ffffff;
|
||||
padding:15rpx 30rpx;
|
||||
/* border-bottom: 2rpx solid #666; */
|
||||
box-shadow: 0rpx 3rpx 7rpx rgb(136, 136, 136);
|
||||
font-size: 32rpx;
|
||||
}
|
||||
.content{
|
||||
padding:0 30rpx;
|
||||
margin: 30rpx 0;
|
||||
}
|
||||
.item{
|
||||
background-color: #ffffff;
|
||||
box-shadow: 3rpx 3rpx 10rpx #bfbfbf;
|
||||
margin: 30rpx auto;
|
||||
padding: 30rpx;
|
||||
width: 50vw;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.add{
|
||||
width: 130rpx;
|
||||
height: 130rpx;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 5rpx 3rpx #bfbfbb;
|
||||
background-color: #eeeeee;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.add>image{
|
||||
width: 70%;
|
||||
height: 70%;
|
||||
}
|
||||
.add:active{
|
||||
background-color: #bfbfbf;
|
||||
}
|
||||
|
||||
.type{
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
}
|
||||
.type>image{
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
}
|
||||
114
wechat/pages/add4G/index.js
Normal file
114
wechat/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/pages/add4G/index.json
Normal file
5
wechat/pages/add4G/index.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-button": "@vant/weapp/button/index"
|
||||
}
|
||||
}
|
||||
67
wechat/pages/add4G/index.wxml
Normal file
67
wechat/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/pages/add4G/index.wxss
Normal file
83
wechat/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);
|
||||
}
|
||||
113
wechat/pages/deviceDetail/index.js
Normal file
113
wechat/pages/deviceDetail/index.js
Normal file
@@ -0,0 +1,113 @@
|
||||
// miniprogram/pages/deviceDetail/index.js
|
||||
const { request } = require('../../API/request')
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
newRemark:{},
|
||||
newName:'',
|
||||
info:{},
|
||||
show:false,
|
||||
deleteShow:false
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.getLastPageData();
|
||||
},
|
||||
|
||||
getLastPageData(){
|
||||
const that = this;
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
eventChannel.on('getDeviceInfo', async(res)=>{
|
||||
const data = await request(`system/device/getByUserAndNum/${res.deviceNum}`,'GET');
|
||||
that.setData({
|
||||
info:data.data
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
changeName(e){
|
||||
let info = this.data.info;
|
||||
info.deviceName = e.detail;
|
||||
this.setData({ info });
|
||||
},
|
||||
changeRemark(e){
|
||||
let info = this.data.info;
|
||||
info.remark = e.detail;
|
||||
this.setData({ info });
|
||||
},
|
||||
|
||||
showDialog(){
|
||||
this.setData({ show:true })
|
||||
},
|
||||
|
||||
async onConfirm(){
|
||||
let info = this.data.info;
|
||||
const { deviceName, remark } = info;
|
||||
if (deviceName.trim() === '') {
|
||||
wx.showToast({
|
||||
title: '名称不能为空!',
|
||||
icon:'error',
|
||||
mask:true
|
||||
});
|
||||
return;
|
||||
}
|
||||
const res = await request('system/device/updateDeviceInfo','post',{
|
||||
deviceId:info.deviceId,
|
||||
deviceName,
|
||||
remark,
|
||||
});
|
||||
wx.showToast({
|
||||
title: res.msg,
|
||||
})
|
||||
this.onClose();
|
||||
},
|
||||
onCancel(){
|
||||
this.onClose();
|
||||
},
|
||||
|
||||
onClose(){
|
||||
this.setData({ show:false });
|
||||
},
|
||||
|
||||
showDeleteDialog(){
|
||||
this.setData({
|
||||
deleteShow:true
|
||||
})
|
||||
},
|
||||
|
||||
onCancelDelete(){
|
||||
this.setData({
|
||||
deleteShow:false
|
||||
})
|
||||
},
|
||||
|
||||
onCloseDelete(){
|
||||
this.onCancelDelete();
|
||||
},
|
||||
|
||||
async onConfirmDelete(){
|
||||
let deviceId = this.data.info.deviceId;
|
||||
const res = await request('system/device/unBindDevice','post',{
|
||||
deviceId
|
||||
});
|
||||
if (res.code === 200) {
|
||||
wx.showToast({
|
||||
title: '解除成功',
|
||||
icon:'success',
|
||||
mask:true,
|
||||
duration:1000
|
||||
});
|
||||
wx.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
8
wechat/pages/deviceDetail/index.json
Normal file
8
wechat/pages/deviceDetail/index.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-field": "@vant/weapp/field/index",
|
||||
"van-cell-group": "@vant/weapp/cell-group/index",
|
||||
"van-button": "@vant/weapp/button/index",
|
||||
"van-dialog": "@vant/weapp/dialog/index"
|
||||
}
|
||||
}
|
||||
62
wechat/pages/deviceDetail/index.wxml
Normal file
62
wechat/pages/deviceDetail/index.wxml
Normal file
@@ -0,0 +1,62 @@
|
||||
<!--miniprogram/pages/deviceDetail/index.wxml-->
|
||||
<van-cell-group title='设备信息'>
|
||||
<van-field
|
||||
label="设备编号"
|
||||
value="{{ info.deviceNum }}"
|
||||
readonly
|
||||
/>
|
||||
<van-field
|
||||
label="设备分类"
|
||||
value="{{ info.categoryName }}"
|
||||
readonly
|
||||
/>
|
||||
<van-field
|
||||
label="固件版本"
|
||||
value="{{ info.firmwareVersion }}"
|
||||
readonly
|
||||
/>
|
||||
</van-cell-group>
|
||||
<van-cell-group title='自定义信息'>
|
||||
<van-field
|
||||
label="设备名称"
|
||||
value="{{ info.deviceName }}"
|
||||
bind:change="changeName"
|
||||
/>
|
||||
<van-field
|
||||
label="备注"
|
||||
value="{{ info.remark }}"
|
||||
type='textarea'
|
||||
bind:change="changeRemark"
|
||||
/>
|
||||
</van-cell-group>
|
||||
|
||||
<view class="btn">
|
||||
<van-button block round color="linear-gradient(to right, #4bb0ff, #6149f6)" bindtap="showDialog">
|
||||
提交修改
|
||||
</van-button>
|
||||
</view>
|
||||
<view class="btn">
|
||||
<van-button block round type='danger' bindtap="showDeleteDialog">
|
||||
解除绑定
|
||||
</van-button>
|
||||
</view>
|
||||
|
||||
<van-dialog
|
||||
message='您确定要提交您所做的修改吗?'
|
||||
show="{{ show }}"
|
||||
show-cancel-button
|
||||
bind:close="onClose"
|
||||
bind:confirm="onConfirm"
|
||||
bind:cancel='onCancel'
|
||||
>
|
||||
</van-dialog>
|
||||
|
||||
<van-dialog
|
||||
message='您确定要解除这个设备吗?'
|
||||
show="{{ deleteShow }}"
|
||||
show-cancel-button
|
||||
bind:close="onCloseDelete"
|
||||
bind:confirm="onConfirmDelete"
|
||||
bind:cancel='onCancelDelete'
|
||||
>
|
||||
</van-dialog>
|
||||
6
wechat/pages/deviceDetail/index.wxss
Normal file
6
wechat/pages/deviceDetail/index.wxss
Normal file
@@ -0,0 +1,6 @@
|
||||
/* miniprogram/pages/deviceDetail/index.wxss */
|
||||
|
||||
.btn{
|
||||
width:80vw;
|
||||
margin:30rpx auto;
|
||||
}
|
||||
146
wechat/pages/index/index.js
Normal file
146
wechat/pages/index/index.js
Normal file
@@ -0,0 +1,146 @@
|
||||
// pages/index/index.js
|
||||
const amap = require('../../libs/amap-wx.js');
|
||||
const { request } = require('../../API/request.js');
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
weather:{}, //天气信息
|
||||
products:[],
|
||||
DeviceList:null,
|
||||
onlineList:[],
|
||||
unlineList:[]
|
||||
},
|
||||
|
||||
|
||||
async getDevices(){
|
||||
wx.showLoading({
|
||||
title: '获取设备',
|
||||
mask: true
|
||||
})
|
||||
const res = await request('system/device/listDevice','GET');
|
||||
wx.hideLoading();
|
||||
const result = res.rows;
|
||||
if (res.code !== 200) {
|
||||
wx.showToast({
|
||||
title: '请求失败',
|
||||
icon:'error'
|
||||
});
|
||||
return;
|
||||
}
|
||||
wx.showToast({
|
||||
title: '请求成功',
|
||||
});
|
||||
let onlineList = [];
|
||||
let unlineList = [];
|
||||
result.forEach(v=>{
|
||||
if (v.isOnline == 1) {
|
||||
onlineList.push(v)
|
||||
} else if (v.isOnline == 0) {
|
||||
unlineList.push(v);
|
||||
}
|
||||
})
|
||||
this.setData({
|
||||
onlineList,
|
||||
unlineList,
|
||||
DeviceList:result
|
||||
})
|
||||
},
|
||||
|
||||
goToDeviceControl(e){
|
||||
switch (e.currentTarget.dataset.info.categoryId) {
|
||||
case 1:
|
||||
wx.navigateTo({
|
||||
url: '/pages/4Gswitch/index',
|
||||
success:(res)=>{
|
||||
res.eventChannel.emit('getDeviceInfo',e.currentTarget.dataset.info.deviceId)
|
||||
}
|
||||
})
|
||||
break;
|
||||
case 2:
|
||||
wx.navigateTo({
|
||||
url: '/pages/4Gswitch/index',
|
||||
success:(res)=>{
|
||||
res.eventChannel.emit('getDeviceInfo',e.currentTarget.dataset.info.deviceId)
|
||||
}
|
||||
})
|
||||
break;
|
||||
case 4:
|
||||
wx.navigateTo({
|
||||
url: '/pages/someData/index',
|
||||
success:(res)=>{
|
||||
res.eventChannel.emit('getDeviceInfo',e.currentTarget.dataset.deviceId)
|
||||
}
|
||||
})
|
||||
break;
|
||||
|
||||
case 5:
|
||||
wx.navigateTo({
|
||||
url: '/pages/roomSystem/index',
|
||||
success:(res)=>{
|
||||
res.eventChannel.emit('getDeviceInfo',e.currentTarget.dataset.deviceId)
|
||||
}
|
||||
})
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
getWeather:async function(){
|
||||
let that = this;
|
||||
var myAmapFun = new amap.AMapWX({key:'5cafa1133f593cfe005081749a46e717'});
|
||||
myAmapFun.getWeather({
|
||||
success: function(data){
|
||||
that.setData({
|
||||
weather:data
|
||||
})
|
||||
},
|
||||
fail: function(info){
|
||||
//失败回调
|
||||
console.log(info)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
setTimeout(()=>{
|
||||
this.getDevices();
|
||||
},1000)
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
this.getWeather();
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
this.getDevices();
|
||||
this.getWeather();
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
5
wechat/pages/index/index.json
Normal file
5
wechat/pages/index/index.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh":true,
|
||||
"backgroundTextStyle":"dark"
|
||||
}
|
||||
171
wechat/pages/index/index.wxml
Normal file
171
wechat/pages/index/index.wxml
Normal file
@@ -0,0 +1,171 @@
|
||||
<!--miniprogram/pages/myDevice/index.wxml-->
|
||||
<view class='body'>
|
||||
<view class='top'>
|
||||
<view class='top_left'>
|
||||
<view class='top_big_info'>
|
||||
<text class='temperature'>{{ weather.temperature.data }}℃</text>
|
||||
<text class='city'>城市: {{ weather.city.data }}</text>
|
||||
</view>
|
||||
<view class='top_small_info'>
|
||||
<view>
|
||||
<text class='humidity'>湿度: {{ weather.humidity.data }}</text>
|
||||
<text class='weather'>天气: {{ weather.weather.data }}</text>
|
||||
</view>
|
||||
<text class='winddirection'>风向: {{ weather.winddirection.data }}</text>
|
||||
<text class='windpower'>风力: {{ weather.windpower.data }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class='top_right'>
|
||||
<view class='start'>
|
||||
<image src='/icons/start.png' />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='devices'>
|
||||
<view class='devices_tab'>全部 ({{ DeviceList.length }})</view>
|
||||
<van-tabs swipeable animated>
|
||||
<van-tab title="在线设备({{ onlineList.length }})">
|
||||
<scroll-view scroll-y>
|
||||
<view class="devices_list">
|
||||
<block wx:if="{{ onlineList.length !== 0 }}">
|
||||
<view wx:for='{{ onlineList }}' wx:key='index' class='border'>
|
||||
<!-- <block wx:if="{{ item.isOnline === 2 }}">
|
||||
<view class='devices_item' style="background-color:rgba(0,0,0,.05)" bindtap='deviceNone' data-info='{{item}}'>
|
||||
<view class="info">
|
||||
<view class='img'>
|
||||
<image src='/icons/4g.png' />
|
||||
</view>
|
||||
<view class="_right">
|
||||
<view style="color:#bfbfbf" class="status">未激活</view>
|
||||
<view style="font-size:24rpx;color:#666">{{ item.categoryName }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='name'>{{ item.deviceName }}</view>
|
||||
</view>
|
||||
</block> -->
|
||||
<block wx:if="{{ item.isOnline === 1 }}">
|
||||
<view class='devices_item' bindtap='goToDeviceControl' data-info='{{item}}'>
|
||||
<view class="info">
|
||||
<view class='img'>
|
||||
<image src='/icons/4g.png' />
|
||||
</view>
|
||||
<view class="_right">
|
||||
<view style="color:green" class="status">在线</view>
|
||||
<view style="font-size:24rpx;color:#666">{{ item.categoryName }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='name'>
|
||||
<view>
|
||||
{{ item.deviceName }}
|
||||
</view>
|
||||
<view>
|
||||
<text style="color:#ff0000;font-size:24rpx;font-weight:600">NO.</text>
|
||||
<text style="color:#ff0000;font-size:22rpx;">{{ item.deviceNum }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:if="{{ item.isOnline === 0 }}">
|
||||
<view style="background-color:rgba(0,0,0,.05)" class='devices_item' bindtap='goToDeviceControl' data-info='{{item}}'>
|
||||
<view class="info">
|
||||
<view class='img'>
|
||||
<image src='/icons/4g.png' />
|
||||
</view>
|
||||
<view class="_right">
|
||||
<view style="color:#ff0000" class="status">离线</view>
|
||||
<view style="font-size:24rpx;color:#666">{{ item.categoryName }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='name'>
|
||||
<view>
|
||||
{{ item.deviceName }}
|
||||
</view>
|
||||
<view>
|
||||
<text style="color:#ff0000;font-size:24rpx; font-weight:600">NO.</text>
|
||||
<text style="color:#ff0000;font-size:22rpx;">{{ item.deviceNum }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:elif='{{ onlineList.length === 0 }}'>
|
||||
<view class='noDevice'> 暂无设备,请添加。 </view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</van-tab>
|
||||
<van-tab title="离线设备({{ unlineList.length }})">
|
||||
<scroll-view scroll-y>
|
||||
<view class="devices_list">
|
||||
<block wx:if="{{ unlineList.length !== 0 }}">
|
||||
<view wx:for='{{ unlineList }}' wx:key='index' class='border'>
|
||||
<!-- <block wx:if="{{ item.isOnline === 2 }}">
|
||||
<view class='devices_item' style="background-color:rgba(0,0,0,.05)" bindtap='deviceNone' data-info='{{item}}'>
|
||||
<view class="info">
|
||||
<view class='img'>
|
||||
<image src='/icons/4g2.png' />
|
||||
</view>
|
||||
<view class="_right">
|
||||
<view style="color:#bfbfbf" class="status">未激活</view>
|
||||
<view style="font-size:24rpx;color:#666">{{ item.categoryName }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='name'>{{ item.deviceName }}</view>
|
||||
</view>
|
||||
</block> -->
|
||||
<block wx:if="{{ item.isOnline === 1 }}">
|
||||
<view class='devices_item' bindtap='goToDeviceControl' data-info='{{item}}'>
|
||||
<view class="info">
|
||||
<view class='img'>
|
||||
<image src='/icons/4g2.png' />
|
||||
</view>
|
||||
<view class="_right">
|
||||
<view style="color:green" class="status">在线</view>
|
||||
<view style="font-size:24rpx;color:#666">{{ item.categoryName }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='name'>
|
||||
<view>
|
||||
{{ item.deviceName }}
|
||||
</view>
|
||||
<view>
|
||||
<text style="color:#ff0000;font-size:24rpx;font-weight:600">NO.</text>
|
||||
<text style="color:#ff0000;font-size:22rpx;">{{ item.deviceNum }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:if="{{ item.isOnline === 0 }}">
|
||||
<view style="background-color:rgba(0,0,0,.05)" class='devices_item' bindtap='goToDeviceControl' data-info='{{item}}'>
|
||||
<view class="info">
|
||||
<view class='img'>
|
||||
<image src='/icons/4g2.png' />
|
||||
</view>
|
||||
<view class="_right">
|
||||
<view style="color:#ff0000" class="status">离线</view>
|
||||
<view style="font-size:24rpx;color:#666">{{ item.categoryName }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='name'>
|
||||
<view>
|
||||
{{ item.deviceName }}
|
||||
</view>
|
||||
<view>
|
||||
<text style="color:#ff0000;font-size:24rpx;font-weight:600">NO.</text>
|
||||
<text style="color:#ff0000;font-size:22rpx;">{{ item.deviceNum }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:elif='{{ unlineList.length === 0 }}'>
|
||||
<view class='noDevice'> 暂无设备,请添加。 </view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</van-tab>
|
||||
</van-tabs>
|
||||
</view>
|
||||
</view>
|
||||
154
wechat/pages/index/index.wxss
Normal file
154
wechat/pages/index/index.wxss
Normal file
@@ -0,0 +1,154 @@
|
||||
|
||||
.top{
|
||||
display:flex;
|
||||
justify-content:space-around;
|
||||
background-color:skyblue;
|
||||
background-image: linear-gradient(to bottom right, skyblue, blue);
|
||||
padding:30rpx 0;
|
||||
border-radius:0 0 25rpx 25rpx;
|
||||
color:#ffffff;
|
||||
height:270rpx;
|
||||
}
|
||||
|
||||
.top .top_left{
|
||||
width:420rpx;
|
||||
display:flex;
|
||||
flex-direction:column;
|
||||
justify-content:center;
|
||||
}
|
||||
.top .top_left .top_big_info{
|
||||
padding:10rpx 0;
|
||||
}
|
||||
.top .top_left .top_small_info{
|
||||
padding:10rpx 20rpx;
|
||||
font-size:30rpx;
|
||||
}
|
||||
|
||||
.temperature{
|
||||
font-size:60rpx;
|
||||
display:inline-block;
|
||||
padding:0 20rpx;
|
||||
}
|
||||
.humidity::after{
|
||||
content:'|';
|
||||
width:55rpx;
|
||||
display:inline-block;
|
||||
text-align:center;
|
||||
color:rgba(255,255,255,.5);
|
||||
}
|
||||
.winddirection::after{
|
||||
content:'|';
|
||||
width:55rpx;
|
||||
display:inline-block;
|
||||
text-align:center;
|
||||
color:rgba(255,255,255,.5);
|
||||
}
|
||||
.top .top_right{
|
||||
width:250rpx;
|
||||
display:flex;
|
||||
justify-content:center;
|
||||
align-items:center;
|
||||
}
|
||||
.top .top_right .start{
|
||||
position:relative;
|
||||
width:220rpx;
|
||||
height:220rpx;
|
||||
animation:move 4s linear infinite;
|
||||
}
|
||||
@keyframes move{
|
||||
0%{ top:0rpx }
|
||||
25%{ top:-30rpx }
|
||||
50%{ top:0rpx }
|
||||
75%{ top:30rpx }
|
||||
100%{ top:0rpx }
|
||||
}
|
||||
.top .top_right .start image{
|
||||
width:100%;
|
||||
height:100%;
|
||||
}
|
||||
|
||||
.devices .devices_tab{
|
||||
font-size:36rpx;
|
||||
padding:20rpx;
|
||||
}
|
||||
.devices .devices_list{
|
||||
padding:10rpx 0;
|
||||
display:flex;
|
||||
flex-wrap:wrap;
|
||||
}
|
||||
.devices .devices_list .border{
|
||||
width:50%;
|
||||
display:flex;
|
||||
justify-content:center;
|
||||
}
|
||||
.devices .devices_list .devices_item{
|
||||
width:280rpx;
|
||||
height:220rpx;
|
||||
margin:30rpx 20rpx;
|
||||
border-radius:10rpx;
|
||||
display:flex;
|
||||
flex-direction:column;
|
||||
justify-content:center;
|
||||
box-shadow:0rpx 5rpx 10rpx #bfbfbf;
|
||||
}
|
||||
.info{
|
||||
flex: 3;
|
||||
display: flex;
|
||||
}
|
||||
.status{
|
||||
padding: 15rpx;
|
||||
text-align: right;
|
||||
flex: 1;
|
||||
}
|
||||
.devices .devices_list .devices_item:active{
|
||||
background-color:rgba(0,0,0,.1);
|
||||
}
|
||||
.devices .devices_list .devices_item .img{
|
||||
width:50%;
|
||||
display:flex;
|
||||
justify-content:center;
|
||||
align-items:center;
|
||||
}
|
||||
.devices .devices_list .devices_item image{
|
||||
width:100rpx;
|
||||
height:100rpx;
|
||||
}
|
||||
.devices .devices_list .devices_item .name{
|
||||
flex:2;
|
||||
padding:0 20rpx;
|
||||
/* background-color:rgba(0,0,0,.1); */
|
||||
border-top:1rpx solid #bfbfbf;
|
||||
display:flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
.noDevice{
|
||||
display:block;
|
||||
width:100%;
|
||||
height:200rpx;
|
||||
text-align:center;
|
||||
line-height:200rpx;
|
||||
}
|
||||
.addDevice{
|
||||
background-color:blue;
|
||||
width:80rpx;
|
||||
height:80rpx;
|
||||
border-radius:50%;
|
||||
position:fixed;
|
||||
right:0;
|
||||
top:30%;
|
||||
display:flex;
|
||||
justify-content:center;
|
||||
align-items:center;
|
||||
}
|
||||
.addDevice:active{
|
||||
background-color:deepskyblue;
|
||||
}
|
||||
.addDevice image{
|
||||
width:40rpx;
|
||||
height:40rpx;
|
||||
}
|
||||
scroll-view{
|
||||
height: 60vh;
|
||||
width: 100vw;
|
||||
}
|
||||
54
wechat/pages/my/my.js
Normal file
54
wechat/pages/my/my.js
Normal file
@@ -0,0 +1,54 @@
|
||||
// pages/my/my.js
|
||||
Page({
|
||||
data: {
|
||||
userInfo:{},
|
||||
isLogin:false
|
||||
},
|
||||
|
||||
getUserInfo(){
|
||||
const that = this;
|
||||
wx.showLoading({
|
||||
title: '正在登录'
|
||||
});
|
||||
wx.getUserProfile({
|
||||
desc:'用以展示您的头像和昵称等信息',
|
||||
success(res){
|
||||
console.log(res);
|
||||
wx.setStorageSync('userInfo',JSON.parse(res.rawData));
|
||||
wx.setStorageSync('isLogin',true);
|
||||
that.setData({
|
||||
userInfo:JSON.parse(res.rawData),
|
||||
isLogin:true
|
||||
})
|
||||
},
|
||||
complete(){
|
||||
wx.hideLoading();
|
||||
},
|
||||
fail(err){
|
||||
if (err.errMsg == 'getUserProfile:fail auth deny') {
|
||||
wx.showToast({
|
||||
title: '授权取消',
|
||||
icon:'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getPhoneNumber(e){
|
||||
console.log('===========');
|
||||
console.log(e);
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.setData({
|
||||
userInfo:wx.getStorageSync('userInfo'),
|
||||
isLogin:wx.getStorageSync('isLogin') || false
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
})
|
||||
3
wechat/pages/my/my.json
Normal file
3
wechat/pages/my/my.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
34
wechat/pages/my/my.wxml
Normal file
34
wechat/pages/my/my.wxml
Normal file
@@ -0,0 +1,34 @@
|
||||
<!--pages/my/my.wxml-->
|
||||
<view class="top">
|
||||
<view class="userInfo">
|
||||
<view class="picture">
|
||||
<image wx:if="{{ isLogin === true }}" src="{{ userInfo.avatarUrl }}" />
|
||||
<image wx:if="{{ isLogin === false }}" src="/icons/notlogin.png"></image>
|
||||
</view>
|
||||
<view wx:if="{{ isLogin === true }}" class="other">
|
||||
<view class="username">{{ userInfo.nickName }}</view>
|
||||
<view class="phone">
|
||||
<van-button color="linear-gradient(to right, #4bb0ff, #6149f6)"
|
||||
open-type='getPhoneNumber' bindgetphonenumber='getPhoneNumber'
|
||||
round size="small">
|
||||
绑定手机
|
||||
</van-button>
|
||||
</view>
|
||||
<!-- <view class="phone">
|
||||
<van-tag type="success">手机</van-tag>
|
||||
<text>12345678900</text>
|
||||
</view> -->
|
||||
</view>
|
||||
<view wx:if="{{ isLogin === false }}">
|
||||
<van-button round color="linear-gradient(to right, #4bb0ff, #6149f6)" bindtap="getUserInfo">登录授权</van-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="tips">
|
||||
<van-cell-group inset>
|
||||
<van-cell title="公司简介" size="large" icon='/icons/jianjie.png' is-link/>
|
||||
<van-cell title="关于我们" size="large" icon='/icons/about.png' is-link/>
|
||||
<van-cell title="加入我们" size="large" icon='/icons/join.png' is-link/>
|
||||
</van-cell-group>
|
||||
</view>
|
||||
52
wechat/pages/my/my.wxss
Normal file
52
wechat/pages/my/my.wxss
Normal file
@@ -0,0 +1,52 @@
|
||||
/* pages/my/my.wxss */
|
||||
.top{
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 270rpx;
|
||||
background-image: linear-gradient(120deg,#58bcff ,#2b63ff);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.userInfo{
|
||||
width: 85%;
|
||||
height: 200rpx;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
background-color: #ffffff;
|
||||
border-radius: 15rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
box-shadow: 0 0 10rpx #47b6ff;
|
||||
|
||||
}
|
||||
.picture{
|
||||
width: 150rpx;
|
||||
height: 150rpx;
|
||||
border-radius: 50%;
|
||||
margin: 0 60rpx;
|
||||
box-shadow: 0 0 10rpx #a0a0a0;
|
||||
background-color: #6fc5ff;
|
||||
}
|
||||
.picture>image{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.other{
|
||||
flex: 1;
|
||||
height: 160rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.username{
|
||||
font-size: 42rpx;
|
||||
}
|
||||
.phone{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.tips{
|
||||
margin: 95rpx 0;
|
||||
}
|
||||
Reference in New Issue
Block a user