123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432 |
- // pages/shouye/shouye.js
- const util = require('../../utils/util.js')
- const app = getApp()
- const link = app.globalData.url
- 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",
- activity_tags:"",
- // pid:"9112489_209622235",
- pid:"9112489_212035116",
- keyword:""
- },
- _asyncData() {
- this.setData({
- scrollAbleTabs: [
- {
- tab: '精选',
- key: '0'
- },
- {
- tab: '秒杀',
- key: '4'
- }, {
- tab: '百亿补贴',
- key: '7'
- }, {
- tab: '千万补贴',
- key: '10851'
- }, {
- tab: '品牌',
- key: '31'
- },{
- tab:'官方爆品',
- key:'10564'
- },
- {
- tab:'大牌',
- key:'24'
- }],
- });
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // this._asyncData
- var that = this;
- that.page = 1
- that.pageSize = 18
-
- //获取数据
- setTimeout(that._asyncData, 0);
- wx.request( {
- url: link + "/v1/forward/lhf",
- header: {
- "Content-Type": "application/json",
- "function":"/v1/pdd/ddk/search"
- },
- method: "POST",
- 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:function(e){
- var that = this
- console.log(e)
- that.keyword = e.detail.value
- that.activity_tags = ""
- that.pid = "9112489_209622235"
- console.log(that.keyword)
- console.log(that.pid)
- that.page = 1
- that.pageSize = 18
- wx.request( {
- url: link + "/v1/forward/lhf",
- header: {
- "Content-Type": "application/json",
- "function":"/v1/pdd/ddk/search"
- },
- method: "POST",
- data: { page: that.page.toString(), page_size: that.pageSize.toString(), activity_tags: that.activity_tags, pid:that.pid, keyword: that.keyword},
- complete: function( res ) {
- wx.hideLoading();
- console.log(res)
-
- that.totalCount = res.data.data.goods_search_response.total_count
- that.data.goodsList = res.data.data.goods_search_response.goods_list
- // 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;
- }
- }
- })
-
-
- // wx.navigateTo({
- // url: '../search/search'
- // })
- },
- keyData:function(e){
- var that = this
- that.keyword = ""
- if (e.detail.activeKey == "0"){
- that.activity_tags = ""
- } else{
- that.activity_tags = "["+e.detail.activeKey + "]"
- }
-
- console.log(e)
- that.page = 1
- that.pageSize = 18
- wx.request( {
- url: link + "/v1/forward/lhf",
- header: {
- "Content-Type": "application/json",
- "function":"/v1/pdd/ddk/search"
- },
- method: "POST",
- data: { page: that.page.toString(), page_size: that.pageSize.toString(), activity_tags: that.activity_tags},
- complete: function( res ) {
- wx.hideLoading();
- console.log(res)
-
- that.totalCount = res.data.data.goods_search_response.total_count
- that.data.goodsList = res.data.data.goods_search_response.goods_list
- // 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;
- }
- }
- })
- },
- goodsCollection: function(e){
- var that=this
- var currentPage=that.data.page+1;
- wx.request({
- url: link + '/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 () {
- var that = this
- wx.getClipboardData({
- success (res){
- console.log(res.data)
- var da = res.data
- if (res.data != 0){
- console.log('不为0')
- wx.setClipboardData({
- data: '0',
- success (res) {
- }
- })
- wx.showModal({
- title: '搜索产品',
- content: res.data,
- success: function(res) {
- if (res.confirm) {
- console.log('用户点击确认')
- //搜索数据
- that.page = 1
- that.pageSize = 18
- that.pid = "9112489_209622235"
- that.keyword = da
- that.activity_tags = ""
- wx.request( {
- url: link + "/v1/forward/lhf",
- header: {
- "Content-Type": "application/json",
- "function":"/v1/pdd/ddk/search"
- },
- method: "POST",
- // data: { page: that.page.toString(), page_size: that.pageSize.toString(),with_coupon:"true", activity_tags: that.activity_tags},
- data: { page: that.page.toString(), page_size: that.pageSize.toString(), pid:that.pid, activity_tags: that.activity_tags,keyword: that.keyword},
- complete: function( res ) {
- wx.hideLoading();
-
- console.log(res)
- that.totalCount = res.data.data.goods_search_response.total_count
- that.data.goodsList = res.data.data.goods_search_response.goods_list
- that.setData({
- goodsList: that.data.goodsList,
- })
-
- console.log(res.data.data.goods_search_response)
- if( res == null || res.data == null ) {
- console.error( '网络请求失败' );
- return;
- }
- }
- })
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- 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: link + "/v1/forward/lhf",
- // url: "http://127.0.0.1:8081/v1/pdd/ddk/search",
- header: {
- "Content-Type": "application/json",
- "function":"/v1/pdd/ddk/search"
- },
- method: "POST",
- //data: { cityname: "上海", key: "1430ec127e097e1113259c5e1be1ba70" },
- data: { page: that.page.toString(), page_size: that.pageSize.toString(), activity_tags: that.activity_tags,keyword:that.keyword,pid:that.pid},
- 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 () {
- // }
- })
|