contros.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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" @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: ""
  51. },
  52. id: ''
  53. }
  54. },
  55. methods: {
  56. //forecast.send_control.device_control config: {"interval":10,"content":"content","timeout":"1"}
  57. async timing(datas) { //提交数据
  58. const res = await this.$myRequest({
  59. url: '/api/api_gateway?method=weather.weather.qxz_status',
  60. data: {
  61. device_type_id: 5,
  62. d_id: this.id,
  63. config: JSON.stringify(datas)
  64. }
  65. })
  66. },
  67. //forecast.send_control.admin_device_control
  68. async restart(datas) { //重启
  69. const res = await this.$myRequest({
  70. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  71. data: {
  72. device_type_id: 5,
  73. d_id: this.id,
  74. cmd: datas
  75. }
  76. })
  77. if (res == true) {
  78. uni.showToast({
  79. title: '指令下发成功!'
  80. });
  81. } else {
  82. uni.showToast({
  83. title: '指令下发失败!'
  84. });
  85. }
  86. },
  87. //forecast.send_control.get_device_config
  88. async uploading() { //上传时间
  89. const res = await this.$myRequest({
  90. url: '/api/api_gateway?method=forecast.send_control.get_device_config',
  91. data: {
  92. device_type_id: 5,
  93. d_id: this.id,
  94. control_type: "data"
  95. }
  96. })
  97. console.log(res)
  98. if (res == true) {
  99. uni.showToast({
  100. title: '指令下发成功!'
  101. });
  102. } else {
  103. uni.showToast({
  104. title: '指令下发失败!'
  105. });
  106. }
  107. },
  108. clickLeft() { //返回
  109. uni.navigateBack({
  110. delta: 1
  111. })
  112. },
  113. ensure() { //提交
  114. this.timing(this.config)
  115. },
  116. sliderChange(e) { //滑动块
  117. this.config.interval = e.detail.value
  118. },
  119. chongqi() { //重启按钮
  120. this.restart('reboot')
  121. },
  122. shengji() { //升级按钮
  123. this.restart('update')
  124. },
  125. search() { //查询按钮
  126. this.uploading()
  127. }
  128. },
  129. onLoad(option) {
  130. this.id = option.id
  131. }
  132. }
  133. </script>
  134. <style lang="scss">
  135. .operation_title {
  136. border-left: 6rpx solid #28AE4F;
  137. padding-left: 20rpx;
  138. margin-bottom: 20rpx;
  139. height: 36rpx;
  140. }
  141. .operation {
  142. position: absolute;
  143. top: 54px;
  144. width: 90%;
  145. left: 5%;
  146. .operation_btn {
  147. display: flex;
  148. padding-left: 20rpx;
  149. button {
  150. font-size: 24rpx;
  151. padding: 0 38rpx;
  152. background-color: #28AE4F;
  153. color: #FFFFFF;
  154. }
  155. button:last-child {
  156. width: 360rpx !important;
  157. }
  158. }
  159. }
  160. .viewing {
  161. position: absolute;
  162. top: 124px;
  163. width: 90%;
  164. left: 5%;
  165. .viewing_text {
  166. .viewing_text_top,
  167. .viewing_text_bot {
  168. display: flex;
  169. background-color: #F7F8FA;
  170. padding-left: 20rpx;
  171. margin-bottom: 20rpx;
  172. height: 60rpx;
  173. line-height: 60rpx;
  174. font-size: 24rpx;
  175. input {
  176. font-size: 24rpx;
  177. margin-top: 16rpx;
  178. width: 400rpx;
  179. }
  180. }
  181. }
  182. }
  183. .timing {
  184. position: absolute;
  185. top: 234px;
  186. width: 90%;
  187. left: 5%;
  188. }
  189. .ensure {
  190. width: 100%;
  191. position: absolute;
  192. top: 600rpx;
  193. .ensure_btn {
  194. width: 90%;
  195. margin: 0 auto;
  196. height: 60rpx;
  197. line-height: 60rpx;
  198. text-align: center;
  199. background-color: #28AE4F;
  200. color: #FFFFFF;
  201. border-radius: 200rpx;
  202. }
  203. }
  204. </style>