You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
clothesProject/pages/navigation/index/recommand/recommand.js

259 lines
5.5 KiB

// pages/navigation/index/recommand/recommand.js
import Toast from './@vant/weapp/toast/toast';
let app=getApp();
Page({
/**
* 页面的初始数据
*/
data: {
active: 0,
show_clothes:[],//显示衣服
show_recommend:[],//显示推荐
show_match_clothes:[],//显示搭配
recommend:{
//-10-5℃
a:{
recommend:['coat9','pants4'],//推荐
match_clothes:[]//搭配
},
//5-15℃
b:{
recommend:['hoodie3','pants5'],//推荐
match_clothes:['sweater8','pants7']//搭配
},
//5-15℃
c:{
recommend:['hoodie1','pants1'],//推荐
match_clothes:[]//搭配
},
//25-40℃
d:{
recommend:['skirt10'],//推荐
match_clothes:['t-shirt2','pants10']//搭配
}
},
},
on_clear()
{
this.setData({ show_recommend:[],show_match_clothes:[]});
},
onChange(event) {
// event.detail 为当前输入的值
let s=26-event.detail,t=0;
console.log("温度",s,event.detail.length);
if(event.detail==' '||event.detail.length==0)
{
event.detail="无"
}
this.setData({ show_recommend:[],show_match_clothes:[]});
if(event.detail<5&&event.detail>-10)
{
for(let n in this.data.recommend.a)
{
if(n=='recommend')
{
//推荐
for(let i in this.data.recommend.a[n])
{
this.data.show_recommend.push("/pages/img/衣服/"+this.data.recommend.a[n][i]+".jpg")
}
}else{
//搭配
for(let i in this.data.recommend.a[n])
{
this.data.show_match_clothes.push("/pages/img/衣服/"+this.data.recommend.a[n][i]+".jpg")
}
}
}
console.log("数据a")
this.setData({ show_recommend:this.data.show_recommend,show_match_clothes:this.data.show_match_clothes});
return 0;
}else if(event.detail<15&&event.detail>5)
{
console.log("数据b")
for(let n in this.data.recommend.b)
{
if(n=='recommend')
{
//推荐
for(let i in this.data.recommend.b[n])
{
this.data.show_recommend.push("/pages/img/衣服/"+this.data.recommend.b[n][i]+".jpg")
}
}else{
//搭配
for(let i in this.data.recommend.b[n])
{
this.data.show_match_clothes.push("/pages/img/衣服/"+this.data.recommend.b[n][i]+".jpg")
}
}
}
this.setData({ show_recommend:this.data.show_recommend,show_match_clothes:this.data.show_match_clothes});
return 0;
}else if(event.detail<25&&event.detail>15)
{
console.log("数据c")
for(let n in this.data.recommend.c)
{
if(n=='recommend')
{
//推荐
for(let i in this.data.recommend.c[n])
{
this.data.show_recommend.push("/pages/img/衣服/"+this.data.recommend.c[n][i]+".jpg")
}
}else{
//搭配
for(let i in this.data.recommend.c[n])
{
this.data.show_match_clothes.push("/pages/img/衣服/"+this.data.recommend.c[n][i]+".jpg")
}
}
}
this.setData({ show_recommend:this.data.show_recommend,show_match_clothes:this.data.show_match_clothes});
return 0;
}else if(event.detail<40&&event.detail>25)
{
for(let n in this.data.recommend.d)
{
if(n=='recommend')
{
//推荐
for(let i in this.data.recommend.d[n])
{
this.data.show_recommend.push("/pages/img/衣服/"+this.data.recommend.d[n][i]+".jpg")
}
}else{
//搭配
for(let i in this.data.recommend.d[n])
{
this.data.show_match_clothes.push("/pages/img/衣服/"+this.data.recommend.d[n][i]+".jpg")
}
}
}
this.setData({ show_recommend:this.data.show_recommend,show_match_clothes:this.data.show_match_clothes});
console.log("数据1111",this.data.show_recommend,this.data.show_match_clothes)
return 0;
}
this.data.show_clothes=[];
for(let n in app.globalData.clothes)
{
if(app.globalData.clothes[n].t==s)
{
this.data.show_clothes[t]=app.globalData.clothes[n];
this.data.show_clothes[t].img="/pages/img/衣服/"+app.globalData.clothes[n].name+".jpg";
t++;
}
}
console.log("衣服",this.data.show_clothes);
let g_this=this;
if(this.data.show_clothes.length>0)
{
console.log("可以跳转")
wx.navigateTo({
url: './show_clothes/show_clothes',
events: {
// 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
acceptDataFromOpenedPage: function(data) {
console.log(data)
},
someEvent: function(data) {
console.log(data)
}
},
success: function(res) {
// 通过 eventChannel 向被打开页面传送数据
res.eventChannel.emit('show_clothes', { data: g_this.data.show_clothes })
}
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})