eventDetail.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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.uid=this.data.user_id;
  222. form.conference_id=this.data.info.id;
  223. form.conference_name = this.data.info.name;
  224. if(!form.name){
  225. wx.showToast({
  226. title: '请输入姓名!',
  227. icon:'none'
  228. })
  229. return;
  230. }
  231. // if (!form.job) {
  232. // wx.showToast({
  233. // title: '请输入职务!',
  234. // icon: 'none'
  235. // })
  236. // return;
  237. // }
  238. if (!form.phone) {
  239. wx.showToast({
  240. title: '请输入手机号!',
  241. icon: 'none'
  242. })
  243. return;
  244. }
  245. if (!form.code) {
  246. wx.showToast({
  247. title: '请输入验证码!',
  248. icon: 'none'
  249. })
  250. return;
  251. }
  252. wx.showLoading({
  253. title: '正在提交',
  254. })
  255. wx.request({
  256. url: host + '/api/user/signup',
  257. method:'POST',
  258. data: form,
  259. success:(res=>{
  260. if(res.data.code == 0){
  261. wx.hideLoading()
  262. this.setData({
  263. page: 2,
  264. apply_id:res.data.data
  265. })
  266. }else{
  267. wx.showToast({
  268. title: '提交失败',
  269. icon:'none'
  270. })
  271. }
  272. })
  273. })
  274. },
  275. //提交凭证
  276. submit1:function(e){
  277. var form = e.detail.value;
  278. form.id=this.data.apply_id;
  279. form.proof_img = this.data.proof_img;
  280. if (!form.proof_img) {
  281. wx.showToast({
  282. title: '请上传凭证!',
  283. icon: 'none'
  284. })
  285. return;
  286. }
  287. if (!form.paytype) {
  288. wx.showToast({
  289. title: '请选择支付方式!',
  290. icon: 'none'
  291. })
  292. return;
  293. }
  294. if (!form.billtype) {
  295. wx.showToast({
  296. title: '请选择发票类型!',
  297. icon: 'none'
  298. })
  299. return;
  300. }
  301. if (!form.billhead) {
  302. wx.showToast({
  303. title: '请输入发票抬头!',
  304. icon: 'none'
  305. })
  306. return;
  307. }
  308. if (!form.billno) {
  309. wx.showToast({
  310. title: '请输入识别号!',
  311. icon: 'none'
  312. })
  313. return;
  314. }
  315. if (form.billtype == 2){
  316. if (!form.billaddress || !form.billphone || !form.billbank || !form.billbankno) {
  317. wx.showToast({
  318. title: '请填写完整的发票信息!',
  319. icon: 'none'
  320. })
  321. return;
  322. }
  323. }
  324. wx.showLoading({
  325. title: '正在提交',
  326. })
  327. wx.request({
  328. url: host + '/api/user/signup',
  329. method: 'PUT',
  330. data: e.detail.value,
  331. success: (res => {
  332. wx.hideLoading();
  333. if (res.data.code == 0) {
  334. wx.showToast({
  335. title: '提交成功',
  336. })
  337. this.setData({
  338. page:4
  339. })
  340. }
  341. }),
  342. fail:error=>{
  343. wx.hideLoading()
  344. }
  345. })
  346. },
  347. home:function(){
  348. wx.redirectTo({
  349. url: '../order/order',
  350. })
  351. },
  352. zk1: function () {
  353. this.setData({
  354. zk1: 1
  355. })
  356. },
  357. sq1: function () {
  358. this.setData({
  359. zk1: 0
  360. })
  361. },
  362. zk2: function () {
  363. this.setData({
  364. zk2: 1
  365. })
  366. },
  367. sq2: function () {
  368. this.setData({
  369. zk2: 0
  370. })
  371. },
  372. /**
  373. * 生命周期函数--监听页面初次渲染完成
  374. */
  375. onReady: function () {
  376. },
  377. /**
  378. * 生命周期函数--监听页面显示
  379. */
  380. onShow: function () {
  381. },
  382. /**
  383. * 生命周期函数--监听页面隐藏
  384. */
  385. onHide: function () {
  386. },
  387. /**
  388. * 生命周期函数--监听页面卸载
  389. */
  390. onUnload: function () {
  391. },
  392. /**
  393. * 页面相关事件处理函数--监听用户下拉动作
  394. */
  395. onPullDownRefresh: function () {
  396. },
  397. /**
  398. * 页面上拉触底事件的处理函数
  399. */
  400. onReachBottom: function () {
  401. },
  402. /**
  403. * 用户点击右上角分享
  404. */
  405. onShareAppMessage: function () {
  406. }
  407. })