updatePassword.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view>
  3. <!-- //查找 -->
  4. <view class="search">
  5. <view class="search-title">
  6. {{$t('dosugar.equipmentClientID')}}
  7. </view>
  8. <view class="search-input">
  9. <input type="text" :placeholder="$t('dosugar.placeholder')" v-model="searchClientId" />
  10. </view>
  11. <view class="search-button">
  12. <button type="primary" size="mini" class="" @click="search()">
  13. <p class="">{{$t('alarmClock.add')}}</P>
  14. </button>
  15. </view>
  16. </view>
  17. <!-- //多选下拉框 -->
  18. <view class="select-item">
  19. <ld-select :multiple="true" :list="equipmentNameList" label-key="label" value-key="value"
  20. :cancel-text="$t('common.cancel')" :confirm-text="$t('common.ok')"
  21. :placeholder="$t('alarmClock.placeholder')" clearable v-model="equipmentIds" @change="selectChange2"></ld-select>
  22. </view>
  23. <view class="search">
  24. <view class="search-title">
  25. {{$t('updatePassword.adminPwd')}}:
  26. </view>
  27. <view class="search-input2">
  28. <input type="text" v-model="adminPwd" />
  29. </view>
  30. </view>
  31. <view class="search">
  32. <view class="search-title">
  33. {{$t('updatePassword.guestPwd')}}:
  34. </view>
  35. <view class="search-input2">
  36. <input type="text" v-model="guestPwd" />
  37. </view>
  38. </view>
  39. <view class="line"></view>
  40. <!-- //提交按钮 -->
  41. <view class="tr">
  42. <button type="primary" formType="submit" @click="update()" class="button">
  43. <p class="p1">{{$t('alarmClock.update')}}</p>
  44. </button>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. mapState,
  51. mapActions,
  52. mapMutations
  53. } from 'vuex'
  54. import MxDatePicker from "../../components/mx-datepicker/mx-datepicker.vue";
  55. // import ldSelect from "../../components/ld-select/ld-select.vue";
  56. import ldSelect from "../../components/ld-select/ld-select.vue"
  57. import likeButton from "../../components/like-button/like-button.vue";
  58. export default {
  59. components: {
  60. MxDatePicker,
  61. ldSelect,
  62. likeButton
  63. },
  64. data() {
  65. return {
  66. value: '',
  67. searchClientId: null,
  68. equipmentName: null,
  69. equipmentNameList: [],
  70. globalUser: {},
  71. equipmentIds: [],
  72. adminPwd:null,
  73. guestPwd:null
  74. }
  75. },
  76. onShow() {
  77. this.globalUser = uni.getStorageSync("globalUser");
  78. uni.setNavigationBarTitle({
  79. title: this.$t('remoteList.password')
  80. });
  81. var token = uni.getStorageSync("token");
  82. if (token.length > 1) {
  83. this.getEquipmentListData();
  84. } else {
  85. uni.reLaunch({
  86. url: '../../../pages/Login/Login',
  87. });
  88. }
  89. },
  90. onLoad() {
  91. },
  92. methods: {
  93. ...mapActions('chart', ['getEquipmentListByUser', 'addAlarmClock', 'addAlarmClockItem', 'updateAlarmClock']),
  94. getEquipmentListData() {
  95. this.getEquipmentListByUser(this.globalUser)
  96. .then(data => {
  97. // this.merchantList = data;
  98. // console.log("1223");
  99. var listName = data[0].equipmentList;
  100. var equipmentNameList = this.equipmentNameList;
  101. var co = {};
  102. co["value"] = 'all';
  103. co["label"] = this.$t('common.allDevice');
  104. equipmentNameList.push(co);
  105. for (var i = 0; i < listName.length; i++) {
  106. var cov = {};
  107. cov["value"] = listName[i].id;
  108. cov["label"] = this.$t('common.name') + listName[i].name + ' , '+ this.$t('common.ID') + listName[i].clientId.substring(
  109. listName[i].clientId.length - 6, listName[i].clientId.length);
  110. equipmentNameList.push(cov);
  111. }
  112. this.equipmentNameList = equipmentNameList;
  113. var listId = data[0].id;
  114. if (listId != null && listId != '1') {
  115. uni.setStorageSync("listName", listName);
  116. }
  117. uni.stopPullDownRefresh();
  118. }, _ => void uni.stopPullDownRefresh());
  119. },
  120. onSelected(e) { //选择
  121. this.showPicker = false;
  122. if (e) {
  123. this[this.type] = e.value;
  124. //选择的值
  125. // console.log('value => ' + e.value);
  126. //原始的Date对象
  127. // console.log('date => ' + e.date);
  128. }
  129. },
  130. // bindPickerChange: function(e) {
  131. // this.indexType = e.target.value
  132. // },
  133. addEids(equipmentIds) {
  134. // console.log('equipmentIds' + equipmentIds);
  135. var eids = equipmentIds.split(",");
  136. var idss = this.equipmentIds;
  137. var is = this.equipmentNameList
  138. for (var k = 0; k < eids.length; k++) {
  139. var id = eids[k];
  140. if (id != "" && id != '') {
  141. this.equipmentIds.push(parseInt(id));
  142. }
  143. }
  144. },
  145. search() {
  146. // console.log("search");
  147. var clientId = this.searchClientId;
  148. var list = uni.getStorageSync("listName");
  149. var n = 0;
  150. for (var i = 0; i < list.length; i++) {
  151. var code = list[i].clientId.substring(list[i].clientId.length - 6, list[i].clientId.length);
  152. if (code == clientId) {
  153. n++;
  154. var id = list[i].id;
  155. this.equipmentIds.push(id);
  156. break;
  157. }
  158. }
  159. if (n == 0) {
  160. uni.showModal({
  161. title: this.$t('common.tip'),
  162. content: this.$t('common.noDevice'),
  163. success: (res) => {
  164. }
  165. })
  166. }
  167. if (n > 0) {
  168. uni.showModal({
  169. title: this.$t('common.tip'),
  170. content: this.$t('common.addDevice'),
  171. success: (res) => {
  172. }
  173. })
  174. }
  175. },
  176. selectChange2(val) {
  177. //有改动文件 import likeButton from "../../components/like-button/like-button.vue";
  178. if (val == "all") {
  179. this.equipmentIds = [];
  180. var list = uni.getStorageSync("listName");
  181. for (var i = 0; i < list.length; i++) {
  182. this.equipmentIds.push(list[i].id);
  183. }
  184. } else {
  185. this.equipmentIds = val
  186. }
  187. // console.log('this.equipmentIds => ' + this.equipmentIds);
  188. },
  189. switchChange: function(e) {
  190. this.status = e.target.value;
  191. },
  192. update() {
  193. var that = this;
  194. uni.showModal({
  195. title: that.$t('equipmentStatusList.tip'),
  196. content:that.$t('updatePassword.sure') ,
  197. success: (re) => {
  198. if (re.confirm) {
  199. var serverurl = that.serverurl;
  200. var token = uni.getStorageSync("token");
  201. uni.request({
  202. url: serverurl + '/TEquipment/updatePassword?equipmentIds='+that.equipmentIds+'&guestPwd='+that.guestPwd+'&adminPwd='+that.adminPwd,
  203. // data: {
  204. // "equipmentIds": that.equipmentIds,
  205. // "guestPwd": that.guestPwd,
  206. // "adminPwd": that.adminPwd,
  207. // },
  208. method: "POST",
  209. header: {
  210. 'token': token
  211. },
  212. success: (res) => {
  213. if(res.data.code){
  214. uni.showToast({
  215. title: res.data.message,
  216. duration: 1000
  217. });
  218. }
  219. }
  220. });
  221. }
  222. }
  223. })
  224. },
  225. }
  226. }
  227. </script>
  228. <style>
  229. .test {
  230. text-align: center;
  231. padding: 10px 0;
  232. }
  233. .time {
  234. font-size: 78upx;
  235. }
  236. .btime {
  237. margin: 20upx;
  238. font-size: 28upx;
  239. }
  240. /* button {
  241. margin: 20upx;
  242. font-size: 28upx;
  243. } */
  244. /* #ifdef MP-ALIPAY */
  245. .uni-badge {
  246. margin-left: 20rpx;
  247. }
  248. /* #endif */
  249. .uni-badge {
  250. font-size: 40upx;
  251. }
  252. .example-body {
  253. flex-direction: row;
  254. justify-content: flex-start;
  255. padding-bottom: 15upx;
  256. font-size: 40upx;
  257. }
  258. .uni-badge-left-margin {
  259. font-size: 40upx;
  260. margin-left: 50upx;
  261. }
  262. .uni-list-cell {
  263. padding-top: 20upx;
  264. padding-bottom: 10upx;
  265. font-size: 35upx;
  266. }
  267. .line {
  268. height: 2upx;
  269. background: #8C959F;
  270. }
  271. .search {
  272. width: 100%;
  273. padding-top: 15upx;
  274. display: flex;
  275. flex-direction: row;
  276. justify-content: flex-start;
  277. }
  278. .search-title {
  279. width: 28%;
  280. text-align: center;
  281. font-size: 26upx;
  282. font-family: "PingFang-SC-Bold";
  283. }
  284. .search-input{
  285. width: 48%;
  286. height: 25px;
  287. text-align: center;
  288. font-size: 26upx;
  289. /* font-family: "PingFang-SC-Bold"; */
  290. box-shadow: 0upx 0upx 20upx #D3D3D3;
  291. border-radius: 5upx;
  292. }
  293. .search-button{
  294. width: 20%;
  295. padding-left: 10px;
  296. padding-bottom: 5px;
  297. text-align: center;
  298. height: 60upx;
  299. text-align: left;
  300. }
  301. .search-input2 {
  302. width: 65%;
  303. text-align: center;
  304. font-size: 26upx;
  305. font-family: "PingFang-SC-Bold";
  306. box-shadow: 0upx 0upx 20upx #D3D3D3;
  307. border-radius: 5upx;
  308. }
  309. .select-item {
  310. /* padding-top: 20upx; */
  311. }
  312. .tr {
  313. padding-top: 15upx;
  314. display: flex;
  315. flex-direction: row;
  316. justify-content: flex-start;
  317. font-size: 48upx;
  318. font-family: "PingFang-SC-Bold";
  319. position: fixed;
  320. bottom: 100upx;
  321. width: 100%;
  322. }
  323. .button {
  324. margin: auto;
  325. width: 60%;
  326. height: 100upx;
  327. }
  328. .p1 {
  329. font-size: 48upx;
  330. }
  331. </style>