添加部分页面

This commit is contained in:
qianlile
2021-08-21 20:11:09 +08:00
parent fe4902da1c
commit dbaee1db02
903 changed files with 1198 additions and 35963 deletions

View File

@@ -0,0 +1,118 @@
// miniprogram/pages/deviceDetail/index.js
const { requestApi } = require('../../API/request')
Page({
/**
* 页面的初始数据
*/
data: {
newRemark:{},
newName:'',
info:{},
show:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getLastPageData();
},
getLastPageData(){
const that = this;
const eventChannel = this.getOpenerEventChannel();
eventChannel.on('getDeviceInfo', async(res)=>{
const data = await requestApi(`/system/device/getByNum/${res.deviceNum}`,{ method:'GET' });
that.setData({
info:JSON.parse(data.result).data
})
})
},
changeName(e){
this.setData({ newName:e.detail })
},
changeRemark(e){
this.setData({ newRemark:e.detail })
},
showDialog(){
this.setData({ show:true })
},
async onConfirm(){
wx.showLoading({
title: '正在提交',
});
let info = this.data.info;
info.deviceName = this.data.newName;
info.newRemark = this.data.newRemark;
const res = await requestApi('/system/device',{
method:'PUT',
body:info,
json:true
});
wx.hideLoading();
wx.showToast({
title: res.result.msg,
})
this.onClose();
},
onCancel(){
this.onClose();
},
onClose(){
this.setData({ show:false });
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
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-cell-group": "@vant/weapp/cell-group/index",
"van-button": "@vant/weapp/button/index",
"van-dialog": "@vant/weapp/dialog/index"
}
}

View File

@@ -0,0 +1,46 @@
<!--miniprogram/pages/deviceDetail/index.wxml-->
<van-cell-group title='设备信息'>
<van-field
label="设备编号"
value="{{ info.deviceNum }}"
readonly
/>
<van-field
label="设备分类"
value="4G开关"
readonly
/>
</van-cell-group>
<van-cell-group title='自定义信息'>
<van-field
label="设备名称"
value="{{ info.deviceName }}"
bind:change="changeName"
/>
<van-field
label="设备位置"
value="客厅"
/>
<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>
<van-dialog
message='您确定要提交您所做的修改吗?'
show="{{ show }}"
show-cancel-button
bind:close="onClose"
bind:confirm="onConfirm"
bind:cancel='onCancel'
>
</van-dialog>

View File

@@ -0,0 +1,6 @@
/* miniprogram/pages/deviceDetail/index.wxss */
.btn{
width:80vw;
margin:30rpx auto;
}