eventDetail.js 8.7 KB

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