123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <template>
- <view>
- <view class="device" v-for="item in devices" :key="item.code">
- <view class="col">
- <view class="switch" @click="changeStatus(item)">
- <switch :checked="item.useStatus" color="#007AFE" @change="switchChange" />
- </view>
- <view class="list" @tap="showDetail" :data-code="item.code">查看 ></view>
- </view>
- <text class="title">{{item.name}}</text>
- <view class="content">
- <text>设备SN:{{item.sn}}</text>
- <text>设备类型:{{item.type}}</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- devices: [],
- }
- },
- onLoad(e) {
- console.log(e);
- uni.request({
- url: 'http://127.0.0.1:9999/device/list?gatewayCode=' + e.code,
- method: 'GET',
- data: {},
- success: res => {
- this.devices = res.data.data.devices;
- console.log(this.devices);
- },
- });
- },
- methods: {
- switchChange(e) {
- },
- async changeStatus(item) {
- item.deviceStatus == 1 ? item.deviceStatus = 0 : item.deviceStatus = 1;
- console.log(item.deviceStatus);
- let vm = this;
- let url = uni.$api.device.update;
- let data = {
- code: item.code,
- deviceStatus: item.deviceStatus,
- ip: item.ip,
- name: item.name,
- sn: item.sn,
- type: item.type,
- operatorNumber: item.operatorNumber,
- projectNumber: item.projectNumber,
- gatewayNumber: item.gatewayNumber,
- operatorCode: item.operatorCode,
- projectCode: item.projectCode,
- gatewayCode: item.gatewayCode,
- };
- let res = await uni.$http.get(url, data);
- console.log(res);
- },
- showDetail(e) {
- console.log(e);
- var code = e.currentTarget.dataset.code;
- uni.navigateTo({
- url: '/pages/device/deviceInfo/deviceInfo?code=' + code,
- });
- }
- }
- }
- </script>
- <style>
- .list {
- font-size: 28rpx;
- color: #007AFF;
- margin-right: 20rpx;
- margin-top: 85rpx;
- }
- .switch {
- transform: scale(0.6);
- }
- .col {
- float: right;
- }
- .device {
- width: 702rpx;
- height: 230rpx;
- background-color: white;
- margin-top: 30rpx;
- margin-left: 24rpx;
- border-radius: 10rpx;
- padding-top: 30rpx;
- }
- .content {
- display: flex;
- flex-direction: column;
- margin-top: 30rpx;
- margin-left: 30rpx;
- line-height: 60rpx;
- color: #444546;
- font-size: 28rpx;
- }
- .title {
- font-size: 36rpx;
- margin-left: 30rpx;
- color: #282828;
- font-weight: 600;
- }
- </style>
|