Procházet zdrojové kódy

修改设备名称

李天标 před 6 roky
rodič
revize
cfbc99e569

+ 5 - 0
pages/User/equipmentStatusList.vue

@@ -95,6 +95,11 @@
 				this.getEquipmentListByUser(this.loginUser)
 				.then(data => {
 					this.merchantList = data;
+					var listName = data[0].equipmentList;
+					var listId = data[0].id;
+					if(listId!=null && listId!='1'){
+						uni.setStorageSync("listName",listName);
+					}
 					uni.stopPullDownRefresh();
 				}
 				, _ => void uni.stopPullDownRefresh());

+ 5 - 0
pages/User/merchantList.vue

@@ -92,6 +92,11 @@
 				this.getEquipmentListByUser(this.loginUser)
 				.then(data => {
 					this.merchantList = data;
+					var listName = data[0].equipmentList;
+					var listId = data[0].id;
+					if(listId!=null && listId!='1'){
+						uni.setStorageSync("listName",listName);
+					}
 					uni.stopPullDownRefresh();
 				}
 				, _ => void uni.stopPullDownRefresh());

+ 129 - 19
pages/User/user.vue

@@ -1,5 +1,5 @@
 <template>
-    <!-- <view class="content">
+	<!-- <view class="content">
         <view class="btn-row">
             <button type="default" @tap="bindLogout">退出登录</button>
         </view>
@@ -7,50 +7,121 @@
 	<view class="page-fill">
 		<view class="header">
 			<image src="../../static/icons/CpoxxFw_-5-AFyVyAABLIH8xBTw233.png" class="face"></image>
-	
+
 			<view class="info-wapper">
 				<view class="nickname">
-					用户名:{{username}}
+					用户名:{{name}}
 				</view>
 			</view>
 			<view>
 				<button type="default" @tap="bindLogout" class="settings">退出</button>
 			</view>
 		</view>
+		<view v-if="show">
+			<view v-for="(list,index) in listName" :key="index" class="body">
+				<view class="input-two">
+					<input :id=list.id type="text" class="input" @focus="setStyle()" @blur="setStyle2()" :value=list.name @input="getValue" />
+					<p id="p2" class="p2" :style="{display:showOrNo}">如:广东省广州市xx广场301型x号机</p>
+				</view>
+				<view class="">
+					<button type="primary" @click="updata()" class="button">
+						<p class="p">更改</p>
+					</button>
+				</view>
+
+			</view>
+		</view>
 	</view>
+
 </template>
 
 <script>
-    import {
-        mapState,
-        mapMutations
-    } from 'vuex'
+	import {
+		mapState,
+		mapMutations
+	} from 'vuex'
 
-    export default {
+	export default {
 		data() {
 			return {
-				username: null,
+				name: '',
+				show: false,
+				listName: [],
+				value: null,
+				id: null,
+				showOrNo: null
 			};
 		},
+		onPullDownRefresh() {
+			setTimeout(function() {
+				uni.stopPullDownRefresh();
+			}, 800);
+		},
 		onShow() {
+			uni.startPullDownRefresh();
 			var me = this;
-			var username = uni.getStorageSync("username");
-			me.username = username;
+			var name = uni.getStorageSync("name");
+			me.name = name;
+			var listName = uni.getStorageSync("listName");
+			me.listName = listName;
+			var adminId = listName[0].adminId;
+			if (adminId != '1' && adminId != null) {
+				me.show = true;
+			}
+		},
+		onLoad() {
+
 		},
-        computed: {
-        },
-        methods: {
-            bindLogout() {
+
+		computed: {},
+		methods: {
+			bindLogout() {
 				uni.reLaunch({
 					url: '/pages/Login/Login',
 				});
-            }
-        }
-    }
+			},
+			setStyle() {
+				this.showOrNo = "block";
+			},
+			setStyle2() {
+				this.showOrNo = "none";
+			},
+			updata() {
+
+				var id = this.id;
+				var value = this.value;
+				if (value != null && value != '') {
+					uni.request({
+						url: 'http://127.0.0.1:8090/TEquipment/updateName',
+						data: {
+							id: id,
+							name: value
+						},
+						dataType: 'json',
+						method: "POST",
+						success: (res) => {
+							debugger;
+							uni.showModal({
+								title: '提示',
+								content: '名称:' + value + res.data.message,
+							});
+						}
+					});
+				}
+			},
+			getValue: function(event) {
+				// 绕过v-model 获取input输入框的值  
+				var value = event.target.value;
+				var id = event.target.id;
+				this.value = value;
+				this.id = id;
+			}
+		}
+	}
 </script>
 
 <style>
-.page-fill {
+	.page-fill {
 		width: 100%;
 		height: 100%;
 	}
@@ -97,4 +168,43 @@
 		width: 160upx;
 		height: 110upx;
 	}
+
+	.button {
+		padding: 10upx 10upx 10upx 0upx;
+		width: 80upx;
+		height: 60upx;
+	}
+
+	.input {
+		padding: 10upx 10upx 10upx 0upx;
+		background-color: #EEEEEE;
+		width: 550upx;
+		height: 50upx;
+	}
+
+	.body {
+		background-color: #D9D9D9;
+		padding: 10upx 10upx 10upx 10upx;
+		display: flex;
+		flex-direction: row;
+		justify-content: flex-start;
+	}
+
+	.input-two {
+		width: 600upx;
+		height: 100upx;
+	}
+
+	.p {
+		width: 80upx;
+		height: 50upx;
+	}
+
+	.p2 {
+		color: #DD524D;
+		display: none;
+		width: 600upx;
+		height: 50upx;
+		border: 1px;
+	}
 </style>

+ 1 - 1
store/index.js

@@ -39,7 +39,7 @@ const store = new Vuex.Store({
 				.then(res => {
 					// const { token, userObj } = res.data;
 					//用户名缓存
-					uni.setStorageSync("username", res.data.username);
+					uni.setStorageSync("name", res.data.name);
 					const userObj = res.data;
 					commit('setLoading', false);
 					commit('setLoginUser', userObj);