221 lines
5.5 KiB
JavaScript
221 lines
5.5 KiB
JavaScript
|
|
var util = require('../../utils/util.js');
|
|||
|
|
var api = require('../../config/api.js');
|
|||
|
|
|
|||
|
|
var app = getApp();
|
|||
|
|
Page({
|
|||
|
|
data: {
|
|||
|
|
//已选的项目
|
|||
|
|
disablecheck : true,
|
|||
|
|
//上一个页面带来的信息
|
|||
|
|
selectName: '',
|
|||
|
|
selectNationId: '',
|
|||
|
|
selectClassName: '',
|
|||
|
|
selectSchoolName: '',
|
|||
|
|
selectPatid: '',
|
|||
|
|
|
|||
|
|
//学生信息
|
|||
|
|
studentlist:[],
|
|||
|
|
studentSwitch: false,
|
|||
|
|
|
|||
|
|
standardList: [],
|
|||
|
|
smStandardList: [],
|
|||
|
|
smStandardContent: '',
|
|||
|
|
addtionList: [],
|
|||
|
|
smAddtionList: [],
|
|||
|
|
id: 0,
|
|||
|
|
currentCategory: {},
|
|||
|
|
scrollLeft: 0,
|
|||
|
|
scrollTop: 0,
|
|||
|
|
scrollHeight: 0,
|
|||
|
|
page: 1,
|
|||
|
|
limit: 10
|
|||
|
|
},
|
|||
|
|
onLoad: function(options) {
|
|||
|
|
// 页面初始化 options为页面跳转所带来的参数
|
|||
|
|
this.setData({
|
|||
|
|
selectName:options.name,
|
|||
|
|
selectNationId:options.nationid,
|
|||
|
|
selectClassName:options.classname,
|
|||
|
|
selectSchoolName:options.schoolname,
|
|||
|
|
selectPatid: options.patid
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
var that = this;
|
|||
|
|
wx.getSystemInfo({
|
|||
|
|
success: function(res) {
|
|||
|
|
that.setData({
|
|||
|
|
scrollHeight: res.windowHeight
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//checkbox status
|
|||
|
|
onCheckOptionChange(event) {
|
|||
|
|
let itemIndex = event.target.dataset.itemIndex;
|
|||
|
|
let that = this;
|
|||
|
|
// console.log(itemIndex);
|
|||
|
|
// console.log(event);
|
|||
|
|
|
|||
|
|
//编辑状态
|
|||
|
|
let tmpCartData = this.data.smAddtionList.map(function(element, index, array) {
|
|||
|
|
if (index == itemIndex) {
|
|||
|
|
element.checked = !element.checked;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return element;
|
|||
|
|
});
|
|||
|
|
that.setData({
|
|||
|
|
smAddtionList: tmpCartData
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
//checkbox status
|
|||
|
|
onCheckStandardChange(event) {
|
|||
|
|
let itemIndex = event.target.dataset.itemIndex;
|
|||
|
|
let that = this;
|
|||
|
|
// console.log(itemIndex);
|
|||
|
|
// console.log(event);
|
|||
|
|
|
|||
|
|
//编辑状态
|
|||
|
|
let tmpCartData = this.data.smStandardList.map(function(element, index, array) {
|
|||
|
|
if (index == itemIndex) {
|
|||
|
|
element.checked = !element.checked;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return element;
|
|||
|
|
});
|
|||
|
|
that.setData({
|
|||
|
|
smStandardList: tmpCartData
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
numFilter(value){
|
|||
|
|
console.log(value);
|
|||
|
|
const realVal = parseFloat(value).toFixed(2);//表示保留一位函数
|
|||
|
|
return realVal;
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
onReady: function() {
|
|||
|
|
// 页面渲染完成
|
|||
|
|
},
|
|||
|
|
onShow: function() {
|
|||
|
|
// 页面显示
|
|||
|
|
console.log("category onshow");
|
|||
|
|
this.getstandardList();
|
|||
|
|
this.getaddtionList();
|
|||
|
|
|
|||
|
|
//this.getPerList();
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
onHide: function() {
|
|||
|
|
// 页面隐藏
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
getstandardList: function() {
|
|||
|
|
var that = this;
|
|||
|
|
|
|||
|
|
util.request(api.kfiteminfo, {
|
|||
|
|
packageno: '666',
|
|||
|
|
patid: this.data.selectPatid
|
|||
|
|
})
|
|||
|
|
.then(function(res) {
|
|||
|
|
console.log(res.data);
|
|||
|
|
that.setData({
|
|||
|
|
standardList: res.data,
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 将后台返回的 res 数组数据进行新增一个字段
|
|||
|
|
if(res.data != null){
|
|||
|
|
res.data.forEach(function(item) {
|
|||
|
|
// 获取图片数组length范围内的随机 index
|
|||
|
|
//var randomIndex = Math.floor(Math.random() * that.data.srcList.length);
|
|||
|
|
item.checked = 0;
|
|||
|
|
});
|
|||
|
|
that.setData({
|
|||
|
|
smStandardList: res.data,
|
|||
|
|
smStandardContent: res.data[0].itemno
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
getaddtionList: function() {
|
|||
|
|
var that = this;
|
|||
|
|
|
|||
|
|
util.request(api.kfiteminfo, {
|
|||
|
|
packageno: '0',
|
|||
|
|
patid: this.data.selectPatid
|
|||
|
|
})
|
|||
|
|
.then(function(res) {
|
|||
|
|
console.log(res.data);
|
|||
|
|
that.setData({
|
|||
|
|
addtionList: res.data,
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if(res.data != null){
|
|||
|
|
// 将后台返回的 res 数组数据进行新增一个字段
|
|||
|
|
res.data.forEach(function(item) {
|
|||
|
|
// 获取图片数组length范围内的随机 index
|
|||
|
|
//var randomIndex = Math.floor(Math.random() * that.data.srcList.length);
|
|||
|
|
item.checked = 0;
|
|||
|
|
});
|
|||
|
|
that.setData({
|
|||
|
|
smAddtionList: res.data
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
console.log(this.data.smAddtionList.length, "smAddtionList length");
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
addFast: function(){
|
|||
|
|
var filterNum = this.data.smStandardList.filter(function(person,index,arrs){
|
|||
|
|
return person.checked==true
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
var filterNum1 = this.data.smAddtionList.filter(function(person,index,arrs){
|
|||
|
|
return person.checked==true
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if( (filterNum.length == 0) && (filterNum1.length == 0)){
|
|||
|
|
wx.showToast({
|
|||
|
|
title: '没有选择项目',
|
|||
|
|
})
|
|||
|
|
}else{
|
|||
|
|
app.globalData.gStandardList = this.data.smStandardList;
|
|||
|
|
app.globalData.gAddtionList = this.data.smAddtionList;
|
|||
|
|
app.globalData.gStandardContent = this.data.smStandardContent;
|
|||
|
|
|
|||
|
|
// 设置好list,转到结算页面
|
|||
|
|
try {
|
|||
|
|
// wx.setStorageSync('cartId', res.data);
|
|||
|
|
// wx.setStorageSync('grouponRulesId', checkedGroupon.id);
|
|||
|
|
// wx.setStorageSync('grouponLinkId', that.data.grouponLink.id);
|
|||
|
|
|
|||
|
|
wx.navigateTo({
|
|||
|
|
url: '/pages/checkoutkf/checkoutkf?name=' + this.data.selectName + '&nationid=' + this.data.selectNationId + '&classname=' + this.data.selectClassName + '&schoolname=' + this.data.selectSchoolName + '&patid=' + this.data.selectPatid,
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
} catch (e) {}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
onTabItemTap(item) {
|
|||
|
|
// 判断是否要阻止切换
|
|||
|
|
console.log("切换tab");
|
|||
|
|
if (app.globalData.hasXyrw == false) {
|
|||
|
|
// 阻止切换
|
|||
|
|
wx.switchTab({
|
|||
|
|
url: '/pages/index/index'
|
|||
|
|
})
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
// 允许切换
|
|||
|
|
return true;
|
|||
|
|
},
|
|||
|
|
onUnload: function() {
|
|||
|
|
// 页面关闭
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
})
|