user.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <!-- <view class="content">
  3. <view class="btn-row">
  4. <button type="default" @tap="bindLogout">退出登录</button>
  5. </view>
  6. </view> -->
  7. <view class="page-fill">
  8. <view class="header">
  9. <image src="../../static/icons/CpoxxFw_-5-AFyVyAABLIH8xBTw233.png" class="face"></image>
  10. <view class="info-wapper">
  11. <view class="nickname">
  12. 用户名:{{name}}
  13. </view>
  14. </view>
  15. <view>
  16. <button type="default" @tap="bindLogout" class="settings">退出</button>
  17. </view>
  18. </view>
  19. <view v-if="show">
  20. <view class="">
  21. 修改设备名称
  22. </view>
  23. <view v-for="(list,index) in listName" :key="index" class="body">
  24. <view class="input-two">
  25. <input :id=list.id type="text" class="input" @focus="setStyle()" @blur="setStyle2()" :value=list.name @input="getValue" />
  26. <p id="p2" class="p2" :style="{display:showOrNo}">如:广东省广州市xx广场301型x号机</p>
  27. </view>
  28. <view class="">
  29. <button type="primary" @click="updata1()" class="button">
  30. <p class="p">更改</p>
  31. </button>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. mapState,
  40. mapActions,
  41. mapMutations
  42. } from 'vuex'
  43. export default {
  44. data() {
  45. return {
  46. name: '',
  47. show: false,
  48. listName: [],
  49. value: null,
  50. id: null,
  51. parm: {
  52. name: null,
  53. id: null
  54. },
  55. showOrNo: null
  56. };
  57. },
  58. onPullDownRefresh() {
  59. setTimeout(function() {
  60. uni.stopPullDownRefresh();
  61. }, 800);
  62. },
  63. onShow() {
  64. // uni.startPullDownRefresh();
  65. var me = this;
  66. var name = uni.getStorageSync("name");
  67. me.name = name;
  68. var listName = uni.getStorageSync("listName");
  69. me.listName = listName;
  70. if (listName != '' && listName != null) {
  71. var adminId = listName[0].adminId;
  72. if (adminId != '1' && adminId != null) {
  73. me.show = true;
  74. }
  75. }
  76. },
  77. onLoad() {
  78. },
  79. methods: {
  80. bindLogout() {
  81. //清楚缓存
  82. uni.clearStorageSync();
  83. uni.reLaunch({
  84. url: '/pages/Login/Login',
  85. });
  86. },
  87. setStyle() {
  88. this.showOrNo = "block";
  89. },
  90. setStyle2() {
  91. this.showOrNo = "none";
  92. },
  93. // updata() {
  94. // //挂载方式
  95. // var serverurl = this.serverurl;
  96. // var id = this.id;
  97. // var value = this.value;
  98. // if (value != null && value != '') {
  99. // uni.request({
  100. // url: serverurl+'/TEquipment/updateName',
  101. // data: {
  102. // id: id,
  103. // name: value
  104. // },
  105. // dataType: 'json',
  106. // method: "POST",
  107. // success: (res) => {
  108. // uni.showModal({
  109. // title: '提示',
  110. // content: '名称:' + value + res.data.message,
  111. // });
  112. // }
  113. // });
  114. // }
  115. // },
  116. getValue: function(event) {
  117. // 绕过v-model 获取input输入框的值
  118. var value = event.target.value;
  119. var id = event.target.id;
  120. this.value = value;
  121. this.id = id;
  122. this.parm.name = value;
  123. this.parm.id = id;
  124. },
  125. ...mapActions('chart', ['updata']),
  126. updata1() {
  127. if (this.parm.id != null) {
  128. this.updata(this.parm)
  129. .then(res => {
  130. uni.showModal({
  131. title: '提示',
  132. content: '名称:' + this.parm.name + res.message,
  133. });
  134. }, _ => void uni.stopPullDownRefresh());
  135. }
  136. }
  137. }
  138. }
  139. </script>
  140. <style>
  141. .page-fill {
  142. width: 100%;
  143. height: 100%;
  144. }
  145. .header {
  146. padding: 60upx 30upx 40upx 30upx;
  147. background-color: #ffd655;
  148. background: url(../../static/icons/CpoxxFwu_1OAYFAIAAAzO_Q1tPg693.png) repeat;
  149. display: flex;
  150. flex-direction: row;
  151. justify-content: flex-start;
  152. }
  153. .face {
  154. width: 120upx;
  155. height: 120upx;
  156. border-radius: 50%;
  157. flex-shrink: 0;
  158. }
  159. .info-wapper {
  160. width: 60%;
  161. margin-left: 40upx;
  162. display: flex;
  163. flex-direction: column;
  164. }
  165. .nickname {
  166. color: #6a5018;
  167. font-size: 12px;
  168. font-weight: bold;
  169. padding: 30upx 0upx 0upx 0upx;
  170. }
  171. .set-wapper {
  172. display: flex;
  173. flex-direction: row;
  174. justify-content: flex-end;
  175. width: 15%;
  176. }
  177. .settings {
  178. width: 160upx;
  179. height: 110upx;
  180. }
  181. .button {
  182. padding: 10upx 10upx 10upx 0upx;
  183. width: 80upx;
  184. height: 60upx;
  185. }
  186. .input {
  187. padding: 10upx 10upx 10upx 0upx;
  188. background-color: #EEEEEE;
  189. width: 550upx;
  190. height: 50upx;
  191. }
  192. .body {
  193. background-color: #D9D9D9;
  194. padding: 10upx 10upx 10upx 10upx;
  195. display: flex;
  196. flex-direction: row;
  197. justify-content: flex-start;
  198. }
  199. .input-two {
  200. width: 600upx;
  201. height: 100upx;
  202. }
  203. .p {
  204. width: 80upx;
  205. height: 50upx;
  206. }
  207. .p2 {
  208. color: #DD524D;
  209. display: none;
  210. width: 600upx;
  211. height: 50upx;
  212. border: 1px;
  213. }
  214. </style>