contros.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;width: 100%;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="设备控制"></uni-nav-bar>
  7. </view>
  8. <view class="contros_box">
  9. <view class="operation">
  10. <p class="operation_title">操作</p>
  11. <view class="operation_btn">
  12. <button @click="chongqi">重 启</button>
  13. <!-- <button @click="shengji">升 级</button> -->
  14. <button @click="search">查询时间上传间隔</button>
  15. </view>
  16. </view>
  17. <view class="viewing" v-if="led==1">
  18. <p class="operation_title">显示屏设置</p>
  19. <view class="viewing_text">
  20. <view class="viewing_text_top">
  21. 标题文字设置 :
  22. <input type="text" v-model="config.content" />
  23. </view>
  24. <view class="viewing_text_bot">
  25. <p>显示时间设置(min) :</p>
  26. <input type="number" v-model="config.timeout" />
  27. </view>
  28. </view>
  29. </view>
  30. <view class="timing">
  31. <p class="operation_title">上传时间间隔(min)</p>
  32. <view class="timing_text">
  33. <slider value="0" v-model="config.interval" @change="sliderChange" step="1" min="0" max="359" show-value block-size="18" activeColor="#57C878" />
  34. </view>
  35. </view>
  36. <view class="ensure">
  37. <view class="ensure_btn" @click="ensure">
  38. 确 定
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. config: {
  50. content: "",
  51. timeout: "",
  52. interval: 1
  53. },
  54. id: '',
  55. led:0
  56. }
  57. },
  58. methods: {
  59. // forecast.send_control.device_control_info 设备配置查询
  60. async controsdata(datas) { //提交数据
  61. const res = await this.$myRequest({
  62. url: '/api/api_gateway?method=forecast.send_control.device_control_info',
  63. data: {
  64. d_id: this.id,
  65. cmd: "config"
  66. }
  67. })
  68. console.log(res)
  69. this.config.interval = res.interval
  70. this.led = Number(res.led)
  71. },
  72. //forecast.send_control.device_control config: {"interval":10,"content":"content","timeout":"1"}
  73. async timing(datas) { //提交数据
  74. const res = await this.$myRequest({
  75. url: '/api/api_gateway?method=forecast.send_control.device_control',
  76. data: {
  77. device_type_id: 5,
  78. d_id: this.id,
  79. config: JSON.stringify(datas)
  80. }
  81. })
  82. console.log(res)
  83. if(res){
  84. uni.showToast({
  85. title: '指令下发成功!'
  86. });
  87. }else{
  88. uni.showToast({
  89. title: '指令下发失败!',
  90. icon: "none"
  91. });
  92. }
  93. },
  94. //forecast.send_control.admin_device_control
  95. async restart(datas) { //重启
  96. const res = await this.$myRequest({
  97. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  98. data: {
  99. device_type_id: 5,
  100. d_id: this.id,
  101. cmd: datas
  102. }
  103. })
  104. if (res == true) {
  105. uni.showToast({
  106. title: '指令下发成功!'
  107. });
  108. } else {
  109. uni.showToast({
  110. title: '指令下发失败!',
  111. icon: "none"
  112. });
  113. }
  114. },
  115. //forecast.send_control.get_device_config
  116. async uploading() { //上传时间
  117. const res = await this.$myRequest({
  118. url: '/api/api_gateway?method=forecast.send_control.get_device_config',
  119. data: {
  120. device_type_id: 5,
  121. d_id: this.id,
  122. control_type: "interval"
  123. }
  124. })
  125. console.log(res)
  126. if (res == true) {
  127. uni.showToast({
  128. title: '指令下发成功!'
  129. });
  130. } else {
  131. uni.showToast({
  132. title: '指令下发失败!',
  133. icon: "none"
  134. });
  135. }
  136. },
  137. clickLeft() { //返回
  138. uni.navigateBack({
  139. delta: 1
  140. })
  141. },
  142. ensure() { //提交
  143. this.timing(this.config)
  144. console.log(this.config)
  145. },
  146. sliderChange(e) { //滑动块
  147. this.config.interval = e.detail.value
  148. },
  149. chongqi() { //重启按钮
  150. this.restart('reboot')
  151. },
  152. // shengji() { //升级按钮
  153. // this.restart('update')
  154. // },
  155. search() { //查询按钮
  156. this.uploading()
  157. }
  158. },
  159. onLoad(option) {
  160. this.id = option.id
  161. },
  162. onShow() {
  163. this.controsdata()
  164. }
  165. }
  166. </script>
  167. <style lang="scss">
  168. .operation_title {
  169. border-left: 6rpx solid #28AE4F;
  170. padding-left: 20rpx;
  171. margin-bottom: 20rpx;
  172. height: 36rpx;
  173. }
  174. .contros_box{
  175. position: absolute;
  176. top: 54px;
  177. width: 90%;
  178. left: 5%;
  179. }
  180. .operation {
  181. width: 95%;
  182. .operation_btn {
  183. display: flex;
  184. padding-left: 20rpx;
  185. box-sizing: border-box;
  186. button {
  187. font-size: 24rpx;
  188. background-color: #28AE4F;
  189. color: #FFFFFF;
  190. box-sizing: border-box;
  191. height: 60rpx;
  192. }
  193. button:last-child {
  194. width: 360rpx !important;
  195. }
  196. }
  197. }
  198. .viewing {
  199. width: 95%;
  200. margin-top: 30rpx;
  201. .viewing_text {
  202. .viewing_text_top,
  203. .viewing_text_bot {
  204. display: flex;
  205. background-color: #F7F8FA;
  206. padding-left: 20rpx;
  207. margin-bottom: 20rpx;
  208. height: 60rpx;
  209. line-height: 60rpx;
  210. font-size: 24rpx;
  211. input {
  212. font-size: 24rpx;
  213. margin: 16rpx 0 0 10rpx;
  214. width: 380rpx;
  215. }
  216. }
  217. }
  218. }
  219. .timing {
  220. width: 95%;
  221. margin-top: 30rpx;
  222. }
  223. .ensure {
  224. width: 100%;
  225. margin-top: 30rpx;
  226. .ensure_btn {
  227. width: 90%;
  228. margin: 0 auto;
  229. height: 60rpx;
  230. line-height: 60rpx;
  231. text-align: center;
  232. background-color: #28AE4F;
  233. color: #FFFFFF;
  234. border-radius: 200rpx;
  235. }
  236. }
  237. </style>