volume.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view>
  3. <view class="search">
  4. <view class="search-title">
  5. {{$t('dosugar.equipmentClientID')}}
  6. </view>
  7. <view class="search-input">
  8. <input type="text" :placeholder="$t('dosugar.placeholder')" v-model="searchClientId" />
  9. </view>
  10. <view class="search-button">
  11. <button type="primary" size="mini" class="" @click="search()">
  12. <p class="">{{$t('dosugar.search')}}</P>
  13. </button>
  14. </view>
  15. </view>
  16. <view class="td-right">
  17. <view class="uni-list">
  18. <view class="uni-list-cell">
  19. <view class="uni-list-cell-left">
  20. {{$t('dosugar.chooseEquipment')}}
  21. </view>
  22. <view class="uni-list-cell-db" style="overflow: hidden;text-overflow: ellipsis;">
  23. <picker @change="changeEquipment" :value="index" :range="equipmentNameList">
  24. <view class="uni-input">{{equipmentNameList[index]}}</view>
  25. </picker>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="uni-title">{{$t('volume.volu')}}</view>
  31. <view>
  32. <slider :value="volume" @change="sliderChange" min="0" max="15" show-value />
  33. </view>
  34. <view class="tr">
  35. <button type="primary" formType="submit" @click="update()" class="button">
  36. <p class="p1">{{$t('flowers.submit')}}</p>
  37. </button>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. mapState,
  44. mapActions,
  45. mapMutations
  46. } from 'vuex'
  47. export default {
  48. data() {
  49. return {
  50. index: null,
  51. equipmentName: null,
  52. equimentType: null,
  53. equipmentId: null,
  54. equipmentNameList: [],
  55. globalUser: null,
  56. show: true,
  57. volume:0,
  58. searchClientId: null
  59. }
  60. },
  61. onShow() {
  62. var token = uni.getStorageSync("token");
  63. this.globalUser = uni.getStorageSync("globalUser");
  64. uni.setNavigationBarTitle({
  65. title: this.$t('remoteList.volume')
  66. });
  67. if (token.length > 1) {
  68. this.getEquipmentListData();
  69. // this.getParam();
  70. } else {
  71. uni.reLaunch({
  72. url: '../Login/Login',
  73. });
  74. }
  75. },
  76. methods: {
  77. ...mapActions('chart', ['getParameters', 'updateParameters', 'getEquipmentListByUser','updata']),
  78. getEquipmentListData() {
  79. this.getEquipmentListByUser(this.globalUser)
  80. .then(data => {
  81. // this.merchantList = data;
  82. var listName = data[0].equipmentList;
  83. var equipmentNameList = [];
  84. for (var i = 0; i < listName.length; i++) {
  85. equipmentNameList.push(this.$t('common.name') + listName[i].name + ' , '+ this.$t('common.ID') + listName[i].clientId.substring(
  86. listName[i].clientId.length - 6, listName[i].clientId.length));
  87. }
  88. this.equipmentNameList = equipmentNameList;
  89. var listId = data[0].id;
  90. if (listId != null && listId != '1') {
  91. uni.setStorageSync("listName", listName);
  92. }
  93. uni.stopPullDownRefresh();
  94. }, _ => void uni.stopPullDownRefresh());
  95. },
  96. search() {
  97. var clientId = this.searchClientId;
  98. var list = uni.getStorageSync("listName");
  99. var n = 0;
  100. for (var i = 0; i < list.length; i++) {
  101. var code = list[i].clientId.substring(list[i].clientId.length - 6, list[i].clientId.length);
  102. if (code == clientId) {
  103. n++;
  104. this.index = i;
  105. var id = list[i].id;
  106. this.equipmentId = id;
  107. this.clientId = list[i].clientId;
  108. this.volume = list[i].volume;
  109. break;
  110. }
  111. }
  112. if (n == 0) {
  113. uni.showModal({
  114. title: "提示",
  115. content: "找不到该机器",
  116. success: (res) => {
  117. }
  118. })
  119. }
  120. },
  121. sliderChange(e) {
  122. this.volume = e.detail.value;
  123. // console.log('音量发生变化:' + this.volume)
  124. },
  125. //改变机器
  126. changeEquipment: function(e) {
  127. this.searchClientId = null;
  128. this.index = e.target.value;
  129. var list = uni.getStorageSync("listName");
  130. this.equipmentId = list[e.target.value].id;
  131. this.clientId = list[e.target.value].clientId;
  132. this.volume = list[e.target.value].volume;
  133. },
  134. update() {
  135. uni.showModal({
  136. title: "提示",
  137. content: "是否修改音量?",
  138. success: (res) => {
  139. if (res.confirm) {
  140. const param = {};
  141. param['id'] = this.equipmentId;
  142. param['volume'] = this.volume;
  143. if (param != null) {
  144. this.updata(param)
  145. .then(res => {
  146. uni.showModal({
  147. title: '提示',
  148. content: res.message,
  149. });
  150. }, _ => void uni.stopPullDownRefresh());
  151. }
  152. } else if (res.cancel) {
  153. }
  154. }
  155. })
  156. },
  157. }
  158. }
  159. </script>
  160. <style>
  161. .search {
  162. width: 100%;
  163. padding-top: 30upx;
  164. display: flex;
  165. flex-direction: row;
  166. justify-content: flex-start;
  167. }
  168. .search-title {
  169. width: 28%;
  170. text-align: center;
  171. font-size: 26upx;
  172. font-family: "PingFang-SC-Bold";
  173. }
  174. .search-input{
  175. width: 48%;
  176. height: 25px;
  177. text-align: center;
  178. font-size: 26upx;
  179. /* font-family: "PingFang-SC-Bold"; */
  180. box-shadow: 0upx 0upx 20upx #D3D3D3;
  181. border-radius: 5upx;
  182. }
  183. .search-button{
  184. width: 20%;
  185. padding-left: 10px;
  186. padding-bottom: 5px;
  187. text-align: center;
  188. height: 60upx;
  189. text-align: left;
  190. }
  191. .line {
  192. height: 50upx;
  193. }
  194. .line2 {
  195. height: 10upx;
  196. }
  197. .body {
  198. background-color: #FFFFFF;
  199. width: 700upx;
  200. padding: 10upx 10upx 10upx 10upx;
  201. display: flex;
  202. flex-direction: row;
  203. justify-content: flex-start;
  204. font-size: 32upx;
  205. }
  206. .tr {
  207. padding-top: 15upx;
  208. display: flex;
  209. flex-direction: row;
  210. justify-content: flex-start;
  211. font-size: 48upx;
  212. font-family: "PingFang-SC-Bold";
  213. position: fixed;
  214. bottom: 100upx;
  215. width: 100%;
  216. }
  217. .p1 {
  218. font-size: 48upx;
  219. }
  220. .p {
  221. width: 350upx;
  222. text-align: right;
  223. }
  224. .input {
  225. width: 200upx;
  226. box-shadow: 0upx 0upx 20upx #D3D3D3;
  227. border-radius: 5upx;
  228. text-align: center;
  229. }
  230. .button {
  231. margin: auto;
  232. width: 60%;
  233. height: 100upx;
  234. }
  235. .p2 {
  236. font-size: 30upx;
  237. /* #ifndef H5 */
  238. padding-top: 3upx;
  239. /* #endif */
  240. position: absolute;
  241. /* 水平居中 */
  242. left: 50%;
  243. -webkit-transform: translateX(-50%);
  244. transform: translateX(-50%);
  245. }
  246. .uni-title{
  247. padding-left: 20upx;
  248. font-size: 26upx;
  249. font-family: "PingFang-SC-Bold";
  250. }
  251. </style>