note.vue 6.3 KB

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