瀏覽代碼

10.21commit

eason 1 年之前
父節點
當前提交
fad34515b4

+ 94 - 9
fore-end/app.js

@@ -6,19 +6,104 @@ App({
     logs.unshift(Date.now())
     wx.setStorageSync('logs', logs)
 
+	//开发者信息
+	const wxInfo = {
+		appid: 	'wxc25f00d0fc026ae7',
+		appSecret: '9e94011d65b0f4307b1cab14022ea060'
+	}
+const ui_w = 360;
+//把vid存到缓存
+wx.setStorage({
+	key: 'vid',
+	data: '',
+	success: function() {
+		console.log('写入vid缓存成功')
+	},
+	fail: function() {
+		console.log('写入vid发生错误')
+	}
+})
+// 获取屏幕的宽度
+var clientWidth = wx.getSystemInfoSync().windowWidth;
+
+
     // 登录
     wx.login({
-      success: res => {
+      success: (res) => {
+		  //获取用户昵称和头像
+		
+		  //和微信接口服务校验
 		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'
-			}
+		var url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' + wxInfo.appid + '&secret=' + wxInfo.appSecret + '&js_code=' + res.code + '&grant_type=authorization_code'
+		 wx.request({
+		  url: url,
+		  success(res){
+			wx.setStorageSync('vid', res.data.openid);
+			console.log(wx.getStorageSync('vid'));
+			wx.getUserProfile({
+				desc: '登录',
+				
+				success: (res) => {
+					wx.setStorageSync('nickName', res.userInfo.nickuName);
+					wx.setStorageSync('avatarUrl', res.userInfo.avatarUrl);
+				}
+			  });
+			//登录
+			wx.request({
+				url: 'http://192.168.31.28:8084/user/login',
+				method:'POST',
+				header: {
+					'content-type': 'application/x-www-form-urlencoded'
+				},
+				data:{
+					vid: wx.getStorageSync('vid')
+				},
+				
+				success(res){
+					console.log(res);
+					var avatar = wx.getStorageSync('avatarUrl');
+					var name = wx.getStorageSync('nickName');
+					// console.log(vid);
+					console.log('vid: '+ wx.getStorageSync('vid'));
+					if(res.data.code == 403){
+						
+							wx.request({
+								url: 'http://192.168.31.28:8084/user/register',
+								method: 'POST',
+								data: {
+									avatar: avatar,
+									name: name,
+									vid: wx.getStorageSync('vid'),
+									phone: '',
+									sign: '',
+								},
+								success(res){
+								  console.log('注册成功');
+								  console.log(res);
+								  wx.request({
+									url: 'http://192.168.31.28:8084/user/login',
+									method: 'POST',
+									header: {
+										'content-type': 'application/x-www-form-urlencoded'
+									},
+									data:{
+										vid: wx.getStorageSync('vid')
+									},
+									
+									success(res){
+										console.log(res);
+									}
+								  })
+								}
+							  })
+				}
+						
+				}
+			})
+		  }
 		})
+		
+		
       }
     })
   },

+ 63 - 61
fore-end/app.json

@@ -1,63 +1,65 @@
 {
-  "usingComponents": {
-	"van-button": "@vant/weapp/button/index",
-	"van-cell": "@vant/weapp/cell/index",
-	"van-cell-group": "@vant/weapp/cell-group/index",
-	"van-image": "@vant/weapp/image/index",
-	"van-loading": "@vant/weapp/loading/index",
-	"van-icon": "@vant/weapp/icon/index",
-	"van-field": "@vant/weapp/field/index",
-	"van-toast": "@vant/weapp/toast/index"
-  },
-  "pages": [
-    "pages/home/home",
-	"pages/classify/classify",
-	"pages/append/append",
-    "pages/message/message",
-	"pages/user/user",
-	"pages/userchange/userchange"
-  ],
-  "window": {
-    "backgroundTextStyle": "light",
-    "navigationBarBackgroundColor": "#fff",
-    "navigationBarTitleText": "Weixin",
-    "navigationBarTextStyle": "black"
-  },
-  "networkTimeout": {
-    "request": 1000000,
-    "connectSocket": 100000,
-    "uploadFile": 100000,
-    "downloadFile": 100000
-  },
-  "tabBar": {
-    "list": [
-      {
-        "pagePath": "pages/home/home",
-        "iconPath": "/assets/tabBar_img/home.png",
-        "selectedIconPath": "/assets/tabBar_img/home-active.png"
-      },
-      {
-        "pagePath": "pages/classify/classify",
-        "iconPath": "/assets/tabBar_img/classify.png",
-        "selectedIconPath": "/assets/tabBar_img/classify-active.png"
-      },
-      {
-        "pagePath": "pages/append/append",
-        "iconPath": "/assets/tabBar_img/append.png",
-        "selectedIconPath": "/assets/tabBar_img/append-active.png"
-      },
-      {
-        "pagePath": "pages/message/message",
-        "iconPath": "/assets/tabBar_img/message.png",
-        "selectedIconPath": "/assets/tabBar_img/message-active.png"
-      },
-      {
-        "pagePath": "pages/user/user",
-        "iconPath": "/assets/tabBar_img/user.png",
-        "selectedIconPath": "/assets/tabBar_img/user-active.png"
-      }
+    "usingComponents": {
+        "van-button": "@vant/weapp/button/index",
+        "van-cell": "@vant/weapp/cell/index",
+        "van-cell-group": "@vant/weapp/cell-group/index",
+        "van-image": "@vant/weapp/image/index",
+        "van-loading": "@vant/weapp/loading/index",
+        "van-icon": "@vant/weapp/icon/index",
+        "van-field": "@vant/weapp/field/index",
+        "van-toast": "@vant/weapp/toast/index"
+    },
+    "pages": [
+        "pages/home/home",
+        "pages/classify/classify",
+        "pages/append/append",
+        "pages/message/message",
+        "pages/user/user",
+        "pages/userchange/userchange",
+        "pages/myOrder/myOrder",
+        "pages/register/register"
     ],
-    "borderStyle": "white"
-  },
-  "sitemapLocation": "sitemap.json"
-}
+    "window": {
+        "backgroundTextStyle": "light",
+        "navigationBarBackgroundColor": "#fff",
+        "navigationBarTitleText": "Weixin",
+        "navigationBarTextStyle": "black"
+    },
+    "networkTimeout": {
+        "request": 1000000,
+        "connectSocket": 100000,
+        "uploadFile": 100000,
+        "downloadFile": 100000
+    },
+    "tabBar": {
+        "list": [
+            {
+                "pagePath": "pages/home/home",
+                "iconPath": "/assets/tabBar_img/home.png",
+                "selectedIconPath": "/assets/tabBar_img/home-active.png"
+            },
+            {
+                "pagePath": "pages/classify/classify",
+                "iconPath": "/assets/tabBar_img/classify.png",
+                "selectedIconPath": "/assets/tabBar_img/classify-active.png"
+            },
+            {
+                "pagePath": "pages/append/append",
+                "iconPath": "/assets/tabBar_img/append.png",
+                "selectedIconPath": "/assets/tabBar_img/append-active.png"
+            },
+            {
+                "pagePath": "pages/message/message",
+                "iconPath": "/assets/tabBar_img/message.png",
+                "selectedIconPath": "/assets/tabBar_img/message-active.png"
+            },
+            {
+                "pagePath": "pages/user/user",
+                "iconPath": "/assets/tabBar_img/user.png",
+                "selectedIconPath": "/assets/tabBar_img/user-active.png"
+            }
+        ],
+        "borderStyle": "white"
+    },
+    "sitemapLocation": "sitemap.json"
+}

+ 66 - 0
fore-end/pages/myOrder/myOrder.js

@@ -0,0 +1,66 @@
+// pages/myOrder.js
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad(options) {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload() {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh() {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom() {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage() {
+
+    }
+})

+ 3 - 0
fore-end/pages/myOrder/myOrder.json

@@ -0,0 +1,3 @@
+{
+    "usingComponents": {}
+}

+ 2 - 0
fore-end/pages/myOrder/myOrder.wxml

@@ -0,0 +1,2 @@
+<!--pages/myOrder.wxml-->
+<text>pages/myOrder.wxml</text>

+ 1 - 0
fore-end/pages/myOrder/myOrder.wxss

@@ -0,0 +1 @@
+/* pages/myOrder.wxss */

+ 81 - 0
fore-end/pages/register/register.js

@@ -0,0 +1,81 @@
+// pages/register.js
+const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad(options) {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload() {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh() {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom() {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage() {
+
+	},
+
+
+
+  data: {
+    avatarUrl: defaultAvatarUrl,
+  },
+  onChooseAvatar(e) {
+    const { avatarUrl } = e.detail 
+    this.setData({
+      avatarUrl,
+	})
+	bindonChooseAvatar
+  }
+
+})

+ 3 - 0
fore-end/pages/register/register.json

@@ -0,0 +1,3 @@
+{
+    "usingComponents": {}
+}

+ 5 - 0
fore-end/pages/register/register.wxml

@@ -0,0 +1,5 @@
+<!--pages/register.wxml-->
+<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
+  <image class="avatar" src="{{avatarUrl}}"></image>
+</button> 
+<input type="nickname" class="weui-input" placeholder="请输入昵称"/>

+ 1 - 0
fore-end/pages/register/register.wxss

@@ -0,0 +1 @@
+/* pages/register.wxss */

+ 1 - 37
fore-end/pages/user/user.js

@@ -74,43 +74,7 @@ Page({
 		})
 	},
 	
-	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,
-				  fontSize: (clientWidth / ui_w) * 19 + 'px'
-			  })
-			  wx.setStorage({
-				  key: 'nickName',
-				  data: res.userInfo.nickName,
-				  success: function() {
-					  console.log('写入nickName缓存成功')
-				  },
-				  fail: function() {
-					  console.log('写入nickName发生错误')
-				  }
-			  })
-			  wx.setStorage({
-				key: 'avatarUrl',
-				data: res.userInfo.avatarUrl,
-				success: function() {
-					console.log('写入avatarUrl缓存成功')
-				},
-				fail: function() {
-					console.log('写入avatarUrl发生错误')
-				}
-			})
-		  }
-		});
-
-	},
+	
 	
 })
 

+ 1 - 31
fore-end/pages/userchange/userchange.js

@@ -170,38 +170,8 @@ Page({
 		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',

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

@@ -4,7 +4,7 @@
 	<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="{{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="{{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>