remoteControl.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <view>
  3. <u-navbar title="远程控制" title-color="#101010" >
  4. <view class="u-nav-slot" slot="right" v-if="0" >
  5. 操作日志
  6. </view>
  7. </u-navbar>
  8. <view class="tabs-box" v-if="!popShow" >
  9. <view class="tabs1" v-show="tenantList.length>1" :style="{width: tenantList.length>4 ? '' : '100%'}" >
  10. <u-tabs :list="tenantList1" inactive-color="#777777" active-color="#333333 "
  11. bg-color="#fff" :is-scroll="false" :current="current" @change="change"></u-tabs>
  12. </view>
  13. <view class="icon" @click="popShow=true" v-if="tenantList.length >= 4" >
  14. <u-icon name="arrow-down" color="#777777" size="28"></u-icon>
  15. </view>
  16. </view>
  17. <!-- 标签弹出层 -->
  18. <u-popup v-model="popShow" length="80%" @close="keyword=''" duration="10" mode="top" :negative-top="188" border-radius="32">
  19. <u-navbar title="远程控制" title-color="#101010" >
  20. <view class="u-nav-slot" slot="right" v-if="0" >
  21. 操作日志
  22. </view>
  23. </u-navbar>
  24. <view class="head-head">
  25. <u-search placeholder="请输入关键字" :show-action="false" v-model="keyword"></u-search>
  26. </view>
  27. <view class="head-head-placeholder ">
  28. </view>
  29. <view class="popup-tabs" v-if="false">
  30. <view class="tabs1">
  31. <!-- <u-tabs :list="tenantList1" inactive-color="#777777" active-color="#333333 "
  32. bg-color="#fff" :is-scroll="false" :current="current" @change="change"></u-tabs> -->
  33. <u-tabs :list="tenantList1" :is-scroll="false" :current="current" @change="change"></u-tabs >
  34. </view>
  35. <view class="more">
  36. <u-icon name="arrow-up" color="#777777" size="40" @click="popShow=false"></u-icon>
  37. </view>
  38. </view>
  39. <view class="tabs-options">
  40. <view class="item" v-for="(item, index) in tenantList"
  41. v-show="keyword==''||(item.name&&item.name.indexOf(keyword)!=-1)"
  42. :class="{
  43. 'item-index' : item.id==formData.tenantId
  44. }"
  45. :key="index"
  46. @click="merchantChange(item,index)">
  47. {{item.name}}
  48. </view>
  49. <u-divider nonetext="没有找到相关内容"
  50. border-color="#CFD2D5">已经到底了</u-divider>
  51. </view>
  52. </u-popup>
  53. <view class="main">
  54. <view class="switch" v-for="(item,i) in remoteReadingMeterList" :key="i" >
  55. <view class="switch-name">
  56. <view class="name">
  57. {{item.name}}
  58. </view>
  59. <view class="place">
  60. {{item.installationAddressSimple}}
  61. </view>
  62. </view>
  63. <view class="switch-icon">
  64. <view class="icon icon2" v-if="role" >
  65. <img src="@/assets/img/switchIcon.png"
  66. @click="switchBtnApi(item,0)" class="img"
  67. v-if="item.switchStatus" alt="" ></img >
  68. <img src="@/assets/img/switchClose.png"
  69. @click="switchBtnApi(item,1)" class="img"
  70. v-else alt="" ></img >
  71. </view>
  72. <view v-else style=" display: flex; flex-direction: column;">
  73. <span class="spanClass span1" v-if="item.switchStatus">开启</span>
  74. <span class="spanClass span2" v-else>关闭</span>
  75. <span class="spanClass span1" v-if="item.online">在线</span>
  76. <span class="spanClass span2" v-else>离线</span>
  77. </view>
  78. <!-- <image class="img" src="@/assets/img/switch-open.png" ></image -->
  79. </view>
  80. </view>
  81. </view>
  82. <u-divider :isnone="remoteReadingMeterList.length==0" nonetext="无记录"
  83. border-color="#CFD2D5">已经到底了</u-divider>
  84. </view>
  85. </template>
  86. <script>
  87. import * as API from '@/apis/pagejs/tenantList.js'
  88. export default {
  89. data() {
  90. return {
  91. formData:{},
  92. popShow:false,
  93. tenantList:[],
  94. tenantList1:[],
  95. remoteReadingMeterList:[],
  96. list1: [{
  97. name: '格莱慧'
  98. }, {
  99. name: '楚之源'
  100. }, {
  101. name: '杜宝银',
  102. }, {
  103. name: '王玉清',
  104. }, {
  105. name: '荆州万乘',
  106. }],
  107. list2: [{
  108. name: '全部'
  109. }, {
  110. name: '一楼大厅'
  111. }, {
  112. name: '门房',
  113. }, {
  114. name: '八楼',
  115. }, {
  116. name: '九楼',
  117. }],
  118. current:0,
  119. current1: 0,
  120. current2: 0,
  121. role:false,
  122. codes:"",
  123. keyword:'',
  124. }
  125. },
  126. onReady() {
  127. this.codes =this.carhelp.getPersonInfo().codes;
  128. this.role=this.codes&&this.codes.indexOf('switch')!=-1;
  129. this.getTenantList()
  130. },
  131. methods: {
  132. switchBtnApiMethod(node,key){
  133. uni.showLoading({
  134. title: "加载中",
  135. mask: true,
  136. })
  137. API.remoteSwitch({
  138. meterId:node.id,
  139. enabled:key
  140. }).then((res) => {
  141. uni.hideLoading();
  142. node.switchStatus=key
  143. }).catch(error => {
  144. uni.showToast({
  145. title: error,
  146. icon: "none"
  147. })
  148. })
  149. },
  150. switchBtnApi(node,key){
  151. uni.showModal({
  152. confirmColor:`${key?'#3CC51F':'red'}`,
  153. confirmText:`${key?'开启':'关闭'}`,
  154. content: `确认是否要"${key?'开启':'关闭'}"${node.name}`,
  155. title: "提示",
  156. success:res=> {
  157. if(res.confirm){
  158. this.switchBtnApiMethod(node,key);
  159. }
  160. }
  161. })
  162. console.log(node,key)
  163. },
  164. getTenantMeterList(){
  165. uni.showLoading({
  166. mask:true,title:'加载中...'
  167. })
  168. API.tenantMeterList(this.formData).then((response) => {
  169. uni.hideLoading();
  170. //this.list=response.data.data;
  171. this.remoteReadingMeterList=response.data.remoteReadingMeterList
  172. }).catch(error => {
  173. uni.hideLoading();
  174. uni.showToast({
  175. icon: "none",
  176. title: error
  177. })
  178. })
  179. },
  180. change(index) {
  181. this.current = index;
  182. this.formData.tenantId = this.tenantList1[index].id;
  183. this.popShow = false;
  184. this.merchantChangeApi()
  185. },
  186. merchantChange(item, index) {
  187. // if(this.current==0){
  188. // this.current=1;
  189. // }
  190. this.formData.tenantId= item.id;
  191. //this.$forceUpdate()
  192. this.getTenantListSort(this.tenantList)
  193. this.merchantChangeApi()
  194. this.popShow = false;
  195. },
  196. getTenantList(){
  197. uni.showLoading({
  198. title: "加载中",
  199. mask: true,
  200. })
  201. API.tenantList().then((response) => {
  202. uni.hideLoading();
  203. var list=response.data.tenantInfoList;
  204. this.formData.tenantId=list[0].id
  205. this.getTenantListSort(list)
  206. this.merchantChangeApi()
  207. }).catch(error => {
  208. uni.showToast({
  209. title: error,
  210. icon: "none"
  211. })
  212. })
  213. },
  214. getTenantListSort(list){
  215. for(var i in list){
  216. var obj=list[i]
  217. if(this.formData.tenantId==obj.id){
  218. var obj1=list[this.current];
  219. list[this.current]=obj;
  220. list[i]=obj1;
  221. }
  222. }
  223. this.tenantList=list;
  224. var mList1 = [];
  225. for (var i = 0; i < list.length; i++) {
  226. if (i >= 4) {
  227. } else {
  228. mList1.push(list[i]);
  229. }
  230. }
  231. this.tenantList1 = mList1;
  232. },
  233. merchantChangeApi(){
  234. this.getTenantMeterList()
  235. },
  236. change1(index) {
  237. this.current1 = index;
  238. },
  239. change2(index) {
  240. this.current2 = index;
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. page{
  247. background: url('@/assets/img/controlCover.png') center fixed ;
  248. background-size:cover;
  249. }
  250. .u-nav-slot {
  251. margin-right: 32rpx;
  252. }
  253. // 标签
  254. .tabs-box{
  255. display: flex;
  256. align-items: center;
  257. justify-content: space-between;
  258. padding: 16rpx 32rpx 16rpx 0;
  259. .tabs{
  260. width: 96%;
  261. }
  262. /deep/.u-tabs{
  263. background-color: inherit !important
  264. }
  265. }
  266. .main{
  267. padding: 0 32rpx;
  268. display: flex;
  269. justify-content: space-between;
  270. flex-wrap: wrap;
  271. background: inherit;
  272. .switch{
  273. width: 100%;
  274. background-color: #fff;
  275. border-radius: 12px;
  276. padding: 24rpx 24rpx;
  277. display: flex;
  278. align-items: center;
  279. justify-content: space-between;
  280. margin-top: 24rpx;
  281. }
  282. .switch-name{
  283. margin-right: 2px;
  284. .name{
  285. color: rgba(51,51,51,1);
  286. font-size: 32rpx;
  287. font-weight: bold;
  288. }
  289. .place{
  290. color: rgba(119,119,119,1);
  291. font-size: 24rpx;
  292. }
  293. }
  294. .switch-icon{
  295. white-space: pre;
  296. .img{
  297. width: 64rpx;
  298. height: 64rpx;
  299. }
  300. }
  301. }
  302. // 标签
  303. .tabs-box{
  304. display: flex;
  305. align-items: center;
  306. justify-content: space-between;
  307. padding: 16rpx 32rpx 16rpx 0;
  308. .tabs{
  309. width: 96%;
  310. }
  311. }
  312. .tabs-box{
  313. background-color: #fff;
  314. display: flex;
  315. align-items: center;
  316. justify-content: space-between;
  317. padding: 16rpx 32rpx 16rpx 32rpx;
  318. .tabs1{
  319. width: 96%;
  320. }
  321. }
  322. .popup-tabs {
  323. background-color: #fff;
  324. display: flex;
  325. align-items: center;
  326. justify-content: space-between;
  327. padding-top: 32rpx;
  328. padding-right: 32rpx;
  329. color: rgba(51, 51, 51, 1);
  330. font-size: 32rpx;
  331. .tabs1 {
  332. width: 88%;
  333. }
  334. }
  335. /deep/.u-tab-item {
  336. width: 25% !important;
  337. flex: none !important;
  338. }
  339. .tabs-options {
  340. //display: flex;
  341. padding: 24rpx 32rpx ;
  342. flex-wrap: wrap;
  343. .item {
  344. //width: 25%;
  345. color:rgb(119, 119, 119);
  346. margin-bottom: 24rpx;
  347. font-size: 32rpx;
  348. }
  349. .item-index{
  350. color: rgb(51, 51, 51);
  351. font-weight: bold;
  352. }
  353. }
  354. .spanClass{
  355. margin: 2px 0;
  356. padding: 2rpx 8rpx;
  357. border: 1px solid #00b962;
  358. color: #00b962;
  359. border-radius: 3px;
  360. white-space: pre;
  361. }
  362. .span2{
  363. border: 1px solid #ff7b00;
  364. color: #ff7b00;
  365. }
  366. .head-head{
  367. background: #fff;
  368. padding:24rpx;
  369. position: fixed;
  370. left: 0;
  371. right: 0;
  372. top: 80rpx;
  373. z-index: 991;
  374. }
  375. .head-head-placeholder{
  376. height: 112rpx;
  377. }
  378. </style>