note.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" title="短信预警"></uni-nav-bar>
  7. </view>
  8. <view class="earlywarning">
  9. <view class="kind">
  10. <view class="kind_top">
  11. <p class="kind_top_title">目标种类预警</p>
  12. <u-switch v-model="checked1" size="30" style="margin-top: 6rpx;" active-color="#58C876"></u-switch>
  13. </view>
  14. <view class="kind_bot">
  15. <p class="kind_bot_title">害虫种类数量设置:</p>
  16. <input type="number" v-model="form.pestCategoryNum" :disabled="!checked1" />
  17. </view>
  18. <p class="hint">(每天害虫种类数量达到此数量时,短信预警)</p>
  19. </view>
  20. <view class="kind">
  21. <view class="kind_top">
  22. <p class="kind_top_title">指定害虫数量预警</p>
  23. <u-switch v-model="checked2" size="30" style="margin-top: 6rpx;" active-color="#58C876"></u-switch>
  24. </view>
  25. <view class="kind_bot">
  26. <p class="kind_bot_title">害虫种类:</p>
  27. <view class="input" @click="pickertf = !pickertf">
  28. <input type="text" v-model="selector[form.appointPestName]" :disabled="!checked2" />
  29. <u-icon name="arrow-down" class="icon"></u-icon>
  30. <u-picker v-model="pickertf" mode="selector" @confirm="confirmFun2" :default-selector="[form.appointPestName]"
  31. :range="selector"></u-picker>
  32. </view>
  33. </view>
  34. <view class="kind_bot">
  35. <p class="kind_bot_title">害虫数量:</p>
  36. <input type="number" v-model="form.appointPestNum" :disabled="!checked2" />
  37. </view>
  38. <p class="hint">(每天指定害虫数量达到此数量时,短信预警)</p>
  39. </view>
  40. <view class="kind">
  41. <view class="kind_top">
  42. <p class="kind_top_title">害虫数量总和预警</p>
  43. <u-switch v-model="checked3" size="30" style="margin-top: 6rpx;" active-color="#58C876"></u-switch>
  44. </view>
  45. <view class="kind_bot">
  46. <p class="kind_bot_title">害虫总和数量设置:</p>
  47. <input type="number" v-model="form.pestTotalNum" :disabled="!checked3" />
  48. </view>
  49. <p class="hint">(每天害虫数量总和达到此数量时,短信预警)</p>
  50. </view>
  51. <view class="kind">
  52. <view class="kind_top">
  53. <p class="kind_top_title">综合预警</p>
  54. <u-switch v-model="checked4" size="30" style="margin-top: 6rpx;" active-color="#58C876"></u-switch>
  55. </view>
  56. <view class="kind_bot">
  57. <p class="kind_bot_title">每天检测害虫种类及数量,短信预警</p>
  58. </view>
  59. </view>
  60. <view class="kind">
  61. <view class="kind_top">
  62. <p class="kind_top_title">信息接受</p>
  63. </view>
  64. <view class="kind_bot">
  65. <p class="kind_bot_title">信息接受手机号:</p>
  66. <input type="number" v-model="form.phone" @blur="phonereg" />
  67. </view>
  68. <p class="hint" v-if="phonetf">请输入正确的手机号</p>
  69. </view>
  70. <view class="tijiao" @click="btn">
  71. 确 定
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. import cbddatas from "../../../../static/data/cbd_pest_library.js"
  79. export default {
  80. data() {
  81. return {
  82. checked1: false,
  83. checked2: false,
  84. checked3: false,
  85. checked4: false,
  86. pickertf: false,
  87. device_id: '',
  88. conf: "",
  89. form: {},
  90. phonetf: false,
  91. selector: []
  92. }
  93. },
  94. methods: {
  95. async notealloc() { //查询短信配置
  96. const res = await this.$myRequest({
  97. url: '/api/api_gateway?method=forecast.forecast_system.cbd_msg_conf',
  98. data: {
  99. device_id: this.device_id,
  100. conf: this.conf
  101. }
  102. })
  103. this.form = JSON.parse(res)
  104. console.log(this.form)
  105. //种类
  106. if (this.form.pestCategory == "on") {
  107. this.checked1 = true
  108. } else {
  109. this.checked1 = false
  110. }
  111. //pestTotal 总和开关
  112. if (this.form.pestTotal == "on") {
  113. this.checked3 = true
  114. } else {
  115. this.checked3 = false
  116. }
  117. //pestWarn综合预警
  118. if (this.form.pestWarn == "on") {
  119. this.checked4 = true
  120. } else {
  121. this.checked4 = false
  122. }
  123. //appointPest指定害虫
  124. if (this.form.appointPest == "on") {
  125. this.checked2 = true
  126. } else {
  127. this.checked2 = false
  128. }
  129. },
  130. btn() {
  131. if (this.checked1 == true) {
  132. this.form.pestCategory = "on"
  133. } else {
  134. this.form.pestCategory = "off"
  135. }
  136. //pestTotal 总和开关
  137. if (this.checked3 == true) {
  138. this.form.pestTotal = "on"
  139. } else {
  140. this.form.pestTotal = "off"
  141. }
  142. //pestWarn综合预警
  143. if (this.checked4 == true) {
  144. this.form.pestWarn = "on"
  145. } else {
  146. this.form.pestWarn = "off"
  147. }
  148. //appointPest指定害虫
  149. if (this.checked2 == true) {
  150. this.form.appointPest = "on"
  151. } else {
  152. this.form.appointPest = "off"
  153. }
  154. // console.log(this.form)
  155. this.conf = JSON.stringify(this.form)
  156. this.notealloc()
  157. uni.navigateBack({
  158. delta: 1
  159. })
  160. },
  161. phonereg() {
  162. if (/^1[23456789]\d{9}$/.test(this.form.phone)) {
  163. this.phonetf = false
  164. } else {
  165. this.phonetf = true
  166. }
  167. },
  168. confirmFun2(index) {
  169. this.form.appointPestName = index
  170. },
  171. clickLeft() {
  172. uni.navigateBack({
  173. delta: 1
  174. })
  175. }
  176. },
  177. onLoad(option) {
  178. this.device_id = option.device_id
  179. this.notealloc()
  180. for (var key in cbddatas) {
  181. this.selector[key] = cbddatas[key]
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss">
  187. .earlywarning {
  188. position: absolute;
  189. top: 54px;
  190. width: 100%;
  191. .kind {
  192. width: 90%;
  193. margin: 0 auto 40rpx;
  194. .kind_top {
  195. display: flex;
  196. justify-content: space-between;
  197. .kind_top_title {
  198. border-left: 8rpx solid #28AE4F;
  199. height: 40rpx;
  200. padding-left: 20rpx;
  201. }
  202. }
  203. .kind_bot {
  204. display: flex;
  205. padding-left: 28rpx;
  206. margin: 30rpx 0 0;
  207. .kind_bot_title {
  208. font-size: 26rpx;
  209. color: #A7A7A7;
  210. margin-right: 10rpx;
  211. }
  212. input {
  213. border: 2rpx solid #E4E4E4;
  214. font-size: 26rpx;
  215. width: 55%;
  216. padding-left: 10rpx;
  217. }
  218. .input {
  219. position: relative;
  220. width: 55%;
  221. input {
  222. width: 100%;
  223. }
  224. .icon {
  225. position: absolute;
  226. top: 10rpx;
  227. right: 0;
  228. }
  229. }
  230. }
  231. .hint {
  232. font-size: 24rpx;
  233. text-align: right;
  234. color: #ff0000;
  235. margin-top: 10rpx;
  236. }
  237. }
  238. .tijiao {
  239. width: 90%;
  240. text-align: center;
  241. font-size: 34rpx;
  242. height: 60rpx;
  243. line-height: 60rpx;
  244. color: #FFFFFF;
  245. background-color: #28AE4F;
  246. margin: 80rpx auto 0;
  247. border-radius: 30rpx;
  248. }
  249. }
  250. </style>