// StepPage/pages/second/second.js Page({ /** * 页面的初始数据 */ data: { s_title:'', searchBvalue:'', searchValue:'', searchSvalue:'', itemList:[], productList:[], specialList:[], title:'', b_title:"", show:false, b_show:false, s_show:false, searchList:[], searchBList:[], searchSList:[], inside:'1', surface:'1', set_status:'' }, onChangeInside(event) { let app = getApp(); app.globalData.inside = event.detail; this.setData({ inside: event.detail, }); }, onClickInside(event) { const { name } = event.currentTarget.dataset; let app = getApp(); app.globalData.inside = name; this.setData({ inside: name, }); }, onChangeSurface(event) { let app = getApp(); app.globalData.surface = event.detail; this.setData({ surface: event.detail, }); }, onClickSurface(event) { const { name } = event.currentTarget.dataset; let app = getApp(); app.globalData.surface = name; this.setData({ surface: name, }); }, handleCancel(){ this.setData({ show:false }) }, handleChoose(data){ let app = getApp(); let basic_type_item_id; basic_type_item_id =data.target.dataset.item.id; app.globalData.basic_type_item_id = basic_type_item_id; app.globalData.img_type = data.target.dataset.item.img_type; app.globalData.img = []; app.globalData.img_type.split(',').forEach(ele => { if(ele){ let obj ={}; obj.type=ele; obj.src = ''; obj.url = `https://zh.qingyaokeji.com/${ele}.jpg` app.globalData.img.push(obj) } }); app.globalData.choose_b_r_f_id = (data.target.dataset.item.b_r_f_id).split(',').map(c=>c&&(c*1)); this.setData({ show:false, searchValue:'', searchList:[], title:data.target.dataset.item.title }) }, handleCancelFile(){ this.setData({ b_show:false }) }, handleCancelSpecial(){ this.setData({ s_show:false }) }, handleChooseFile(data){ let app = getApp(); let basic_type_bussiness_id = data.target.dataset.item.id; app.globalData.basic_type_bussiness_id = basic_type_bussiness_id; app.globalData.bussiness_special_type = data.target.dataset.item.special_type; this.setData({ b_show:false, searchBvalue:'', searchBList:[], b_title:data.target.dataset.item.title }) }, handleChooseSpecial(data){ let app = getApp(); let basic_type_special_id = data.target.dataset.item.id; app.globalData.basic_type_special_id = basic_type_special_id; this.setData({ s_show:false, searchSvalue:'', searchSList:[], s_title:data.target.dataset.item.title }) }, onChooseSpecial(){ this.setData({ s_show:true, searchSList:this.data.specialList }) }, onChooseBusiness(){ this.setData({ b_show:true, searchBList:this.data.itemList }) }, onChoose(){ this.setData({ show:true, searchList:this.data.productList }) }, onSearchBusiness(event){ let arr = this.data.itemList.filter(v=>v.title.indexOf(event.detail)!=-1); this.setData({ searchBList:arr }) }, onSearchSpecial(event){ let arr = this.data.specialList.filter(v=>v.title.indexOf(event.detail)!=-1); this.setData({ searchSList:arr }) }, onSearch(event){ let arr = this.data.productList.filter(v=>v.title.indexOf(event.detail)!=-1); this.setData({ searchList:arr }) }, handleNext(){ let app = getApp(); let openid = app.globalData.openID; app.globalData.inside = this.data.inside; app.globalData.surface = this.data.surface; if(!this.data.title||!this.data.b_title){ return wx.showToast({ icon:'none', title: '请选择必填信息!', }) } if(this.data.set_status){ wx.redirectTo({ url: '../third/third', }) }else{ app.globalData.img = app.globalData.img?app.globalData.img:[]; app.globalData.img_type =app.globalData.img_type?app.globalData.img_type:''; app.globalData.stepData = app.globalData.stepData.filter(v=>v.sort!=2); app.globalData.stepData.push({ sort:2, data:{ title:this.data.title, s_title:this.data.s_title, b_title:this.data.b_title, inside:this.data.inside, surface:this.data.surface } }) wx.p.request({ url: `${app.globalData.url}wx/saveWxConstructionData`, method:'POST', data:{ openid, type:1, data:JSON.stringify(app.globalData) } }).then(res=>{ if(res.data.code==200){ wx.redirectTo({ url: '../third/third', }) } }) } }, handleReturn(){ let app = getApp(); let openid = app.globalData.openID; app.globalData.basic_type_special_id = ''; app.globalData.basic_type_bussiness_id = ''; app.globalData.basic_type_item_id = ''; app.globalData.inside = '1'; app.globalData.surface = '1'; app.globalData.img_type = ''; app.globalData.choose_b_r_f_id = []; if(this.data.set_status){ wx.redirectTo({ url: '../first/first', }) }else{ app.globalData.stepData.forEach((v,index)=>{ if(v.sort == '2'){ app.globalData.stepData.splice(index,1); } }) wx.p.request({ url: `${app.globalData.url}wx/saveWxConstructionData`, method:'POST', data:{ openid, type:1, data:JSON.stringify(app.globalData) } }).then(res=>{ if(res.data.code==200){ wx.redirectTo({ url: '../first/first', }) } }) } }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let app = getApp(); let openid = app.globalData.openID; app.globalData.inside = '1'; app.globalData.surface = '1'; wx.p.request({ url: `${app.globalData.url}wx/basicTypeList`, method:'POST', data:{ openid } }).then(res=>{ if(res.data.code==200){ res.data.data.type_two.forEach(v=>{ v.is_choose = false; }) res.data.data.type_one.forEach(v=>{ v.is_choose = false; }) this.setData({ productList:res.data.data.type_two, itemList:res.data.data.type_one, specialList:res.data.data.type_three, inside:app.globalData.inside, surface:app.globalData.surface }) } if(app.globalData.set_status){ app.globalData.inside = app.globalData.detailData.inside+''; app.globalData.surface = app.globalData.detailData.surface+''; app.globalData.basic_type_item_id = app.globalData.detailData.basic_type_item_id; app.globalData.img_type = app.globalData.detailData.item_message.img_type; app.globalData.img = []; app.globalData.img_type.split(',').forEach(ele => { if(ele){ let obj ={}; obj.type=ele; obj.src = ''; obj.url = `https://zh.qingyaokeji.com/${ele}.jpg`; app.globalData.img.push(obj) } }); app.globalData.choose_b_r_f_id = (app.globalData.detailData.item_message.b_r_f_id).split(',').map(c=>c&&(c*1)); app.globalData.basic_type_bussiness_id = app.globalData.detailData.basic_type_bussiness_id; app.globalData.basic_type_special_id = app.globalData.detailData.basic_type_special_id; console.log(app.globalData) this.setData({ title: app.globalData.detailData.basic_type_item_name, s_title: app.globalData.detailData.basic_type_special_name, b_title: app.globalData.detailData.basic_type_bussiness_name, inside:app.globalData.detailData.inside+'', surface: app.globalData.detailData.surface+'', set_status : app.globalData.set_status }) }else{ this.setData({ set_status : '' }) wx.p.request({ url: `${app.globalData.url}wx/getWxConstructionData`, method:'POST', data:{ type:1, openid } }).then(res=>{ if(res.data.code==200){ if(res.data.data.data){ let data = JSON.parse(res.data.data.data); let box = data.stepData.find(v=>v.sort==2); app.globalData = data; app.globalData.set_status = ''; if(box){ this.setData({ title:box.data.title, s_title:box.data.s_title, b_title:box.data.b_title, inside:box.data.inside?box.data.inside+'':'1', surface:box.data.surface?box.data.surface+'':'1' }) } } } }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })