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/index.js

166 lines
2.9 KiB

2 years ago
// pages/navigation/index/index.js
import Toast from './@vant/weapp/toast/toast';
let app=getApp();
Page({
/**
* 页面的初始数据
*/
data: {
active: 0,
show_clothes:[],//显示衣服
},
//增加服饰
add()
{
console.log("增加服饰")
wx.navigateTo({
url: './add/camera/camera',
})
},
//删除服饰
delete()
{
console.log("删除服饰")
wx.navigateTo({
url: './delete/delete',
})
},
tabbar_change(event) {
// event.detail 的值为当前选中项的索引
console.log("跳转",event.detail);
this.setData({ active: event.detail });
},
//添加的
on_clear()
{
this.setData({ show_recommend:[],show_match_clothes:[]});
},
// 搜索
onChange(event) {
// event.detail 为当前输入的值
console.log(event.detail);
let s=26-event.detail,t=0;
let a=event.detail,r=0;
console.log("温度",s);
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++;
}
else if(app.globalData.clothes[n].kind==a||app.globalData.clothes[n].pattern==a||app.globalData.clothes[n].style==a||app.globalData.clothes[n].colour==a||app.globalData.clothes[n].thickness==a||app.globalData.clothes[n].season==a)
{
this.data.show_clothes[r]=app.globalData.clothes[n];
this.data.show_clothes[r].img="/pages/img/衣服/"+app.globalData.clothes[n].name+".jpg";
r++;
}
}
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() {
}
})