updatePassword.vue 8.1 KB

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