123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- 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<list.length;i++){
- 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({list:list})
- },
- selectareatap: function (e) {
- this.setData({
- square_start: e.currentTarget.dataset.start,
- square_end: e.currentTarget.dataset.end,
- })
- this.caselistfun();
- },
- caselistfun: function (e) {
- var that = this;
- casepage = 1;
- utils.$get({
- url: app.globalData.webUrl + 'client/caselist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- page: 1,
- uid: app.globalData.personMsg.id,
- commu_id: that.data.nowcommunity, // 小区id
- style_id: that.data.nowstyle, //风格id
- square_start: that.data.square_start, //面积开始值
- square_end: that.data.square_end, //面积结束值
- keyword: that.data.keyword,
- housetype_id: that.data.nowhousetype,
- case_type:this.data.noweffect,
- },
- success: function (res) {
- that.setData({
- datashow: true
- })
- if (res.data.code == '0') {
- that.setData({
- caselist: res.data.data,
- })
- }
- setTimeout(function () {
- wx.hideLoading()
- }, 1000)
- },
- fail() {
- wx.hideLoading()
- }
- })
- },
- setstyletap: function (e) {
- this.setData({
- nowstyle: e.currentTarget.dataset.type
- })
- this.caselistfun();
- },
- setcommunitytap: function (e) {
- this.setData({
- nowcommunity: e.currentTarget.dataset.type,
- // communityflag:true,
- nowcommunitname: e.currentTarget.dataset.text,
- })
- this.caselistfun();
- },
- opencommunitytap:function(){
- this.setData({
- communityflag:true,
- })
- },
- dothis:function(){},
- openVRLink(e) {
- let id = e.currentTarget.dataset.id;
- let vrlink = e.currentTarget.dataset.vrlink;
- wx.navigateTo({
- url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&aid=' + id,
- })
- },
- colsecommunitytap:function(){
- this.setData({
- communityflag:false
- })
- },
- sethousetypetap: function (e) {
- this.setData({
- nowhousetype: e.currentTarget.dataset.type
- })
- this.caselistfun();
- },
- casemsgtap: function (e) {
- wx.navigateTo({
- url: '/pages/decorateguidemsg/decorateguidemsg?cid=' + e.currentTarget.dataset.cid+"&type="+this.data.type
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- var that = this;
- casepage = 1;
- utils.$get({
- url: app.globalData.webUrl + 'client/caselist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- page: 1,
- uid: app.globalData.personMsg.id,
- commu_id: that.data.nowcommunity, // 小区id
- style_id: that.data.nowstyle, //风格id
- square_start: that.data.square_start, //面积开始值
- square_end: that.data.square_end, //面积结束值
- keyword: that.data.keyword,
- housetype_id: that.data.nowhousetype,
- case_type:this.data.noweffect,
- },
- success: function (res) {
- wx.stopPullDownRefresh()
- if (res.data.code == '0') {
- that.setData({
- caselist: res.data.data
- })
- }
- setTimeout(function () {
- wx.hideLoading()
- }, 1000)
- }
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- var that = this;
- casepage = casepage * 1 + 1;
- utils.$get({
- url: app.globalData.webUrl + 'client/caselist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- page: casepage,
- uid: app.globalData.personMsg.id,
- commu_id: that.data.nowcommunity, // 小区id
- style_id: that.data.nowstyle, //风格id
- square_start: that.data.square_start, //面积开始值
- square_end: that.data.square_end, //面积结束值
- keyword: that.data.keyword,
- housetype_id: that.data.nowhousetype,
- case_type:this.data.noweffect,
- },
- success: function (res) {
- let caselist = that.data.caselist;
- if (res.data.code == '0') {
- caselist = caselist.concat(res.data.data);
- that.setData({
- caselist: caselist
- })
- }
- setTimeout(function () {
- wx.hideLoading()
- }, 1000)
- }
- })
- },
- addsharetap: function (type) {
- let that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/share/addlog',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: '0',
- type: type,
- },
- success: function (r) {}
- })
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- this.addsharetap('toolAll');
- return {
- title: app.globalData.personMsg.binded.name + "的装修案例",
- imageUrl: app.globalData.imgUrl + "xcx/caseposter.jpg",
- path: '/share/pages/caselist/caselist?u=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&c=&s=&st=&e=&h='
- }
- }
- })
|