const app = getApp(); var utils = require("../../utils/http"), casepage = 1; Page({ /** * 页面的初始数据 */ data: { nowstyle: '', stylelist: [], square_start: '', //面积开始值 square_end: '', //面积结束值 nowcommunity: '', communitylist: [], nowhousetype: '', housetypelist: [], imgUrl: app.globalData.imgUrl, caselist: [], keyword: '', datashow: false, loginFlag:true, mobileflag:false, canIUseGetUserProfile: false, shareobj:{}, employeeflag:false,//false是用户,true是员工 communityflag:false, nowcommunitname:'', type:'', typearr:[ {id:1,name:'效果案例',type:1}, {id:2,name:'实景案例',type:2} ], noweffect:'' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.showLoading({ title: '加载中...', }) if(options.type){ this.setData({ type:options.type }) } this.casestylefun(); this.housestylefun(); this.casecommunityfun(); this.caselistfun(); }, seteffectap(e){ this.setData({ noweffect:e.currentTarget.dataset.type }) this.caselistfun(); }, 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({ stylelist: res.data.data }) } } }) }, 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({ housetypelist: res.data.data }) } } }) }, onChoose(e) { var that=this; that.setData({ nowcommunity:e.detail.item.currentTarget.dataset.cid, nowcommunitname:e.detail.item.currentTarget.dataset.item.name, communityflag:false }) wx.showLoading({ title: '加载中...', }) that.caselistfun(); }, casecommunityfun: function () { var that = this; utils.$get({ url: app.globalData.webUrl + 'api/communitylist', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: {}, success: function (res) { if (res.data.code == '0') { that.setData({ communitylist: res.data.data }) } that.getCitys(); } }) }, getCitys() { const _this = this const cities = this.data.communitylist; // 按拼音排序 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