timeSet.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view class="content">
  3. <view class="box-title">当前定时{{ title }}时间</view>
  4. <timeSelector showType="time" @btnConfirm="btnConfirm0" @btnCancel="btnCancel0">
  5. <view class="box-time">
  6. <input type="text" class="input" :value="time0" />
  7. </view>
  8. </timeSelector>
  9. <timeSelector showType="time" @btnConfirm="btnConfirm1" @btnCancel="btnCancel1">
  10. <view class="box-time">
  11. <input type="text" class="input" :value="time1" />
  12. </view>
  13. </timeSelector>
  14. <timeSelector showType="time" @btnConfirm="btnConfirm2" @btnCancel="btnCancel2">
  15. <view class="box-time">
  16. <input type="text" class="input" :value="time2" />
  17. </view>
  18. </timeSelector>
  19. <timeSelector showType="time" @btnConfirm="btnConfirm3" @btnCancel="btnCancel3">
  20. <view class="box-time">
  21. <input type="text" class="input" :value="time3" />
  22. </view>
  23. </timeSelector>
  24. <timeSelector showType="time" @btnConfirm="btnConfirm4" @btnCancel="btnCancel4">
  25. <view class="box-time">
  26. <input type="text" class="input" :value="time4" />
  27. </view>
  28. </timeSelector>
  29. <timeSelector showType="time" @btnConfirm="btnConfirm5" @btnCancel="btnCancel5">
  30. <view class="box-time">
  31. <input type="text" class="input" :value="time5" />
  32. </view>
  33. </timeSelector>
  34. <timeSelector showType="time" @btnConfirm="btnConfirm6" @btnCancel="btnCancel6">
  35. <view class="box-time">
  36. <input type="text" class="input" :value="time6" />
  37. </view>
  38. </timeSelector>
  39. <timeSelector showType="time" @btnConfirm="btnConfirm7" @btnCancel="btnCancel7">
  40. <view class="box-time">
  41. <input type="text" class="input" :value="time7" />
  42. </view>
  43. </timeSelector>
  44. <timeSelector showType="time" @btnConfirm="btnConfirm8" @btnCancel="btnCancel8">
  45. <view class="box-time">
  46. <input type="text" class="input" :value="time8" />
  47. </view>
  48. </timeSelector>
  49. <timeSelector showType="time" @btnConfirm="btnConfirm9" @btnCancel="btnCancel9">
  50. <view class="box-time">
  51. <input type="text" class="input" :value="time9" />
  52. </view>
  53. </timeSelector>
  54. <view class="bu">
  55. <button type="primary" @click="submit()" class="button">
  56. <p class="p">提交</p>
  57. </button>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import {
  63. mapState,
  64. mapActions,
  65. mapMutations
  66. } from 'vuex';
  67. import timeSelector from '@/components/wing-time-selector/wing-time-selector.vue';
  68. export default {
  69. components: {
  70. timeSelector
  71. },
  72. data() {
  73. return {
  74. title: '',
  75. time0: '',
  76. time1: '',
  77. time2: '',
  78. time3: '',
  79. time4: '',
  80. time5: '',
  81. time6: '',
  82. time7: '',
  83. time8: '',
  84. time9: ''
  85. };
  86. },
  87. onLoad() {
  88. var timeFlag = uni.getStorageSync("timeFlag");
  89. var rule;
  90. if(timeFlag=='boot'){
  91. this.title = '开机';
  92. rule = uni.getStorageSync("bootTime");
  93. }
  94. if(timeFlag=='off'){
  95. this.title = '关机';
  96. rule = uni.getStorageSync("offTime");
  97. }
  98. var rules = rule.split(",");
  99. if(rules.length>0){
  100. for(var i=0;i<rules.length;i++){
  101. switch (i) {
  102. case 0:
  103. this.time0=rules[i];
  104. break;
  105. case 1:
  106. this.time1=rules[i];
  107. break;
  108. case 2:
  109. this.time2=rules[i];
  110. break;
  111. case 3:
  112. this.time3=rules[i];
  113. break;
  114. case 4:
  115. this.time4=rules[i];
  116. break;
  117. case 5:
  118. this.time5=rules[i];
  119. break;
  120. case 6:
  121. this.time6=rules[i];
  122. break;
  123. case 7:
  124. this.time7=rules[i];
  125. break;
  126. case 8:
  127. this.time8=rules[i];
  128. break;
  129. case 9:
  130. this.time9=rules[i];
  131. break;
  132. }
  133. }
  134. }
  135. },
  136. onShow() {
  137. },
  138. methods: {
  139. ...mapActions('chart', ['updateRule']),
  140. btnConfirm0(e) {
  141. console.log('确定时间为:', e);
  142. this.time0 = e.key;
  143. },
  144. btnCancel0() {
  145. this.time0 = '';
  146. },
  147. btnConfirm1(e) {
  148. this.time1 = e.key;
  149. },
  150. btnCancel1() {
  151. this.time1 = '';
  152. },
  153. btnConfirm2(e) {
  154. this.time2 = e.key;
  155. },
  156. btnCancel2() {
  157. this.time2 = '';
  158. },
  159. btnConfirm3(e) {
  160. this.time3 = e.key;
  161. },
  162. btnCancel3() {
  163. this.time3 = '';
  164. },
  165. btnConfirm4(e) {
  166. this.time4 = e.key;
  167. },
  168. btnCancel4() {
  169. this.time4 = '';
  170. },
  171. btnConfirm5(e) {
  172. this.time5 = e.key;
  173. },
  174. btnCancel5() {
  175. this.time5 = '';
  176. },
  177. btnConfirm6(e) {
  178. this.time6 = e.key;
  179. },
  180. btnCancel6() {
  181. this.time6 = '';
  182. },
  183. btnConfirm7(e) {
  184. this.time7 = e.key;
  185. },
  186. btnCancel7() {
  187. this.time7 = '';
  188. },
  189. btnConfirm8(e) {
  190. this.time8 = e.key;
  191. },
  192. btnCancel8() {
  193. this.time8 = '';
  194. },
  195. btnConfirm9(e) {
  196. this.time9 = e.key;
  197. },
  198. btnCancel9() {
  199. this.time9 = '';
  200. },
  201. submit() {
  202. var rules = [];
  203. if (this.time0 != '') {
  204. rules.push(this.time0);
  205. }
  206. if (this.time1 != '') {
  207. rules.push(this.time1);
  208. }
  209. if (this.time2 != '') {
  210. rules.push(this.time2);
  211. }
  212. if (this.time3 != '') {
  213. rules.push(this.time3);
  214. }
  215. if (this.time4 != '') {
  216. rules.push(this.time4);
  217. }
  218. if (this.time5 != '') {
  219. rules.push(this.time5);
  220. }
  221. if (this.time6 != '') {
  222. rules.push(this.time6);
  223. }
  224. if (this.time7 != '') {
  225. rules.push(this.time7);
  226. }
  227. if (this.time8 != '') {
  228. rules.push(this.time8);
  229. }
  230. if (this.time9 != '') {
  231. rules.push(this.time9);
  232. }
  233. var rule;
  234. if (rules.length > 0) {
  235. rule = rules.join(",");
  236. }
  237. const param = {};
  238. var equipmentId = uni.getStorageSync("timeSet");
  239. if (equipmentId != '') {
  240. param['id'] = equipmentId;
  241. }
  242. var timeFlag = uni.getStorageSync("timeFlag");
  243. if(timeFlag=='boot'){
  244. param['bootTime'] =rules.toString();
  245. }
  246. if(timeFlag=='off'){
  247. param['offTime'] =rules.toString();
  248. }
  249. return this.updateRule(param)
  250. .then(data => {
  251. if (data.message == "SUCCESS") {
  252. uni.setStorageSync("bootTime",data.data.bootTime);
  253. uni.setStorageSync("offTime",data.data.offTime);
  254. uni.showToast({
  255. title: "修改成功",
  256. icon: 'none',
  257. duration: 1000
  258. });
  259. }
  260. if (data == "ERROR") {
  261. uni.showToast({
  262. title: "修改失败",
  263. icon: 'none',
  264. duration: 1000
  265. });
  266. }
  267. if (data == "") {
  268. uni.showToast({
  269. title: "修改异常",
  270. icon: 'none',
  271. duration: 1000
  272. });
  273. }
  274. }, _ => void uni.stopPullDownRefresh());
  275. },
  276. }
  277. };
  278. </script>
  279. <style>
  280. .box-title {
  281. margin: 24upx;
  282. font-size: 40upx;
  283. font-weight: bold;
  284. color: #333333;
  285. padding-left: 40upx;
  286. }
  287. .box-time {
  288. margin: 24upx;
  289. font-size: 30upx;
  290. color: #3496fb;
  291. padding-top: 10upx;
  292. padding-left: 40upx;
  293. }
  294. .input {
  295. /* padding: 10upx 20upx 10upx 0upx; */
  296. padding-left: 20upx;
  297. padding-top: 10upx;
  298. background-color: #FFFFFF;
  299. width: 600upx;
  300. height: 50upx;
  301. box-shadow: 0upx 0upx 20upx #D3D3D3;
  302. border-radius: 5upx;
  303. }
  304. .bu {
  305. font-size: 50upx
  306. }
  307. .button {
  308. width: 220upx;
  309. height: 100upx;
  310. }
  311. .p {
  312. /* transform: translateY(-8upx); */
  313. font-size: 50upx
  314. }
  315. </style>