eventDetail.js 8.1 KB

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