message.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. // pages/message/message.js
  2. const {getUserRelation,addUserRelation, getUserInfoList, getGoodsInfoList} = require('../../API/appraise')
  3. import messageMap from '../../utils/util'
  4. var getRelationOption = {
  5. data:{
  6. }
  7. }
  8. var addRelationOption = {
  9. data:{
  10. "goodsId":9,
  11. "owner": '7386090454720188416',
  12. "target": '7384540497554968576',
  13. "type":1
  14. }
  15. }
  16. var getUserInfoListOption = {
  17. data:{
  18. uid:[]
  19. }
  20. }
  21. var getGoodsInfoListOption = {
  22. data:{
  23. id:[]
  24. }
  25. }
  26. var key = "commodityPicture";
  27. let key1 = "avatarUrl";
  28. let key2 = "merchantName";
  29. let key3 = "id";
  30. function sendSocketMessage(msg){
  31. wx.sendSocketMessage({
  32. data: msg,
  33. })
  34. }
  35. Page({
  36. /**
  37. * 页面的初始数据
  38. */
  39. data: {
  40. message:[
  41. {
  42. id:1,
  43. item:{
  44. avatarUrl: "http://192.168.31.30:8084/pics/1698753512AiD8PaNrvqsDb1493fda534929a5b5d05f80a8cf3d16.jpg",
  45. commodityPicture: "https://img.js.design/assets/img/6229b69ff89eeaf3b7fd1919.jpg",
  46. merchantName: "daisy",
  47. lastMessageRecord:'你好',
  48. messageTime:'11-7 21:42'
  49. }
  50. },
  51. {
  52. id:2,
  53. item:{
  54. avatarUrl: "https://img.js.design/assets/img/61c6d4ab9cd4d011e8f0b298.png",
  55. commodityPicture: "https://img.js.design/assets/smartFill/img334164da748e08.jpg",
  56. merchantName: "kaka",
  57. lastMessageRecord:'价格可以商量一下吗',
  58. messageTime:'11-6 21:11'
  59. }
  60. },
  61. {
  62. id:3,
  63. item:{
  64. avatarUrl: "http://192.168.31.30:8084/pics/1698845584tmp_69fe84d4b7b444512c31c8693e95336113d42d50aaca0699.jpg",
  65. commodityPicture: "https://img.js.design/assets/img/64ca428a87e21a113298b895.jpg",
  66. merchantName: "cherry",
  67. lastMessageRecord:'OK',
  68. messageTime:'11-4 19:46'
  69. }
  70. },
  71. {
  72. id:4,
  73. item:{
  74. avatarUrl: "http://192.168.31.30:8084/pics/1698846108tmp_c0bcb90fd9ef93e065c22b977d7bc8aea17a1ac1e8393c21.jpg",
  75. commodityPicture: "https://img.js.design/assets/smartFill/img313164da746310.jpg",
  76. merchantName: "666",
  77. lastMessageRecord:'期待下次交易',
  78. messageTime:'11-1 21:30'
  79. }
  80. },
  81. ]
  82. },
  83. /**
  84. * 生命周期函数--监听页面加载
  85. */
  86. onLoad(options) {
  87. },
  88. /**
  89. * 生命周期函数--监听页面初次渲染完成
  90. */
  91. onReady() {
  92. var message = this.data.message;
  93. // addUserRelation(addRelationOption).then((res) => {
  94. // console.log(res);
  95. // }).catch((err) => {
  96. // console.log(err);
  97. // })
  98. // getRelationOption.data = {
  99. // uid: wx.getStorageSync('uid'),
  100. // }
  101. // getUserRelation(getRelationOption).then((res) => {
  102. // console.log(res);
  103. // const fUid = res.data.data.fUid;
  104. // let fUidLength = fUid.length;
  105. // let target = [];
  106. // for(let i=0;i<fUidLength;i++)
  107. // {
  108. // target[i] = fUid[i].target;
  109. // }
  110. // var goodsId = [];
  111. // for(let i=0;i<fUidLength;i++)
  112. // {
  113. // goodsId[i] = fUid[i].goodsId;
  114. // }
  115. // console.log(target);
  116. // console.log(goodsId);
  117. // getUserInfoListOption.data.uid = target;
  118. // console.log(getUserInfoListOption);
  119. // getUserInfoList(getUserInfoListOption).then((res) => {
  120. // console.log(res);
  121. // const users = res.data.data.users;
  122. // for(let i=0;i<users.length;i++)
  123. // {
  124. // message.push({item:{}});
  125. // message[i][key3] = i+1;
  126. // message[i].item[key1] = users[i].avatar;
  127. // message[i].item[key2] = users[i].name;
  128. // message[i].item['targetId'] = users[i].uid;
  129. // }
  130. // console.log(message);
  131. // getGoodsInfoListOption.data.id = goodsId;
  132. // getGoodsInfoList(getGoodsInfoListOption).then((res => {
  133. // console.log(res);
  134. // const goods = res.data.data.goods;
  135. // for(let i=0;i<goods.length;i++)
  136. // {
  137. // message[i].item[key] = goods[i].Pic;
  138. // message[i].item['goodsId'] = goods[i].Id;
  139. // }
  140. // this.setData({
  141. // message:message
  142. // })
  143. // })).catch((err) => {
  144. // console.log(err);
  145. // })
  146. // }).catch((err) => {
  147. // console.log(err);
  148. // })
  149. // }).catch((err) => {
  150. // console.log(err);
  151. // })
  152. },
  153. /**
  154. * 生命周期函数--监听页面显示
  155. */
  156. onShow() {
  157. },
  158. /**
  159. * 生命周期函数--监听页面隐藏
  160. */
  161. onHide() {
  162. },
  163. /**
  164. * 生命周期函数--监听页面卸载
  165. */
  166. onUnload() {
  167. },
  168. /**
  169. * 页面相关事件处理函数--监听用户下拉动作
  170. */
  171. onPullDownRefresh() {
  172. },
  173. /**
  174. * 页面上拉触底事件的处理函数
  175. */
  176. onReachBottom() {
  177. },
  178. /**
  179. * 用户点击右上角分享
  180. */
  181. onShareAppMessage() {
  182. },
  183. toChat(e) {
  184. let item = e.target.dataset.item;
  185. wx.navigateTo({
  186. url: '/pages/chat/chat?toUid='+item.targetId+'&goodsId='+item.goodsId,
  187. })
  188. }
  189. })