Browse Source

11.2commit message信息获取

eason 1 năm trước cách đây
mục cha
commit
3323d07cfb

+ 24 - 2
fore-end/API/appraise.js

@@ -11,7 +11,9 @@ const API = {
 	getCategoryURL: '/category',
 	getCategoryURL: '/category',
 	getCategoryGoods: '/goods/category',
 	getCategoryGoods: '/goods/category',
 	getUserRelationUrl: '/relation/friend',
 	getUserRelationUrl: '/relation/friend',
-	addUserRelationUrl: '/relation/create'
+	addUserRelationUrl: '/relation/create',
+	getUserInfoListUrl: '/user/list',
+	getGoodsInfoListUrl: '/goods/list'
 	
 	
     //放接口URL
     //放接口URL
 }
 }
@@ -113,7 +115,7 @@ function getUserRelation(params) {
 		}
 		}
 	)
 	)
 }
 }
-
+//添加用户关系
 function addUserRelation(params) {
 function addUserRelation(params) {
 	return request.post(
 	return request.post(
 		API.addUserRelationUrl,
 		API.addUserRelationUrl,
@@ -122,6 +124,24 @@ function addUserRelation(params) {
 		}
 		}
 	)
 	)
 }
 }
+//传入uid批量获取用户信息
+function getUserInfoList(params) {
+	return request.post(
+		API.getUserInfoListUrl,
+		{
+			data: params.data,
+		}
+	)
+}
+//传入商品id批量获取商品信息
+function getGoodsInfoList(params) {
+	return request.post(
+		API.getGoodsInfoListUrl,
+		{
+			data:params.data,
+		}
+	)
+}
 
 
 module.exports = {
 module.exports = {
     createCommont,
     createCommont,
@@ -135,6 +155,8 @@ module.exports = {
 	getClassifyGoods,
 	getClassifyGoods,
 	getUserRelation,
 	getUserRelation,
 	addUserRelation,
 	addUserRelation,
+	getUserInfoList,
+	getGoodsInfoList,
 	loginURl: API.loginURL,
 	loginURl: API.loginURL,
 	registerURL: API.registerURL
 	registerURL: API.registerURL
 }
 }

+ 94 - 52
fore-end/pages/message/message.js

@@ -1,5 +1,5 @@
 // pages/message/message.js
 // pages/message/message.js
-const {getUserRelation,addUserRelation} = require('../../API/appraise')
+const {getUserRelation,addUserRelation, getUserInfoList, getGoodsInfoList} = require('../../API/appraise')
 var getRelationOption = {
 var getRelationOption = {
 	data:{
 	data:{
 		uid: wx.getStorageSync('uid'),
 		uid: wx.getStorageSync('uid'),
@@ -8,67 +8,63 @@ var getRelationOption = {
 
 
 var addRelationOption = {
 var addRelationOption = {
 	data:{
 	data:{
-		"goodsId":2,
+		"goodsId":7,
 		"owner": '7384540497554968576',
 		"owner": '7384540497554968576',
-		"target": '7385700531999608832',
+		"target": '7386092638421651456',
 		"type":1
 		"type":1
 	}
 	}
 }
 }
+
+var getUserInfoListOption = {
+	data:{
+		uid:[]
+	}
+}
+
+var getGoodsInfoListOption = {
+	data:{
+		id:[]
+	}
+}
+
+var message = [
+	{
+		// id:0,
+		item:{
+			// avatarUrl:'',
+			// merchantName:'',
+			// lastMessageRecord:'',
+			// messageTime: '',
+			// commodityPicture: ''
+		}
+	}
+]
+var key = "commodityPicture";
+let key1 = "avatarUrl";
+let key2 = "merchantName";
+let key3 = "id";
 Page({
 Page({
 
 
     /**
     /**
      * 页面的初始数据
      * 页面的初始数据
      */
      */
     data: {
     data: {
+		// message:message
 		message: [
 		message: [
 			{
 			{
 				id:1,
 				id:1,
-				item: {
-					avatarUrl:'https://img.js.design/assets/smartFill/img340164da748e08.jpg',
-					merchantName: '商家1',
-					lastMessageRecord: '你好',
-					messageTime: '10-31',
-					commodityPicture: 'https://img.js.design/assets/smartFill/img409164da755928.jpg'
+				item:{
+					avatarUrl: "http://192.168.31.28:8084/pics/1698753512AiD8PaNrvqsDb1493fda534929a5b5d05f80a8cf3d16.jpg",
+					commodityPicture: "https://img.js.design/assets/img/6229b69ff89eeaf3b7fd1919.jpg",
+					merchantName: "daisy",
 				}
 				}
 			},
 			},
 			{
 			{
 				id:2,
 				id:2,
-				item: {
-					avatarUrl:'https://img.js.design/assets/smartFill/img334164da748e08.jpg',
-					merchantName: '商家2',
-					lastMessageRecord: '你好',
-					messageTime: '10-31',
-					commodityPicture: 'https://img.js.design/assets/smartFill/img436164da758808.jpg'
-				}
-			},
-			{
-				id:3,
-				item: {
-					avatarUrl:'https://img.js.design/assets/smartFill/img327164da748e08.jpeg',
-					merchantName: '商家3',
-					lastMessageRecord: '你好',
-					messageTime: '10-31',
-					commodityPicture: 'https://img.js.design/assets/smartFill/img424164da758808.jpg'
-				}
-			},
-			{
-				id:4,
-				item: {
-					avatarUrl:'https://img.js.design/assets/smartFill/img320164da746310.jpg',
-					merchantName: '商家4',
-					lastMessageRecord: '你好',
-					messageTime: '10-31',
-					commodityPicture: 'https://img.js.design/assets/smartFill/img409164da755928.jpg'
-				}
-			},
-			{
-				id:5,
-				item: {
-					avatarUrl:'https://img.js.design/assets/smartFill/img340164da748e08.jpg',
-					merchantName: '商家5',
-					lastMessageRecord: '你好',
-					messageTime: '10-31',
-					commodityPicture: 'https://img.js.design/assets/smartFill/img427164da758808.jpg'
+				item:{
+					avatarUrl: "http://192.168.31.28:8084/pics/1698845584tmp_69fe84d4b7b444512c31c8693e95336113d42d50aaca0699.jpg",
+					commodityPicture: "https://img.js.design/assets/img/64ca428a87e21a113298b895.jpg",
+					merchantName: "cherry"
 				}
 				}
 			}
 			}
 		]
 		]
@@ -79,30 +75,76 @@ Page({
      * 生命周期函数--监听页面加载
      * 生命周期函数--监听页面加载
      */
      */
     onLoad(options) {
     onLoad(options) {
-		addUserRelation(addRelationOption).then((res) => {
-			console.log(res);
-		}).catch((err) => {
-			console.log(err);
-		})
+		// addUserRelation(addRelationOption).then((res) => {
+		// 	console.log(res);
+		// }).catch((err) => {
+		// 	console.log(err);
+		// })
 		getUserRelation(getRelationOption).then((res) => {
 		getUserRelation(getRelationOption).then((res) => {
 			console.log(res);
 			console.log(res);
+			console.log(res.data.data.fUid.length);
+			var fUidLength = res.data.data.fUid.length;
+			var target = [];
+			for(var i=0;i<fUidLength;i++)
+			{
+				target[i] = res.data.data.fUid[i].target;
+			}
+			var goodsId = [];
+			for(var i=0;i<fUidLength;i++)
+			{
+				goodsId[i] = res.data.data.fUid[i].goodsId;
+			}
+			console.log(target);
+			console.log(goodsId);
+			getUserInfoListOption.data.uid = target;
+			console.log(getUserInfoListOption);
+			getUserInfoList(getUserInfoListOption).then((res) => {
+				console.log(res);
+				for(var i=0;i<res.data.data.users.length;i++)
+				{
+					message[i][key3] = i+1;
+					message[i].item[key1] = res.data.data.users[i].avatar;
+					message[i].item[key2] = res.data.data.users[i].name;
+					message.push({item:{}});
+				}
+				console.log(message);
+				getGoodsInfoListOption.data.id = goodsId;
+				getGoodsInfoList(getGoodsInfoListOption).then((res => {
+					console.log(res);
+					for(var i=0;i<res.data.data.goods.length;i++)
+					{
+						message[i].item[key] = res.data.data.goods[i].Pic;
+					}
+					console.log(message);
+				})).catch((err) => {
+					console.log(err);
+				})
+			}).catch((err) => {
+				console.log(err);
+			})
 		}).catch((err) => {
 		}).catch((err) => {
 			console.log(err);
 			console.log(err);
 		})
 		})
+		this.setData({
+			message:message,
+		})
     },
     },
 
 
     /**
     /**
      * 生命周期函数--监听页面初次渲染完成
      * 生命周期函数--监听页面初次渲染完成
      */
      */
     onReady() {
     onReady() {
-
+		
     },
     },
 
 
     /**
     /**
      * 生命周期函数--监听页面显示
      * 生命周期函数--监听页面显示
      */
      */
     onShow() {
     onShow() {
-
+		// console.log(message);
+		// this.setData({
+		// 	message:message,
+		// })
     },
     },
 
 
     /**
     /**