volume.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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" 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. if (token.length > 1) {
  65. this.getEquipmentListData();
  66. // this.getParam();
  67. } else {
  68. uni.reLaunch({
  69. url: '../Login/Login',
  70. });
  71. }
  72. },
  73. methods: {
  74. ...mapActions('chart', ['getParameters', 'updateParameters', 'getEquipmentListByUser','updata']),
  75. getEquipmentListData() {
  76. this.getEquipmentListByUser(this.globalUser)
  77. .then(data => {
  78. // this.merchantList = data;
  79. var listName = data[0].equipmentList;
  80. var equipmentNameList = [];
  81. for (var i = 0; i < listName.length; i++) {
  82. equipmentNameList.push("名称:" + listName[i].name + " 编号:" + listName[i].clientId.substring(
  83. listName[i].clientId.length - 6, listName[i].clientId.length));
  84. }
  85. this.equipmentNameList = equipmentNameList;
  86. var listId = data[0].id;
  87. if (listId != null && listId != '1') {
  88. uni.setStorageSync("listName", listName);
  89. }
  90. uni.stopPullDownRefresh();
  91. }, _ => void uni.stopPullDownRefresh());
  92. },
  93. search() {
  94. var clientId = this.searchClientId;
  95. var list = uni.getStorageSync("listName");
  96. var n = 0;
  97. for (var i = 0; i < list.length; i++) {
  98. var code = list[i].clientId.substring(list[i].clientId.length - 6, list[i].clientId.length);
  99. if (code == clientId) {
  100. n++;
  101. this.index = i;
  102. var id = list[i].id;
  103. this.equipmentId = id;
  104. this.clientId = list[i].clientId;
  105. this.volume = list[i].volume;
  106. break;
  107. }
  108. }
  109. if (n == 0) {
  110. uni.showModal({
  111. title: "提示",
  112. content: "找不到该机器",
  113. success: (res) => {
  114. }
  115. })
  116. }
  117. },
  118. sliderChange(e) {
  119. this.volume = e.detail.value;
  120. // console.log('音量发生变化:' + this.volume)
  121. },
  122. //改变机器
  123. changeEquipment: function(e) {
  124. this.searchClientId = null;
  125. this.index = e.target.value;
  126. var list = uni.getStorageSync("listName");
  127. this.equipmentId = list[e.target.value].id;
  128. this.clientId = list[e.target.value].clientId;
  129. this.volume = list[e.target.value].volume;
  130. },
  131. update() {
  132. uni.showModal({
  133. title: "提示",
  134. content: "是否修改音量?",
  135. success: (res) => {
  136. if (res.confirm) {
  137. const param = {};
  138. param['id'] = this.equipmentId;
  139. param['volume'] = this.volume;
  140. if (param != null) {
  141. this.updata(param)
  142. .then(res => {
  143. uni.showModal({
  144. title: '提示',
  145. content: res.message,
  146. });
  147. }, _ => void uni.stopPullDownRefresh());
  148. }
  149. } else if (res.cancel) {
  150. }
  151. }
  152. })
  153. },
  154. }
  155. }
  156. </script>
  157. <style>
  158. .search {
  159. width: 100%;
  160. padding-top: 30upx;
  161. display: flex;
  162. flex-direction: row;
  163. justify-content: flex-start;
  164. }
  165. .search-title {
  166. width: 28%;
  167. text-align: center;
  168. font-size: 26upx;
  169. font-family: "PingFang-SC-Bold";
  170. }
  171. .search-input {
  172. width: 45%;
  173. text-align: center;
  174. font-size: 26upx;
  175. font-family: "PingFang-SC-Bold";
  176. box-shadow: 0upx 0upx 20upx #D3D3D3;
  177. border-radius: 5upx;
  178. }
  179. .search-button {
  180. width: 20%;
  181. padding-left: 7upx;
  182. text-align: center;
  183. }
  184. .line {
  185. height: 50upx;
  186. }
  187. .line2 {
  188. height: 10upx;
  189. }
  190. .body {
  191. background-color: #FFFFFF;
  192. width: 700upx;
  193. padding: 10upx 10upx 10upx 10upx;
  194. display: flex;
  195. flex-direction: row;
  196. justify-content: flex-start;
  197. font-size: 32upx;
  198. }
  199. .tr {
  200. padding-top: 15upx;
  201. display: flex;
  202. flex-direction: row;
  203. justify-content: flex-start;
  204. font-size: 48upx;
  205. font-family: "PingFang-SC-Bold";
  206. position: fixed;
  207. bottom: 100upx;
  208. width: 100%;
  209. }
  210. .p1 {
  211. font-size: 48upx;
  212. }
  213. .p {
  214. width: 350upx;
  215. text-align: right;
  216. }
  217. .input {
  218. width: 200upx;
  219. box-shadow: 0upx 0upx 20upx #D3D3D3;
  220. border-radius: 5upx;
  221. text-align: center;
  222. }
  223. .button {
  224. margin: auto;
  225. width: 60%;
  226. height: 100upx;
  227. }
  228. .p2 {
  229. font-size: 30upx;
  230. /* #ifndef H5 */
  231. padding-top: 3upx;
  232. /* #endif */
  233. position: absolute;
  234. /* 水平居中 */
  235. left: 50%;
  236. -webkit-transform: translateX(-50%);
  237. transform: translateX(-50%);
  238. }
  239. .uni-title{
  240. padding-left: 20upx;
  241. font-size: 26upx;
  242. font-family: "PingFang-SC-Bold";
  243. }
  244. </style>