eventDetail.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. // pages/actDetail/actDetail.js
  2. const app = getApp()
  3. var host = app.globalData.host;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. text:'发送验证码',
  10. info: {},
  11. uid: '',
  12. show1:1,
  13. show2: 1,
  14. zk1: 0,
  15. zk2: 0,
  16. sex_array: ['男', '女'],
  17. sex: -1,
  18. job_array: ['非中科院单位','中科院单位'],
  19. job: 0,
  20. show: 0,
  21. list:[],
  22. index:[0,0,0],
  23. page:1,
  24. proof_img:'',
  25. user_id:'', //用户id
  26. apply_id:'', //报名ID
  27. phone:''
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad: function (options) {
  33. if (options.apply_id){
  34. this.setData({
  35. page: 3,
  36. show:1,
  37. apply_id: options.apply_id
  38. })
  39. }
  40. var that = this;
  41. wx.showNavigationBarLoading()
  42. var that = this;
  43. wx.getStorage({
  44. key: 'uid',
  45. success: res => {
  46. if (res.data) {
  47. this.setData({
  48. user_id: res.data
  49. })
  50. wx.request({
  51. url: host + '/api/detail',
  52. method: 'GET',
  53. data: {
  54. type: 'conference',
  55. id: options.id,
  56. uid: res.data
  57. },
  58. success: function (res) {
  59. wx.hideNavigationBarLoading();
  60. const info = res.data.data
  61. if (info.sign_note) { info.sign_note = info.sign_note.replace(/\\n/, '\n') }
  62. that.setData({
  63. info: info
  64. })
  65. setTimeout(()=>{
  66. const query = wx.createSelectorQuery()
  67. query.select('#content').boundingClientRect(rect => {
  68. let height = rect.height;
  69. console.log(height)
  70. if(height<60){
  71. that.setData({
  72. show1:0
  73. })
  74. }
  75. }).exec()
  76. query.select('#content1').boundingClientRect(rect => {
  77. let height = rect.height;
  78. if (height < 60) {
  79. that.setData({
  80. show2: 0
  81. })
  82. }
  83. }).exec()
  84. },100)
  85. },
  86. fail: function () {
  87. wx.hideLoading();
  88. wx.showToast({
  89. title: '服务器开小差啦!',
  90. icon: 'none'
  91. })
  92. }
  93. })
  94. }
  95. },
  96. })
  97. //中科院单位
  98. wx.request({
  99. url: host + '/api/organization/list',
  100. method: 'GET',
  101. success: function (res) {
  102. wx.hideNavigationBarLoading();
  103. var list=[];
  104. list[0] = res.data.data;
  105. list[1] = list[0][0].children;
  106. list[2] = list[1][0].children;
  107. that.setData({
  108. list: list
  109. })
  110. },
  111. })
  112. },
  113. map:function(){
  114. const latitude = Number(this.data.info.hotel.latitude);
  115. const longitude = Number(this.data.info.hotel.longitude);
  116. wx.openLocation({
  117. latitude,
  118. longitude,
  119. scale: 18
  120. })
  121. },
  122. init: function () {
  123. const query = wx.createSelectorQuery()
  124. const that = this
  125. query.select('#editor').context(function (res) {
  126. res.context.setContents({
  127. html: that.data.info.content
  128. })
  129. })
  130. .exec()
  131. },
  132. upload:function(){
  133. wx.chooseImage({
  134. count:0,
  135. success: res=>{
  136. wx.showLoading({
  137. title: '正在上传',
  138. })
  139. wx.uploadFile({
  140. url: host + '/api/uploadfile',
  141. filePath: res.tempFilePaths[0],
  142. name: 'file',
  143. success:response=>{
  144. wx.hideLoading();
  145. let data = JSON.parse(response.data);
  146. this.setData({
  147. proof_img:data.data
  148. })
  149. }
  150. })
  151. },
  152. })
  153. },
  154. phoneChange:function(e){
  155. this.setData({
  156. phone: e.detail.value
  157. })
  158. },
  159. sendcode:function(){
  160. if(this.data.phone.length<11){
  161. wx.showToast({
  162. title: '请输入正确的手机号',
  163. icon: 'none'
  164. })
  165. return;
  166. }
  167. wx.request({
  168. url: host + '/api/phcode',
  169. method: 'POST',
  170. data: { phone: this.data.phone},
  171. success: res=> {
  172. if(res.data.code == 0){
  173. wx.showToast({
  174. title: '验证码已发送',
  175. })
  176. this.countdown()
  177. }else{
  178. wx.showToast({
  179. title: '发送失败',
  180. icon: 'none'
  181. })
  182. }
  183. },
  184. })
  185. },
  186. countdown:function(){
  187. var time=60,text;
  188. var timer=setInterval(()=>{
  189. if(time>0){
  190. time--;
  191. text = time+'s'
  192. }else{
  193. text='发送验证码'
  194. clearInterval(timer)
  195. }
  196. this.setData({
  197. text: text
  198. })
  199. },1000)
  200. },
  201. bindMultiPickerColumnChange:function(e){
  202. console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
  203. var list = this.data.list, i = e.detail.value, j = e.detail.column;
  204. var index=this.data.index;
  205. index[j] = i
  206. if (e.detail.column == 0){
  207. list[1] = list[i][0].children;
  208. list[2] = list[1][0].children;
  209. index[1]=0;
  210. index[2]=0;
  211. }
  212. if (e.detail.column == 1) {
  213. list[1] = list[i][0].children;
  214. list[2] = list[1][0].children;
  215. index[2] = 0;
  216. }
  217. this.setData({
  218. list: list,
  219. index: index
  220. })
  221. },
  222. bindSexChange:function(e){
  223. this.setData({
  224. sex: e.detail.value
  225. })
  226. },
  227. bindPickerChange:function(e){
  228. this.setData({
  229. job: e.detail.value
  230. })
  231. },
  232. skip:function(){
  233. wx.redirectTo({
  234. url: '../order/order'
  235. })
  236. },
  237. next: function () {
  238. this.setData({
  239. page: this.data.page+1
  240. })
  241. },
  242. close:function(){
  243. this.setData({
  244. show: 0
  245. })
  246. },
  247. open: function () {
  248. this.setData({
  249. show: 1
  250. })
  251. },
  252. //提交报名信息
  253. submit: function (e) {
  254. var form = e.detail.value;
  255. var list = this.data.list, index=this.data.index;
  256. if (this.data.info.signup_fields.indexOf('company')>=0){
  257. form.organizer_unit = list[0][index[0]].value +","+ list[1][index[1]].value +","+ list[2][index[2]].value
  258. }
  259. form.sex=this.data.sex
  260. form.uid=this.data.user_id;
  261. form.conference_id=this.data.info.id;
  262. form.conference_name = this.data.info.name;
  263. form.type = 'conference';
  264. if(!form.name){
  265. wx.showToast({
  266. title: '请输入姓名!',
  267. icon:'none'
  268. })
  269. return;
  270. }
  271. // if (!form.job) {
  272. // wx.showToast({
  273. // title: '请输入职务!',
  274. // icon: 'none'
  275. // })
  276. // return;
  277. // }
  278. if (!form.phone) {
  279. wx.showToast({
  280. title: '请输入手机号!',
  281. icon: 'none'
  282. })
  283. return;
  284. }
  285. if (!form.code) {
  286. wx.showToast({
  287. title: '请输入验证码!',
  288. icon: 'none'
  289. })
  290. return;
  291. }
  292. wx.showLoading({
  293. title: '正在提交',
  294. })
  295. wx.request({
  296. url: host + '/api/user/signup',
  297. method:'POST',
  298. data: form,
  299. success:(res=>{
  300. if(res.data.code == 0){
  301. wx.hideLoading()
  302. this.setData({
  303. page: 2,
  304. apply_id:res.data.data
  305. })
  306. }else{
  307. wx.showToast({
  308. title: res.data.message,
  309. icon:'none'
  310. })
  311. }
  312. })
  313. })
  314. },
  315. //提交凭证
  316. submit1:function(e){
  317. var form = e.detail.value;
  318. form.id=this.data.apply_id;
  319. form.proof_img = this.data.proof_img;
  320. if (!form.proof_img) {
  321. wx.showToast({
  322. title: '请上传凭证!',
  323. icon: 'none'
  324. })
  325. return;
  326. }
  327. if (!form.paytype) {
  328. wx.showToast({
  329. title: '请选择支付方式!',
  330. icon: 'none'
  331. })
  332. return;
  333. }
  334. if (!form.billtype) {
  335. wx.showToast({
  336. title: '请选择发票类型!',
  337. icon: 'none'
  338. })
  339. return;
  340. }
  341. if (!form.billhead) {
  342. wx.showToast({
  343. title: '请输入发票抬头!',
  344. icon: 'none'
  345. })
  346. return;
  347. }
  348. if (!form.billno) {
  349. wx.showToast({
  350. title: '请输入识别号!',
  351. icon: 'none'
  352. })
  353. return;
  354. }
  355. if (form.billtype == 2){
  356. if (!form.billaddress || !form.billphone || !form.billbank || !form.billbankno) {
  357. wx.showToast({
  358. title: '请填写完整的发票信息!',
  359. icon: 'none'
  360. })
  361. return;
  362. }
  363. }
  364. wx.showLoading({
  365. title: '正在提交',
  366. })
  367. wx.request({
  368. url: host + '/api/user/signup',
  369. method: 'PUT',
  370. data: e.detail.value,
  371. success: (res => {
  372. wx.hideLoading();
  373. if (res.data.code == 0) {
  374. wx.showToast({
  375. title: '提交成功',
  376. })
  377. this.setData({
  378. page:4
  379. })
  380. }
  381. }),
  382. fail:error=>{
  383. wx.hideLoading()
  384. }
  385. })
  386. },
  387. home:function(){
  388. wx.redirectTo({
  389. url: '../order/order',
  390. })
  391. },
  392. zk1: function () {
  393. this.setData({
  394. zk1: 1
  395. })
  396. },
  397. sq1: function () {
  398. this.setData({
  399. zk1: 0
  400. })
  401. },
  402. zk2: function () {
  403. this.setData({
  404. zk2: 1
  405. })
  406. },
  407. sq2: function () {
  408. this.setData({
  409. zk2: 0
  410. })
  411. },
  412. /**
  413. * 生命周期函数--监听页面初次渲染完成
  414. */
  415. onReady: function () {
  416. },
  417. /**
  418. * 生命周期函数--监听页面显示
  419. */
  420. onShow: function () {
  421. },
  422. /**
  423. * 生命周期函数--监听页面隐藏
  424. */
  425. onHide: function () {
  426. },
  427. /**
  428. * 生命周期函数--监听页面卸载
  429. */
  430. onUnload: function () {
  431. },
  432. /**
  433. * 页面相关事件处理函数--监听用户下拉动作
  434. */
  435. onPullDownRefresh: function () {
  436. },
  437. /**
  438. * 页面上拉触底事件的处理函数
  439. */
  440. onReachBottom: function () {
  441. },
  442. /**
  443. * 用户点击右上角分享
  444. */
  445. onShareAppMessage: function () {
  446. }
  447. })