|
@@ -1,6 +1,11 @@
|
|
|
|
|
|
-const { getCategoryAPI,getClassifyGoods} = require('../../API/appraise')
|
|
|
-
|
|
|
+const { getCategoryAPI, getAllGoods, getUserInfo} = require('../../API/appraise')
|
|
|
+const { formatTime } = require('../../utils/util')
|
|
|
+var getOrderOption = {
|
|
|
+ data: {
|
|
|
+ id: wx.getStorageSync('uid'),
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
Page({
|
|
|
|
|
@@ -12,6 +17,14 @@ Page({
|
|
|
classifyList: [],
|
|
|
|
|
|
scrollTop: 0,
|
|
|
+
|
|
|
+ allGoods: [],
|
|
|
+ page: 1,
|
|
|
+ pageSize: 6,
|
|
|
+ isLoading: false,
|
|
|
+ time: Number,
|
|
|
+ id: 0,
|
|
|
+ uid: Number
|
|
|
},
|
|
|
|
|
|
userTo() {
|
|
@@ -24,6 +37,11 @@ Page({
|
|
|
url: '/pages/classify/classify',
|
|
|
})
|
|
|
},
|
|
|
+ messageTo() {
|
|
|
+ wx.switchTab({
|
|
|
+ url: '/pages/message/message',
|
|
|
+ })
|
|
|
+ },
|
|
|
searchTo() {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/search/search',
|
|
@@ -32,8 +50,9 @@ Page({
|
|
|
|
|
|
detailClassifyTo({ currentTarget }) {
|
|
|
const id = currentTarget.dataset.num;
|
|
|
+ const title = currentTarget.dataset.title;
|
|
|
wx.navigateTo({
|
|
|
- url: '/pages/classify_detail/classify_detail?classify_id=' + id,
|
|
|
+ url: '/pages/classify_detail/classify_detail?classify_id=' + id + '&title=' + title,
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -41,6 +60,7 @@ Page({
|
|
|
*/
|
|
|
onLoad(options) {
|
|
|
this.getClassifyList();
|
|
|
+ this.getGoodsList();
|
|
|
this.setData({
|
|
|
avatarUrl:wx.getStorageSync('avatarUrl'),
|
|
|
nickName:wx.getStorageSync('nickName')
|
|
@@ -49,16 +69,55 @@ Page({
|
|
|
|
|
|
getClassifyList() {
|
|
|
getCategoryAPI(this.data)
|
|
|
- .then((data) => {
|
|
|
+ .then((res) => {
|
|
|
+ const { code, data, mesage } = res.data;
|
|
|
this.setData({
|
|
|
classifyList: data
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
getGoodsList() {
|
|
|
- getClassifyGoods(this.data).then((data) => {
|
|
|
- console.log(data);
|
|
|
+ var time = formatTime(new Date());
|
|
|
+ this.setData({
|
|
|
+ time: time
|
|
|
+ })
|
|
|
+
|
|
|
+ wx.showLoading({
|
|
|
+ title: '数据获取中',
|
|
|
+ })
|
|
|
+ getAllGoods(this.data).then((res) => {
|
|
|
+ const { code, data, message } = res.data;
|
|
|
+ const d = data.data;
|
|
|
+ this.setData({
|
|
|
+ allGoods: [...this.data.allGoods, ...d],
|
|
|
+ isLoading: true
|
|
|
+ })
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ isLoading: false
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ detailTo(e) {
|
|
|
+ const id = e.currentTarget.dataset.id;
|
|
|
+ const title = e.currentTarget.dataset.title;
|
|
|
+ const price = e.currentTarget.dataset.price;
|
|
|
+ const comImg = e.currentTarget.dataset.pic;
|
|
|
+ this.setData({
|
|
|
+ uid: parseInt(getOrderOption.data.id)
|
|
|
+ })
|
|
|
+ const uid = this.data.uid;
|
|
|
+
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/details/details?id=' + id + '&title=' + title + '&price=' + price + '&img=' + comImg + '&uid=' + uid,
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -100,7 +159,12 @@ Page({
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom() {
|
|
|
-
|
|
|
+ if(this.data.isLoading) {
|
|
|
+ this.setData({
|
|
|
+ page: this.data.page + 1,
|
|
|
+ })
|
|
|
+ this.getGoodsList()
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
|
|
@@ -108,16 +172,6 @@ Page({
|
|
|
*/
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- * 监听页面滑动
|
|
|
- */
|
|
|
- onPageScroll(data) {
|
|
|
-
|
|
|
- this.setData({
|
|
|
- scrollTop: data.scrollTop
|
|
|
- })
|
|
|
}
|
|
|
})
|
|
|
|