123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- // pages/indexPages/yyqhPages/selectTime/selectTime.js
- import {
- queryReserveDate,
- queryReserveTimePeriod,
- xcxjxyy
- } from "../../../../apis/index"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- hall: "",
- business: "",
- dateBoxStyle: '',
- orgAreaNumber: "",
- dates: [],
- dateIndex: 0,
- times: [],
- timeIndex: 0,
- sfYy: false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- let that = this
- that.init(options)
- },
- init(e) {
- let that = this
- if (e) {
- if (e.business) {
- that.setData({
- hall: wx.getStorageSync('MY_HALL').bsfwtmc,
- business: JSON.parse(e.business)
- })
- }
- that.getData()
- }
- },
- selectDate(e) {
- let that = this
- let index = e.currentTarget.dataset.index
- let item = e.currentTarget.dataset.item
- that.setData({
- dateIndex: index
- })
- that.getTime()
- },
- selectTime(e) {
- let that = this
- let index = e.currentTarget.dataset.index
- let item = e.currentTarget.dataset.item
- that.setData({
- timeIndex: index
- })
- },
- showHiden() {
- let that = this
- let dateBoxStyle = that.data.dateBoxStyle
- if (dateBoxStyle == '') {
- that.setData({
- dateBoxStyle: "timesActive"
- })
- } else {
- that.setData({
- dateBoxStyle: ""
- })
- }
- },
- getWeek(e) {
- let weeks = [
- "周日",
- "周一",
- "周二",
- "周三",
- "周四",
- "周五",
- "周六",
- ]
- return weeks[e]
- },
- getData(e) {
- let that = this
- wx.showLoading({
- title: '正在获取可预约日期',
- })
- let form = {
- bsfwtDm: wx.getStorageSync('MY_HALL').bsfwtDm
- }
- queryReserveDate(form).then(res => {
- wx.hideLoading()
- if (res.code == 200) {
- that.setData({
- dates: res.billDateList.map((e) => {
- return {
- week: that.getWeek(new Date(e).getDay()),
- date: e.substring(5, 10),
- dates: e
- }
- }),
- orgAreaNumber: res.orgAreaNumber
- })
- that.getTime()
- } else {
- wx.showToast({
- title: res.msg || res.message,
- icon: "none",
- duration: 5000
- })
- }
- })
- },
- getTime() {
- let that = this
- wx.showLoading({
- title: '正在获取预约时间段',
- })
- let form = {
- orgAreaNumber: that.data.orgAreaNumber,
- billDate: that.data.dates[that.data.dateIndex].dates,
- bsfwtDm: wx.getStorageSync('MY_HALL').bsfwtDm,
- ywId: that.data.ywId
- }
- queryReserveTimePeriod(form).then(res => {
- wx.hideLoading()
- if (res.code == 200) {
- that.setData({
- times: res.periodList
- })
- } else {
- wx.showToast({
- title: res.msg || res.message,
- icon: "none",
- duration: 5000
- })
- }
- })
- },
- next() {
- let that = this
- let times = that.data.times[that.data.timeIndex]
- let dates = that.data.dates[that.data.dateIndex].dates
- let orgAreaNumber = that.data.orgAreaNumber
- let yyrs = Number(times.capacity) - Number(times.appointNum)
- let sfYy = that.data.sfYy
- if (!sfYy) {
- if (yyrs != 0) {
- that.setData({
- sfYy: true
- })
- wx.showLoading({
- title: '正在预约中...',
- })
- let form = {
- bsfwtDm: wx.getStorageSync('MY_HALL').bsfwtDm,
- ywId: that.data.business.ywId,
- ywxxId: that.data.business.ywxxId,
- unionid: wx.getStorageSync('PUBLIC_ID').unionid,
- yyrq: dates,
- yysjd: times.periodName,
- periodCode: times.periodCode,
- orgAreaNumber: orgAreaNumber,
- remainTicketNum: yyrs,
- }
- xcxjxyy(form).then(res => {
- that.setData({
- sfYy: true
- })
- wx.hideLoading()
- if (res.code == 200) {
- let datas = res.data
- wx.setStorageSync('YYDATA', datas)
- wx.reLaunch({
- url: '../success/success?business=' + JSON.stringify(that.data.business),
- })
- } else {
- wx.showToast({
- title: res.msg || res.message,
- icon: "none",
- duration: 5000
- })
- }
- })
- } else {
- wx.showToast({
- title: '可预约人数为 0,请换个时间段预约',
- icon: "none",
- duration: 5000
- })
- }
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|