From a801508b135b79b12d411af5a8d7e4059a7abf24 Mon Sep 17 00:00:00 2001
From: liuwh <liuwh@hugeinfo.com.cn>
Date: Sun, 23 Feb 2020 12:37:28 +0800
Subject: [PATCH] Merge branch 'master' of http://120.79.193.119:9090/r/nsjcy/frontEnd/nsjcy
---
SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js | 203 ++++++++++++++++++++++++++++++++++++--------------
1 files changed, 147 insertions(+), 56 deletions(-)
diff --git a/SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js b/SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js
index 363690b..496552f 100644
--- a/SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js
+++ b/SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js
@@ -1,72 +1,86 @@
// pages/fzpxInfo/fzpxInfo.js
+var app = getApp();
+var Validator = require("../../utils/validate.tools.js");
+const verify = Validator.Validator;
+
Page({
/**
* 页面的初始数据
*/
data: {
- id: '',
- swiperList: [],
- title: '',
- num: '',
- yuan: '',
- duixiang: '',
- neirong1: '',
- neirong2: '',
- neirong3: ''
+ loading: false,
+ peopleInfo: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
- console.log(options)
- if (options.id == '1') {
- this.setData({
- swiperList: [{
- id: 0,
- type: 'image',
- url: './../../images/home/peixun1.png'
- }],
- title: '法治培训知识',
- num: '22/60',
- yuan: '检察院',
- duixiang: '南沙周边企业',
- neirong1: '1.参观基地周边工作环境,学习工作态度',
- neirong2: '2.学习课程科普知识,参与活动回答测试',
- neirong3: '3.与领导沟通交流未检学习'
- })
- } else if (options.id == '2') {
- this.setData({
- swiperList: [{
- id: 0,
- type: 'image',
- url: './../../images/home/peixun2.png'
- }],
- title: '法治科普课堂',
- num: '22/40',
- yuan: '检察院',
- duixiang: '南沙周边企业',
- neirong1: '1.参观基地周边工作环境,学习工作态度',
- neirong2: '2.学习课程科普知识,参与活动回答测试',
- neirong3: '3.与领导沟通交流未检学习'
- })
- } else {
- this.setData({
- swiperList: [{
- id: 0,
- type: 'image',
- url: './../../images/home/peixun3.jpg'
- }],
- title: `“沙鸥”宣讲团开展法治巡讲活动`,
- num: '60/60',
- yuan: '南沙区人民检察院',
- duixiang: '辖区各中小学生',
- neirong1: '1.生活情境与法律知识结合,注意课程的日常性、实用性,与法律有关的知识为课程的重点',
- neirong2: '2.根据中小学生对知识的接受程度和心理特征设计课程',
- neirong3: '3.通过体验式教学让学生更容易掌握本次课程的法律知识点'
- })
- }
+ var that = this;
+ that.setData({
+ id: options.id,
+ flag: options.flag,
+ loading: true
+ });
+ wx.showLoading({
+ title: '加载中',
+ })
+ wx.request({
+ url: app.globalData.url + '/api/activity/find?id=' + options.id,
+ success: function(res) {
+ console.log(res);
+ that.setData({
+ loading: false
+ });
+ wx.hideLoading();
+ if (res.data.code == 0) {
+ res.data.data.startTime = app.formatDate(res.data.data.startTime)
+ that.setData({
+ activity: res.data.data
+ })
+ console.log('传过来', options.flag)
+ // 处理报名状态
+ if (options.flag == 'true') {
+ //可报名
+ console.log('可报名')
+ if (res.data.data.activityPersonNum < res.data.data.activityPersonQuota) {
+ if (res.data.data.activityStatus == 1) {
+ that.setData({
+ canApply: true
+ })
+ }
+ if (res.data.data.activityStatus == 2) {
+ that.setData({
+ canApply: false,
+ statusWord: '活动正在进行'
+ })
+ }
+ if (res.data.data.activityStatus == 3) {
+ that.setData({
+ canApply: false,
+ statusWord: '活动已结束'
+ })
+ }
+ } else {
+ that.setData({
+ canApply: false,
+ statusWord: '报名人数已满'
+ })
+ }
+
+ } else {
+ //不可报名
+ console.log('不可报名')
+ that.setData({
+ canApply: false,
+ statusWord: '您已报名'
+ })
+ }
+
+ }
+ }
+ })
},
// 跳转
@@ -77,4 +91,81 @@
duration: 2000
})
},
+
+ // 呼叫组织方
+ makePhoneCall: function(e) {
+ var phone = e.currentTarget.dataset['phone'];
+ wx.makePhoneCall({
+ phoneNumber: phone
+ })
+ },
+
+ inputChange: function(e) {
+ var name = e.currentTarget.dataset.name;
+ this.setData({
+ peopleInfo: {
+ ...this.data.peopleInfo,
+ [name]: e.detail.value
+ }
+ })
+ },
+
+ // 提交报名
+ submit: function() {
+ var peopleInfo = this.data.peopleInfo;
+ var userinfo = wx.getStorageSync("user");
+ var personId = userinfo.id;
+
+ peopleInfo.personId = personId;
+ peopleInfo.activityInfoId = this.data.id;
+ peopleInfo.isHit = 0;
+ if (!peopleInfo.proposerName) {
+ return wx.showToast({
+ title: '请填写姓名',
+ icon: 'none'
+ })
+ }
+ if (!peopleInfo.proposerPhone) {
+ return wx.showToast({
+ title: '请填写联系电话',
+ icon: 'none'
+ })
+ } else {
+ if (!verify.phone(peopleInfo.proposerPhone)) {
+ return wx.showToast({
+ title: '联系电话格式不正确',
+ icon: 'none'
+ })
+ }
+ }
+ var that = this;
+ wx.showLoading({
+ title: '报名中',
+ })
+ wx.request({
+ url: app.globalData.url + '/api/activity/activityApply',
+ data: peopleInfo,
+ method: 'POST',
+ header: {
+ "Content-Type": "application/json"
+ },
+ success: function(res) {
+ wx.hideLoading();
+ if (res.data.code == 0) {
+ wx.reLaunch({
+ url: '../index/index',
+ }, wx.showToast({
+ title: '报名成功!',
+ icon: 'success',
+ duration: 2000
+ }))
+ } else {
+ wx.showToast({
+ title: '报名失败,请稍后重试!',
+ icon: 'none'
+ })
+ }
+ }
+ })
+ }
})
\ No newline at end of file
--
Gitblit v1.8.0