daisy 1 tahun lalu
induk
melakukan
379f766af0

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

@@ -250,9 +250,8 @@ function postOrderChange(params) {
 
 //获取推荐商品
 function getRecommend(data) {
-    console.log(data);
     return request.get(
-        API.getRecommendUrl +`?id=${data.user_id}&size=${data.pageSize}`
+        API.getRecommendUrl +`?id=${data.user_id}&size=${data.recommendNum}`
     )
 }
 

+ 4 - 3
fore-end/pages/details/details.js

@@ -24,6 +24,7 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad(options) {
+        console.log(options);
         //将传递过来的关于商品的数据渲染到页面
         this.setData({
             id: options.id,//商品id
@@ -52,6 +53,7 @@ Page({
     GoodsDetail() {
         getGoodsDetail(this.data).then((res) => {
             const { code, data, message} = res.data; 
+            console.log(data);
             //通过获取详细信息将商品的描述获取并渲染
             this.setData({
                 desc: data.Desc,
@@ -62,11 +64,10 @@ Page({
         })
     },
     getUserInfo() {
-        var arr = [this.data.uid];
-        var owner = {data: {uid: []}};
-        owner.data.uid = arr;
+        var owner = {data: {id: [this.data.uid]}};
         console.log(owner);
         getUserInfoList(owner).then((res) => {
+            console.log(res);
             const {users} = res.data.data;
             this.setData({
                 avatar: users[0].avatar,

+ 28 - 69
fore-end/pages/home/home.js

@@ -28,6 +28,8 @@ Page({
         ownerId: [],//发布者ID
         ownerMsg: [],
         user_id: wx.getStorageSync('uid'),//用户id
+        recommendNum: 6,//推荐数目
+        newMsg: [],
     },
 
     userTo() {
@@ -63,8 +65,8 @@ Page({
      */
     onLoad(options) {
 		this.getClassifyList();
-        this.getGoodsList();
-        // this.getRecommendGoods();
+        // this.getGoodsList();
+        this.getRecommendGoods();
 		this.setData({
 			avatarUrl:wx.getStorageSync('avatarUrl'),
 			nickName:wx.getStorageSync('nickName')
@@ -80,8 +82,8 @@ Page({
             })
         })
     },
-    // 获取所有商品
-    getGoodsList() {
+    //获取推荐商品
+    getRecommendGoods() {
         var time = formatTime(new Date());
         this.setData({
             time: time
@@ -90,78 +92,35 @@ Page({
         wx.showLoading({
             title: '数据获取中',
         })
-        getAllGoods(this.data).then((res) => {
+        getRecommend(this.data)
+        .then((res) => {
             const { code, data, message } = res.data;
-            const d = data.data;
-            console.log(d);
-            var arr = [];
-            var owner = {data: {uid: []}};
-            for (let index = 0; index < d.length; index++) {
-                arr = [...arr, d[index].ownerId];
-            }
-            owner.data.uid = arr;
-            console.log(arr);
-            getUserInfoList(owner).then((res) => {
-                const {users} = res.data.data;
-                this.setData({
-                    ownerMsg: [...users, ...this.data.ownerMsg]
-                })
-                console.log(this.data.ownerMsg);
-            }).catch((err) => {
-                console.log(err);
-            })
+            // for (let index = 0; index < data.length; index++) {
+            //     // const ownId = {data: {id: [data[index].ownerId]}};
+            //     // getUserInfoList(ownId).then((res) => {
+            //     //     const {code, data, message} = res.data;
+            //     //     if(data.users != null) {
+            //     //         console.log(data.users[0]);
+            //     //         // data[index].avatar = data.users[0].avatar;
+            //     //         // data[index].name = data.users[0].name;
+            //     //         console.log(data.users[0].name);
+            //     //     }
+            //     // }).catch((err) => {
+            //     //     console.log(err);
+            //     // })                
+            // }
             this.setData({
-                allGoods: [...this.data.allGoods, ...d],
+                allGoods: [...this.data.allGoods, ...data],
                 isLoading: true
             })
+            // console.log(this.data.allGoods);
+        }).catch((err) => {
+            console.log(err);
         })
         this.setData({
             isLoading: false
         })
     },
-    //获取推荐商品
-    // getRecommendGoods() {
-    //     var time = formatTime(new Date());
-    //     this.setData({
-    //         time: time
-    //     })
-    //     //加载的loading效果
-    //     // wx.showLoading({
-    //     //     title: '数据获取中',
-    //     // })
-    //     getRecommend(this.data)
-    //     .then((res) => {
-    //         console.log(res);
-    //         const { code, data, message } = res.data;
-    //         const d = data.data;
-    //         console.log(d);
-    //         var arr = [];
-    //         var owner = {data: {uid: []}};
-    //         for (let index = 0; index < d.length; index++) {
-    //             arr = [...arr, d[index].ownerId];
-    //         }
-    //         owner.data.uid = arr;
-    //         console.log(arr);
-    //         getUserInfoList(owner).then((res) => {
-    //             const {users} = res.data.data;
-    //             this.setData({
-    //                 ownerMsg: [...users, ...this.data.ownerMsg]
-    //             })
-    //             console.log(this.data.ownerMsg);
-    //         }).catch((err) => {
-    //             console.log(err);
-    //         })
-    //         this.setData({
-    //             allGoods: [...this.data.allGoods, ...d],
-    //             isLoading: true
-    //         })
-    //     }).catch((err) => {
-    //         console.log(err);
-    //     })
-    //     this.setData({
-    //         isLoading: false
-    //     })
-    // },
     sendOwnerId() {
 
     },
@@ -222,9 +181,9 @@ Page({
     onReachBottom() {
         if(this.data.isLoading) {
             this.setData({
-                page: this.data.page + 1,
+                recommendNum: this.data.recommendNum + 6
             })
-            this.getGoodsList()
+            this.getRecommendGoods()
         }
     },
 

+ 0 - 3
fore-end/pages/home/home.wxml

@@ -61,9 +61,6 @@
             <image src="{{item.Pic}}" alt="" class="commodity_image"/>
             <text class="commodity_name">{{item.Title}}</text>
             <text class="price">¥{{item.Price}}</text>
-            <!-- <avatar
-                ownerId = '{{item.ownerId}}'
-            ></avatar> -->
             <!-- <view class="seller" bind:tap="showInfo" wx:for="{{ownerMsg}}" wx:key="index">
                 <view class="avater">
                     <image src="{{item.avatar}}" mode="" class="avatar_pic"/>