123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515 |
- // pages/actDetail/actDetail.js
- const app = getApp()
- var host = app.globalData.host;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- text:'发送验证码',
- info: {},
- id:'',
- uid: '',
- show1:1,
- show2: 1,
- zk1: 0,
- zk2: 0,
- sex_array: ['男', '女'],
- sex: -1,
- job_array: ['非中科院单位','中科院单位'],
- job: 0,
- show: 0,
- list:[],
- index:[0,0,0],
- page:1,
- proof_img:'',
- user_id:0, //用户id
- apply_id:'', //报名ID
- phone:''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // options.id=35
- if (options.apply_id){
- this.setData({
- page: 3,
- show:1,
- apply_id: options.apply_id
- })
- }
- this.setData({
- id: options.id
- })
- var that = this;
- wx.showNavigationBarLoading()
- var that = this;
- wx.getStorage({
- key: 'uid',
- success: res => {
- if (res.data) {
- this.setData({
- user_id: res.data
- })
- this.getData()
- }
- },
- fail:err=>{
- wx.switchTab({
- url: '../mine/mine',
- })
- }
- })
-
- //中科院单位
- wx.request({
- url: host + '/api/organization/list',
- method: 'GET',
- success: function (res) {
- wx.hideNavigationBarLoading();
- var list=[];
- list[0] = res.data.data;
- list[1] = list[0][0].children;
- list[2] = list[1][0].children;
-
- that.setData({
- list: list
- })
- },
- })
- },
- getData(){
- var that = this;
- wx.request({
- url: host + '/api/detail',
- method: 'GET',
- data: {
- type: 'conference',
- id: this.data.id,
- uid: this.data.user_id
- },
- success: function (res) {
- wx.hideNavigationBarLoading();
- const info = res.data.data
- if (info.sign_note) { info.sign_note = info.sign_note.replace(/\\n/, '\n') }
- that.setData({
- info: info
- })
- setTimeout(() => {
- const query = wx.createSelectorQuery()
- query.select('#content').boundingClientRect(rect => {
- let height = rect.height;
- console.log(height)
- if (height < 60) {
- that.setData({
- show1: 0
- })
- }
- }).exec()
- query.select('#content1').boundingClientRect(rect => {
- let height = rect.height;
- if (height < 60) {
- that.setData({
- show2: 0
- })
- }
- }).exec()
- }, 100)
- },
- fail: function () {
- wx.hideLoading();
- wx.showToast({
- title: '服务器开小差啦!',
- icon: 'none'
- })
- }
- })
- },
- map:function(){
- const latitude = Number(this.data.info.hotel.latitude);
- const longitude = Number(this.data.info.hotel.longitude);
- wx.openLocation({
- latitude,
- longitude,
- scale: 18
- })
- },
- init: function () {
- const query = wx.createSelectorQuery()
- const that = this
- query.select('#editor').context(function (res) {
- res.context.setContents({
- html: that.data.info.content
- })
- })
- .exec()
- },
- collect: function (e) {
- var that = this, info = this.data.info;
- var data = {
- type: 'conference',
- id: this.data.info.id,
- uid: this.data.user_id
- }
- if (e.target.dataset.id) {
- data.action = 'cancel'
- }
- wx.request({
- url: host + '/api/collect',
- data: data,
- success: function (res) {
- if (res.data.code == 0) {
- if (data.action) {
- wx.showToast({
- title: '已取消',
- icon: 'none'
- })
- info.is_collected = 0
- } else {
- wx.showToast({
- title: '已收藏',
- icon: 'none'
- })
- info.is_collected = 1
- }
- that.setData({
- info: info
- })
- }
- }
- })
- },
- upload:function(){
- wx.chooseImage({
- count:0,
- success: res=>{
- wx.showLoading({
- title: '正在上传',
- })
- wx.uploadFile({
- url: host + '/api/uploadfile',
- filePath: res.tempFilePaths[0],
- name: 'file',
- success:response=>{
- wx.hideLoading();
- let data = JSON.parse(response.data);
- this.setData({
- proof_img:data.data
- })
- }
- })
- },
- })
- },
- phoneChange:function(e){
- this.setData({
- phone: e.detail.value
- })
- },
- sendcode:function(){
- if(this.data.phone.length<11){
- wx.showToast({
- title: '请输入正确的手机号',
- icon: 'none'
- })
- return;
- }
- wx.request({
- url: host + '/api/phcode',
- method: 'POST',
- data: { phone: this.data.phone},
- success: res=> {
- if(res.data.code == 0){
- wx.showToast({
- title: '验证码已发送',
- })
- this.countdown()
- }else{
- wx.showToast({
- title: '发送失败',
- icon: 'none'
- })
- }
- },
- })
- },
- countdown:function(){
- var time=60,text;
- var timer=setInterval(()=>{
- if(time>0){
- time--;
- text = time+'s'
- }else{
- text='发送验证码'
- clearInterval(timer)
- }
- this.setData({
- text: text
- })
- },1000)
- },
- bindMultiPickerColumnChange:function(e){
- console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
- var list = this.data.list, i = e.detail.value, j = e.detail.column;
- var index=this.data.index;
- index[j] = i
- if (e.detail.column == 0){
- list[1] = list[i][0].children;
- list[2] = list[1][0].children;
- index[1]=0;
- index[2]=0;
- }
- if (e.detail.column == 1) {
- list[1] = list[i][0].children;
- list[2] = list[1][0].children;
- index[2] = 0;
- }
- this.setData({
- list: list,
- index: index
- })
- },
- bindSexChange:function(e){
- this.setData({
- sex: e.detail.value
- })
- },
- bindPickerChange:function(e){
- this.setData({
- job: e.detail.value
- })
- },
- skip:function(){
- wx.redirectTo({
- url: '../order/order'
- })
- },
- next: function () {
- this.setData({
- page: this.data.page+1
- })
- },
- close:function(){
- this.setData({
- show: 0
- })
- },
- open: function () {
- this.setData({
- show: 1
- })
- },
- //提交报名信息
- submit: function (e) {
- var form = e.detail.value;
- var list = this.data.list, index=this.data.index;
- if (this.data.info.signup_fields.indexOf('company')>=0){
- form.organizer_unit = list[0][index[0]].value +","+ list[1][index[1]].value +","+ list[2][index[2]].value
- }
- form.sex=this.data.sex
- form.uid=this.data.user_id;
- form.conference_id=this.data.info.id;
- form.conference_name = this.data.info.name;
- form.type = 'conference';
- if(!form.name){
- wx.showToast({
- title: '请输入姓名!',
- icon:'none'
- })
- return;
- }
- // if (!form.job) {
- // wx.showToast({
- // title: '请输入职务!',
- // icon: 'none'
- // })
- // return;
- // }
- if (!form.phone) {
- wx.showToast({
- title: '请输入手机号!',
- icon: 'none'
- })
- return;
- }
- if (!form.code) {
- wx.showToast({
- title: '请输入验证码!',
- icon: 'none'
- })
- return;
- }
- wx.showLoading({
- title: '正在提交',
- })
- wx.request({
- url: host + '/api/user/signup',
- method:'POST',
- data: form,
- success:(res=>{
- if(res.data.code == 0){
- wx.hideLoading()
- this.setData({
- page: 2,
- apply_id:res.data.data
- })
- }else{
- wx.showToast({
- title: res.data.message,
- icon:'none'
- })
- }
- })
- })
-
- },
- //提交凭证
- submit1:function(e){
- var form = e.detail.value;
- form.id=this.data.apply_id;
- form.proof_img = this.data.proof_img;
- if (!form.proof_img) {
- wx.showToast({
- title: '请上传凭证!',
- icon: 'none'
- })
- return;
- }
- if (!form.paytype) {
- wx.showToast({
- title: '请选择支付方式!',
- icon: 'none'
- })
- return;
- }
- if (!form.billtype) {
- wx.showToast({
- title: '请选择发票类型!',
- icon: 'none'
- })
- return;
- }
- if (!form.billhead) {
- wx.showToast({
- title: '请输入发票抬头!',
- icon: 'none'
- })
- return;
- }
- if (!form.billno) {
- wx.showToast({
- title: '请输入识别号!',
- icon: 'none'
- })
- return;
- }
- if (form.billtype == 2){
- if (!form.billaddress || !form.billphone || !form.billbank || !form.billbankno) {
- wx.showToast({
- title: '请填写完整的发票信息!',
- icon: 'none'
- })
- return;
- }
- }
- wx.showLoading({
- title: '正在提交',
- })
- wx.request({
- url: host + '/api/user/signup',
- method: 'PUT',
- data: e.detail.value,
- success: (res => {
- wx.hideLoading();
- if (res.data.code == 0) {
- wx.showToast({
- title: '提交成功',
- })
- this.setData({
- page:4
- })
- }
- }),
- fail:error=>{
- wx.hideLoading()
- }
- })
- },
- home:function(){
- wx.redirectTo({
- url: '../order/order',
- })
- },
- zk1: function () {
- this.setData({
- zk1: 1
- })
- },
- sq1: function () {
- this.setData({
- zk1: 0
- })
- },
- zk2: function () {
- this.setData({
- zk2: 1
- })
- },
- sq2: function () {
- this.setData({
- zk2: 0
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|