123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- // pages/shouye/shouye.js
- const util = require('../../utils/util.js')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- placement: 'left',
- placementArr: ['top', 'left', 'right', 'bottom'],
- scrollAbleTabs: [],
- iconTabs: [{
- tab: '购物车',
- key: 'cart',
- icon: 'cart',
- picPlacement: 'left'
- }, {
- tab: '历史记录',
- key: 'history',
- icon: 'history',
- picPlacement: 'left'
- }, {
- tab: '我的',
- key: 'mine',
- icon: 'user',
- picPlacement: 'left'
- }],
- imagesTabs: [{
- tab: '客厅',
- key: 'dining',
- picPlacement: 'top',
- image: {
- activeImage: '/pages/components/nav/images/tab-icon/dining-active.png',
- defaultImage: '/pages/components/nav/images/tab-icon/dining.png',
- }
- },
- {
- tab: '卧室',
- key: 'badroom',
- picPlacement: 'top',
- image: {
- activeImage: '/pages/components/nav/images/tab-icon/badroom-active.png',
- defaultImage: '/pages/components/nav/images/tab-icon/badroom.png',
- }
- }, {
- tab: '厨房',
- key: 'kichten',
- picPlacement: 'top',
- image: {
- activeImage: '/pages/components/nav/images/tab-icon/kichten-active.png',
- defaultImage: '/pages/components/nav/images/tab-icon/kichten.png',
- }
- },
- {
- tab: '浴室',
- key: 'bathroom',
- picPlacement: 'top',
- image: {
- activeImage: '/pages/components/nav/images/tab-icon/bathroom-active.png',
- 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() {
- this.setData({
- scrollAbleTabs: [{
- tab: '精选',
- key: 'treasure'
- }, {
- tab: '居家生活',
- key: 'life'
- }, {
- tab: '美食厨房',
- key: 'food'
- }, {
- tab: '服饰珠宝',
- key: 'cloth'
- }, {
- tab: '美妆洗护',
- key: 'cosmetics'
- },{
- tab:'家用电器',
- key:'one'
- },
- {
- tab:'运动女装',
- key:'sport'
- }],
- });
- },
- /**
- * 生命周期函数--监听页面加载
- */
- 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(){
- wx.navigateTo({
- url: '../search/search'
- })
- },
- 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
- })
-
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- 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`,
- })
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|