diff --git a/app.json b/app.json index a8cf5e3..2a1a647 100644 --- a/app.json +++ b/app.json @@ -160,7 +160,10 @@ "pages": [ "pages/presell/list/list", "pages/presell/cart/cart", - "pages/presell/goodsInfo/goodsInfo" + "pages/presell/goodsInfo/goodsInfo", + "pages/goods/distributionCategoryList/index", + "pages/goods/goodsList/goodsList", + "pages/payForAnother/payForAnother" ] } diff --git a/packageA/pages/distribution/shop/shop.js b/packageA/pages/distribution/shop/shop.js index 32c1409..a412f34 100644 --- a/packageA/pages/distribution/shop/shop.js +++ b/packageA/pages/distribution/shop/shop.js @@ -1,260 +1,265 @@ // packageA//pages/distribution/commision/commision.js -const app = getApp(); +const app = getApp(); let self = null; -var os = app.globalData.setting, - ut= require("../../../../utils/util.js"); - - +var os = app.globalData.setting, + ut = require("../../../../utils/util.js"); + + Page({ /** * 页面的初始数据 */ data: { - isInputFocus: false,//记录搜索输入框是否聚焦 - inputVal: '',//记录搜索输入框的内容 - isSort: false,//控制排序开关状态,true开启排序 - isDescending: false, //isDescending降序,ascending升序 - imghost: '', - url: os.imghost, - - tabArr: ['最新','销量','评论','价格'], - currentTabIndex: 0, - isShowRow: false,//控制视图切换状态 - isHiddenDropdown: true,//控制筛选下拉菜单显隐 - - list: null, - isLoading: false, // 检测是否已经发送请求,防止重复发送请求 - noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 - pageNum: 1, // 当前页数 - - - rank_switch: false, - card_field: "", - card_name: "", - max_card_field: "", - card_list: null, - - isAll: true, - - default_img: '/miniapp/images/default_g_img.gif', + isInputFocus: false,//记录搜索输入框是否聚焦 + inputVal: '',//记录搜索输入框的内容 + isSort: false,//控制排序开关状态,true开启排序 + isDescending: false, //isDescending降序,ascending升序 + imghost: '', + url: os.imghost, + + tabArr: ['最新', '销量', '评论', '价格'], + currentTabIndex: 0, + isShowRow: false,//控制视图切换状态 + isHiddenDropdown: true,//控制筛选下拉菜单显隐 + + list: null, + isLoading: false, // 检测是否已经发送请求,防止重复发送请求 + noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 + pageNum: 1, // 当前页数 + + + rank_switch: false, + card_field: "", + card_name: "", + max_card_field: "", + card_list: null, + + isAll: true, + + default_img: '/miniapp/images/default_g_img.gif', }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - - wx.setNavigationBarTitle({ - title: "我的小店", - }); - self = this;//保存全局指针 - app.isLogin().then(function(data) {//进入页面前已经授权登录成功 - self.setData({ - userInfo: data, - }); - }); - - //从别人的分享的跳转过来 - var first_leader = decodeURIComponent(options.scene); - if(first_leader && first_leader!='undefined'){ - getApp().globalData.first_leader=first_leader; - this.data.first_leader=first_leader; - - getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + first_leader, { - isShowLoading:false, - data:{r:Math.random()}, - success: function (e) { - if(e.data.code==0){ - self.setData({ - userInfo2:e.data.data, - }); - }; - - }, - }); - - } - - - // 判断会员是否授权登录, - // 没有登录则跳转到登录页, - // 已登录则设置已登录状态,请求加载签到数据 - // isLogin记录登录状态 - // app.isLogin().then(function(data) { - // // 1.登录成功 - // self.setData({ - // isLogin: true, - // userInfo: data, - // currentQuery: { - // store_id: app.globalData.setting.stoid, - // user_id: app.globalData.user_id, - // }, - // }); - // // 2.请求全部商品数据 - // self.getData(true, '/api/weshop/users/distribut/pagemyshop', self.data.currentQuery); - // // 3.请求新品 - // app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { - // data: self.data.currentQuery, - // }).then(function(res) { - // self.setData({ - // newList: res.data.data, - // }); - // }) - // }); + console.log(options); + wx.setNavigationBarTitle({ + title: "我的小店", + }); + + self = this;//保存全局指针 + app.isLogin().then(function (data) {//进入页面前已经授权登录成功 + self.setData({ + userInfo: data, + }); + }); + //从别人的分享的跳转过来 + var first_leader = decodeURIComponent(options.scene); + if (first_leader && first_leader != 'undefined') { + getApp().globalData.first_leader = first_leader; + this.data.first_leader = first_leader; + + getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + first_leader, { + isShowLoading: false, + data: { r: Math.random() }, + success: function (e) { + if (e.data.code == 0) { + self.setData({ + userInfo2: e.data.data, + }); + }; + + }, + }); + + } + + + // 判断会员是否授权登录, + // 没有登录则跳转到登录页, + // 已登录则设置已登录状态,请求加载签到数据 + // isLogin记录登录状态 + // app.isLogin().then(function(data) { + // // 1.登录成功 + // self.setData({ + // isLogin: true, + // userInfo: data, + // currentQuery: { + // store_id: app.globalData.setting.stoid, + // user_id: app.globalData.user_id, + // }, + // }); + // // 2.请求全部商品数据 + // self.getData(true, '/api/weshop/users/distribut/pagemyshop', self.data.currentQuery); + // // 3.请求新品 + // app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { + // data: self.data.currentQuery, + // }).then(function(res) { + // self.setData({ + // newList: res.data.data, + // }); + // }) + // }); }, /** * 生命周期函数--监听页面初次渲染完成 */ - onReady: function () {}, + onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - //自己登录的 - if(app.globalData.userInfo && !this.data.first_leader) { - if(!this.data.isLogin) { - this.setData({ - userInfo: app.globalData.userInfo, - imghost: app.globalData.setting.imghost, - currentQuery: { - store_id: app.globalData.setting.stoid, - user_id: app.globalData.user_id, - }, - isLogin: true, - }); - - // 请求数据 - app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?orderType=desc', { - data: this.data.currentQuery, - }).then(res => { - self.setData({ - list: res.data.data, - total: res.data.data.total, - }); - }); - - // 新品 - app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2&orderType=desc', { - data: self.data.currentQuery, - }).then(res => { - self.setData({ - newList: res.data.data, - }); - }); - // 广告banner - app.request.promiseGet("/api/weshop/ad/page", { - data: { - pid: 401, - enabled: 1, - store_id: app.globalData.setting.stoid, - } - }).then(res => { - if(res.data.code == 0 && res.data.data) { - let item = res.data.data.pageData[0]; - if(item && item.ad_code) { - self.setData({ - ad_img: item.ad_code, - }); - }; - }; - }); - - }; - } - //被人分享点击开的 - else if(this.data.first_leader){ - this.setData({ - imghost: app.globalData.setting.imghost, - currentQuery: { - store_id: app.globalData.setting.stoid, - user_id: this.data.first_leader, - }, - isLogin: true, - }); - - // 请求数据 - this.getData(true, '/api/weshop/users/distribut/pagemyshop', this.data.currentQuery); - // 新品 - app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { - data: self.data.currentQuery, - }).then(res => { - self.setData({ - newList: res.data.data, - }); - }); - // 广告banner - app.request.promiseGet("/api/weshop/ad/page", { - data: { - pid: 401, - enabled: 1, - store_id: app.globalData.setting.stoid, - } - }).then(res => { - if(res.data.code == 0 && res.data.data) { - let item = res.data.data.pageData[0]; - if(item && item.ad_code) { - self.setData({ - ad_img: item.ad_code, - }); - }; - }; - }); - } - var th=this; - //更新一下会员的信息 - if(getApp().globalData.user_id) { - if(!getApp().globalData.userInfo['is_distribut']){ - th.setData({ishidden_comise:1}) - } - getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.user_id, { - isShowLoading:false, - success: function (e) { - getApp().globalData.userInfo = e.data.data; - getApp().getConfig2(function (e) { - var swithc_list = e.switch_list; - var sw_arr = JSON.parse(swithc_list); - //---如果后台有开等级卡的开关--- - if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { - th.setData({ - rank_switch: true - }); - //---回调卡的列表--- - th.getPlusCardType(function (ob) { - th.setData({ - card_list: ob.card_list - }); - var ti = setInterval(function () { - var user = getApp().globalData.userInfo; - if (!user) return false; - clearInterval(ti); - if (user.card_field && user['card_expiredate']) { - var str = user['card_expiredate'].replace(/-/g, '/'); - var end = new Date(str); - end = Date.parse(end) / 1000; - var now = ut.gettimestamp(); - //--- 判断是等级会员,且在有效期范围内 --- - if (user.card_field && now < end) { - var card_name = ob.name_map.get(user.card_field); - if (card_name.length > 4) card_name = card_name.substring(0, 8); - th.setData({ - card_field: user.card_field, - card_name: card_name, - card_list: ob.card_list - }); - } - } - }, 500) - }) - } - }) - } - }) - } - - + //自己登录的 + if (app.globalData.userInfo && !this.data.first_leader) { + if (!this.data.isLogin) { + this.setData({ + userInfo: app.globalData.userInfo, + imghost: app.globalData.setting.imghost, + isLogin: true, + currentQuery: { + store_id: app.globalData.setting.stoid, + user_id: app.globalData.user_id, + }, + }); + // 请求数据 + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?orderType=desc', { + data: this.data.currentQuery, + }).then(res => { + self.setData({ + list: res.data.data, + total: res.data.data.total, + }); + }); + + // 新品 + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2&orderType=desc', { + data: self.data.currentQuery, + }).then(res => { + self.setData({ + newList: res.data.data, + }); + }); + // 广告banner + app.request.promiseGet("/api/weshop/ad/page", { + data: { + pid: 401, + enabled: 1, + store_id: app.globalData.setting.stoid, + } + }).then(res => { + if (res.data.code == 0 && res.data.data) { + let item = res.data.data.pageData[0]; + if (item && item.ad_code) { + self.setData({ + ad_img: item.ad_code, + }); + }; + }; + }); + + }; + } + //被人分享点击开的 + else if (this.data.first_leader) { + console.log(11); + this.setData({ + imghost: app.globalData.setting.imghost, + currentQuery: { + store_id: app.globalData.setting.stoid, + user_id: this.data.first_leader, + }, + isLogin: true, + }); + console.log('fenxiang'); + // 请求数据 + this.getData(true, '/api/weshop/users/distribut/pagemyshop', this.data.currentQuery); + // 新品 + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { + data: self.data.currentQuery, + }).then(res => { + self.setData({ + newList: res.data.data, + }); + }); + // 广告banner + app.request.promiseGet("/api/weshop/ad/page", { + data: { + pid: 401, + enabled: 1, + store_id: app.globalData.setting.stoid, + } + }).then(res => { + if (res.data.code == 0 && res.data.data) { + let item = res.data.data.pageData[0]; + if (item && item.ad_code) { + self.setData({ + ad_img: item.ad_code, + }); + }; + }; + }); + } + var th = this; + //更新一下会员的信息 + if (getApp().globalData.user_id) { + if (!getApp().globalData.userInfo['is_distribut']) { + th.setData({ ishidden_comise: 1 }) + } + getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.user_id, { + isShowLoading: false, + success: function (e) { + getApp().globalData.userInfo = e.data.data; + getApp().getConfig2(function (e) { + var swithc_list = e.switch_list; + var sw_arr = JSON.parse(swithc_list); + //---如果后台有开等级卡的开关--- + if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { + th.setData({ + rank_switch: true + }); + //---回调卡的列表--- + th.getPlusCardType(function (ob) { + th.setData({ + card_list: ob.card_list + }); + var ti = setInterval(function () { + var user = getApp().globalData.userInfo; + if (!user) return false; + clearInterval(ti); + if (user.card_field && user['card_expiredate']) { + var str = user['card_expiredate'].replace(/-/g, '/'); + var end = new Date(str); + end = Date.parse(end) / 1000; + var now = ut.gettimestamp(); + //--- 判断是等级会员,且在有效期范围内 --- + if (user.card_field && now < end) { + var card_name = ob.name_map.get(user.card_field); + if (card_name.length > 4) card_name = card_name.substring(0, 8); + th.setData({ + card_field: user.card_field, + card_name: card_name, + card_list: ob.card_list + }); + } + } + }, 500) + }) + } + }) + } + }) + } + + if (app.globalData.key_word) { + this.setData({ + inputVal: app.globalData.key_word, + }) + this.search(); + } }, /** @@ -268,7 +273,7 @@ Page({ * 生命周期函数--监听页面卸载 */ onUnload: function () { - + app.globalData.key_word=null; }, /** @@ -282,449 +287,449 @@ Page({ * 页面上拉触底事件的处理函数 */ onReachBottom: function () { - let url = ''; - if(this.data.isAll) { - url = '/api/weshop/users/distribut/pagemyshop'; - } else { - url = '/api/weshop/users/distribut/pagemyshop?type=2'; - }; - this.scrollToLower(url, this.data.currentQuery); + let url = ''; + if (this.data.isAll) { + url = '/api/weshop/users/distribut/pagemyshop'; + } else { + url = '/api/weshop/users/distribut/pagemyshop?type=2'; + }; + this.scrollToLower(url, this.data.currentQuery); }, /** * 用户点击右上角分享 *--点击分享事件--分享我的小店 *--*/ - onShareAppMessage: function(t) { - + onShareAppMessage: function (t) { + var th = this; - var title= "我的小店"; - var user_id=this.data.first_leader; - if(!user_id){ - user_id=getApp().globalData.user_id - } - var url="/packageA/pages/distribution/shop/shop?scene=" + user_id; - if(getApp().globalData.user_id){ - url+="&first_leader="+getApp().globalData.user_id; + var title = "我的小店"; + var user_id = this.data.first_leader; + if (!user_id) { + user_id = getApp().globalData.user_id } - - var ob={ + var url = "/packageA/pages/distribution/shop/shop?scene=" + user_id; + if (getApp().globalData.user_id) { + url += "&first_leader=" + getApp().globalData.user_id; + } + + var ob = { title: title, - path:url, - }; + path: url, + }; return ob; - + + }, + + /** + * 点击下拉菜单 + */ + clickDropdown() { + this.setData({ + isHiddenDropdown: !this.data.isHiddenDropdown, + }); + }, + + /** + * 点击遮罩层 + */ + clickMask() { + this.setData({ + isHiddenDropdown: true, + }); + }, + + /** + * 选择下拉菜单项 + */ + selectDropdown(e) { + let currentIndex = e.target.dataset.index; + this.setData({ + isHiddenDropdown: true, + currentSelect: this.data.dropdownArr[currentIndex], + }); + }, + + /** + * 搜索输入框聚焦 + */ + inputFocus() { + this.setData({ + isInputFocus: true, + }); + }, + + + /** + * 搜索输入框失焦 + */ + inputBlur() { + this.setData({ + isInputFocus: false, + }); + }, + + /** + * 获取搜索输入框输入的内容 + */ + input(e) { + this.data.inputVal = e.detail.value; + }, + + /** + * 搜索输入框清空内容 + */ + inputClear() { + let inputVal = this.data.inputVal; + console.log('input', inputVal); + if (inputVal) { + this.setData({ + inputVal: '', + }); + }; + }, + + /** + * 搜索输入框聚焦 + */ + search() { + let data = this.data.currentQuery; + data.key = this.data.inputVal; + if (data.orderField) { + delete data.orderField; + }; + if (data.page) { + delete data.page; + }; + this.setData({ + currentTabIndex: 4, + isSort: false, + isDescending: false, + currentQuery: data, + pageNum: 1, + }); + this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); + }, + + /** + * 点击排序 + */ + clickSort(e) { + let data = this.data.currentQuery; + // data.orderField = 'shop_price'; + data.orderField = 'prom_price'; + if (data.page) { + delete data.page; + }; + if (!this.data.isSort) { + this.setData({ + isSort: true, + }); + data.orderType = 'asc'; + } else { + this.setData({ + isDescending: !this.data.isDescending, + }); + + if (this.data.isDescending) { + data.orderType = 'desc'; + } else { + data.orderType = 'asc'; + }; + + }; + console.log('当前参数:', data); + + this.setData({ + currentQuery: data, + noMore: false, + }); + + // 请求数据 + this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); + }, + + /** + * 点击视图切换按钮 + */ + change() { + this.setData({ + isShowRow: !this.data.isShowRow + }); + }, + + /** + * 点击Tab + */ + clickTab(e) { + let data = this.data.currentQuery; + let isSort = this.data.isSort; + let currentIndex = e.target.dataset.index; + if (currentIndex != 3) { + if (isSort) { + isSort = false; + }; + if (data.orderType) {// 清除orderType + delete data.orderType; + }; + }; + this.setData({ + list: null, + isAll: true, + currentTabIndex: currentIndex, + isSort, + pageNum: 1, + noMore: false, + }); + if (data.page) {// 清除page + delete data.page; + }; + + + + if (currentIndex == 0) { + if (data.orderField) {// 清除orderField + delete data.orderField; + }; + }; + if (currentIndex == 1) { + data.orderField = 'sales_sum'; + }; + if (currentIndex == 2) { + data.orderField = 'comment_count'; + }; + + if (currentIndex == 3) { + // console.log('点击价格'); + if (data.orderType) {// 清除orderType + delete data.orderType; + }; + return; + }; + data.orderType = 'desc'; + this.data.currentQuery = data; + this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); + }, + + /** + * 点击筛选 + */ + clickFilter() { + this.setData({ + isHiddenDropdown: !this.data.isHiddenDropdown, + }); + }, + + /** + * 点击遮罩层,关闭筛选下拉菜单 + */ + clickMask() { + if (!this.data.isHiddenDropdown) { + this.setData({ + isHiddenDropdown: true, + }); + } + }, + + /** + * 请求数据 + */ + getData: function (isInit, url, data) { + + app.request.promiseGet(url, { + data: data, + isShowLoading: true, + }) + .then(function (res) { + // console.log('1121', res.data.code); + if (res.data.code == 0) { + + self.setData({ + isLoading: false + }); + + if (isInit) {// 第一次加载 + self.setData({ + list: res.data.data, + }); + } else { + self.setData({ + 'list.pageData': self.data.list.pageData.concat(res.data.data.pageData) + }); + }; + + if ((res.data.data.pageData.length == 0) || (res.data.data.pageSize * res.data.data.page >= res.data.data.total)) { + self.setData({ + noMore: true + }); + }; + + } else { + self.setData({ + 'list.pageData': [] + }); + }; + + }) + .catch(function (err) { + console.log('出错拉!!!!', err); + self.setData({ + 'list.pageData': [] + }); + }); + }, + + + /** + * 上拉加载 + */ + scrollToLower(url, requestData) { + + // 数据总量 + let total = this.data.list.total; + // 单页最大数据量 + let pageSize = this.data.list.pageSize; + // 如果数据总量不为0且小于或等于单页最大数据量,说明数据已全部加载,显示‘没有更多了’ + if ((total != 0) && (total <= pageSize)) { + this.setData({ + noMore: true + }); + }; + + if (!this.data.isLoading && !this.data.noMore) { + this.setData({ + isLoading: true, + pageNum: this.data.pageNum + 1 + }); + requestData.page = this.data.pageNum; + console.log('滚动data:', requestData); + this.getData(false, url, requestData); + }; + }, + + /** + * 点击跳转 + */ + goto(e) { + let url = ''; + if (e.target.dataset.url) { + url = e.target.dataset.url; + } else { + url = e.currentTarget.dataset.url; + } + app.goto(url); + }, + + + //--- 获取卡类列表 --- + getPlusCardType: function (func) { + var storid = os.stoid; + var th = this; + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, + {}).then(res => { + + if (res.data.code != 0 || !res.data.data) { + var ob = { + "card_list": [], + "name_map": "" + }; + func(ob); + return false; + } + + var plusCard = res.data.data; + var arr = [1219, 2089, 3031]; + var new_arr = new Array(); + var card_name_map = new Map(); + + var user = getApp().globalData.userInfo; + if (plusCard) { + for (var i = 0; i < plusCard.length; i++) { + if ((!user || user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) { + continue; + } + var name = "card" + plusCard[i].CorrPrice.toLowerCase(); + card_name_map.set(name, plusCard[i].CardName); + new_arr.push(plusCard[i]); + + } + } + var ob = { + "card_list": new_arr, + "name_map": card_name_map + }; + func(ob); + }) + }, + + + /** + * 点击全部 + */ + clickAll() { + let data = this.data.currentQuery; + + if (data.page) delete data.page; + if (data.orderField) delete data.orderField; + if (data.orderType) delete data.orderType; + if (data.key) delete data.key; + + this.setData({ + pageNum: 1, + noMore: false, + isAll: true, + }); + + this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); + }, + + /** + * 点击新品 + */ + clickNew() { + let data = this.data.currentQuery; + + if (data.page) delete data.page; + if (data.orderField) delete data.orderField; + if (data.orderType) delete data.orderType; + if (data.key) delete data.key; + + this.setData({ + pageNum: 1, + noMore: false, + isAll: false, + }); + + this.getData(true, '/api/weshop/users/distribut/pagemyshop?type=2&orderType=desc', data); + // app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { + // data: data, + // }).then(res => { + // self.setData({ + // list: res.data.data, + // }); + // }); + }, + + + /** + * 点击新品 + */ + // imgError(e) { + // this.setData({ + // noImg: true, + // }); + // }, + + + bind_bnerr2: function (e) { + var _errImg = e.target.dataset.errorimg; + var _errurl = e.target.dataset.url; + var ii = _errurl.indexOf(oo.imghost); + if (ii != -1) { + var _errObj = {}; + _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + } }, - - /** - * 点击下拉菜单 - */ - clickDropdown() { - this.setData({ - isHiddenDropdown: !this.data.isHiddenDropdown, - }); - }, - - /** - * 点击遮罩层 - */ - clickMask() { - this.setData({ - isHiddenDropdown: true, - }); - }, - - /** - * 选择下拉菜单项 - */ - selectDropdown(e) { - let currentIndex = e.target.dataset.index; - this.setData({ - isHiddenDropdown: true, - currentSelect: this.data.dropdownArr[currentIndex], - }); - }, - - /** - * 搜索输入框聚焦 - */ - inputFocus() { - this.setData({ - isInputFocus: true, - }); - }, - - - /** - * 搜索输入框失焦 - */ - inputBlur() { - this.setData({ - isInputFocus: false, - }); - }, - - /** - * 获取搜索输入框输入的内容 - */ - input(e) { - this.data.inputVal = e.detail.value; - }, - - /** - * 搜索输入框清空内容 - */ - inputClear() { - let inputVal = this.data.inputVal; - console.log('input', inputVal); - if(inputVal) { - this.setData({ - inputVal: '', - }); - }; - }, - - /** - * 搜索输入框聚焦 - */ - search() { - let data = this.data.currentQuery; - data.key = this.data.inputVal; - if(data.orderField) { - delete data.orderField; - }; - if(data.page) { - delete data.page; - }; - this.setData({ - currentTabIndex: 4, - isSort: false, - isDescending: false, - currentQuery: data, - pageNum: 1, - }); - this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); - }, - - /** - * 点击排序 - */ - clickSort(e) { - let data = this.data.currentQuery; - // data.orderField = 'shop_price'; - data.orderField = 'prom_price'; - if(data.page) { - delete data.page; - }; - if(!this.data.isSort) { - this.setData({ - isSort: true, - }); - data.orderType = 'asc'; - } else { - this.setData({ - isDescending: !this.data.isDescending, - }); - - if(this.data.isDescending) { - data.orderType = 'desc'; - } else { - data.orderType = 'asc'; - }; - - }; - console.log('当前参数:', data); - - this.setData({ - currentQuery: data, - noMore: false, - }); - - // 请求数据 - this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); - }, - - /** - * 点击视图切换按钮 - */ - change() { - this.setData({ - isShowRow: !this.data.isShowRow - }); - }, - - /** - * 点击Tab - */ - clickTab(e) { - let data = this.data.currentQuery; - let isSort = this.data.isSort; - let currentIndex = e.target.dataset.index; - if(currentIndex != 3) { - if(isSort) { - isSort = false; - }; - if(data.orderType) {// 清除orderType - delete data.orderType; - }; - }; - this.setData({ - list: null, - isAll: true, - currentTabIndex: currentIndex, - isSort, - pageNum: 1, - noMore: false, - }); - if(data.page) {// 清除page - delete data.page; - }; - - - - if(currentIndex == 0) { - if(data.orderField) {// 清除orderField - delete data.orderField; - }; - }; - if(currentIndex == 1) { - data.orderField = 'sales_sum'; - }; - if(currentIndex == 2) { - data.orderField = 'comment_count'; - }; - - if(currentIndex == 3) { - // console.log('点击价格'); - if(data.orderType) {// 清除orderType - delete data.orderType; - }; - return; - }; - data.orderType = 'desc'; - this.data.currentQuery = data; - this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); - }, - - /** - * 点击筛选 - */ - clickFilter() { - this.setData({ - isHiddenDropdown: !this.data.isHiddenDropdown, - }); - }, - - /** - * 点击遮罩层,关闭筛选下拉菜单 - */ - clickMask() { - if(!this.data.isHiddenDropdown) { - this.setData({ - isHiddenDropdown: true, - }); - } - }, - - /** - * 请求数据 - */ - getData: function(isInit, url, data) { - - app.request.promiseGet(url, { - data: data, - isShowLoading: true, - }) - .then(function(res) { - // console.log('1121', res.data.code); - if(res.data.code == 0) { - - self.setData({ - isLoading: false - }); - - if(isInit) {// 第一次加载 - self.setData({ - list: res.data.data, - }); - } else { - self.setData({ - 'list.pageData': self.data.list.pageData.concat(res.data.data.pageData) - }); - }; - - if((res.data.data.pageData.length == 0) || (res.data.data.pageSize * res.data.data.page >= res.data.data.total)) { - self.setData({ - noMore: true - }); - }; - - } else { - self.setData({ - 'list.pageData': [] - }); - }; - - }) - .catch(function(err) { - console.log('出错拉!!!!',err); - self.setData({ - 'list.pageData': [] - }); - }); - }, - - - /** - * 上拉加载 - */ - scrollToLower(url, requestData) { - - // 数据总量 - let total = this.data.list.total; - // 单页最大数据量 - let pageSize = this.data.list.pageSize; - // 如果数据总量不为0且小于或等于单页最大数据量,说明数据已全部加载,显示‘没有更多了’ - if((total != 0)&&(total <= pageSize)) { - this.setData({ - noMore: true - }); - }; - - if(!this.data.isLoading && !this.data.noMore) { - this.setData({ - isLoading: true, - pageNum: this.data.pageNum + 1 - }); - requestData.page = this.data.pageNum; - console.log('滚动data:', requestData); - this.getData(false, url, requestData); - }; - }, - - /** - * 点击跳转 - */ - goto(e) { - let url = ''; - if(e.target.dataset.url) { - url = e.target.dataset.url; - } else { - url = e.currentTarget.dataset.url; - } - app.goto(url); - }, - - - //--- 获取卡类列表 --- - getPlusCardType: function (func) { - var storid = os.stoid; - var th = this; - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, - {}).then(res => { - - if(res.data.code!=0 || !res.data.data){ - var ob = { - "card_list": [], - "name_map": "" - }; - func(ob); - return false; - } - - var plusCard = res.data.data; - var arr = [1219, 2089, 3031]; - var new_arr = new Array(); - var card_name_map = new Map(); - - var user = getApp().globalData.userInfo; - if(plusCard) { - for (var i = 0; i < plusCard.length; i++) { - if ((!user || user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) { - continue; - } - var name = "card" + plusCard[i].CorrPrice.toLowerCase(); - card_name_map.set(name, plusCard[i].CardName); - new_arr.push(plusCard[i]); - - } - } - var ob = { - "card_list": new_arr, - "name_map": card_name_map - }; - func(ob); - }) - }, - - - /** - * 点击全部 - */ - clickAll() { - let data = this.data.currentQuery; - - if(data.page) delete data.page; - if(data.orderField) delete data.orderField; - if(data.orderType) delete data.orderType; - if(data.key) delete data.key; - - this.setData({ - pageNum: 1, - noMore: false, - isAll: true, - }); - - this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); - }, - - /** - * 点击新品 - */ - clickNew() { - let data = this.data.currentQuery; - - if(data.page) delete data.page; - if(data.orderField) delete data.orderField; - if(data.orderType) delete data.orderType; - if(data.key) delete data.key; - - this.setData({ - pageNum: 1, - noMore: false, - isAll: false, - }); - - this.getData(true, '/api/weshop/users/distribut/pagemyshop?type=2&orderType=desc', data); - // app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { - // data: data, - // }).then(res => { - // self.setData({ - // list: res.data.data, - // }); - // }); - }, - - - /** - * 点击新品 - */ - // imgError(e) { - // this.setData({ - // noImg: true, - // }); - // }, - - - bind_bnerr2: function (e) { - var _errImg = e.target.dataset.errorimg; - var _errurl = e.target.dataset.url; - var ii = _errurl.indexOf(oo.imghost); - if (ii != -1) { - var _errObj = {}; - _errObj[_errImg] = this.data.iurl+"/miniapp/images/default_g_img.gif"; - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; - } - }, }) \ No newline at end of file diff --git a/packageA/pages/distribution/shop/shop.wxml b/packageA/pages/distribution/shop/shop.wxml index b1a4555..dfa6459 100644 --- a/packageA/pages/distribution/shop/shop.wxml +++ b/packageA/pages/distribution/shop/shop.wxml @@ -37,6 +37,7 @@ + diff --git a/packageA/pages/distribution/shop/shop.wxss b/packageA/pages/distribution/shop/shop.wxss index 6842380..c4028f6 100644 --- a/packageA/pages/distribution/shop/shop.wxss +++ b/packageA/pages/distribution/shop/shop.wxss @@ -100,10 +100,6 @@ page { margin-top: 20rpx; } */ -.money { - /* word-break: break-all; - word-wrap: break-word; */ -} .money::before { content: '¥'; font-size: 22rpx; @@ -236,10 +232,10 @@ page { /*checkbox 整体大小 */ -checkbox { +/* checkbox { */ /* width: 240rpx; height: 90rpx; */ -} +/* } */ /*checkbox 选项框大小 */ checkbox .wx-checkbox-input { width: 34rpx; diff --git a/packageB/pages/zuhegou/index/index.js b/packageB/pages/zuhegou/index/index.js index c0a7545..0d7eac4 100644 --- a/packageB/pages/zuhegou/index/index.js +++ b/packageB/pages/zuhegou/index/index.js @@ -1139,7 +1139,7 @@ Page({ get_sto(e) { var th = this; this.waitfor2(15, 'is_get_local_ok', function () { - if (!th.data.sele_g) return false; + //if (!th.data.sele_g) return false; var dd = null; var g_distr_type =0; if(th.data.sele_g) g_distr_type=th.data.sele_g.distr_type; @@ -1652,6 +1652,9 @@ Page({ this.setData({ store: 1 }) + + + this.get_sto() }, // -- 加入之前,先判断有没有在购物车中,没有商品就添加 -- diff --git a/packageC/pages/goods/distributionCategoryList/g_filter.wxs b/packageC/pages/goods/distributionCategoryList/g_filter.wxs new file mode 100644 index 0000000..429e75a --- /dev/null +++ b/packageC/pages/goods/distributionCategoryList/g_filter.wxs @@ -0,0 +1,91 @@ +var g_filters = { + //-- 判断是不是有等级价 -- + is_has_rank:function(rank_switch,item){ + if(!rank_switch) return false; + if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true} + return false; + }, + + //-- 判断,不是等级会员时候,要显示的最低等级价和名称 -- + get_card_price:function(goods,all_card,type){ + var price1=parseFloat(goods['cardprice1']); + var price2=parseFloat(goods['cardprice2']); + var price3=parseFloat(goods['cardprice3']); + if(!all_card){ + if(type==0) return 0; + return ""; + } + + + var arr=[]; + var min_price= 0; + var min_name=""; + + var min_price=null; + var min_name=null; + //---设置对应的价格名字---- + for(var i=0;i<3;i++) { + var vl=all_card[i]; + if(!vl) continue; + if(vl['CorrPrice']=="Price1" && price1>0) + { + + if(min_price==null) { + min_price=price1;min_name=vl['CardName']; + } + else if(price10) + { + if(min_price==null) { + min_price=price2;min_name=vl['CardName']; + } + else if(price20) + { + if(min_price==null) { + min_price=price3;min_name=vl['CardName']; + } + else if(price34) min_name=min_name.substring(0, 8); + return min_name; + }, +} +module.exports = { + is_has_rank:g_filters.is_has_rank, + get_card_price:g_filters.get_card_price, +} \ No newline at end of file diff --git a/packageC/pages/goods/distributionCategoryList/index.js b/packageC/pages/goods/distributionCategoryList/index.js new file mode 100644 index 0000000..13d5628 --- /dev/null +++ b/packageC/pages/goods/distributionCategoryList/index.js @@ -0,0 +1,696 @@ +const { app } = require("../../../../utils/common"); +let startY = 0; +let endY = 0; +let scrolltop = 0; +let moveDistance = 0; +const t = getApp(), e = t.request, oo = t.globalData.setting; +var i = function (i) { + return i && i.__esModule ? i : { + default: i + }; +}(require("../../../../utils/LoadMore")), a = new i.default(), ut = require("../../../../utils/util.js"); +//t = i,e = t +Page({ + data: { + is_date: true, + scrollHeight: 0, + currentTab: -1, + abc: 0, + windowHeight: 0, + windowWidth: 0, + eachLetterHeight: 0, + lettersPosition: 0, + catelist: null, //分类读取 + nationlist: null,//国家读取 + groups: null, //品牌读取 + iurl: oo.imghost,//图片地址 + + //控制新旧分类版本 + is_used_share: 0, + //国家的控制属性 + is_country: 1, + //品牌的控制属性 + is_brand: 1, + //选择分类的控制属性 + select_classify_on: 223, + index: 223, + classify_name: "国家",//项目类型 + brand_list: null,//品牌列表 + + catelist: [],// 新的版本左边的边分类1级 + is_level_three: 0,//判断有没有3级 + cat_id: 0, + pl_timer: null,//只有品类的定时器 + is_pl_time: 0, + requestData: null, //风格三的商品数据列表 分页 + stylePage: 1, //商品列表分页标识 + + //风格三使用 + url: t.globalData.setting.imghost, + currentPage: 1, + allData: null, + openFilterModal: !1, + baseUrl: "/api/weshop/users/distribut/pagemyshop?orderType=desc", + requestUrl: "", + tabname: "goods_id", //排序的字段 + adname: "desc", //升降的字段 + is_new: 0, + is_hot: 0, + msgStatus: false, //页面显示暂无数据状态 + countDownNum: 3, + timer: '', //定时器 + lastMsg: false, + toView: "", + is_show_class: false,//是否添加新样式 + status_show: 0, + currentTab: 0, //预设当前项的值 + load: 0, + }, + + + //判断当前滚动超过一屏时,设置tab标题滚动条。 + checkCor: function () { + let that = this; + //这里计算按照实际情况进行修改,动态数据要进行动态分析 + //思路:窗体高度/单个分类高度 200rpx 转px计算 =>得到一屏幕所显示的个数,结合后台传回分类总数进行计算 + //数据很多可以多次if判断然后进行滚动距离计算即可 + if (that.data.currentTab > 7) { + that.setData({ + scrollTop: 500 + }) + } else { + that.setData({ + scrollTop: 0 + }) + } + }, + /* onPageScroll(e){ + console.log(e); + }, + calcHeight: function calcHeight(callback) { + var query = this.createSelectorQuery(); + query.select('.weui-vtabs-content__item').boundingClientRect(function (rect) { + callback && callback(rect); + }).exec(); +}, */ + + onLoad: function (tt) { + wx.setNavigationBarTitle({ + title: "分类", + }); + var that = this;//保存全局指针 + t.isLogin().then(function (data) {//进入页面前已经授权登录成功 + console.log(data); + that.setData({ + userInfo: data, + }); + }); + var first_leader = tt.first_leader; + if (first_leader) { + //-- user_id代过来免登录 -- + getApp().globalData.first_leader = first_leader; + } + + that.get_brand(); + clearInterval(that.data.timer); + that.setData({ countDownNum: 3, stylePage: 1 }); + + const res = wx.getSystemInfoSync(), + letters = this.data.letters; + this.setData({ + abc: t.globalData.heigth - 88 - 88 - 16, + windowHeight: res.windowHeight, + windowWidth: res.windowWidth, + + }); + + if (this.data.is_used_share == 0) { + this.get_nation(); + } + + getApp().getConfig2(function (e) { + var data = e; + var switch_list_data = data.switch_list; + var switch_list = JSON.parse(switch_list_data); + var is_newsgoodstype = switch_list.is_newsgoodstype; + if (is_newsgoodstype == undefined) { + is_newsgoodstype = 0; + } + that.setData({ is_used_share: is_newsgoodstype }); + if (e.categoryset.indexOf("," + 1 + ",") != -1) { that.setData({ is_show_pl: 1 }); } + if (e.categoryset.indexOf("," + 3 + ",") != -1) { that.setData({ is_show_pp: 1 }); } + if (e.categoryset.indexOf("," + 2 + ",") != -1) { that.setData({ is_show_gb: 1 }); } + that.setData({ store_config: e, is_do: 1 }); + + //---有勾品类--- + if (that.data.is_show_pl) { + that.getGoodsCategoris(); + } + if (that.data.is_show_gb != 1 && that.data.is_show_pp != 1 && that.data.is_show_pl) { + that.data.pl_timer = setInterval(function () { + if (that.data.catelist.length > 0) { + console.log(catelist); + var item = that.data.catelist[0], arr = item.array; + //----如果有下级的时候----- + if (item.array && item.array.length > 0) { + var is_lev_thr = 0 + for (var i = 0; i < arr.length; i++) { + if (arr[i].arrays.length > 0) { is_lev_thr = 1; break; } + } + that.setData({ is_level_three: is_lev_thr }); + if (is_lev_thr != 1) { + that.setData({ select_classify_on: 0, index: 0, classify_name: item.items.name, cat_id: item.items.id, goodslist: item.array }); + console.log("id:=" + item.items.id) + that.style(that.data.stylePage, that.data.cat_id); + } else { + that.setData({ select_classify_on: 0, index: 0, classify_name: item.items.name, cat_id: item.items.id, goodslist: arr }); + console.log("id:=" + item.items.id) + that.style(that.data.stylePage, that.data.cat_id); + } + } + else { + that.setData({ select_classify_on: 0, index: 0, goodslist: null, classify_name: item.items.name, is_level_three: 0 }); + } + clearInterval(that.data.pl_timer); + } + }, 1000); + + } else if (that.data.is_show_gb != 1 && that.data.is_show_pp) { + that.setData({ select_classify_on: 220, classify_name: "品牌" }); + } + + //---如果后台又开等级卡的开关--- + if (switch_list.rank_switch && switch_list.rank_switch == "2") { + that.setData({ rank_switch: true }); + var user = getApp().globalData.userInfo; + var ti = setInterval(function () { + if (!user) return false; + clearInterval(ti); + //---回调卡的列表--- + that.getPlusCardType(function (ob) { + that.setData({ card_list: ob.card_list }); + if (user.card_field && user['card_expiredate']) { + var str = user['card_expiredate'].replace(/-/g, '/'); + var end = new Date(str); + end = Date.parse(end) / 1000; + var now = ut.gettimestamp(); + + //--- 判断是等级会员,且在有效期范围内 --- + if (user.card_field && now < end) { + var card_name = ob.name_map.get(user.card_field); + //if (card_name.length > 4) card_name = card_name.substring(0, 4); + that.setData({ card_field: user.card_field, card_name: card_name, card_list: ob.card_list }); + } + } + }) + }, 500) + } + var catelist = that.data.catelist; + + if (that.data.is_show_pl) that.setData({ currentTab: 0 }); + else if (that.data.is_show_gb) { that.setData({ currentTab: 1 }); that.get_nation(); } + else if (that.data.is_show_pp) { that.setData({ currentTab: 2 }); that.get_brand(); } + + //----求传参过来的控制----- + if (getApp().globalData.cat_type == 1 && that.data.is_show_gb) { + that.setData({ currentTab: 1 }); + that.get_nation(); + } else if (getApp().globalData.cat_type == 2 && that.data.is_show_pp) { + that.setData({ currentTab: 2 }); + that.get_brand(); + } else if (that.data.is_show_pl) { + that.setData({ currentTab: 0 }); + } + // 获取默认选中的第一个 + if (that.data.is_show_gb && that.data.select_classify_on == 223) { + that.setData({ status_show: 1 }); + } else if (that.data.is_show_pp && that.data.select_classify_on == 220) { + that.setData({ status_show: 2 }); + } + that.data.load = 1; + }) + }, + onShow: function () { + if (t.globalData.userInfo) { + let currentData = { + store_id: t.globalData.setting.stoid, + user_id: t.globalData.user_id, + }; + this.setData({ + userInfo: t.globalData.userInfo, + imghost: t.globalData.setting.imghost, + currentData, + }); + this.getGoodsCategoris(); + } + + }, + + + + //获取分类 + async getGoodsCategoris() { + // if(this.data.is_no_more)return false; + // if(this.data.isLoading)return false; + let { currentData } = this.data; + let Plurl = `/api/weshop/users/distribut/listmyshopCat`; + const categoris = await e.promiseGet(Plurl, { + data: currentData, + isShowLoading: false, + }); + console.log(categoris); + if (categoris.data.code == 0 && categoris.data.data.length > 0) { + let catelist = categoris.data.data; + this.setData({ + catelist, + }) + } + + }, + requestCategories: function (t) { + var s = this; + e.get("/api/goods/goodsSecAndThirdCategoryList", { + data: { + parent_id: t + }, + success: function (e) { + s.setData({ + categories: e.data.result, + currentCategoryId: t + }); + } + }); + }, + + //跳转到分类的商品列表 + go_cate: function (t) { + var cid = t.currentTarget.dataset.cid; + var pid = t.currentTarget.dataset.pid; + var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid; + lurl += "&pid=" + pid; + wx.navigateTo({ url: lurl }); + }, + + //跳转到品牌的商品列表 + go_brand: function (t) { + var cid = t.currentTarget.dataset.bid; + var lurl = "../../goods/goodsList/goodsList?brand_id=" + cid; + wx.navigateTo({ url: lurl }); + }, + + //跳转到国别的商品列表 + go_nation: function (t) { + var cid = t.currentTarget.dataset.nid; + var lurl = "../../goods/goodsList/goodsList?nation_id=" + cid; + wx.navigateTo({ url: lurl }); + }, + //获取国别 + get_nation: function () { + var s = this; + e.get("/api/weshop/users/distribut/listmyshopNation", { + data: { + store_id: oo.stoid, + user_id: t.globalData.user_id, + }, + success: function (e) { + console.log(e); + var dda = e.data.data; + s.setData({ nationlist: dda }) + } + }); + }, + + //获取品牌 + get_brand: function () { + var compare = function (prop) { + return function (obj1, obj2) { + var val1 = obj1[prop]; var val2 = obj2[prop]; + if (!isNaN(Number(val1)) && !isNaN(Number(val2))) { + val1 = Number(val1); val2 = Number(val2); + } + if (val1 < val2) { + return -1; + } else if (val1 > val2) { + return 1; + } else { return 0; } + } + } + + var s = this; + e.get("/api/weshop/users/distribut/listmyshopBrand", { + data: { + store_id: oo.stoid, + user_id: t.globalData.user_id, + }, + success: function (e) { + console.log(e); + var arr = new Array(); + var dda = e.data.data; + s.setData({ brand_list: dda }); + + for (var i = 0; i < dda.length; i++) { + //console.log(dda[i].logo) + if (dda[i].logo == "") { + dda[i].logo = s.data.iurl + "/miniapp/images/no_brand_def.jpg"; + } else if (dda[i].logo && dda[i].logo.indexOf("http") < 0) { + dda[i].logo = oo.imghost + dda[i].logo; + } + + //进行排序,只有是默认排序的时候,才按首字母排序 + if (parseInt(s.data.is_used_share) != 0) continue; + + if (arr.length > 0) { + var find = 0; + //寻找字母在arr数组中是否存在,不存在就要添加,存在就在要这个数组添加元素 + for (var k = 0; k < arr.length; k++) { + if (dda[i].zm == arr[k].zm) { find = k + 1; break; } + } + if (find == 0) { + var item = { zm: dda[i].zm, array: new Array() } + item.array.push(dda[i]); + arr.push(item); + } else { + arr[find - 1].array.push(dda[i]); + } + } else { + var item = { zm: dda[i].zm, array: new Array() } + item.array.push(dda[i]); + arr.push(item); + } + } + if (parseInt(s.data.is_used_share) == 0) { + arr.sort(compare("zm")); + } else { + var ob = { array: dda }; + arr.push(ob); + } + + + + s.setData({ groups: arr }); + //console.log(s.data.groups) + } + }); + }, + //---------分享配置-------- + onShareAppMessage: function (e) { + + var url = "pages/goods/categoryList/categoryList"; + var userInfo = getApp().globalData.userInfo; + //是分销商才带 + if (userInfo) { + url += "?first_leader=" + userInfo.user_id; + } + console.log("--分类分享---分享--"); + console.log(url); + + return { + title: "商品分类", + path: url, + } + }, + //图片失败,默认图片 + bind_bnerr: function (e) { + var _errImg = e.target.dataset.errorimg; + var _errObj = {}; + _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + }, + + + getInput(e) { + this.setData({ + keyword: e.detail.value.trim(), + }); + }, + + search: function (t) { + let keyword = this.data.keyword; + if (!keyword) { + t.showWarning("请输入搜索关键词"); + return false + } + // this.search(val); + // wx.navigateTo({ + // url: `/packageA/pages/distribution/shop/shop?key_word=${val}`, + // }); + wx.navigateBack({ + delta: 1 + }); + getApp().globalData.key_word = keyword; + }, + //图片失败,默认图片 + bind_bnerr_t3: function (e) { + var _errImg = e.target.dataset.errorimg; + var _errObj = {}; + _errObj[_errImg] = "/miniapp/images/default_g_img.gif"; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + + }, + + async click_classify(e) { + let { cid, current } = e.currentTarget.dataset; + this.setData({ + select_classify_on: current, + cat_id: cid, + is_no_more: 0, + isLoading: 0, + countDownNum: 3, + stylePage: 1, + is_none: 0, + }); + if (current == 220 || current == 223) { + console.log(111); + let classify_name = null; + current == 220 ? classify_name = '品牌' : classify_name = '国家'; + this.setData({ + classify_name, + }) + } else { + this.setData({ + classify_name: this.data.catelist[current].name, + }) + wx.pageScrollTo({ + scrollTop: 0 + }) + this.checkCor(); + this.requestGoodsList(); + } + // classify_name + }, + /* //分销小店的商品 + async getShopGoods() { + let { currentData, baseUrl } = this.data; + console.log(currentData); + currentData.pageSize = 2000; + console.log(currentData); + const distriGoods = await e.promiseGet(baseUrl, { + data: currentData, + isShowLoading: false, + }); + console.log(distriGoods); + if (distriGoods.data.code == 0 && distriGoods.data.data.pageData.length > 0) { + this.setData({ + shopGoodsData: distriGoods.data.data.pageData, + }) + } + }, */ + async requestGoodsList() { + console.log('hanshu'); + if (this.data.isLoading) return false; + // if(this.data.is_no_more)return + if (this.data.is_no_more && this.data.is_up) return false; + this.data.isLoading = 1; + let { currentData } = this.data; + currentData.cat_id = this.data.cat_id; + currentData.page = this.data.stylePage; + // console.log(data); + let url = `/api/weshop/users/distribut/pagemyshop`; + const { data: res } = await e.promiseGet(url, { + isShowLoading: true, + data: currentData, + }); + console.log(res); + + let index = this.getCurrentIndex(); + let next_classify_name = this.data.catelist[index].name; + this.setData({ + isLoading: 0, + is_no_more: 0, + is_get: 1, + select_classify_on: index, + classify_name: next_classify_name, + next_classify_name, + }); + if (res.code == 0 && res.data.pageData.length > 0) { + // if(res.data.pageData.length 1) { + this.setData({ + requestData: this.data.requestData.concat(res.data.pageData), + }); + } else { + this.setData({ + requestData: res.data.pageData, + }); + } + + } else { + //上拉加载 + if (res.data.page > 1) { + this.setData({ + is_no_more: 1, + }) + } else { + this.setData({ + requestData: [], + }); + //如果类目为空则3秒后加载下一类目 + this.data.timer = setInterval(() => { + this.setData({ + countDownNum: this.data.countDownNum - 1, + }); + if (this.data.countDownNum == 0) { + clearInterval(this.data.timer); + this.get_next_cate(index); + } + }, 1000); + } + } + }, + + //查找当前类目在 catelist的下标 为后面下一个类目使用 + getCurrentIndex() { + + let index = this.data.catelist.findIndex(item => { + return item.id == this.data.cat_id + }); + //当前处于类目最后一个 + if (index + 1 == this.data.catelist.length) { + this.setData({ + is_none: 1, + }) + }; + return index; + }, + + + get_next_cate(index) { + console.log('get_next_cate'); + index = index + 1; + let nex_cat_id = this.data.catelist[index].id; + this.setData({ + cat_id: nex_cat_id, + stylePage: 1, + is_get: 0, + next_classify_name: this.data.catelist[index].name, + }); + this.data.is_up = 0; + this.requestGoodsList(); + }, + onReachBottom: function () { + + }, + //选择更多 + select_more: function (e) { + var cid = e.currentTarget.dataset.cid; + var pid = e.currentTarget.dataset.pid; + var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid; + wx.navigateTo({ url: lurl }); + + }, + //扫一扫 + getScancode: function () { + // 允许从相机和相册扫码 + wx.scanCode({ + success: (res) => { + console.log(res); + var key_word = res.result; + wx.navigateBack({ + delta: 1 + }); + getApp().globalData.key_word = key_word; + } + }) + }, + onUnload: function () { + //this.destroyActivityTimer(); + }, + + onPullDownRefresh: function () { + + }, + touchstart(e) { + // if (!this.data.is_no_more) return false; + // if(this.data.is_next){ + // this.setData({ + // is_no_more:0, + // }) + // } + // this.data.is_next=0; + startY = e.changedTouches[0].clientY; + console.log('gdsg'); + }, + touchend(e) { + + endY = e.changedTouches[0].clientY; + moveDistance = startY - endY; + if(moveDistance<0){ + scrolltop=0 + } + console.log(scrolltop); + if (this.data.is_no_more && !this.data.is_up) { + this.data.is_up = 1; + return false; + } + + if (this.data.is_no_more && moveDistance >= 300 && scrolltop > 0) { + this.data.is_up = 0; + this.get_next_cate(this.data.select_classify_on); + } + + }, + // 左侧更新 + scrollLower: function () { + scrolltop = 1; + if (this.data.isLoading) return false; + if (this.data.is_no_more) return false; + + + this.setData({ + stylePage: this.data.stylePage + 1, + countDownNum: 3, + }); + !this.data.is_none && this.requestGoodsList(); + + + }, + + //--- 获取卡类列表 --- + getPlusCardType: function (func) { + var storid = oo.stoid; + var th = this; + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { + var plusCard = res.data.data; + var arr = [1219, 2089, 3031]; + var new_arr = new Array(); + var card_name_map = new Map(); + var user = getApp().globalData.userInfo; + for (var i = 0; i < plusCard.length; i++) { + if ((user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) { + continue; + } + var name = "card" + plusCard[i].CorrPrice.toLowerCase(); + card_name_map.set(name, plusCard[i].CardName); + new_arr.push(plusCard[i]); + } + + var ob = { "card_list": new_arr, "name_map": card_name_map }; + func(ob); + }) + }, + +}); \ No newline at end of file diff --git a/packageC/pages/goods/distributionCategoryList/index.json b/packageC/pages/goods/distributionCategoryList/index.json new file mode 100644 index 0000000..9dde39f --- /dev/null +++ b/packageC/pages/goods/distributionCategoryList/index.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "分类", + "enablePullDownRefresh": false +} \ No newline at end of file diff --git a/packageC/pages/goods/distributionCategoryList/index.wxml b/packageC/pages/goods/distributionCategoryList/index.wxml new file mode 100644 index 0000000..84b9936 --- /dev/null +++ b/packageC/pages/goods/distributionCategoryList/index.wxml @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + 搜索 + + + + + + + + + 国家 + + + + + 品牌 + + + + + + {{item.name}} + + + + + + + + + + + + {{ishaf_three==1?good_list.name:classify_name}} + + + + + + + + {{bitem.name}} + + + {{bitem.enname}} + + + + + + + + + + + {{classify_name}} + + + + + + + {{user.name}} + + + + + + + + + + + {{classify_name}} + + + + + + + + + + + + + + + {{item.goods_name}} + + + + + {{item.prom_integral}}积分 + + + ¥{{item.prom_price}} + + + ¥{{item.market_price}} + + + 分成金额:{{filter.toFix(item.commission,2)}} + 评论{{item.comment_count}} + + + + + + + + + + + ¥{{item[card_field]}} + + + {{card_name}} + + + + ¥{{item.market_price}} + + + 分成金额:{{filter.toFix(item.commission,2)}} + 评论{{item.comment_count}} + + + + ¥{{item.shop_price}} + + ¥{{item.market_price}} + + + 分成金额:{{filter.toFix(item.commission,2)}} + 评论{{item.comment_count}} + + + + + + + ¥{{item.shop_price}} + ¥{{item.market_price}} + + + + ¥{{g_filter.get_card_price(item,card_list,0)}} + + + + {{g_filter.get_card_price(item,card_list,1)}} + + + + + + 分成金额:{{filter.toFix(item.commission,2)}} + 评论{{item.comment_count}} + + + + ¥{{item.shop_price}} + + ¥{{item.market_price}} + + + + 分成金额:{{filter.toFix(item.commission,2)}} + + 评论{{item.comment_count}} + + + + + + ¥{{item.shop_price}} + + ¥{{item.market_price}} + + + 分成金额:{{filter.toFix(item.commission,2)}} + 评论{{item.comment_count}} + + + + + + + + + 向上拉继续浏览{{next_classify_name}} + + + + + + 该类别暂无推荐商品 + {{countDownNum}} 秒后自动跳到下一个类别 + + + + + + + + + + + + + + + + 商家暂未设置分类 + 去逛逛 + + \ No newline at end of file diff --git a/packageC/pages/goods/distributionCategoryList/index.wxss b/packageC/pages/goods/distributionCategoryList/index.wxss new file mode 100644 index 0000000..89fc5fd --- /dev/null +++ b/packageC/pages/goods/distributionCategoryList/index.wxss @@ -0,0 +1,567 @@ +/*---nyf 2018-9-7---*/ + +page{height: 100%; background: #fff !important;} +.top_view{ width: 100%;background: #fff;} + +.swiper-tab{ + width: 70%; + text-align: center; + height: 88rpx; + line-height: 88rpx; + display: flex; + flex-flow: row; + justify-content: center; + margin-left: 15%; + +} +.swiper-tab-item{ + width: 30%; + color:#434343; +} +.active{ + color:#F65959; + /* border-bottom: 4rpx solid #F65959; */ +} +swiper{ + text-align: center; + min-height:200rpx; + height: auto; +} + +/*--搜索--*/ +.search-box { + width: 100% !important; + height: 88rpx !important; + z-index: 10 !important; + border-radius: 0 !important; + /*-background: linear-gradient(rgba(0,0,0,.2),rgba(255,255,255,0));-*/ + background: #f2f2f2 !important; + padding: 0 !important; + font-size: medium !important; +} + +.logo { + width: 48rpx; + height: 48rpx; + margin: 0 18rpx; + border-radius: 50%; + overflow: hidden; +} + +.search-inner { + display: flex; + align-items: center; + margin: 0rpx 30rpx; + width: 675rpx; + height: 58rpx; + border-radius: 29rpx; + background-color: #fff; + position: relative; + top: 15rpx; +} + +.search-img { + margin-right: 12rpx; + width: 30rpx; + height: 30rpx; + margin-top: -8rpx; + margin-left: 20rpx; +} + +.search-cont { + /* height: 58rpx; + width: 536rpx; */ + /* padding-left: 12rpx; */ + line-height: 58rpx; + font-size: 28rpx; + color: #666; +} + +.search-fixed { + background: rgba(242,48,48,0.8); +} + +/*--分类--*/ +.f_item{position: relative;} +.f_item .pic_view{position: relative; height: 240rpx;} + +.fl_img{width: 100%; height: 100%;} +.fenlei_text_v{text-align: left; margin-bottom: 10rpx; margin-top: 15rpx} +.over_view{width: 100%; height: 100%; position: absolute;top: 0; left: 0; background-color: rgba(0,0,0,0.1);} +.f_item_over_t{margin: 0 auto; position: absolute; top:80rpx;left: 50%; color: #fff; font-weight: bold; + + + margin-left: -100rpx; z-index: 8; width: 200rpx; text-align: center; font-size: 50rpx } +.f_text{width: 25%; +text-align: center; +display: inline-block; +font-size: 30rpx; +color: #9f9f9f; +overflow: hidden; +text-overflow: ellipsis; +white-space: nowrap; +line-height: 50rpx; + +} + +/*--国家--*/ +.nation_box{ position: absolute;width: 260rpx; height: 160rpx; background-size: 100% 100%; background-repeat: no-repeat; + top:110rpx;left: 50%; /* margin-left: -130rpx; */z-index: 8; background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAN8AAACACAYAAACLIbwOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MkVDREM1NjhCMDU3MTFFNjg3NEZDNzlCNDg1N0FGRjUiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MkVDREM1NjlCMDU3MTFFNjg3NEZDNzlCNDg1N0FGRjUiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDoyRUNEQzU2NkIwNTcxMUU2ODc0RkM3OUI0ODU3QUZGNSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDoyRUNEQzU2N0IwNTcxMUU2ODc0RkM3OUI0ODU3QUZGNSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PlO56qEAAAFJSURBVHja7NfRCYAgFIbRDMd0Doe4a9ietxWUIjDOeZYefvhIS2aOA/jcaQIQH4gPEB+IDxAfiA8QH2ynzhyKiGYqWNN7vx7HN/MhYO2H5doJ3nwgPkB8ID5AfCA+QHwgPkB8ID5AfCA+EJ8JQHwgPkB8ID5AfCA+QHwgPkB8ID5AfCA+EB8gPhAfID4QHyA+EB8gPhAfID4QHyA+EB+IDxAfiA8QH4gPEB+IDxAfiA8QH4gPEB+ID8QHiA/EB4gPxAeID8QHiA/EB4gPxAeID8QH4gPEB+IDxAfiA8QH4gPEB+IDxAfiA8QH4gPxAeID8QHiA/EB4gPxAeID8QHiA/EB4gPxgfgA8YH4APGB+ADxgfgA8YH4APGB+ADxgfhAfID4QHyA+OB/6uzBiGjmgveUzBxmANdOEB8gPhAfID4QHyA+2MotwAD/ZBI/EDK5cgAAAABJRU5ErkJggg==");} + + .n_img{width: 100%; height: 375rpx;} + .nt_1{height:82rpx; line-height: 100rpx;} + .nt_1_t{ border-bottom: 1rpx solid #999; font-size: 32rpx; display: inline-block; height: 82rpx} + .nt_2{height: 66rpx;font-size: 32rpx; line-height: 66rpx;color:#999} + /*---品牌---*/ + .nav { + position: fixed; + right: 3rpx; + height: 300rpx; + width: 48rpx; + top:0rpx; + font-family: Arial, Helvetica, sans-serif; + z-index: 99999999999; +} +.letter { + width: 35.6rpx; + height: 35.6rpx; + font-size: 30rpx; +} +.letter-text { + display: inline-block; + width: 100%; + height: 100%; + text-align: center; + line-height: 30rpx; + border-radius: 50%; +} +.letter-actived { + background-color: #ccc; +} + +.group-name { + padding: 10rpx 30rpx; + height: 50rpx; + line-height: 50rpx; + text-align: left; +} +.group-users { + background-color: #fff; text-align: left; padding-bottom: 10rpx; +} +.user { + height: 88rpx; + width: 208rpx; + border: 1px solid #eee; + display: inline-block; + margin-top:15rpx; + margin-left:20rpx; +} +.user-avatar { + border-right: 1px solid #eee; + width: 100rpx; +} +.user-avatar-img { + width: 100%; + height: 100%; +} +.user-name { + padding-left: 30rpx; +} +.fenlei-list{z-index: -1;} + + + + + +/* 商品分类新的版本 */ +/* 分享样式*/ +.xc-search-box { + width: 95%; + height: 120rpx; + padding: 0 20rpx; + z-index: 10; + background: #fff; + /* border-top: 4rpx solid #eee; */ + border-bottom: 1rpx solid #eee; +} + +.share-height{ + line-height: 20rpx; +/* margin-right: 15rpx; */ +margin-top: 8rpx; + +} +.scanning_black-img{ + width:50rpx; + height: 45rpx; + margin-bottom: 5rpx; + +} +/* .search-img.left{ */ + /* margin-left: 35rpx; */ +/* } */ + +.xc-search-inner { + margin: 0 20rpx; + display: flex; + align-items: center; + flex: 1; + /* width: 600rpx; */ + height: 58rpx; + border-radius: 29rpx; + background-color: #f2f2f2; +} +.project_height{ + height: 100%; + +} +.project_type{ + box-sizing: border-box; + width: 26%; + height: 100%; + padding-bottom: 100rpx; + border-right: 1rpx solid #eee; + white-space: nowrap; + overflow: hidden; + overflow-y: scroll; +} +.share_type{ + margin: auto; + width: 58%; + /* margin-top: 40rpx; */ +} +.xc-letter-spacing{ +padding-left: 20rpx; +padding-right: 29rpx; +width: 58%; +margin: auto; +margin-top: 40rpx; +margin-left:28rpx; +} + + +#two_type .xc-letter-spacing{ + padding-left: 20rpx; + padding-right: 29rpx; + width: 58%; + margin: auto; + margin-top: 40rpx; + margin-left:28rpx; + } + +/* 左边菜单点击样式 20200601 luca */ +.is_show_class{ +width: 100%; +background-color: white; +height: 50rpx; +line-height: 50rpx; +color:black; +font-weight: 700; +} + +.world_sn{ +white-space: nowrap; +overflow: hidden; +width: 58%; +/* letter-spacing: 60rpx; */ +margin: auto; +margin-top: 35rpx; +} +/* .select_classify{ */ + /* 20200530 update 转用.is_show_class*/ +/* background: #d60021; +border-radius: 30rpx; +color: #fff; +height: 48rpx; +line-height: 45rpx; */ +/* font-weight:700; */ + +/* } */ +/* .select_classify.width80{ */ + /* 20200530updata */ + /* width: 74.5%; */ + /* height: 100rpx; + line-height: 100rpx; */ +/* } */ +.class_set_height{ + height: 50rpx; + line-height: 50rpx; + padding: 20rpx 0; +} + + .select_classify.width80.text-indent{ + text-indent: 38rpx; + padding-right: 20px; +width: 60%; + + } + .classify_name{ + /* width: 90%; + margin: auto; */ + height: 70rpx; + border-bottom: 1rpx solid #f5f6f6; + line-height: 70rpx; + font-weight: 600; + padding-left: 20rpx; + padding-right: 20rpx; + } + .classify_content{ + width: 100% + + } + .classify_content-frame{ + box-sizing: border-box; + width: 100%; + padding: 0 20rpx; + flex-wrap:wrap; + overflow-y:scroll; + } + .country_img-frame{ + width: 48%; + height: 140rpx; + + } + .country_img{ + width: 100%; + height: 100%; + } + .outer_location{ + top:0rpx; + left: 0rpx; + margin-top: 20rpx; + + } + .nation_box.box{ + width:80%; + height:70%; + top: 50%; + left: 50%; + overflow: hidden; + transform: translate(-50%, -50%); + } + .nt_1.line-height{ + line-height: 65rpx; + height: 72rpx; +margin-top: -5rpx; + + } + .nt_1_t.height{ + height: 54rpx; + } + .nt_1.height{ + height: 56rpx; +line-height: 65rpx; + } + .nt_2.line-height{ + height: 0rpx; + line-height: 0rpx; + + } + .nt_1_t.fs24{ + font-size: 24rpx; + } + .nt_2.fs24{ + font-size: 24rpx; + } + .brand_img_frame{ + width: 50%; + margin-top: 18rpx; + /* margin-right: 15rpx; */ + height: 160rpx; + } + .brand_img{ + width:220rpx; + height:86rpx; + margin-bottom: 10rpx; + margin-top: 10rpx; + + } + .type_img_frame { + width: calc(100% / 3); + height: 140rpx; + margin-top: 20rpx; + margin-bottom: 20rpx; + /* margin-right: 15rpx; */ + } + /* .choice_item{ + position: relative; + } */ + .img-wrap::after { + content: attr(data-txt); + position: absolute; + right: 0; + bottom: 0; + background-color: rgba(0,0,0,.4); + color: white; + font-size: 20rpx; + /* padding: 4rpx; */ + border-radius: 6rpx 6rpx 6rpx 0; +} + + .type_img{ + width:80rpx; + height:80rpx; + margin-bottom: 10rpx; + margin-top: 10rpx; + + } + .brand_img-name{ + width: 100%; + height: 80rpx; + } + .select_classify.width80.text3{ +padding-right: 20rpx; +padding-left: 20rpx; +width: 62%; + + } + .width_height{ + width: 13rpx; + height: 13rpx; + margin-top:12rpx; + } + .select_more{ +line-height: 37rpx; +height: 35rpx; +margin-top: 24rpx; + } + .divider_line{ + width: 100%; + border-bottom: 6rpx solid #eee; + } + .sort-name{ + width: 132rpx; +overflow: hidden; +margin: auto; + +} + +.nation_z_name{ max-width: 130rpx} +.nation_y_name{ max-width: 130rpx; color: #888} + +.no_child_lev{width: 100%; text-align: center; color: #adadad; padding-top: 30rpx} +/* .classify_title { */ + /* width: 80%; */ +/* } */ + +.brand_img_name {color: #666;} + + +.tab-view { + /* height: 100%; */ + width: 200rpx; + /* position: fixed; + left: 0; + top: 92rpx; + z-index: 10; */ +} + +#thress_type3 .tab-bar-item { + width: 200rpx; + height: 110rpx; + box-sizing: border-box; + display: flex; + align-items: center; + justify-content: left; + font-size: 30rpx; + padding-left: 30rpx; + color: #444; + font-weight: 400; +} + +#thress_type3 .active { + position: relative; + color: #000; + font-size: 30rpx; + font-weight: 600; + background: #fff; +} + +#thress_type3 .active::before { + content: ""; + position: absolute; + border-left: 8rpx solid #E41F19; + height: 50rpx; + left: 0; +} + + + + + + +#two_type .tab-bar-item { + width: 200rpx; + height: 110rpx; + box-sizing: border-box; + display: flex; + align-items: center; + justify-content: left; + font-size: 30rpx; + padding-left: 30rpx; + color: #444; + font-weight: 400; +} +#two_type .select_classify { + position: relative; + color: #000; + font-size: 30rpx; + font-weight: 600; + background: #fff; +} + +#two_type .select_classify::before { + content: ""; + position: absolute; + border-left: 8rpx solid #E41F19; + height: 50rpx; + left: 0; + top:50%; + transform: translateY(-50%); +} + + + +#two_type .is_show_class{ + width: 100%; + background-color: white; + color:black; + font-weight: 700; + height: 110rpx; + + } + + + .classify_content > view:last-of-type .classify_content-frame { + padding-bottom: 100rpx; + } + + /* .classify_content > view:only-child .classify_content-frame { */ + /* padding-bottom: 0; */ + /* } */ + + .classify_content > .classify_content-frame { + padding-bottom: 118rpx; + } + + .img-wrap { + position: relative; + width: 180rpx !important; + height: 180rpx !important; + } + + .rmb::before { + content: '¥'; + font-size: 24rpx; + } + + + .item-cont .title { + margin-bottom: 0 !important; + } + + + + +/* 风格三商品列表样式引入 */ +@import "/pages/goods/goodsList/goodsList.wxss"; \ No newline at end of file diff --git a/packageC/pages/goods/goodsList/g_filter.wxs b/packageC/pages/goods/goodsList/g_filter.wxs new file mode 100644 index 0000000..52b2ba5 --- /dev/null +++ b/packageC/pages/goods/goodsList/g_filter.wxs @@ -0,0 +1,86 @@ +var g_filters = { + //-- 判断是不是有等级价 -- + is_has_rank:function(rank_switch,item){ + if(!rank_switch) return false; + if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true} + return false; + }, + + //-- 判断,不是等级会员时候,要显示的最低等级价和名称 -- + get_card_price:function(goods,all_card,type){ + var price1=parseFloat(goods['cardprice1']); + var price2=parseFloat(goods['cardprice2']); + var price3=parseFloat(goods['cardprice3']); + if(!all_card){ + if(type==0) return 0; + return ""; + } + + var arr=[]; + var min_price= 0; + var min_name=""; + + var min_price=null; + var min_name=null; + //---设置对应的价格名字---- + for(var i=0;i<3;i++) { + var vl=all_card[i]; + if(!vl) continue; + if(vl['CorrPrice']=="Price1" && price1>0) + { + if(min_price==null) { + min_price=price1;min_name=vl['CardName']; + } + else if(price10) + { + if(min_price==null) { + min_price=price2;min_name=vl['CardName']; + } + else if(price20) + { + if(min_price==null) { + min_price=price3;min_name=vl['CardName']; + } + else if(price34) min_name=min_name.substring(0, 8); + return min_name; + }, +} +module.exports = { + is_has_rank:g_filters.is_has_rank, + get_card_price:g_filters.get_card_price, +} \ No newline at end of file diff --git a/packageC/pages/goods/goodsList/goodsList.js b/packageC/pages/goods/goodsList/goodsList.js new file mode 100644 index 0000000..036cb27 --- /dev/null +++ b/packageC/pages/goods/goodsList/goodsList.js @@ -0,0 +1,396 @@ +var t = function (t) { + return t && t.__esModule ? t : { + default: t + }; +}(require("../../../../utils/LoadMore.js")), e = getApp(), a = new t.default(), oo = e.globalData.setting, ut = require("../../../../utils/util.js"); +var regeneratorRuntime = require('../../../../utils/runtime.js'); + +Page({ + data: { + url: e.globalData.setting.imghost, + resourceUrl: e.globalData.setting.resourceUrl, + iurl: e.globalData.setting.imghost, + currentPage: 1, + requestData: null, + allData: null, + openFilterModal: !1, + baseUrl: "/api/weshop/goods/page?1=1", + requestUrl: "", + tabname: "sort", //排序的字段 + adname: "asc", //升降的字段 + is_new: 0, + is_hot: 0, + page:1, + prom_goods_list: null, + rq_data: null, + isToggle: false, //切换商品视图控制符 + }, + + onLoad: function (t) { + + this.data.rq_data = t; + + //接受有没有导购的参数 + var first_leader = t.first_leader; + if (first_leader) { + getApp().globalData.first_leader = first_leader; + //调用接口判断是不是会员 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + oo.stoid + "/" + first_leader, {}).then(res => { + if (res.data.code == 0) { + getApp().globalData.guide_id = res.data.data.id; + } + }) + } + // this.getShopGoods(); + var th = this; + a.init(this, "", "requestData"); + var url = this.data.baseUrl; + this.data.is_new = t.is_new; + this.data.is_hot = t.is_hot; + if (0 != t.cat_id && t.cat_id != undefined) { + url += "&cat_id=" + t.cat_id; + if (t.pid == undefined || t.pid == null) { + url += "&parent_id=0"; + } else { + if (t.pid != "three") { + url += "&parent_id=" + t.pid; + } + } + } + + if (0 != t.brand_id && t.brand_id != undefined) { url += "&brand_id=" + t.brand_id; } + if (0 != t.nation_id && t.nation_id != undefined) { url += "&nation_id=" + t.nation_id; } + + if (0 != t.group_id && t.group_id != undefined) { url += "&group_id=" + t.group_id; } + if (0 != t.gid && t.gid != undefined) { url += "&group_id=" + t.gid; } + + if (0 != t.max_price && t.max_price != undefined) { url += "&min_pirce=" + t.min_pirce + "&max_price=" + t.max_price; } + + if (0 != t.is_new && t.is_new != undefined) { url += "&is_new=" + t.is_new; } + if (0 != t.is_hot && t.is_hot != undefined) { url += "&is_hot=" + t.is_hot; } + + if (getApp().globalData.userInfo) { + url += "&user_id=" + getApp().globalData.userInfo.user_id; + } + this.setData({ + baseUrl:url, + }) + //优惠活动的凑单 + if (t.prom_type == 3) { + if (0 != t.prom_id && t.prom_id != undefined) { url += "&prom_id=" + t.prom_id; } + if (0 != t.prom_type && t.prom_type != undefined) { url += "&prom_type=" + t.prom_type; } + //-- 获取 -- + getApp().request.promiseGet("/api/weshop/promgoodslist/list", { + data: { prom_id: t.prom_id } + }).then(res => { + if (res.data.code == 0) { + var arr = res.data.data; + th.set_prom_list(arr); + } + }) + } + this.getInitData() + + getApp().getConfig2(function (rs) { + //计算等级价相关 + var swithc_list = rs.switch_list; + var sw_arr = JSON.parse(swithc_list); + //---如果后台又开等级卡的开关--- + if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { + th.setData({ rank_switch: true }); + var user = getApp().globalData.userInfo; + var ti = setInterval(function () { + if (!user) return false; + clearInterval(ti); + //---回调卡的列表--- + th.getPlusCardType(function (ob) { + th.setData({ card_list: ob.card_list }); + if (user.card_field) { + var str = user['card_expiredate'].replace(/-/g, '/'); + var end = new Date(str); + end = Date.parse(end) / 1000; + var now = ut.gettimestamp(); + + //--- 判断是等级会员,且在有效期范围内 --- + if (user.card_field && now < end) { + var card_name = ob.name_map.get(user.card_field); + // if(card_name.length>4) card_name=card_name.substring(0,4); + th.setData({ card_field: user.card_field, card_name: card_name, card_list: ob.card_list }); + } + } + }) + }, 500) + } + }); + + }, + async getInitData(){ + await this.getShopGoods(); + await this.requestGoodsList(this.data.baseUrl); + }, + //设置优惠券的 + set_prom_list: async function (arr) { + var th = this; + for (var i in arr) { + //优惠的实际内容 + var content = JSON.parse(arr[i].preferential_type); + arr[i].content = content; + + //--送礼包-- + if (content.is_libao) { + //-- 获取 -- + await getApp().request.promiseGet("/api/weshop/libao/libaoForm/page?id=" + content.libao + "&store_id=" + oo.stoid, { + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) + arr[i].content.lb_name = res.data.data.pageData[0].lbtitle; + }) + } + //--送赠品-- + if (content.is_gift) { + //-- 获取 -- + await getApp().request.promiseGet("/api/weshop/prom/gift/page?id=" + content.gift + "&store_id=" + oo.stoid, { + }).then(res => { + if (res.data.code == 0) + arr[i].content.gift_name = res.data.data.pageData[0].goods_name; + }) + } + } + th.setData({ prom_goods_list: arr }); + }, + + changeTab: function (t) { + var ord = t.currentTarget.dataset.href; + var ad = t.currentTarget.dataset.ad; + var url = this.data.requestUrl; + + if (this.data.tabname != ord) { + this.setData({ tabname: ord, adname: "desc" }); + } else { + ad = ad == "desc" ? "asc" : "desc"; + this.setData({ adname: ad }); + } + this.resetData(), this.requestGoodsList(url); + }, + + //分销小店的商品 + async getShopGoods() { + let data= { + store_id: oo.stoid, + user_id: getApp().globalData.user_id, + page:this.data.page, + pageSize:2000, + }; + // this.setData({ + // is_go:0 + // }) + // a.init(this, "", "shopGoodsData"); + // let url=`/api/weshop/users/distribut/pagemyshop?orderType=desc&store_id=${oo.stoid}&user_id=${getApp().globalData.user_id}`; + let url=`/api/weshop/users/distribut/pagemyshop?orderType=desc`; + const distriGoods = await getApp().request.promiseGet(url, { + data: data, + isShowLoading: false, + }); + console.log(distriGoods,1); + if (distriGoods.data.code == 0 && distriGoods.data.data.pageData.length > 0) { + this.setData({ + shopGoodsData: distriGoods.data.data.pageData, + }) + } + // this.requestGoodsList(url) + }, + + + requestGoodsList: async function (t) { + + if(this.data.is_no_more){ + getApp().showWarning("加载完啦", null, 500, !1); + return false + } + var e = this; + this.data.requestUrl = t; + + //不是商品分组的,不是默认排序的 + if (t.indexOf("group_id") == -1 || e.data.tabname != "sort") { + t += "&orderField=" + e.data.tabname; + t += "&orderType=" + e.data.adname; + } + + t += "&page=" + e.data.currentPage; + t += "&pageSize=" + 2000; + t +="&store_id=" +oo.stoid; + const { data: res } = await getApp().request.promiseGet(t, { + isShowLoading: true, + }) + console.log(res); + + if (res.code == 0 && res.data.pageData.length > 0) { + let arr = []; + arr = res.data.pageData.filter(obj => this.data.shopGoodsData.some(item => item.goods_id == obj.goods_id)); + console.log(arr); + this.setData({ + requestData: arr, + is_no_more:1, + }); + // if (res.data.page > 1) { + // this.setData({ + // requestData: this.data.requestData.concat(arr), + // // select_classify_on: index, + // }); + // } else { + // this.setData({ + // requestData: arr, + // // select_classify_on: index, + // }); + // }; + } + // a.request(t, + // function (t) { + // let arr=[]; + // e.setData({ is_go: 1 }); + // null == e.data.allData && (e.data.allData = Object.assign({}, t.data.result)), + // wx.stopPullDownRefresh(); + + // arr = e.data.requestData.filter(obj => e.data.shopGoodsData.some(item => item.goods_id == obj.goods_id)); + // // e.data.requestData.map(item => { + // // e.data.shopGoodsData.forEach(i => { + // // if (i.nation_id = item.nation_id) { + // // return item + // // } + // // }); + // // arr.push(item); + // // }); + // console.log(arr); + // // e.setData({ + // // requestData: arr, + // // }); + // }, + // null, { is_mainshow: 1, isonsale: 1, store_id: oo.stoid } + // ); + + }, + getInput(e) { + this.setData({ + keyword: e.detail.value.trim(), + }); + }, + + search: function (t) { + let keyword = this.data.keyword; + if (!keyword) { + t.showWarning("请输入搜索关键词"); + return false + } + // this.search(val); + // wx.navigateTo({ + // url: `/packageA/pages/distribution/shop/shop?key_word=${val}`, + // }); + wx.navigateBack({ + delta: 2 + }); + getApp().globalData.key_word = keyword; + }, + onReachBottom: function () { + a.canloadMore() && this.requestGoodsList(this.data.requestUrl); + }, + onPullDownRefresh: function () { + this.resetData(), this.requestGoodsList(this.data.requestUrl); + }, + openFilterModal: function () { + this.setData({ + openFilterModal: !0 + }); + }, + closeFilterModal: function () { + this.setData({ + openFilterModal: !1 + }); + }, + filterGoods: function (t) { + this.resetData(), this.requestGoodsList(t.currentTarget.dataset.href), this.closeFilterModal(); + }, + resetData: function () { + a.resetConfig(), this.data.requestData = null, this.data.currentPage = 1; + }, + + //---回复最初的设置--- + restoreData: function () { + this.setData({ + requestData: null, + }); + this.data.currentPage = 2; + }, + //---------分享配置-------- + onShareAppMessage: function (e) { + var curPage = this; + var pagePath = curPage.route; //当前页面url + if (pagePath.indexOf('/') != 0) { + pagePath = '/' + pagePath; + } + + if (this.data.rq_data && JSON.stringify(this.data.rq_data) != "{}") { + var parm = ut.ob_to_parm(this.data.rq_data); + pagePath += "?" + parm; + } + + if (getApp().globalData.user_id) { + if (pagePath.indexOf("?") > 0) { + pagePath += "&first_leader=" + getApp().globalData.user_id; + } else { + pagePath += "?first_leader=" + getApp().globalData.user_id; + } + } + console.log("11-11" + pagePath); + return { + title: "商品列表", + path: pagePath, + } + }, + //---图片失败,默认图片--- + bind_bnerr2: function (e) { + var _errImg = e.target.dataset.errorimg; + var _errurl = e.target.dataset.url; + var ii = _errurl.indexOf(oo.imghost); + if (ii != -1) { + // var _errObj = {}; + // _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; + this.setData({ + [_errImg] : "/miniapp/images/default_g_img.gif", + }) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + } + }, + + //--- 获取卡类列表 --- + getPlusCardType: function (func) { + var storid = oo.stoid; + var th = this; + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { + var plusCard = res.data.data; + var arr = [1219, 2089, 3031]; + var new_arr = new Array(); + var card_name_map = new Map(); + var user = getApp().globalData.userInfo; + for (var i = 0; i < plusCard.length; i++) { + if ((!user || user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) { + continue; + } + var name = "card" + plusCard[i].CorrPrice.toLowerCase(); + card_name_map.set(name, plusCard[i].CardName); + new_arr.push(plusCard[i]); + } + + var ob = { "card_list": new_arr, "name_map": card_name_map }; + func(ob); + }) + }, + + + + // 切换显示 + bindToggleDisplay() { + this.setData({ + isToggle: !this.data.isToggle, + }); + }, + + +}); \ No newline at end of file diff --git a/packageC/pages/goods/goodsList/goodsList.json b/packageC/pages/goods/goodsList/goodsList.json new file mode 100644 index 0000000..3dc51e0 --- /dev/null +++ b/packageC/pages/goods/goodsList/goodsList.json @@ -0,0 +1,6 @@ + { + "navigationBarTitleText": "商品列表", + "usingComponents": { + "share_box": "/components/share_box/share_box" + } +} \ No newline at end of file diff --git a/packageC/pages/goods/goodsList/goodsList.wxml b/packageC/pages/goods/goodsList/goodsList.wxml new file mode 100644 index 0000000..784b74b --- /dev/null +++ b/packageC/pages/goods/goodsList/goodsList.wxml @@ -0,0 +1,338 @@ + + + + + + 满{{item.condition}} + 减{{item.content.money}}元 + 打{{item.content.sale}}折 + 送{{item.content.int}}积分 + 送{{item.content.coupon}}元优惠券 + 送{{item.content.gift_name}} + 送{{item.content.lb_name}} + + + + + + + + + 搜索 + + + + + + + + + + + + + + + + + + + + + {{item.goods_name}} + + + + + + {{item.prom_integral}}积分 + + + ¥{{item.prom_price}} + + {{item.market_price}} + + + + + + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + + + + + + + + ¥{{item[card_field]}} + + + {{card_name}} + + + + ¥{{item.market_price}} + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + ¥{{item.shop_price}} + + ¥{{item.market_price}} + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + + + + {{item.shop_price}} + {{item.market_price}} + + + + {{g_filter.get_card_price(item,card_list,0)}} + + + {{g_filter.get_card_price(item,card_list,1)}} + + + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + + ¥{{item.shop_price}} + ¥{{item.market_price}} + + + + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + + + + {{item.shop_price}} + {{item.market_price}} + + + + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + + + + + + + + + + + + {{item.goods_name}} + + + + + + {{item.prom_integral}}积分 + + + ¥{{item.prom_price}} + + {{item.market_price}} + + + + + + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + + + + + + + + ¥{{item[card_field]}} + + + {{card_name}} + + + + ¥{{item.market_price}} + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + ¥{{item.shop_price}} + + ¥{{item.market_price}} + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + + + + {{item.shop_price}} + {{item.market_price}} + + + + {{g_filter.get_card_price(item,card_list,0)}} + + + {{g_filter.get_card_price(item,card_list,1)}} + + + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + + ¥{{item.shop_price}} + ¥{{item.market_price}} + + + + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + + + + {{item.shop_price}} + {{item.market_price}} + + + + + 评论{{item.comment_count}} + 已售{{item.sales_sum}} + + + + + + + + + + + + + + + + + + + 没有相关的数据 + 去逛逛 + + + + + \ No newline at end of file diff --git a/packageC/pages/goods/goodsList/goodsList.wxss b/packageC/pages/goods/goodsList/goodsList.wxss new file mode 100644 index 0000000..130fb83 --- /dev/null +++ b/packageC/pages/goods/goodsList/goodsList.wxss @@ -0,0 +1,307 @@ +page { + background-color: #f0f0f0; +} + +.container { + color: #666; +} + +.nav { + display: flex; + border-radius: 30rpx 30rpx 0 0; + overflow: hidden; +} + +.nav-item { + /* float: left; */ + flex: 1; + /* width: 30%; */ + height: 80rpx; + /* line-height: 90rpx; */ + display: flex; + align-items: center; + justify-content: center; + font-size: 26rpx; + border-bottom: 1px solid #f5f5f5; + background-color: #fff; +} + +.nav-item .ico-dg { + width: 12rpx; + height: 8rpx; + margin-left: 10rpx; + line-height: 0; +} + +.nav-item .ico-filter { + width: 20rpx; + height: 20rpx; + margin-left: 10rpx; + line-height: 0; +} + +.ico-dir { + width: 16rpx; + height: 22rpx; + margin-left: 10rpx; + background-repeat: no-repeat; + background-size: cover; + background-position-x: 0; +} + +.ico-dir-dn { + background-position-x: -16rpx; +} + +.ico-dir-up { + background-position-x: -32rpx; +} + +.search-box { + color: #BEBEBE; + font-size: 24rpx; + /* border: 2rpx solid #f23030; */ + border-radius: 40rpx; + padding: 16rpx; + display: flex; + justify-content: space-between; + background-color: #e0e0e0; +} + +.icon-sousuo { + font-size: 26rpx !important; +} + +.search { + width: 10%; +} + +.search-img { + width: 30rpx; + height: 30rpx; +} + +.choice_list { + background-color: #fff; + /* padding-left: 20rpx; + padding-right: 20rpx; */ +} + +.choice_item { + position: relative; + width: 100%; + /* min-height: 200rpx; */ + /* padding: 10rpx 0; */ + /* border-bottom: 1px solid #f5f6f6; */ + font-size: 30rpx; + display: flex; + padding: 20rpx; + box-sizing: border-box; +} + +.img-wrap { + /* float: left; */ + width: 270rpx; + height: 270rpx; + margin-right: 22rpx; + border-radius: 15rpx; + overflow: hidden; + flex-shrink: 0; + /* padding: 0 10rpx 10rpx; */ +} + +.img-wrap image { + width: 100%; + height: 100%; +} + +.item-cont .title { + font-size: 26rpx; + height: 72rpx; + margin-bottom: 20rpx; + /* padding-right: 10rpx; */ + line-height: 36rpx; + color: #2C2C2C; + text-align: justify; + overflow: hidden; +} + +.price { + display: inline-block; + color: #f23030; + /* line-height: 24rpx; */ + font-size: 30rpx; + /* font-weight: bold; + font-size: 28rpx; */ + /* padding-bottom: 20rpx; */ +} + +.rmb::before { + content: '¥'; + font-size: 24rpx; +} + +.comment { + font-size: 24rpx; + /* margin-top: 4rpx; */ + color: #8d8d8d; + /* padding-right: 30rpx; */ +} + +.filter-modal { + position: fixed; + left: 150rpx; + top: 0; + right: 0; + bottom: 0; + z-index: 20; + background-color: white; + overflow-x: hidden; + padding-bottom: 30rpx; +} + +.filter-box { + box-sizing: border-box; + width: 100%; + font-size: 28rpx; + padding: 20rpx; +} + +.filter-name { + width: 100%; + padding: 20rpx 0; + word-break: keep-all; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + font-size: 30rpx; +} + +.filter-items { + width: 100%; +} + +.filter-item { + float: left; + width: fit-content; + max-width: 500rpx; + word-break: keep-all; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + padding: 10rpx; + border-radius: 10rpx; + border: 1rpx #ddd solid; + margin: 0 10rpx 10rpx 0; + background-color: #fdfdfd; + color: #666; +} + +.viewall-btn { + margin-top: 20rpx; + width: 300rpx; +} + +.card_bg { + /* display: flex; + max-width: 110rpx; + height: 25rpx; + align-items: center; + border-radius: 26rpx; + font-size: 19rpx; + background: #333; + color: #fff; + justify-content: center; + margin-left: 8rpx; + margin-top: 7rpx; + line-height: 25rpx; + padding: 2rpx 10rpx; + width: auto; */ + + + box-sizing: border-box; + padding: 2rpx 10rpx; + height: 28rpx; + border-radius: 26rpx; + font-size: 18rpx; + line-height: 28rpx; + max-width: 220rpx; + background: #333; + color: #fff; + margin-left: 8rpx; +} + +/* .card_bg .card_name { + max-width: 76rpx; + width: auto; + overflow: hidden; + white-space: nowrap; +} */ + +.card_name { + position: relative; + top: -3rpx; + display: inline-block; +} + + +.card_bg image { + width: 19rpx; + height: 19rpx; + margin-right: 8rpx; +} + +.mk_price { + margin-left: 10rpx; + font-size: 24rpx; +} + +.item-cont { + line-height: 38rpx; + display: flex; + flex-direction: column; + justify-content: space-evenly; + flex: 1; +} + + +.choice_list.on { + display: flex; + flex-wrap: wrap; + padding-bottom: 12rpx; + padding-left: 16rpx; + padding-right: 16rpx; + background-color: #f0f0f0; +} + +.choice_list.on .choice_item { + padding: 0; + margin-top: 16rpx; + display: block; + width: 350rpx; + background-color: white; + border-radius: 15rpx; +} + +.choice_list.on .choice_item:nth-child(even) { + margin-left: 18rpx; +} + +.choice_list.on .img-wrap { + width: 350rpx; + height: 350rpx; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +.choice_list.on .item-cont { + padding: 10rpx; + display: flex; + flex-direction: column; + justify-content: space-between; +} + + +.choice_list.on .item-cont .flex.on { + display: block; +} diff --git a/packageC/pages/goods/search/g_filter.wxs b/packageC/pages/goods/search/g_filter.wxs new file mode 100644 index 0000000..88f50d8 --- /dev/null +++ b/packageC/pages/goods/search/g_filter.wxs @@ -0,0 +1,87 @@ +var g_filters = { + //-- 判断是不是有等级价 -- + is_has_rank:function(rank_switch,item){ + if(!rank_switch) return false; + if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true} + return false; + }, + + //-- 判断,不是等级会员时候,要显示的最低等级价和名称 -- + get_card_price:function(goods,all_card,type){ + var price1=parseFloat(goods['cardprice1']); + var price2=parseFloat(goods['cardprice2']); + var price3=parseFloat(goods['cardprice3']); + if(!all_card){ + if(type==0) return 0; + return ""; + } + + var arr=[]; + var min_price= 0; + var min_name=""; + + var min_price=null; + var min_name=null; + //---设置对应的价格名字---- + for(var i=0;i<3;i++) { + var vl=all_card[i]; + if(!vl) continue; + if(vl['CorrPrice']=="Price1" && price1>0) + { + if(min_price==null) { + min_price=price1;min_name=vl['CardName']; + } + else if(price10) + { + if(min_price==null) { + min_price=price2;min_name=vl['CardName']; + } + else if(price20) + { + if(min_price==null) { + min_price=price3;min_name=vl['CardName']; + } + else if(price37 ) min_name=min_name.substring(0, 8); + return min_name; + }, +} +module.exports = { + is_has_rank:g_filters.is_has_rank, + get_card_price:g_filters.get_card_price, +} \ No newline at end of file diff --git a/packageC/pages/goods/search/search.js b/packageC/pages/goods/search/search.js new file mode 100644 index 0000000..f94fc8b --- /dev/null +++ b/packageC/pages/goods/search/search.js @@ -0,0 +1,370 @@ +const { app } = require("../../../../utils/common.js"); + +var t = function (t) { + return t && t.__esModule ? t : { + default: t + }; +}(require("../../../../utils/LoadMore.js")), ut = require("../../../../utils/util.js"), + a = getApp(), e = new t.default(), rq = a.request, oo = a.globalData.setting; + +Page({ + data: { + url: a.globalData.setting.imghost, + resourceUrl: a.globalData.setting.resourceUrl, + currentPage: 1, + requestData: null, + allData: null, + openFilterModal: !1, + openSearchModal: !1, + baseUrl: "/api/weshop/goods/page?1=1", + requestUrl: "", + //hotWords: [ [ "手机", "小米", "iphone" ], [ "三星", "华为", "冰箱" ] ] + hotWords: null, + + tabname: "sort", //排序的字段 + adname: "asc", //升降的字段 + rq_data: null, + + + searchRecord: [], + keyword: '', + is_his: 0, + }, + + onLoad: function (t) { + this.data.rq_data = t; + + //接受有没有导购的参数 + var first_leader = t.first_leader; + if (first_leader) { + getApp().globalData.first_leader = first_leader; + //调用接口判断是不是会员 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + oo.stoid + "/" + first_leader, {}).then(res => { + if (res.data.code == 0) { + getApp().globalData.guide_id = res.data.data.id; + } + }) + } + + var th = this; + a.getConfig2(function (rs) { + var arr = new Array(), arr2 = new Array(); + if (rs.hot_keywords != null && ut.trim(rs.hot_keywords) != "") { + var arr1 = rs.hot_keywords.split('|'); + for (var i = 0; i < arr1.length; i++) { + if (i % 5 == 0 && i != 0) { + arr.push(arr2); + arr2 = []; + } else { + arr2.push(arr1[i]); + } + } + if (arr2.length > 0) arr.push(arr2); + th.setData({ hotWords: arr }); + } + + + //计算等级价相关 + var swithc_list = rs.switch_list; + var sw_arr = JSON.parse(swithc_list); + //---如果后台又开等级卡的开关--- + if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { + th.setData({ rank_switch: true }); + var user = getApp().globalData.userInfo; + var ti = setInterval(function () { + if (!user) return false; + clearInterval(ti); + //---回调卡的列表--- + th.getPlusCardType(function (ob) { + th.setData({ card_list: ob.card_list }); + if (user.card_field) { + var str = user['card_expiredate'].replace(/-/g, '/'); + var end = new Date(str); + end = Date.parse(end) / 1000; + var now = ut.gettimestamp(); + + //--- 判断是等级会员,且在有效期范围内 --- + if (user.card_field && now < end) { + var card_name = ob.name_map.get(user.card_field); + if (card_name.length > 7) card_name = card_name.substring(0, 8); + th.setData({ card_field: user.card_field, card_name: card_name, card_list: ob.card_list }); + } + } + }) + }, 500) + } + + + + }) + e.init(this, "", "requestData"); + var url = this.data.baseUrl; + + //扫一扫过来,显示搜索的内容 + var s_key = t.s_key; + if (s_key) { + s_key = s_key.trim(); + this.search(s_key); this.openSearchModal(); + return; + } + + if (0 != t.brand_id && t.brand_id != undefined) { url += "&brand_id=" + t.brand_id; } + if (0 != t.nation_id && t.nation_id != undefined) { url += "&nation_id=" + t.nation_id; } + if (0 != t.max_price && t.max_price != undefined) { url += "&min_pirce=" + t.min_pirce + "&max_price=" + t.max_price; } + + if (url != this.data.baseUrl) return this.requestSearch(url); + this.openSearchModal(); + + // 获取历史搜索记录 + this.getHistorySearch(); + }, + changeTab: function (t) { + var ord = t.currentTarget.dataset.href; + var ad = t.currentTarget.dataset.ad; + + var url = this.data.requestUrl; + + if (this.data.tabname != ord) { + this.setData({ tabname: ord, adname: "desc" }); + } else { + ad = ad == "desc" ? "asc" : "desc"; + this.setData({ adname: ad }); + } + this.resetData(), this.requestSearch(url); + + }, + + //-----------真的调用地址进行搜索------------ + requestSearch: function (t) { + var a = this; + + if (getApp().globalData.userInfo) { + t += "&user_id=" + getApp().globalData.userInfo.user_id; + } + + this.data.requestUrl = t, + //t += "&orderField=" + a.data.tabname; + //t += "&orderType=" + a.data.adname; + //t += "&page=" + a.data.currentPage, + e.request(t, function (t) { + a.data.currentPage++, + null == a.data.allData && (a.data.allData = t.data.data.pageData), + a.closeSearchModal(); + }, + null, { + is_mainshow: 1, isonsale: 1, store_id: oo.stoid, + orderField: a.data.tabname, orderType: a.data.adname, page: a.data.currentPage + } + ); + }, + onReachBottom: function () { + this.data.openSearchModal || e.canloadMore() && this.requestSearch(this.data.requestUrl); + }, + openFilterModal: function () { + this.setData({ + openFilterModal: !0 + }); + }, + closeFilterModal: function () { + this.setData({ + openFilterModal: !1 + }); + }, + filterGoods: function (t) { + this.resetData(), this.requestSearch(t.currentTarget.dataset.href), this.closeFilterModal(); + }, + resetData: function () { + e.resetConfig(), this.data.requestData = null, this.data.currentPage = 1; + }, + + //---回复最初的设置---显示全部分类-- + restoreData: function () { + this.setData({ + requestData: this.data.allData, + }); + this.data.currentPage = 2; + }, + openSearchModal: function () { + this.setData({ + openSearchModal: !0 + }); + }, + closeSearchModal: function () { + this.setData({ + openSearchModal: !1 + }); + }, + submitSearch: function (t) { + console.log(111, t); + var val = t.detail.value.word; + if (val == undefined) val = t.detail.value; + val = val ? val.trim() : ''; + if (!val) { + a.showWarning("请输入搜索关键词"); + return false + } + // this.search(val); + // wx.navigateTo({ + // url: `/packageA/pages/distribution/shop/shop?key_word=${val}`, + // }); + wx.navigateBack({ + delta: 2 + }); + getApp().globalData.key_word = val; + }, + + //热搜关键字 + searchHotWord: function (t) { + + var word = t.currentTarget.dataset.word; + this.historyRecord(word); + wx.navigateBack({ + delta: 2 + }); + getApp().globalData.key_word = word; + // this.search(word); + }, + + //-----点击搜索按钮---- + search: function (t) { + if ("string" != typeof t || "" == t) return a.showWarning("请输入搜索关键词"); + this.data.key_str = t; + this.historyRecord(); + this.resetData(), this.requestSearch(this.data.baseUrl + "&key_str=" + encodeURIComponent(t)); + }, + + //---------分享配置-------- + onShareAppMessage: function (e) { + var curPage = this; + var pagePath = curPage.route; //当前页面url + if (pagePath.indexOf('/') != 0) { + pagePath = '/' + pagePath; + } + + if (this.data.key_str) { + pagePath += "?s_key=" + this.data.key_str; + } + + if (getApp().globalData.user_id) { + + if (pagePath.indexOf("?") > 0) { + pagePath += "&first_leader=" + getApp().globalData.user_id; + } else { + pagePath += "?first_leader=" + getApp().globalData.user_id; + } + } + + console.log("11-11" + pagePath); + return { + title: "商品搜索", + path: pagePath, + } + }, + + + //---------图片失败,默认图片-------- + bind_bnerr: function (e) { + var _errImg = e.target.dataset.errorimg; + var _errObj = {}; + _errObj[_errImg] = this.data.url + "/miniapp/images/default_g_img.gif"; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + }, + + //--- 获取卡类列表 --- + getPlusCardType: function (func) { + var storid = oo.stoid; + var th = this; + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { + var plusCard = res.data.data; + var arr = [1219, 2089, 3031]; + var new_arr = new Array(); + var card_name_map = new Map(); + var user = getApp().globalData.userInfo; + + for (var i = 0; i < plusCard.length; i++) { + if ((!user || user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) { + continue; + } + var name = "card" + plusCard[i].CorrPrice.toLowerCase(); + card_name_map.set(name, plusCard[i].CardName); + new_arr.push(plusCard[i]); + + } + + var ob = { "card_list": new_arr, "name_map": card_name_map }; + func(ob); + }) + }, + + + getInput(e) { + this.setData({ + keyword: e.detail.value + }); + }, + + historyRecord(w) { + let keyword = w; + let self = this; + if (!keyword) { + keyword = this.data.key_str.trim(); + } + let searchRecord = this.data.searchRecord; + if (!searchRecord || searchRecord.length == 0) searchRecord = wx.getStorageSync('searchRecord') || []; + + if (keyword) { + + var index = searchRecord.indexOf(keyword); + if (index > -1) { + // 已经存在该值 + searchRecord.splice(index, 1); + searchRecord.unshift(keyword); + + // 将历史记录添加到缓存中 + wx.setStorage({ + key: 'searchRecord', + data: searchRecord, + success: function (res) { + self.setData({ + searchRecord, + }) + } + }) + + return; + } else { + if (searchRecord.length >= 10) { + searchRecord.pop(); // 删除最早的一条记录 + }; + searchRecord.unshift(keyword); + + // // 将历史记录添加到缓存中 + wx.setStorage({ + key: 'searchRecord', + data: searchRecord, + success: function (res) { + self.setData({ + searchRecord, + }) + } + }) + }; + }; + }, + + + + + getHistorySearch() { + this.setData({ + searchRecord: wx.getStorageSync('searchRecord') || [] //若无存储则为空 + }); + }, + + clearSearchRecord() { + wx.clearStorageSync('searchRecord'); + this.setData({ + searchRecord: [] + }); + }, +}); \ No newline at end of file diff --git a/packageC/pages/goods/search/search.json b/packageC/pages/goods/search/search.json new file mode 100644 index 0000000..0aa7add --- /dev/null +++ b/packageC/pages/goods/search/search.json @@ -0,0 +1,7 @@ +{ + "navigationBarTitleText": "商品搜索", + "enablePullDownRefresh": false, + "usingComponents": { + "share_box": "/components/share_box/share_box" + } +} \ No newline at end of file diff --git a/packageC/pages/goods/search/search.wxml b/packageC/pages/goods/search/search.wxml new file mode 100644 index 0000000..18c65f1 --- /dev/null +++ b/packageC/pages/goods/search/search.wxml @@ -0,0 +1,33 @@ + + + + +
+ + +
+
+ + 热门搜索 + + + {{item}} + + + + + + 历史搜索 + + + + + {{item}} + + + 暂无历史搜索记录 + +
+
\ No newline at end of file diff --git a/packageC/pages/goods/search/search.wxss b/packageC/pages/goods/search/search.wxss new file mode 100644 index 0000000..1711e17 --- /dev/null +++ b/packageC/pages/goods/search/search.wxss @@ -0,0 +1,311 @@ +.container { + color: #666; +} + +.nav-item { + float: left; + width: 30%; + height: 90rpx; + line-height: 90rpx; + display: flex; + align-items: center; + justify-content: center; + font-size: 32rpx; + border-bottom: 2rpx solid #E6E6E6; + background-color: #fff; +} + +.nav-item .ico-dg { + width: 18rpx; + height: 12rpx; + margin-left: 10rpx; + line-height: 0; +} + +.nav-item .ico-filter { + width: 20rpx; + height: 20rpx; + margin-left: 10rpx; + line-height: 0; +} + +.ico-dir { + width: 16rpx; + height: 22rpx; + margin-left: 10rpx; + background-repeat: no-repeat; + background-size: cover; + background-position-x: 0; +} + +.ico-dir-dn { + background-position-x: -16rpx; +} + +.ico-dir-up { + background-position-x: -32rpx; +} + +.nav-search { + width: 10%; +} + +.nav-item .search-img { + width: 30rpx; + height: 30rpx; +} + +.choice_list { + background-color: #fff; +} + +.choice_item { + position: relative; + width: 100%; + min-height: 200rpx; + padding: 10rpx 0; + border-bottom: 2rpx solid #E6E6E6; + font-size: 30rpx; +} + +.img-wrap { + /* float: left; */ + width: 180rpx; + height: 180rpx; + padding: 0 10rpx 0 30rpx; + flex-shrink: 0; + /* padding: 10rpx; */ +} + +.img-wrap image { + width: 100%; + height: 100%; +} + +.item-cont .title { + height: 72rpx; + margin: 16rpx 0; + padding-right: 30rpx; + line-height: 36rpx; + color: #333; + overflow: hidden; + text-align: justify; +} + +.price { + display: inline-block; + color: #f23030; + /* line-height: 24rpx; */ + /* padding-bottom: 20rpx; */ +} + +.comment { + font-size: 25rpx; + padding-right: 30rpx; + margin-top: 4rpx; +} + +.filter-modal { + position: fixed; + left: 150rpx; + top: 0; + right: 0; + bottom: 0; + z-index: 20; + background-color: white; + overflow-x: hidden; + padding-bottom: 30rpx; +} + +.filter-box { + box-sizing: border-box; + width: 100%; + font-size: 28rpx; + padding: 20rpx; +} + +.filter-name { + width: 100%; + padding: 20rpx 0; + word-break: keep-all; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + font-size: 30rpx; +} + +.filter-items { + width: 100%; +} + +.filter-item { + float: left; + width: fit-content; + max-width: 500rpx; + word-break: keep-all; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + padding: 10rpx; + border-radius: 10rpx; + border: 1rpx #ddd solid; + margin: 0 10rpx 10rpx 0; + background-color: #fdfdfd; + color: #666; +} + +.viewall-btn { + margin-top: 20rpx; + width: 300rpx; +} + +.search-modal { + position: fixed; + top: 0; + right: 0; + left: 0; + bottom: 0; + z-index: 20; + background-color: white; + overflow-x: hidden; + padding: 80rpx 30rpx; + font-size: 30rpx; + color: #555; +} + +.search-bar { + width: 100%; + box-sizing: border-box; +} + +.search-input { + width: 80%; + float: left; + border: 1rpx solid #e0e0e0; + box-sizing: border-box; + height: 80rpx; + padding-left: 20rpx; + border-top-left-radius: 10rpx; + border-bottom-left-radius: 10rpx; +} + +.search-btn { + width: 20%; + height: 80rpx; + background-color: #f23030; + display: inline-block; + text-align: center; + border-top-right-radius: 10rpx; + border-bottom-right-radius: 10rpx; +} + +.search-btn .search-img { + height: 45rpx; + width: 45rpx; + padding: 20rpx; +} + +.search-hot { + margin-top: 40rpx; +} + +.hot-title { + font-size: 35rpx; + color: black; + margin-bottom: 30rpx; +} + +.hot-row { + display: flex; + /*--justify-content: space-between---*/ + padding: 15rpx 10rpx; +} + +.hot-item { + padding: 8rpx 8rpx; + border: 1rpx solid #e0e0e0; + border-radius: 10rpx; + font-size: 28rpx; + margin-left: 15rpx; +} + +/* .card_bg { + display: flex; + max-width: 110rpx; + height: 25rpx; + align-items: center; + border-radius: 26rpx; + font-size: 19rpx; + padding: 2rpx 10rpx; + background: #333; + color: #fff; + justify-content: center; + margin-left: 8rpx; + margin-top: 7rpx; + line-height: 25rpx; + width: auto; +} */ + +.card_bg { + box-sizing: border-box; + padding: 2rpx 10rpx; + /* height: 28rpx; */ + border-radius: 26rpx; + font-size: 18rpx; + /* line-height: 28rpx; */ + max-width: 210rpx; + background: #333; + color: #fff; + margin-left: 8rpx; +} + +.card_bg image { + width: 19rpx; + height: 19rpx; + margin-right: 8rpx; + flex-shrink: 0; +} + +.card_name { + position: relative; + top: -4rpx; +} + +/* .card_bg image { + width: 19rpx; + height: 19rpx; + margin-right: 1rpx; + vertical-align: middle; +} + +.card_bg .card_name { + max-width: 76rpx; + width: auto; + overflow: hidden; + white-space: nowrap; +} */ + +.navigator-hover { + opacity: 1; +} + +.mk_price { + margin-left: 10rpx; + font-size: 25rpx; +} + +.item-cont { + /* line-height: 38rpx; */ + flex-grow: 1; +} + +.history { + background-color: #f0f0f0; + color: #7b7b7b; + border: none; + margin-bottom: 8rpx; +} + +.history:first-of-type { + margin-left: 0; +} diff --git a/utils/request.js b/utils/request.js index 9b3c650..7618e7f 100644 --- a/utils/request.js +++ b/utils/request.js @@ -187,7 +187,7 @@ module.exports = { }) }, - //---promise的使用get---- + //---promise的使用post---- promisePost:function(url,data){ var th=this; if(url.indexOf("http")==-1) url=getApp().globalData.setting.url +url; @@ -234,7 +234,7 @@ module.exports = { }, - //---promise的使用delete---- + //---promise的使用put---- promisePut:function(url,data){ var th=this; if(url.indexOf("http")==-1) url=getApp().globalData.setting.url +url;