健康同学微信公众号h5项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

224 line
5.5KB

  1. <template>
  2. <div class="location-monitor-container">
  3. <!-- nav -->
  4. <div class="nav-bar">
  5. <van-nav-bar title="场景模式" left-text="返回" @click-left="onNavBack" left-arrow>
  6. <template #right>
  7. <!-- <div class="setupClock_save" @click="onSubmit">保存</div> -->
  8. <van-button type="primary" @click="onSubmit" size="small">保存</van-button>
  9. </template>
  10. </van-nav-bar>
  11. </div>
  12. <!-- main -->
  13. <div class="main">
  14. <div class="list">
  15. <div class="item">
  16. <div class="top">
  17. <div class="left">
  18. <span class="title">省电模式</span>
  19. </div>
  20. <div class="right">
  21. <!-- <img :src="rightIcon" alt=""> -->
  22. <van-switch v-model="checked" :active-color="$green" />
  23. </div>
  24. </div>
  25. <div class="bottom">
  26. <p>开启后能延长设备的续航时间,但只能打电话</p>
  27. </div>
  28. </div>
  29. <div :class="['item']">
  30. <div class="top">
  31. <div class="left">
  32. <span class="title">常规模式</span>
  33. </div>
  34. </div>
  35. <div class="bottom radios">
  36. <div class="radio-group">
  37. <van-radio-group v-model="radio" direction="horizontal">
  38. <van-radio name="1" :disabled="checked">标准</van-radio>
  39. <van-radio name="2" :disabled="true">个性</van-radio>
  40. </van-radio-group>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. import ToastService from '@/services/toast-service';
  50. import DialogService from '@/services/dialog-service';
  51. import APIHealthy from '@/api/heathly';
  52. export default {
  53. name: '',
  54. data() {
  55. return {
  56. rightIcon: require('../../../assets/img/health/right_more.png'),
  57. checked: false,
  58. selectConfirmActive: 0,
  59. radio: '1',
  60. modeId: null || 1,
  61. roleId: null
  62. };
  63. },
  64. watch: {
  65. checked: {
  66. handler(n) {
  67. if (n === true) {
  68. this.modeId = 2;
  69. } else {
  70. this.modeId = 1;
  71. }
  72. },
  73. deep: true
  74. },
  75. radio: {
  76. handler(n) {
  77. if (n === '1') {
  78. this.modeId = 1;
  79. this.checked = false;
  80. } else if (n === '3') {
  81. this.modeId = 3;
  82. this.checked = false;
  83. }
  84. },
  85. deep: true
  86. }
  87. },
  88. computed: {
  89. imei() {
  90. return this.$store.getters.serialNo;
  91. }
  92. },
  93. created() {
  94. this.getWatchConfig();
  95. //this.getLocationConfig();
  96. },
  97. methods: {
  98. // 返回
  99. onNavBack() {
  100. this.$router.push({
  101. name: 'watchSetting'
  102. });
  103. },
  104. // 保存
  105. onSubmit() {
  106. if (this.modeId == 3) {
  107. return DialogService.confirm({
  108. message: '请切换标准模式或者省电模式再保存'
  109. });
  110. }
  111. this.setWatchConfig();
  112. },
  113. // 设置设备数据上报周期
  114. setWatchConfig() {
  115. ToastService.loading({ message: '设置中' });
  116. let reqBody = {
  117. imei: this.imei,
  118. roleId: this.roleId,
  119. modeId: this.modeId
  120. };
  121. APIHealthy.setWatchConfig(reqBody)
  122. .then(res => {
  123. console.log('设置上报参数', res);
  124. const data = res.data;
  125. if (data.stateCode === 1) {
  126. ToastService.success({ message: '设置成功' });
  127. setTimeout(() => {
  128. this.$router.push({
  129. name: 'watchSetting'
  130. });
  131. }, 1500);
  132. } else {
  133. DialogService.confirm({
  134. title: '设置失败',
  135. message: `${res.data.message}`
  136. });
  137. }
  138. })
  139. .catch(error => {
  140. console.log('接口报错了', error);
  141. })
  142. .finally(() => {
  143. ToastService.clear();
  144. });
  145. },
  146. // 获取设备场景模式参数
  147. getWatchConfig() {
  148. APIHealthy.getWatchConfig(this.imei).then(res => {
  149. let data = res.data.data;
  150. if (data) {
  151. console.log('场景模式', data);
  152. const modeId = data.modeId;
  153. const roleId = data.roleId;
  154. this.modeId = modeId;
  155. this.roleId = roleId;
  156. if (modeId === 1) {
  157. this.radio = '1';
  158. } else if (modeId === 2) {
  159. this.checked = true;
  160. } else if (modeId === 3) {
  161. this.radio = '2';
  162. }
  163. } else {
  164. this.modeId = 1;
  165. this.roleId = this.$store.getters.roleUser === '1' ? 1 : 2;
  166. }
  167. });
  168. }
  169. }
  170. };
  171. </script>
  172. <style lang="scss"></style>
  173. <style scoped lang="scss">
  174. .location-monitor-container {
  175. height: 100vh;
  176. overflow: hidden;
  177. .nav-bar {
  178. height: 90px;
  179. padding: 0 20px;
  180. }
  181. .main {
  182. height: calc(100vh - 160px);
  183. background-color: $background;
  184. padding: 20px;
  185. .list {
  186. height: auto;
  187. border-radius: 8px;
  188. .item {
  189. padding: 20px 15px;
  190. margin: 20px 0;
  191. background-color: #fff;
  192. .top {
  193. height: 60px;
  194. display: flex;
  195. justify-content: space-between;
  196. align-items: center;
  197. }
  198. .bottom {
  199. display: flex;
  200. justify-content: flex-start;
  201. align-items: flex-start;
  202. margin: 10px 0;
  203. p {
  204. font-size: 32px;
  205. color: gray;
  206. /* line-height: 60px; */
  207. }
  208. &.radios {
  209. margin: 20px 0;
  210. @include center();
  211. font-size: 32px;
  212. }
  213. }
  214. }
  215. }
  216. }
  217. .title {
  218. font-size: 32px;
  219. }
  220. }
  221. </style>