eventDetail.js 8.2 KB

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