123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- // pages/message/message.js
- const {getUserRelation,addUserRelation, getUserInfoList, getGoodsInfoList} = require('../../API/appraise')
- var getRelationOption = {
- data:{
- uid: wx.getStorageSync('uid'),
- }
- }
- var addRelationOption = {
- data:{
- "goodsId":7,
- "owner": '7384540497554968576',
- "target": '7386092638421651456',
- "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({
- /**
- * 页面的初始数据
- */
- data: {
- // message:message
- message: [
- {
- id:1,
- item:{
- avatarUrl: "http://192.168.31.28:8084/pics/1698753512AiD8PaNrvqsDb1493fda534929a5b5d05f80a8cf3d16.jpg",
- commodityPicture: "https://img.js.design/assets/img/6229b69ff89eeaf3b7fd1919.jpg",
- merchantName: "daisy",
- }
- },
- {
- id:2,
- item:{
- avatarUrl: "http://192.168.31.28:8084/pics/1698845584tmp_69fe84d4b7b444512c31c8693e95336113d42d50aaca0699.jpg",
- commodityPicture: "https://img.js.design/assets/img/64ca428a87e21a113298b895.jpg",
- merchantName: "cherry"
- }
- }
- ]
-
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- // addUserRelation(addRelationOption).then((res) => {
- // console.log(res);
- // }).catch((err) => {
- // console.log(err);
- // })
- getUserRelation(getRelationOption).then((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) => {
- console.log(err);
- })
- this.setData({
- message:message,
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- // console.log(message);
- // this.setData({
- // message:message,
- // })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|