eventDetail.js 11 KB

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