eventDetail.js 8.3 KB

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