user.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view class="page-fill">
  3. <view class="headimg"></view>
  4. <view class="header">
  5. <image src="../../static/img/userimg.png" class="face"></image>
  6. <view class="info-wapper">
  7. <view class="nickname">
  8. {{name}}
  9. </view>
  10. </view>
  11. <view class="tuichu">
  12. <button @tap="bindLogout" class="settings"><p class="p3">退出</p></button>
  13. </view>
  14. </view>
  15. <view v-if="show">
  16. <view class="xiugai">
  17. 修改设备名称
  18. </view>
  19. <view v-for="(list,index) in listName" :key="index" class="body">
  20. <view class="input-two">
  21. <input :id=list.id type="text" class="input" @focus="setStyle()" @blur="setStyle2()" :value=list.name @input="getValue" />
  22. <p id="p2" class="p2" :style="{display:showOrNo}">如:广东省广州市xx广场301型x号机</p>
  23. </view>
  24. <view class="button2">
  25. <button type="primary" @click="updata1()" class="button">
  26. <p class="p">更改</p>
  27. </button>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. mapState,
  36. mapActions,
  37. mapMutations
  38. } from 'vuex'
  39. export default {
  40. data() {
  41. return {
  42. name: '',
  43. show: false,
  44. listName: [],
  45. value: null,
  46. id: null,
  47. parm: {
  48. name: null,
  49. id: null
  50. },
  51. showOrNo: null
  52. };
  53. },
  54. onPullDownRefresh() {
  55. setTimeout(function() {
  56. uni.stopPullDownRefresh();
  57. }, 800);
  58. },
  59. onShow() {
  60. // uni.startPullDownRefresh();
  61. var me = this;
  62. var name = uni.getStorageSync("name");
  63. me.name = name;
  64. var listName = uni.getStorageSync("listName");
  65. me.listName = listName;
  66. if (listName != '' && listName != null) {
  67. var adminId = listName[0].adminId;
  68. if (adminId != '1' && adminId != null) {
  69. me.show = true;
  70. }
  71. }
  72. },
  73. onLoad() {
  74. },
  75. methods: {
  76. bindLogout() {
  77. //清楚缓存
  78. uni.clearStorageSync();
  79. uni.reLaunch({
  80. url: '/pages/Login/Login',
  81. });
  82. },
  83. setStyle() {
  84. this.showOrNo = "block";
  85. },
  86. setStyle2() {
  87. this.showOrNo = "none";
  88. },
  89. // updata() {
  90. // //挂载方式
  91. // var serverurl = this.serverurl;
  92. // var id = this.id;
  93. // var value = this.value;
  94. // if (value != null && value != '') {
  95. // uni.request({
  96. // url: serverurl+'/TEquipment/updateName',
  97. // data: {
  98. // id: id,
  99. // name: value
  100. // },
  101. // dataType: 'json',
  102. // method: "POST",
  103. // success: (res) => {
  104. // uni.showModal({
  105. // title: '提示',
  106. // content: '名称:' + value + res.data.message,
  107. // });
  108. // }
  109. // });
  110. // }
  111. // },
  112. getValue: function(event) {
  113. // 绕过v-model 获取input输入框的值
  114. var value = event.target.value;
  115. var id = event.target.id;
  116. this.value = value;
  117. this.id = id;
  118. this.parm.name = value;
  119. this.parm.id = id;
  120. },
  121. ...mapActions('chart', ['updata']),
  122. updata1() {
  123. if (this.parm.id != null) {
  124. this.updata(this.parm)
  125. .then(res => {
  126. uni.showModal({
  127. title: '提示',
  128. content: '名称:' + this.parm.name + res.message,
  129. });
  130. }, _ => void uni.stopPullDownRefresh());
  131. }
  132. }
  133. }
  134. }
  135. </script>
  136. <style>
  137. .page-fill {
  138. width: 100%;
  139. height: 100%;
  140. background: #FFFFFF;
  141. }
  142. .headimg{
  143. height: 120upx;
  144. background: #206DC3;
  145. width: 750upx;
  146. }
  147. .header {
  148. height:160upx;
  149. width: 690upx;
  150. background:#FFFFFF;
  151. margin: auto;
  152. padding-top: 50upx;
  153. box-shadow:0upx -1upx 20upx #D3D3D3;
  154. border-radius: 15upx;
  155. transform: translateY(-90upx);
  156. display: flex;
  157. flex-direction: row;
  158. justify-content: flex-start;
  159. }
  160. .face {
  161. width: 116upx;
  162. height: 116upx;
  163. padding-left: 30upx;
  164. border-radius: 50%;
  165. flex-shrink: 0;
  166. }
  167. .info-wapper {
  168. width: 50%;
  169. margin-left: 30upx;
  170. display: flex;
  171. flex-direction: column;
  172. }
  173. .nickname {
  174. color: #363D44;
  175. font-size: 16px;
  176. font-weight: 600;
  177. padding: 30upx 0upx 0upx 0upx;
  178. font-family: "PingFang-SC-Bold";
  179. }
  180. .set-wapper {
  181. display: flex;
  182. flex-direction: row;
  183. justify-content: flex-end;
  184. width: 15%;
  185. }
  186. .tuichu{
  187. width: 100upx;
  188. height: 64upx;
  189. padding-top: 30upx;
  190. /* padding-right: 30upx; */
  191. text-align: center;
  192. margin:0 auto;
  193. }
  194. .settings {
  195. width: 100upx;
  196. height: 64upx;
  197. border-radius: 10upx;
  198. background: #D6101F;
  199. /* padding-right: 50upx; */
  200. /* padding-top: 5upx; */
  201. text-align: center;
  202. margin:0 auto;
  203. }
  204. .p3{
  205. /* #ifdef H5 */
  206. top: -13%;
  207. /* #endif */
  208. font-size: 32upx;
  209. color: #FFFFFF;
  210. font-weight: bold;
  211. width: 100upx;
  212. height: 64upx;
  213. /* #ifndef H5 */
  214. padding-top: 3upx;
  215. /* #endif */
  216. position:absolute;
  217. /* 水平居中 */
  218. left:50%;
  219. -webkit-transform:translateX(-50%);
  220. transform:translateX(-50%);
  221. }
  222. .centerY{
  223. position:absolute;
  224. top:50%;
  225. -webkit-transform:translateY(-50%);
  226. transform:translateY(-50%);
  227. }
  228. .button2{
  229. padding-right: 60upx;
  230. padding-top: 2upx;
  231. }
  232. .button {
  233. /* padding: 5upx 10upx 10upx 0upx; */
  234. width: 80upx;
  235. height: 60upx;
  236. border-radius: 10upx;
  237. }
  238. .p {
  239. /* #ifdef H5 */
  240. top: -13%;
  241. /* #endif */
  242. width: 80upx;
  243. height: 60upx;
  244. font-size: 30upx;
  245. /* #ifndef H5 */
  246. padding-top: 3upx;
  247. /* #endif */
  248. position:absolute;
  249. /* 水平居中 */
  250. left:50%;
  251. -webkit-transform:translateX(-50%);
  252. transform:translateX(-50%);
  253. }
  254. .input {
  255. /* padding: 10upx 20upx 10upx 0upx; */
  256. padding-left: 20upx;
  257. padding-top: 10upx;
  258. background-color: #FFFFFF;
  259. width: 500upx;
  260. height: 50upx;
  261. box-shadow:0upx 0upx 20upx #D3D3D3;
  262. border-radius: 5upx;
  263. }
  264. .xiugai{
  265. width: 92%;
  266. border-left: 20upx;
  267. border-left: 10upx solid #206DC3;
  268. padding-left: 10upx;
  269. height: 38upx;
  270. padding-bottom: 20upx;
  271. font-family: "PingFang-SC-Bold";
  272. font-weight: bold;
  273. margin: auto;
  274. font-size: 32upx;
  275. color: #363D44;
  276. }
  277. .body {
  278. background-color: #FFFFFF;
  279. padding: 10upx 10upx 10upx 10upx;
  280. display: flex;
  281. flex-direction: row;
  282. justify-content: flex-start;
  283. }
  284. .input-two {
  285. width: 600upx;
  286. height: 100upx;
  287. padding-left: 30upx;
  288. }
  289. .p2 {
  290. color: #DD524D;
  291. display: none;
  292. width: 600upx;
  293. height: 50upx;
  294. border: 1px;
  295. }
  296. </style>