123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665 |
- const app=getApp(),utils=require("../../../utils/http"),util = require("../../../utils/util");;
- let casepage=1;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl:app.globalData.imgUrl,
- type:1,
- casestyletype: '',
- nowstyletext:'',
- square: [
- { id: 1, name: '60㎡以下', start: 0, end: 60 },
- { id: 2, name: '60㎡—90㎡', start: 60, end: 90 },
- { id: 3, name: '90㎡—110㎡', start: 90, end: 110 },
- { id: 4, name: '110㎡—140㎡', start: 110, end: 140 },
- { id: 5, name: '140㎡—170㎡', start: 140, end: 170 },
- { id: 6, name: '170㎡—210㎡', start: 170, end: 210 },
- { id: 7, name: '210㎡—240㎡', start: 210, end: 240 },
- { id: 8, name: '240㎡—270㎡', start: 240, end: 270 },
- { id: 9, name: '270㎡以上', start: 270, end: '' }
- ],
- nowsquare: '',
- nowstyleid: '',
- nowhousestyletext:'',
- nowcommunitytext:'',
- casestylelist:[],
- casestyletype:'',
- styleflag:false,
- housestyleflag:false,
- squareflag: false,
- square_start: '',//面积开始值
- square_end: '',//面积结束值
- communitylist:[],
- indexList:[],
- casekeytext:'',
- commu_id:'',
- filtrateflag:false,
- datashow:false,
- wshareshow:false,
- caselist: [],
- leftcaselist: [],
- rightcaselist: [],
- uploadedlist:[],
- islist: false,
- nowtype: 'materialCase',
- nowid: '',
- nowtitle:'',
- nowimg: '',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- wx.hideShareMenu({
- menus: ['shareAppMessage', 'shareTimeline']
- })
- this.setData({
- imgUrl:app.globalData.imgUrl,
- })
- wx.showLoading({
- title: '加载中...',
- })
- this.housestylefun();
- this.communityfun();
- this.casestylefun();
- this.caselistfun();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- clearcommunitytap() {
- this.setData({
- nowcommunitytext: '',
- commu_id: ''
- })
- this.caselistfun();
- },
- allfiltratetap: function () {
- this.setData({
- filtrateflag: true,
- casetype: 1
- })
- },
- setcasekeywordtap: function (e) {
- this.setData({
- casekeytext: e.detail.value
- })
- },
- communitytap(e) {
- this.setData({
- commu_id: e.detail.item.target.dataset.cid,
- nowcommunitytext: e.detail.item.target.dataset.item.name,
- filtrateflag: false
- })
- this.caselistfun();
- },
- setypetap(e){
- this.setData({
- type:e.currentTarget.dataset.type
- })
- this.caselistfun();
- },
- editap(){
- wx.navigateTo({
- url: '/mycustomer/pages/editcase/editcase',
- })
- },
- gotocasetap(e){
- let uploadedlist=this.data.uploadedlist,idx=e.currentTarget.dataset.idx;
- if(uploadedlist[idx].del==1||uploadedlist[idx].publish==0){
- wx.navigateTo({
- url: '/mycustomer/pages/editcase/editcase?cid='+uploadedlist[idx].id,
- })
- }else{
- wx.navigateTo({
- url: '/index/pages/casemsg/casemsg?cid=' + uploadedlist[idx].id,
- })
- }
-
- },
- closefiltratetap: function () {
- this.setData({
- filtrateflag: false
- })
- },
- setsquaretap(e) {
- if (e.detail == "") {
- this.setData({
- squareflag: false
- })
- return false;
- }
- if (e.detail.currentTarget.dataset.type == 1 && e.detail.currentTarget.dataset.idx != '-1') {
- this.setData({
- nowsquare: e.detail.currentTarget.dataset.text,
- squareflag: false,
- square_start: this.data.square[e.detail.currentTarget.dataset.idx].start,//面积开始值
- square_end: this.data.square[e.detail.currentTarget.dataset.idx].end,//面积结束值
- })
- } else if (e.detail.currentTarget.dataset.idx == '-1') {
- this.setData({
- nowsquare: '',
- squareflag: false,
- square_start: '',//面积开始值
- square_end: '',//面积结束值
- })
- }
- this.caselistfun();
- },
- housestylefun: function () {
- var that = this;
- utils.$get({
- url: app.globalData.webUrl + 'api/material/housetypelist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {},
- success: function (res) {
- if (res.data.code == '0') {
- that.setData({
- housestylelist: res.data.data
- })
- }
- }
- })
- },
- sethousestyletap(e) {
- if (e.detail == "") {
- this.setData({
- housestyleflag: false
- })
- return false;
- }
- if (e.detail.currentTarget.dataset.type == 1 && e.detail.currentTarget.dataset.idx != '-1') {
- this.setData({
- nowstyleid: e.detail.currentTarget.dataset.text,
- housestyleflag: false,
- nowhousestyletext: this.data.housestylelist[e.detail.currentTarget.dataset.idx].name
- })
- } else if (e.detail.currentTarget.dataset.idx == '-1') {
- this.setData({
- nowstyleid: '',
- housestyleflag: false,
- nowhousestyletext: ''
- })
- }
- this.caselistfun();
- },
- casetypetap(e) {
- this.setData({
- casetype: e.currentTarget.dataset.type,
- styleflag: e.currentTarget.dataset.type == 1 ? true : '',
- housestyleflag: e.currentTarget.dataset.type == 3 ? true : '',
- squareflag: e.currentTarget.dataset.type == 2 ? true : '',
- filtrateflag: e.currentTarget.dataset.type == 4 ? true : false,
- })
- },
- casestylefun: function () {
- var that = this;
- utils.$get({
- url: app.globalData.webUrl + 'api/stylelist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {},
- success: function (res) {
- if (res.data.code == '0') {
- that.setData({
- casestylelist: res.data.data
- })
- }
- }
- })
- },
- setstyletap(e) {
- if (e.detail == "") {
- this.setData({
- styleflag: false
- })
- return false;
- }
- if (e.detail.currentTarget.dataset.type == 1 && e.detail.currentTarget.dataset.idx != '-1') {
- this.setData({
- casestyletype: e.detail.currentTarget.dataset.text,
- styleflag: false,
- nowstyletext: this.data.casestylelist[e.detail.currentTarget.dataset.idx].name
- })
- } else if (e.detail.currentTarget.dataset.idx == '-1') {
- this.setData({
- casestyletype: '',
- styleflag: false,
- nowstyletext: ''
- })
- }
- this.caselistfun();
- },
- caselistfun: function (e) {
- var that = this;
- if (!!e) {
- that.setData({
- filtrateflag: false
- })
- }
- casepage=1;
- utils.$get({
- url: app.globalData.webUrl + 'api/caselist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- uid: app.globalData.personMsg.id,
- page: 1,
- commu_id: that.data.commu_id,// 小区id
- style_id: that.data.casestyletype,//风格id
- square_start: that.data.square_start,//面积开始值
- square_end: that.data.square_end,//面积结束值
- keyword: that.data.casekeytext,
- housetype_id: that.data.nowstyleid,
- order: that.data.ordertype == 'time' ? 'addtime' : 'view_times',
- my_case:that.data.type==1?'publish':'all'
- },
- success: function (res) {
- that.setData({
- datashow: true
- })
- if (res.data.code == '0') {
- if(that.data.type==1){
- that.setData({
- caselist: res.data.data,
- leftcaselist: [],
- rightcaselist: [],
- datashow: true
- })
- that.caseimgload();
- }else{
- that.setData({
- uploadedlist:res.data.data
- })
- }
-
- }
- setTimeout(function () {
- wx.hideLoading()
- }, 1000)
- }, fail() {
- wx.hideLoading()
- }
- })
- },
- casecollectap: function (e) {
- var that = this;
- let caselist = '';
- if (e.currentTarget.dataset.type == 'rightcaselist') {
- caselist = that.data.rightcaselist;
- } else {
- caselist = that.data.leftcaselist;
- }
- utils.$post({
- url: app.globalData.webUrl + 'api/collect',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- user_id: app.globalData.personMsg.id,
- content_type: "materialCase",
- content_id: e.currentTarget.dataset.cid
- },
- success: function (res) {
- if (res.data.code == '0') {
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- caselist[e.currentTarget.dataset.idx].collected = !caselist[e.currentTarget.dataset.idx].collected;
- if (e.currentTarget.dataset.type == 'rightcaselist') {
- that.setData({
- rightcaselist: caselist
- })
- } else {
- that.setData({
- leftcaselist: caselist
- })
- }
- }
- }
- })
- },
- caseimgload: function () {
- var that = this;
- var leftlist = that.data.leftcaselist;
- var rightlist = that.data.rightcaselist;
- var indexlist = that.data.caselist;
- if (indexlist.length == 0) {
- return false;
- }
- if (!indexlist[0]) {
- return false;
- }
- if (leftlist.length == 0) {
- leftlist.push(indexlist[0]);
- indexlist.shift();
- that.setData({
- caselist: indexlist,
- leftcaselist: leftlist,
- rightcaselist: rightlist
- })
- } else {
- var leftheight, rightheight;
- wx.createSelectorQuery().in(this).select('#leftcasebox').boundingClientRect(function (res) {
- // if(!res){
- // return false;
- // }
- leftheight = res.height;
- wx.createSelectorQuery().in(that).select('#rightcasebox').boundingClientRect(function (rs) {
- // if(!rs){
- // return false;
- // }
- leftlist = that.data.leftcaselist;
- rightlist = that.data.rightcaselist;
- indexlist = that.data.caselist;
- rightheight = rs.height;
- if (!indexlist[0]) {
- return false;
- }
- if (leftheight > rightheight && (leftheight - rightheight) > 20) {
- rightlist.push(indexlist[0]);
- indexlist.shift();
- } else {
- leftlist.push(indexlist[0]);
- indexlist.shift();
- }
- that.setData({
- caselist: indexlist,
- leftcaselist: leftlist,
- rightcaselist: rightlist
- })
- }).exec();
- }).exec();
- }
- },
- communityfun: function (e) {
- var that = this;
- that.setData({
- casepage: 1,
- })
- utils.$get({
- url: app.globalData.webUrl + 'api/communitylist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- page: 1,
- sort: this.data.ordertype == 'time' ? '' : 'updatetime',
- from: '1'
- },
- success: function (res) {
- that.setData({
- datashow: true
- })
- let indexList = [], str = '';
- if (res.data.code == '0') {
- for (let i in res.data.data) {
- res.data.data[i].firstword = res.data.data[i].pinyin.slice(0, 1).toUpperCase();
- if (res.data.data[i].pinyin.slice(0, 1).toUpperCase() != str) {
- str = res.data.data[i].pinyin.slice(0, 1).toUpperCase() + '';
- indexList.push(str);
- }
- }
- that.setData({
- communitycaselist: res.data.data,
- indexList: indexList
- })
- that.communitygetCitys();
- }
- setTimeout(function () {
- wx.hideLoading()
- }, 1000)
- }, fail() {
- wx.hideLoading()
- }
- })
- },
- communitygetCitys() {
- const _this = this
- const cities = this.data.communitycaselist;
- // 按拼音排序
- cities.sort((c1, c2) => {
- let pinyin1 = c1.pinyin;
- let pinyin2 = c2.pinyin;
- return pinyin1.localeCompare(pinyin2)
- })
- // 添加首字母
- const map = new Map()
- for (const city of cities) {
- const alpha = city.pinyin.charAt(0).toUpperCase()
- if (!map.has(alpha)) map.set(alpha, [])
- map.get(alpha).push({ name: city.name, id: city.id })
- }
- const keys = []
- for (const key of map.keys()) {
- keys.push(key)
- }
- keys.sort()
- const list = []
- for (const key of keys) {
- list.push({
- alpha: key,
- subItems: map.get(key)
- })
- }
- for (let i = 0; i < list.length; i++) {
- list[i].subItems[0].case_num = '0';
- for (let k = 0; k < list[i].subItems.length; k++) {
- for (let j = 0; j < cities.length; j++) {
- if (list[i].subItems[k].name == cities[j].name) {
- list[i].subItems[k].case_num = cities[j].case_num;
- list[i].id = cities[j].id;
- }
- }
- }
- }
- _this.setData({ communitylist: list })
- },
- casemsgtap: function (e) {
- wx.navigateTo({
- url: '/index/pages/casemsg/casemsg?cid=' + e.currentTarget.dataset.cid,
- })
- },
- casesharetap: function (e) {
- var that = this;
- that.setData({
- nowtype: 'materialCase',
- nowid: e.currentTarget.dataset.cid,
- nowtitle: e.currentTarget.dataset.title,
- nowimg: e.currentTarget.dataset.img,
- wshareshow: true,
- })
- },
- setpostertap: function () {
- let that = this;
- let type = that.data.nowtype, usrl = "";
- type = "materialCase";
- usrl = '&u=' + app.globalData.personMsg.id + '&c=' + that.data.commu_id + '&s=' + that.data.casestyletype + '&st=' + that.data.square_start + '&e=' + that.data.square_end + '&h=' + that.data.nowstyleid
- wx.navigateTo({
- url: '/index/pages/setposter/setposter?type=' + type + '&aid=' + this.data.nowid + "&listshare=" + usrl,
- })
- },
- sendfriendtap: function () {
- this.sharelogtap();
- },
- shareurltap: function () {
- let that = this;
- wx.showLoading({
- title: '加载中...',
- })
- util.schemefun('/share/pages/materialcase/materialcase', 'cid=' + that.data.nowid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, that.data.nowid, 'materialCase', '');
- this.sharelogtap();
- },
- sharelogtap: function (e) {
- var that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/share/addlog',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.nowid,
- type: that.data.nowtype
- },
- success: function (r) {
- }
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- const that=this;
- casepage=1;
- utils.$get({
- url: app.globalData.webUrl + 'api/caselist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- uid: app.globalData.personMsg.id,
- page: 1,
- commu_id: that.data.commu_id,// 小区id
- style_id: that.data.casestyletype,//风格id
- square_start: that.data.square_start,//面积开始值
- square_end: that.data.square_end,//面积结束值
- keyword: that.data.casekeytext,
- housetype_id: that.data.nowstyleid,
- order: that.data.ordertype == 'time' ? 'addtime' : 'view_times',
- my_case:that.data.type==1?'publish':'all'
- },
- success: function (res) {
- wx.stopPullDownRefresh()
- if (res.data.code == '0') {
- if(that.data.type==1){
- that.setData({
- caselist: res.data.data,
- leftcaselist: [],
- rightcaselist: [],
- datashow: true
- })
- that.caseimgload();
- }else{
- that.setData({
- uploadedlist:res.data.data
- })
- }
-
- }
- }, fail() {
- wx.stopPullDownRefresh()
- }
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- const that=this;
- casepage=casepage*1+1;
- utils.$get({
- url: app.globalData.webUrl + 'api/caselist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- uid: app.globalData.personMsg.id,
- page: casepage,
- commu_id: that.data.commu_id,// 小区id
- style_id: that.data.casestyletype,//风格id
- square_start: that.data.square_start,//面积开始值
- square_end: that.data.square_end,//面积结束值
- keyword: that.data.casekeytext,
- housetype_id: that.data.nowstyleid,
- order: that.data.ordertype == 'time' ? 'addtime' : 'view_times',
- my_case:that.data.type==1?'publish':'all'
- },
- success: function (res) {
- wx.stopPullDownRefresh()
- if (res.data.code == '0') {
- if(that.data.type==1){
- let arrflag = false;
- let caselist = that.data.caselist;
- if (caselist.length != 0) {
- arrflag = true;
- }
- caselist = caselist.concat(res.data.data)
- that.setData({
- caselist: caselist
- })
- if (!arrflag) {
- that.caseimgload();
- }
- }else{
- let uploadedlist=that.data.uploadedlist;
- uploadedlist=uploadedlist.concat(res.data.data);
- that.setData({
- uploadedlist:uploadedlist
- })
- }
-
- }
- }, fail() {
- wx.stopPullDownRefresh()
- }
- })
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- this.sharelogtap();
- return {
- title: that.data.nowtitle,
- imageUrl: that.data.nowimg,
- path: '/share/pages/materialcase/materialcase?cid=' + that.data.nowid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
- }
- }
- })
|