modulation.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <!-- 音量调节 -->
  3. <div class="page flex-col">
  4. <s-header :name="$t('device.parameterAdjustment')" :noback="false"></s-header>
  5. <div class="wrap1 flex-col">
  6. <div class="box2 flex-col">
  7. <div class="section3 flex-row justify-between">
  8. <div class="box3 flex-col"></div>
  9. <span class="info1">{{$t('device.equipmentName')}}:{{deviceDetal ? deviceDetal.name : ''}}</span>
  10. </div>
  11. <img
  12. class="img1"
  13. referrerpolicy="no-referrer"
  14. src="https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPng8947935ab81635fdedd8124b11e305eef66286421b69c84fef22233014a3fa9a"
  15. />
  16. </div>
  17. <div class="box4 flex-row justify-between">
  18. <span class="word3">{{$t('device.slideSliderToAdjustVolume')}}</span>
  19. <span class="word4">{{volume}}</span>
  20. </div>
  21. <van-slider v-model="volume" :max="15"/>
  22. <van-button round type="primary" class="volumeChangeButton" @click="volumeChange()">{{$t('device.submitModification')}}</van-button>
  23. <!-- <div class="box6 flex-col"><span class="word5">提交修改</span></div> -->
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { onMounted, ref } from 'vue';
  29. import sHeader from "@/components/SimpleHeader";
  30. import { useRoute, useRouter } from 'vue-router';
  31. import { getDeviceDetal, updateVolume } from '@/service/device'
  32. import { Toast, Dialog } from 'vant';
  33. import { useI18n } from 'vue-i18n';
  34. export default {
  35. setup() {
  36. const { t } = useI18n();
  37. const route = useRoute();
  38. const router = useRouter();
  39. const deviceId = route.query.deviceId;
  40. const deviceDetal = ref(null);
  41. const volume = ref(0);
  42. // 初始化页面获取列表
  43. onMounted(async () => {
  44. getDeviceDetalFun();
  45. console.log(deviceId);
  46. });
  47. // 获取设备列表数据
  48. const getDeviceDetalFun = async () => {
  49. const { data } = await getDeviceDetal({id : deviceId});
  50. if (data.code === '00000') {
  51. deviceDetal.value = data.data;
  52. volume.value = data.data.volume ? data.data.volume : 0;
  53. } else { Toast.fail(data.message); }
  54. }
  55. // 音量调节保存
  56. const volumeChange = async () => {
  57. // const volumeB = 15 / 100 ;
  58. // const volumeC = parseInt(volume.value * volumeB);
  59. const { data } = await updateVolume({id: deviceId, volume: volume.value.toString()});
  60. if (data.code) {
  61. Dialog.alert({
  62. confirmButtonColor: '#4d6add',
  63. message: t('device.sentSuccessfully'),
  64. }).then(() => {
  65. //返回上一页
  66. router.go(-1);
  67. });
  68. } else { Toast.fail(data.message); }
  69. console.log('volumeChange', {equipmentId: deviceId, volume: volume.value.toString()});
  70. }
  71. return {
  72. deviceDetal,
  73. volume,
  74. volumeChange
  75. };
  76. },
  77. components: { sHeader },
  78. };
  79. </script>
  80. <style lang="less" scoped>
  81. @import "../../common/style/common";
  82. .page {
  83. background-color: rgba(255, 255, 255, 1);
  84. position: relative;
  85. width: 100%;
  86. height: calc(100vh - 44px);
  87. overflow: hidden;
  88. .van-slider {
  89. width: 92%;
  90. height: 4px;
  91. margin: 0 auto;
  92. margin-top: 35px;
  93. background-color: #dfdfe5;
  94. .van-slider__bar {
  95. background-color: rgba(77, 193, 147, 1);
  96. }
  97. .van-slider__button {
  98. background-color: rgba(77, 193, 147, 1);
  99. width: 16px;
  100. height: 16px;
  101. }
  102. }
  103. .volumeChangeButton {
  104. background-color: #4d6add;
  105. width: 220px;
  106. height: 34px;
  107. margin: 49px auto;
  108. .van-button__text { font-size: 15px; }
  109. }
  110. .wrap1 {
  111. width: 100%;
  112. height: 274px;
  113. .box2 {
  114. background-color: rgba(255, 255, 255, 1);
  115. z-index: 23;
  116. height: 54px;
  117. margin-top: 1px;
  118. width: 100%;
  119. position: relative;
  120. .section3 {
  121. width: 162px;
  122. height: 20px;
  123. margin: 17px 0 0 15px;
  124. .box3 {
  125. background-color: rgba(128, 150, 236, 1);
  126. border-radius: 2px;
  127. width: 4px;
  128. height: 12px;
  129. margin-top: 4px;
  130. }
  131. .info1 {
  132. width: 150px;
  133. height: 20px;
  134. overflow-wrap: break-word;
  135. color: rgba(64, 77, 116, 1);
  136. font-size: 14px;
  137. font-family: PingFangSC-Medium;
  138. text-align: left;
  139. white-space: nowrap;
  140. line-height: 20px;
  141. display: block;
  142. }
  143. }
  144. .img1 {
  145. z-index: 31;
  146. position: absolute;
  147. left: 0;
  148. top: 53px;
  149. width: 100%;
  150. height: 2px;
  151. }
  152. }
  153. .box4 {
  154. width: 147px;
  155. height: 14px;
  156. margin: 19px 0 0 15px;
  157. .word3 {
  158. width: 104px;
  159. height: 13px;
  160. overflow-wrap: break-word;
  161. color: rgba(64, 77, 116, 1);
  162. font-size: 13px;
  163. text-align: left;
  164. white-space: nowrap;
  165. line-height: 13px;
  166. margin-top: 1px;
  167. display: block;
  168. }
  169. .word4 {
  170. width: 33px;
  171. height: 13px;
  172. overflow-wrap: break-word;
  173. color: rgba(64, 77, 116, 1);
  174. font-size: 15px;
  175. font-family: PingFangSC-Medium;
  176. text-align: left;
  177. white-space: nowrap;
  178. line-height: 15px;
  179. display: block;
  180. }
  181. }
  182. }
  183. }
  184. </style>