123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- import HTTP from "../../../../../requestFn/Api"
- const app = getApp();
- Page({
- data: {
- detail: [],
- dialog: false,
- garden_id: null,
- event_id: null,
- autoplay: true,
- interval: 5000,
- duration: 3000,
- wrap: false,
- height: 0,
- },
- onLoad(options) {
- const that = this;
- const {
- garden_id
- } = app.globalData;
- that.setData({
- garden_id
- })
- const eventChannel = that.getOpenerEventChannel()
- eventChannel.on('acceptDataFromOpenerPage', function (data) {
- const {content} = data.data[0];
- const event_id = data.data[0].id
-
- that.setData({
- detail: data.data,
- event_id,
- content
- })
- })
- },
- onShow() {
- if (this.data.dialog) {
- const promise3 = new Promise((resolve, reject) => {
- wx.createSelectorQuery().select('#js_btn2_1')
- .boundingClientRect((rect) => {
- console.log(rect);
- resolve(rect.height);
- })
- .exec();
- });
- const promise4 = new Promise((resolve, reject) => {
- wx.createSelectorQuery().select('#js_btn2_2')
- .boundingClientRect((rect) => {
- resolve(rect.height);
- })
- .exec();
- });
- Promise.all([promise3, promise4]).then((values) => {
- if (values[0] != values[1]) {
- this.setData({
- wrap: true
- });
- }
- });
- }
- },
- eventSign() {
- this.setData({
- dialog: true,
- });
- },
- close() {
- this.setData({
- dialog: false,
- });
- },
- formSubmit(e) {
- const that = this;
- const {
- garden_id,
- event_id
- } = that.data
- const {
- name,
- phone,
- count,
- comment
- } = e.detail.value
- console.log('form发生了submit事件,携带数据为:', e.detail.value)
- if (name == "") {
- wx.showToast({
- title: '请输入姓名',
- icon: "error",
- })
- return false
- }
- if (phone == "") {
- wx.showToast({
- title: '请输入手机号码',
- icon: "error",
- })
- return false
- }
- if (!/^1[345789]\d{9}$/.test(phone)) {
- wx.showToast({
- title: "手机号码有误",
- duration: 2000,
- icon: "error",
- });
- return false;
- }
- if (count == "") {
- wx.showToast({
- title: '请输入报名人数',
- icon: "error",
- })
- return false
- }
- HTTP.EventSign({
- garden_id,
- event_id,
- name,
- phone,
- count: count - 0,
- comment
- }).then(res => {
- if (res.code == 0) {
- wx.showToast({
- title: '报名成功',
- icon: "success",
- success() {
- that.close()
- wx.navigateBack({
- delta: 1,
- })
- }
- })
- }
- })
- },
- changeHeight(e) {
- const {
- height
- } = e.detail;
- console.log(height);
- this.setData({
- height
- })
- }
- })
|