|
@@ -1,4 +1,5 @@
|
|
|
// pages/shouye/shouye.js
|
|
|
+const util = require('../../utils/util.js')
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -60,7 +61,16 @@ Page({
|
|
|
defaultImage: '/pages/components/nav/images/tab-icon/bathroom.png',
|
|
|
}
|
|
|
}
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ goodsList:[],
|
|
|
+ listId:"",
|
|
|
+ page:1,
|
|
|
+ pageSize:10,
|
|
|
+ currentPage:0,
|
|
|
+ totalCount:0,
|
|
|
+ listId:"",
|
|
|
+ show:true,
|
|
|
+ lType:"loading"
|
|
|
},
|
|
|
|
|
|
_asyncData() {
|
|
@@ -97,6 +107,38 @@ Page({
|
|
|
onLoad: function (options) {
|
|
|
// this._asyncData
|
|
|
setTimeout(this._asyncData, 0);
|
|
|
+ //获取数据
|
|
|
+ var that = this;
|
|
|
+ that.page = 1
|
|
|
+ that.pageSize = 18
|
|
|
+ wx.request( {
|
|
|
+ url: "http://49.234.19.130:8081/v1/pdd/ddk/search",
|
|
|
+ //url: "http://127.0.0.1:8081/v1/pdd/ddk/search",
|
|
|
+ header: {
|
|
|
+ "Content-Type": "application/json"
|
|
|
+ },
|
|
|
+ method: "POST",
|
|
|
+ //data: { cityname: "上海", key: "1430ec127e097e1113259c5e1be1ba70" },
|
|
|
+ data: { page: that.page.toString(), page_size: that.pageSize.toString() },
|
|
|
+ complete: function( res ) {
|
|
|
+ wx.hideLoading();
|
|
|
+ console.log(res)
|
|
|
+ that.totalCount = res.data.data.goods_search_response.total_count
|
|
|
+ for (var i = 0; i < res.data.data.goods_search_response.goods_list.length; i++) {
|
|
|
+ that.data.goodsList.push( res.data.data.goods_search_response.goods_list[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ goodsList: that.data.goodsList,
|
|
|
+ })
|
|
|
+
|
|
|
+ console.log(res.data.data.goods_search_response)
|
|
|
+ if( res == null || res.data == null ) {
|
|
|
+ console.error( '网络请求失败' );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
search(){
|
|
@@ -105,6 +147,36 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ goodsCollection: function(e){
|
|
|
+ var that=this
|
|
|
+ var currentPage=that.data.page+1;
|
|
|
+ wx.request({
|
|
|
+ url: 'http://49.234.19.130:8081/v1/pdd/ddk/search',
|
|
|
+ data: {
|
|
|
+ listId:that.data.listId,
|
|
|
+ pageSize:10,
|
|
|
+ page: that.data.page+1,
|
|
|
+ },
|
|
|
+ method:'GET',
|
|
|
+ header:{
|
|
|
+ 'Accept': 'application/json'
|
|
|
+ },
|
|
|
+
|
|
|
+ success (res) {
|
|
|
+ wx.hideLoading();
|
|
|
+ for (var i = 0; i < res.data.goodsSearchInfo.goodsSearchResponse.goodsList.length; i++) {
|
|
|
+ that.data.goodsList.push( res.data.goodsSearchInfo.goodsSearchResponse.goodsList[i]);
|
|
|
+ }
|
|
|
+ that.setData({
|
|
|
+ goodsList: that.data.goodsList,//res.data.goodsSearchInfo.goodsSearchResponse.goodsList,
|
|
|
+ listId:res.data.goodsSearchInfo.goodsSearchResponse.listId,
|
|
|
+ currentPage:currentPage
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
@@ -144,7 +216,54 @@ Page({
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
+ //获取数据
|
|
|
+ var that = this;
|
|
|
+ if ((that.totalCount+that.pageSize-1)/that.pageSize <= that.page){ //提示页码到了
|
|
|
+ that.setData({
|
|
|
+ lType:"end"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ that.page +=1
|
|
|
+ wx.request( {
|
|
|
+ url: "http://49.234.19.130:8081/v1/pdd/ddk/search",
|
|
|
+ // url: "http://127.0.0.1:8081/v1/pdd/ddk/search",
|
|
|
+ header: {
|
|
|
+ "Content-Type": "application/json"
|
|
|
+ },
|
|
|
+ method: "POST",
|
|
|
+ //data: { cityname: "上海", key: "1430ec127e097e1113259c5e1be1ba70" },
|
|
|
+ data: { page: that.page.toString(), page_size: that.pageSize.toString() },
|
|
|
+ complete: function( res ) {
|
|
|
+ wx.hideLoading();
|
|
|
+ console.log(res)
|
|
|
+ that.totalCount = res.data.data.goods_search_response.total_count
|
|
|
+ for (var i = 0; i < res.data.data.goods_search_response.goods_list.length; i++) {
|
|
|
+ that.data.goodsList.push( res.data.data.goods_search_response.goods_list[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ goodsList: that.data.goodsList,
|
|
|
+ })
|
|
|
+
|
|
|
+ console.log(res.data.data.goods_search_response)
|
|
|
+ if( res == null || res.data == null ) {
|
|
|
+ console.error( '网络请求失败' );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
+ goodsDetail:function(e){
|
|
|
+ const goodsSign=e.currentTarget.dataset.sign;
|
|
|
+ const searchId=e.currentTarget.dataset.searchid;
|
|
|
+
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/pages/details/details?goodsSign=${goodsSign}&searchId=${searchId}`,
|
|
|
+ // url: `/pages/goods-detail/index`,
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/**
|