contros.vue 5.2 KB

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