eason 1 rok temu
rodzic
commit
2d4ebe93c7

+ 10 - 1
fore-end/app.js

@@ -9,7 +9,16 @@ App({
     // 登录
     wx.login({
       success: res => {
-        // 发送 res.code 到后台换取 openId, sessionKey, unionId
+		console.log("code: "+res.code);
+		wx.request({
+			url: 'http://192.168.31.28:8084/user/login',
+			method:'POST',
+			data:{
+				code : res.code,
+				Appid: 	'wxc25f00d0fc026ae7',
+				AppSecret: '9e94011d65b0f4307b1cab14022ea060'
+			}
+		})
       }
     })
   },

+ 17 - 8
fore-end/pages/user/user.js

@@ -1,4 +1,5 @@
 // pages/user/user.js
+
 Page({
 
     /**
@@ -72,23 +73,28 @@ Page({
 		  url: '/pages/userchange/userchange',
 		})
 	},
-
+	
 	getUserProfile(){
+		const ui_w = 360;
+		// 获取屏幕的宽度
+		var clientWidth = wx.getSystemInfoSync().windowWidth;
 		wx.getUserProfile({
 		  desc: '登录',
+		  
 		  success: (res) => {
 			  this.setData({
 				  nickName: res.userInfo.nickName,
-				  avatarUrl: res.userInfo.avatarUrl
+				  avatarUrl: res.userInfo.avatarUrl,
+				  fontSize: (clientWidth / ui_w) * 19 + 'px'
 			  })
 			  wx.setStorage({
-				  key: 'nickname',
+				  key: 'nickName',
 				  data: res.userInfo.nickName,
 				  success: function() {
-					  console.log('写入nickname缓存成功')
+					  console.log('写入nickName缓存成功')
 				  },
 				  fail: function() {
-					  console.log('写入nickname发生错误')
+					  console.log('写入nickName发生错误')
 				  }
 			  })
 			  wx.setStorage({
@@ -102,6 +108,9 @@ Page({
 				}
 			})
 		  }
-		})
-	}
-})
+		});
+
+	},
+	
+})
+

+ 3 - 3
fore-end/pages/user/user.wxml

@@ -1,11 +1,11 @@
 <!--pages/user/user.wxml-->
 <van-cell-group inset>
 	<view class="pages-user">
-		<view class="pages-user-profile" bindtap="userName">
-			<image class="pages-user-profile-1" src="{{avatarUrl}}"></image>
+		<view class="pages-user-profile" bindtap="getUserProfile">
+			<image class="pages-user-profile-1" src="{{avatarUrl}}" style="width: 244rpx; height: 238rpx; display: inline-block; box-sizing: border-box; left: 10rpx; top: 13rpx; position: relative"></image>
 		</view>
 		<view class="pages-user-username">
-			<view class="pages-user-username-1">{{userName}}</view>
+			<view class="pages-user-username-1" style="font-size: {{fontSize}};">{{nickName}}</view>
 			<view class="pages-user-username-2">wxID:{{userWxID}}</view>
 			<view class="pages-user-username-4">
 				<!-- <van-icon name="/assets/tabBar_img/修改.png"></van-icon> -->

+ 5 - 6
fore-end/pages/user/user.wxss

@@ -37,10 +37,9 @@ page{
 
 .pages-user-username-1{
 	position: relative;
-	left: 65px;
+	left: 30px;
 	top: 1px;
-	width: 100px;
-	height: 37px;
+	width: 180px;
 	opacity: 1;
 	color: rgba(0, 0, 0, 0.62);
 	font-size: 20px;
@@ -50,8 +49,8 @@ page{
 
 .pages-user-username-2{
 	position: relative;
-	left: 70px;
-	top: 10px;
+	left: 30px;
+	top: 5px;
 	width: 104px;
 	height: 20px;
 	opacity: 1;
@@ -69,7 +68,7 @@ page{
 .pages-user-username-3{
 	position: relative;
 	top: 10px;
-	left: 35px;
+	left: 20px;
 }
 
 .pages-user-username-3>.van-cell:after{

+ 134 - 4
fore-end/pages/userchange/userchange.js

@@ -6,14 +6,34 @@ Page({
      * 页面的初始数据
      */
     data: {
-		imageUrl:''
+		avatarUrl:'',
+		nickName:'',
+		phoneNumber:'',
+		password:'',
+		personalSignatrue:'编辑个性签名,展示我的独特态度'
     },
 
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad(options) {
-
+		var that = this;
+		wx.getStorage({
+			key: 'nickName',
+			success (res) {
+			  that.setData({
+				nickName:res.data
+			  })
+			}
+		  })
+		  wx.getStorage({
+			key: 'avatarUrl',
+			success (res) {
+			  that.setData({
+				avatarUrl:res.data
+			  })
+			}
+		  })
     },
 
     /**
@@ -79,11 +99,121 @@ Page({
 		upLoad( imagePath ).then((res) => {
 			console.log(res);
 			this.setData({
-				imageUrl: res.Url
+				avatarUrl: res.Url
+			});
+			wx.setStorage({
+				key: 'avatarUrl',
+				data: res.Url,
+				success: function() {
+					console.log('写入avatarUrl缓存成功')
+				},
+				fail:function() {
+					console.log('写入avatarUrl发生错误')
+				}
 			});
 		})
 	},
+
+	onChangeUsername:function(e){
+		wx.setStorage({
+			key: 'nickName',
+			data: e.detail,
+			success: function() {
+				console.log('写入nickName缓存成功')
+			},
+			fail:function() {
+				console.log('写入nickName发生错误')
+			}
+		})
+	},
+
+	onChangePhonenumber:function(e){
+		wx.setStorage({
+			key: 'phoneNumber',
+			data: e.detail,
+			success: function() {
+				console.log('写入phoneNumber缓存成功')
+			},
+			fail:function() {
+				console.log('写入phoneNumber发生错误')
+			}
+		})
+	},
+
+	onChangePassword: function(e) {
+		wx.setStorage({
+			key: 'password',
+			data: e.detail,
+			success: function() {
+				console.log('写入password缓存成功')
+			},
+			fail:function() {
+				console.log('写入password发生错误')
+			}
+		})
+	},
+
+	onChangePersonalSignatrue: function(e) {
+		wx.setStorage({
+			key: 'personalSignatrue',
+			data: e.detail,
+			success: function() {
+				console.log('写入personalSignatrue缓存成功')
+			},
+			fail:function() {
+				console.log('写入personalSignatrue发生错误')
+			}
+		})
+	},
+	
 	changeInfo:function(){
-		
+		var avatarUrl = wx.getStorageSync('avatarUrl');
+		var nickName = wx.getStorageSync('nickName');
+		var phoneNumber = wx.getStorageSync('phoneNumber');
+		var password = wx.getStorageSync('password');
+		var personalSignatrue = wx.getStorageSync('personalSignatrue');
+		// wx.getStorage({
+		// 	key: 'avatarUrl',
+		// 	success(res) {
+		// 		avatarUrl = res.data
+		// 	}
+		// })
+		// wx.getStorage({
+		// 	key: 'nickName',
+		// 	success(res) {
+		// 		nickName = res.data
+		// 	}
+		// })
+		// wx.getStorage({
+		// 	key: 'phoneNumber',
+		// 	success(res) {
+		// 		var phoneNumber = res.data
+		// 	}
+		// })
+		// wx.getStorage({
+		// 	key: 'password',
+		// 	success(res) {
+		// 		var password = res.data
+		// 	}
+		// })
+		// wx.getStorage({
+		// 	key: 'personalSignatrue',
+		// 	success(res) {
+		// 		var personalSignatrue = res.data
+		// 	}
+		// })
+		wx.request({
+		  url: 'http://192.168.31.28:8084/user/modify',
+		  method: 'POST',
+		  data: {
+			  "avatar": avatarUrl,
+			  "name": nickName,
+			  "phone": phoneNumber,
+			  "uid": 1,
+		  },
+		  success (res) {
+			  console.log(res)
+		  }
+		})
 	}
 })

+ 5 - 5
fore-end/pages/userchange/userchange.wxml

@@ -1,11 +1,11 @@
 <!--pages/userchange/index.wxml-->
 <view class="pages">
-	<van-image round fit="cover" src="{{imageUrl}}" class="pages-userchange-profile" bindtap="chooseImage"></van-image>
+	<van-image round fit="cover" src="{{avatarUrl}}" class="pages-userchange-profile" bindtap="chooseImage" bindinput="onChangePhoto"></van-image>
 	<van-cell-group>
-		<van-field label="昵称"  class="pages-userchange-username" custom-style="background: rgba(56, 56, 56, 0.17);border-radius: 15px;width:320px;margin-bottom:33px;" title-width="60px" value="deter" placeholder="请输入昵称" adjust-position ></van-field>
-		<van-field label="电话" type="number" class="pages-userchange-username" custom-style="background: rgba(56, 56, 56, 0.17);border-radius: 15px;width:320px;margin-bottom:33px;" title-width="60px" value="{{photonumber}}" placeholder="请输入电话号码" adjust-position ></van-field>
-		<van-field label="密码" class="pages-userchange-username" custom-style="background: rgba(56, 56, 56, 0.17);border-radius: 15px;width:320px;margin-bottom:33px;" title-width="60px" value="{{username}}" placeholder="请输入密码" adjust-position password="{{true}}" ></van-field>
-		<van-field label="个性签名" class="pages-userchange-username" custom-style="background: rgba(56, 56, 56, 0.17);border-radius: 15px;width:320px;margin-bottom:33px;" title-width="60px" value="{{username}}" placeholder="请输入个性签名" adjust-position password="{{true}}" ></van-field>
+		<van-field label="昵称"  class="pages-userchange-username" custom-style="background: rgba(56, 56, 56, 0.17);border-radius: 15px;width:320px;margin-bottom:33px;" title-width="60px" value="{{nickName}}" placeholder="请输入昵称" adjust-position bindinput="onChangeUsername"></van-field>
+		<van-field label="电话" type="number" class="pages-userchange-username" custom-style="background: rgba(56, 56, 56, 0.17);border-radius: 15px;width:320px;margin-bottom:33px;" title-width="60px" value="{{phoneNumber}}" placeholder="请输入电话号码" adjust-position bindinput="onChangePhonenumber"></van-field>
+		<van-field label="密码" class="pages-userchange-username" custom-style="background: rgba(56, 56, 56, 0.17);border-radius: 15px;width:320px;margin-bottom:33px;" title-width="60px" value="{{password}}" placeholder="请输入密码" adjust-position password="{{true}}" bindinput="onChangePassword"></van-field>
+		<van-field label="个性签名" class="pages-userchange-username" custom-style="background: rgba(56, 56, 56, 0.17);border-radius: 15px;width:320px;margin-bottom:33px;" title-width="60px" value="{{personalSignatrue}}" placeholder="请输入个性签名" adjust-position bindinput="onChangePersonalSignatrue"></van-field>
 	</van-cell-group>
 	<van-button round color="rgba(16, 128, 227, 1)" custom-style="width:150px;height:45px;transform: translate(75%, 0%);" bindtap="changeInfo">提交修改</van-button>
 </view>

+ 3 - 1
fore-end/utils/util.js

@@ -71,8 +71,10 @@ function upLoad(filePath) {
 	)
 }
 
+
+
 module.exports = {
     formatTime,
 	http,
-	upLoad
+	upLoad,
   }