bridgeSpace/pages/list/list.js

219 lines
4.6 KiB
JavaScript

// pages/list/list.js
let app = getApp()
// const computedBehavior = require('miniprogram-computed')
// behaviors: [computedBehavior],
Page({
/**
* 页面的初始数据
*/
data: {
options: [
{
value: "1",
label: "全部",
},
{
value: "油船",
label: "油船",
},
{
value: "危化品船",
label: "危化品船",
},
],
optionsweight: [
{
value: "1",
label: "全部",
},
{
value: "1000吨以上",
label: "1000吨以上",
},
{
value: "1000吨以下",
label: "1000吨以下",
},
],
optionsWork: [
{
value: "1",
label: "全部",
},
{
value: "结构认知",
label: "结构认知",
},
{
value: "消防演习",
label: "消防演习",
},
{
value: "装货作业",
label: "装货作业",
},
{
value: "卸货作业",
label: "卸货作业",
},
{
value: "溢油演习",
label: "溢油演习",
},
{
value: "洗舱作业",
label: "洗舱作业",
},
{
value: "密闭空间",
label: "密闭空间",
},
],
modelShow: false,
video: "1",
videoSrc: "",
dataList: [],
showPicker:true,
ship: 0,//默认显示位置
weight: 0,//默认显示位置
type: 0,//默认显示位置
},
filterFunc(val, target, filterArr) {
// 参数不存在或为空时,就相当于查询全部
if (val == undefined || val == '1') {
return filterArr;
}
return filterArr.filter((p) => p[target].indexOf(val) > -1);
},
bindPickerChange2: function (e) {
this.setData({
ship: e.detail.value
})
this.handleList()
},
bindPickerweight: function (e) {
this.setData({
weight: e.detail.value
})
this.handleList()
},
bindPickerwork: function (e) {
this.setData({
type: e.detail.value
})
this.handleList()
},
handleModel:function(item) {
console.log(item);
wx.request({
url: 'https://www.umayle.com/inland/Api/VideoController.ashx',
data:{
openId: app.globalData.openId, videoId: item.currentTarget.dataset.id
},
method: 'get',
success:(_res_)=>{
if (_res_.data.code == 1) {
this.setData({
modelShow : true,
video : "1"
})
} else {
this.setData({
modelShow : true,
video : "2",
videoSrc :item.currentTarget.dataset.video
})
}
}
})
},
handleClose() {
this.setData({
modelShow : false,
})
},
handleList(){
let objVal = {};
objVal.ship = this.data.options[this.data.ship].value
objVal.weight = this.data.optionsweight[this.data.weight].value
objVal.type = this.data.optionsWork[this.data.type].value
wx.request({
url: 'https://download-1300932214.cos.ap-nanjing.myqcloud.com/inlandVessel/data.json',
method: 'get',
success:(_res_)=>{
let arr = _res_.data.data;
Object.keys(objVal).forEach((e) => {
// 调用自己定义好的筛选方法
arr = this.filterFunc(objVal[e], e, arr);
});
this.setData({
dataList: arr
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.request({
url: 'https://download-1300932214.cos.ap-nanjing.myqcloud.com/inlandVessel/data.json',
method: 'get',
success:(_res_)=>{
this.setData({
dataList:_res_.data.data
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
wx.hideHomeButton();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})