devControl.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="device-details-page">
  3. <cu-custom :isBack="true">
  4. <template slot="content">
  5. <view class="nav-title">参数设置</view>
  6. </template>
  7. </cu-custom>
  8. <view class="control-board">
  9. <view class="title">操作</view>
  10. <text style="color:red">注:步长值最小值10cm、最大值200cm且为整数</text>
  11. <u-form :model="form" ref="uForm" label-width="200rpx">
  12. <u-form-item label="第1层步长值">
  13. <view style="display:flex;justify-content: space-between">
  14. <u-input v-model="form.depth[0]" max="200" min="10" maxlength="3" />cm
  15. </view>
  16. </u-form-item>
  17. <u-form-item label="第2层步长值">
  18. <view style="display:flex;justify-content: space-between;">
  19. <u-input v-model="form.depth[1]" max="200" min="10" maxlength="3" />cm
  20. </view>
  21. </u-form-item>
  22. <u-form-item label="第3层步长值">
  23. <view style="display:flex;justify-content: space-between">
  24. <u-input v-model="form.depth[2]" max="200" min="10" maxlength="3" />cm
  25. </view>
  26. </u-form-item>
  27. </u-form>
  28. <u-button type="success" class="sub-btn" @click="submitControlParams()">确定</u-button>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. onLoad(options) {
  35. const deviceInfo = JSON.parse(decodeURIComponent(options.deviceInfo));
  36. this.deviceInfo = deviceInfo;
  37. this.getDevControlParams();
  38. },
  39. data() {
  40. return {
  41. deviceInfo: {},
  42. form: {
  43. depth: [],
  44. },
  45. };
  46. },
  47. methods: {
  48. async getDevControlParams() {
  49. await this.$myRequest({
  50. url: '/api/api_gateway?method=weather.weather.nd_topic_change',
  51. data: {
  52. device_id: this.deviceInfo.devBid,
  53. }
  54. }).then(res => {
  55. const depth = res.depth.split(',') || [];
  56. this.form.depth = depth
  57. })
  58. },
  59. async submitControlParams(){
  60. if(this.form.depth.length !== 3){
  61. uni.showToast({
  62. title: "请输入3个步长值",
  63. icon: "none",
  64. });
  65. return
  66. }
  67. if(!this.form.depth.every(item => item >= 10 && item <= 200 && Number.isInteger(Number(item)))){
  68. uni.showToast({
  69. title: "请输入正确的步长值",
  70. icon: "none",
  71. });
  72. return
  73. }
  74. await this.$myRequest({
  75. url: '/api/api_gateway?method=weather.weather.nd_topic_change',
  76. data: {
  77. device_id: this.deviceInfo.devBid,
  78. depth: this.form.depth.join(','),
  79. }
  80. }).then(res => {
  81. uni.showToast({
  82. title: "操作成功",
  83. icon: "none",
  84. });
  85. });
  86. },
  87. },
  88. };
  89. </script>
  90. <style lang="scss" scoped>
  91. .device-details-page {
  92. background: linear-gradient(
  93. 180deg,
  94. #ffffff00 0%,
  95. #f5f6fa 23.64%,
  96. #f5f6fa 100%
  97. ),
  98. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  99. min-height: 100vh;
  100. padding: 0 32rpx;
  101. padding-top: 98rpx;
  102. }
  103. .nav-title{
  104. text-align: center;
  105. }
  106. .control-board {
  107. border-radius: 16rpx;
  108. background: #fff;
  109. padding: 32rpx;
  110. margin-top: 46rpx;
  111. .title {
  112. margin-bottom: 16rpx;
  113. color: #303133;
  114. font-size: 28rpx;
  115. font-weight: 400;
  116. }
  117. .date-title {
  118. margin-bottom: 52rpx;
  119. }
  120. .reload-btn {
  121. width: 100%;
  122. background: #0bbc58;
  123. margin-bottom: 48rpx;
  124. border-radius: 16rpx;
  125. }
  126. .date-slider {
  127. }
  128. }
  129. .footer-board {
  130. border-top: 2rpx solid #e4e7ed;
  131. background: #fff;
  132. position: fixed;
  133. bottom: 0;
  134. left: 0;
  135. right: 0;
  136. height: 164rpx;
  137. padding: 16rpx 32rpx 0 32rpx;
  138. .sub-btn {
  139. width: 100%;
  140. background: #0bbc58;
  141. border-radius: 16rpx;
  142. }
  143. }
  144. </style>