eventDetail.js 9.0 KB

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