|
@@ -1,153 +1,179 @@
|
|
-// pages/patternList/patternList.js
|
|
|
|
-var app = getApp();
|
|
|
|
-var yongtuList = [];
|
|
|
|
-var duxiangList = [];
|
|
|
|
|
|
+// newsShop/pages/patternMenu/patternMenu.js
|
|
|
|
+let app = getApp();
|
|
|
|
+let host = app.globalData.servsers; // 请求的url
|
|
Page({
|
|
Page({
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 页面的初始数据
|
|
|
|
+ */
|
|
data: {
|
|
data: {
|
|
- urlHttp: '',
|
|
|
|
- yongtuList : yongtuList,
|
|
|
|
- duxiangList : duxiangList,
|
|
|
|
- yongtuLength : 0,
|
|
|
|
- duixiangLength : 0,
|
|
|
|
- activeTab1 : -1, //tab选中状态值
|
|
|
|
- activeTab2: -1,
|
|
|
|
- activeTab3: -1,
|
|
|
|
- activeId1 : -1, //记录选中tab的id
|
|
|
|
- activeId2: -1,
|
|
|
|
- activeId3: -1,
|
|
|
|
- activeName1: '', //记录选中tab的名称
|
|
|
|
- activeName2: '',
|
|
|
|
- activeName3: '',
|
|
|
|
- hiddenmodal: true, //弹窗
|
|
|
|
|
|
+ host:host,
|
|
|
|
+ isSelect: "1", //默认全部
|
|
|
|
+ dataStateArray: [
|
|
|
|
+ {
|
|
|
|
+ state: '1',
|
|
|
|
+ label: "营销礼赠",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ state: '2',
|
|
|
|
+ label: "商务送礼",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ state: '3',
|
|
|
|
+ label: "员工/福利",
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ filterArray: [
|
|
|
|
+ // { name: '1', value: '0~499元' },
|
|
|
|
+ // { name: '2', value: '500~999元' },
|
|
|
|
+ // { name: '3', value: '1000~1999元' },
|
|
|
|
+ // { name: '4', value: '2000元以上' },
|
|
|
|
+ ],
|
|
|
|
+ requestState:true, //检测请求状态是否结束了
|
|
|
|
+ filterStatic: false,
|
|
|
|
+ isNew: true,
|
|
|
|
+ isMin: true,
|
|
|
|
+ goodsList:[],
|
|
|
|
+ page:1, //默认是第一页
|
|
|
|
+ limit:20, //一页20条数据
|
|
|
|
+ maxPrice:null,//最大价格
|
|
|
|
+ minPrice:null,//最低价格
|
|
|
|
+ priceSort: null, //价格排序,默认降序
|
|
|
|
+ timeSort: null, //价时间排序,默认降序
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
|
+ */
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
- var that = this;
|
|
|
|
- var host = getApp().globalData.servsers;
|
|
|
|
- that.setData({
|
|
|
|
- urlHttp: host
|
|
|
|
- })
|
|
|
|
|
|
+ this.getGiftNavTab(this)
|
|
|
|
+ },
|
|
|
|
|
|
- wx.request({
|
|
|
|
- url: host + "commodityapi/findAllScene",
|
|
|
|
- data: {
|
|
|
|
- },
|
|
|
|
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
|
- header: {
|
|
|
|
- 'Accept': 'application/json'
|
|
|
|
- },
|
|
|
|
- success: function (res) {
|
|
|
|
- var yongtuLength = res.data.purposeList.length;
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
|
+ */
|
|
|
|
+ onReady: function () {
|
|
|
|
|
|
- console.log(res.data.objectList)
|
|
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
|
+ */
|
|
|
|
+ onShow: function () {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
|
+ */
|
|
|
|
+ onHide: function () {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
|
+ */
|
|
|
|
+ onUnload: function () {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
+ */
|
|
|
|
+ onPullDownRefresh: function () {
|
|
|
|
|
|
- var duixiangLength = res.data.objectList.length;
|
|
|
|
- that.setData({
|
|
|
|
- yongtuList: res.data.purposeList,
|
|
|
|
- duxiangList: res.data.objectList,
|
|
|
|
- yongtuLength: yongtuLength,
|
|
|
|
- duixiangLength: duixiangLength
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- //送礼用途
|
|
|
|
- yongtuClick:function(e){
|
|
|
|
- var that = this;
|
|
|
|
- var id = e.currentTarget.dataset.id;
|
|
|
|
- var activeName1 = e.currentTarget.dataset.name;
|
|
|
|
- var flagId = e.currentTarget.dataset.flagid;
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
|
+ */
|
|
|
|
+ onReachBottom: function () {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 用户点击右上角分享
|
|
|
|
+ */
|
|
|
|
+ onShareAppMessage: function () {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ tab(e){
|
|
|
|
+ let that = this;
|
|
that.setData({
|
|
that.setData({
|
|
- activeTab1 : id,
|
|
|
|
- activeName1: activeName1,
|
|
|
|
- activeId1: flagId
|
|
|
|
|
|
+ isSelect: e.currentTarget.dataset.id,
|
|
|
|
+ goodsList:[],
|
|
|
|
+ page:1,
|
|
})
|
|
})
|
|
|
|
+ that.getGiftList(that)
|
|
},
|
|
},
|
|
-
|
|
|
|
- //送礼对象
|
|
|
|
- duixiangClick: function (e) {
|
|
|
|
- var that = this;
|
|
|
|
- var id = e.currentTarget.dataset.id;
|
|
|
|
- var activeName2 = e.currentTarget.dataset.name;
|
|
|
|
- var flagId = e.currentTarget.dataset.flagid;
|
|
|
|
|
|
+ timeSortTap(){ // 时间筛选
|
|
|
|
+ let that = this;
|
|
that.setData({
|
|
that.setData({
|
|
- activeTab2: id,
|
|
|
|
- activeName2: activeName2,
|
|
|
|
- activeId2: flagId
|
|
|
|
|
|
+ timeSort: that.data.timeSort === null ? 'asc' : that.data.timeSort === 'asc' ? 'desc' : 'asc',
|
|
|
|
+ goodsList: [],
|
|
|
|
+ page: 1,
|
|
})
|
|
})
|
|
|
|
+ that.getGiftList(that)
|
|
},
|
|
},
|
|
-
|
|
|
|
- //预算范围
|
|
|
|
- fanweiClick:function(e){
|
|
|
|
- var that = this;
|
|
|
|
- var id = e.currentTarget.dataset.id;
|
|
|
|
- var activeName3 = e.currentTarget.dataset.name;
|
|
|
|
- var flagId = e.currentTarget.dataset.flagid;
|
|
|
|
|
|
+ priceSortTap() { // 价格筛选
|
|
|
|
+ let that = this;
|
|
that.setData({
|
|
that.setData({
|
|
- activeTab3: id,
|
|
|
|
- activeName3: activeName3,
|
|
|
|
- activeId3: flagId
|
|
|
|
|
|
+ priceSort: that.data.priceSort === null ? 'asc' : that.data.priceSort === 'asc' ? 'desc' : 'asc',
|
|
|
|
+ goodsList: [],
|
|
|
|
+ page: 1,
|
|
})
|
|
})
|
|
|
|
+ that.getGiftList(that)
|
|
},
|
|
},
|
|
-
|
|
|
|
- //生成礼品清单
|
|
|
|
- saveChange:function(e){
|
|
|
|
- var that = this;
|
|
|
|
- var host = getApp().globalData.servsers;
|
|
|
|
- var activeId1 = that.data.activeId1;
|
|
|
|
- var activeId2 = that.data.activeId2;
|
|
|
|
- var activeId3 = that.data.activeId3;
|
|
|
|
- var activeName1 = that.data.activeName1;
|
|
|
|
- var activeName2 = that.data.activeName2;
|
|
|
|
- var activeName3 = that.data.activeName3;
|
|
|
|
- if (activeId1 == -1) {
|
|
|
|
- that.setData({
|
|
|
|
- hiddenmodal: false,
|
|
|
|
- modalCont: '请选择送礼用途'
|
|
|
|
- })
|
|
|
|
- setTimeout(function () {
|
|
|
|
- that.setData({
|
|
|
|
- hiddenmodal: true
|
|
|
|
- })
|
|
|
|
- }, 1000)
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- if (activeId2 == -1) {
|
|
|
|
- that.setData({
|
|
|
|
- hiddenmodal: false,
|
|
|
|
- modalCont: '请选择送礼对象'
|
|
|
|
- })
|
|
|
|
- setTimeout(function () {
|
|
|
|
- that.setData({
|
|
|
|
- hiddenmodal: true
|
|
|
|
- })
|
|
|
|
- }, 1000)
|
|
|
|
- return false;
|
|
|
|
|
|
+ getGiftNavTab(that){
|
|
|
|
+ wx.request({
|
|
|
|
+ url: host + '/classifyapi/classifyTwoAll',
|
|
|
|
+ method: 'get',
|
|
|
|
+ data: {
|
|
|
|
+ classifyHigher:'3060'
|
|
|
|
+ },
|
|
|
|
+ success(res){
|
|
|
|
+ console.log(res,"res")
|
|
|
|
+ that.setData({
|
|
|
|
+ dataStateArray:res.data.rows,
|
|
|
|
+ isSelect:res.data.rows[0].id
|
|
|
|
+ })
|
|
|
|
+ that.getGiftList(that)
|
|
}
|
|
}
|
|
- if (activeId3 == -1) {
|
|
|
|
- that.setData({
|
|
|
|
- hiddenmodal: false,
|
|
|
|
- modalCont: '请选择预算范围'
|
|
|
|
- })
|
|
|
|
- setTimeout(function () {
|
|
|
|
- that.setData({
|
|
|
|
- hiddenmodal: true
|
|
|
|
- })
|
|
|
|
- }, 1000)
|
|
|
|
- return false;
|
|
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ getGiftList(that){
|
|
|
|
+ let data = {
|
|
|
|
+ channelId: 5, // 渠道id,现在为5,一件选礼为5
|
|
|
|
+ classId: that.data.isSelect,
|
|
|
|
+ limit: that.data.limit, // 一页20条数据
|
|
|
|
+ offset: that.data.page, //当前页数
|
|
|
|
+ }
|
|
|
|
+ if (that.data.priceSort) {
|
|
|
|
+ data.priceSort = that.data.priceSort
|
|
|
|
+ }
|
|
|
|
+ if (that.data.timeSort) {
|
|
|
|
+ data.timeSort = that.data.timeSort
|
|
|
|
+ }
|
|
|
|
+ if (that.data.maxPrice){
|
|
|
|
+ data.maxPrice = that.data.maxPrice
|
|
|
|
+ }
|
|
|
|
+ if (that.data.minPrice) {
|
|
|
|
+ data.minPrice = that.data.minPrice
|
|
|
|
+ }
|
|
|
|
+ wx.request({
|
|
|
|
+ url: host +'/commodityapi/queryCommodityByClass',
|
|
|
|
+ method:'get',
|
|
|
|
+ data:data,
|
|
|
|
+ success(res){
|
|
|
|
+ let dataArray = that.data.goodsList;
|
|
|
|
+ res.data.rows.forEach(el=>{
|
|
|
|
+ el.logo = el.commodity_logo.split(",")
|
|
|
|
+ })
|
|
|
|
+ dataArray.push(...res.data.rows)
|
|
|
|
+ that.setData({
|
|
|
|
+ goodsList: dataArray
|
|
|
|
+ })
|
|
}
|
|
}
|
|
- wx.navigateTo({
|
|
|
|
- url: '/pages/patternList/patternList?activeId1=' + that.data.activeId1 +
|
|
|
|
- '&activeName1=' + activeName1 +
|
|
|
|
- '&activeId2=' + that.data.activeId2 +
|
|
|
|
- '&activeName2=' + activeName2 +
|
|
|
|
- '&activeId3=' + activeId3 +
|
|
|
|
- '&activeName3=' + activeName3
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
|
|
+ })
|
|
}
|
|
}
|
|
-})
|
|
|
|
-var that;
|
|
|
|
-var Util = require('../../utils/util.js');
|
|
|
|
|
|
+})
|