小程序开发——选座小程序

 const db = wx.cloud.database()
 const _ = db.command
    db.collection('seats').doc(_.and(
    [
	  { row:"2"},
	  {column: '2'}
	])).update(
	{
  	 data: {
     status:"booked"
  },
})

1、每人最多选一个座位

if (this.data.selectSeatList.length == 2) {
              wx.showToast({
                title: '最多选择1个座位',
                icon: 'none',
                duration: 1000,
                mask: true
              })
let seatInfo = item.column + "排" + item.row + "座";
            this.remove(seatInfo);
let seatInfo = item.column + "排" + item.row + "座";
              seat.seatInfo = seatInfo;
              seat.x = item.row;
              seat.y = item.column;
              seat.index = item.row + item.column;
              this.data.selectSeatList.push(seat);
remove(val) {
    for (var a = 0; a < this.data.selectSeatList.length; a++) {
      if (this.data.selectSeatList[a].seatInfo == val) {
        this.data.selectSeatList.splice(a, 1);
        break;
      }
    }
    this.setData({
      selectSeatList: this.data.selectSeatList
    })
  },

2、提交时至少选择一个座位

submit() {
    if (this.data.selectSeatList.length == 0) {
      wx.showToast({
        title: '请选择一个座位',
      })
    }else{

你可能感兴趣的:(网页开发,小程序)