eventDetail.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad: function (options) {
  29. options.id=1;
  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. that.setData({
  60. info: res.data.data
  61. })
  62. },
  63. fail: function () {
  64. wx.hideLoading();
  65. wx.showToast({
  66. title: '服务器开小差啦!',
  67. icon: 'none'
  68. })
  69. }
  70. })
  71. //中科院单位
  72. wx.request({
  73. url: host + '/api/organization/list',
  74. method: 'GET',
  75. success: function (res) {
  76. wx.hideNavigationBarLoading();
  77. var list=[];
  78. list[0] = res.data.data;
  79. list[1] = list[0][0].children;
  80. list[2] = list[1][0].children;
  81. that.setData({
  82. list: list
  83. })
  84. },
  85. })
  86. },
  87. upload:function(){
  88. wx.chooseImage({
  89. count:0,
  90. success: res=>{
  91. wx.showLoading({
  92. title: '正在上传',
  93. })
  94. wx.uploadFile({
  95. url: host + '/api/uploadfile',
  96. filePath: res.tempFilePaths[0],
  97. name: 'file',
  98. success:response=>{
  99. wx.hideLoading();
  100. let data = JSON.parse(response.data);
  101. this.setData({
  102. proof_img:data.data
  103. })
  104. }
  105. })
  106. },
  107. })
  108. },
  109. bindMultiPickerColumnChange:function(e){
  110. console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
  111. var list = this.data.list, i = e.detail.value, j = e.detail.column;
  112. var index=this.data.index;
  113. index[j] = i
  114. if (e.detail.column == 0){
  115. list[1] = list[i][0].children;
  116. list[2] = list[1][0].children;
  117. index[1]=0;
  118. index[2]=0;
  119. }
  120. if (e.detail.column == 1) {
  121. list[1] = list[i][0].children;
  122. list[2] = list[1][0].children;
  123. index[2] = 0;
  124. }
  125. this.setData({
  126. list: list,
  127. index: index
  128. })
  129. },
  130. bindSexChange:function(e){
  131. this.setData({
  132. sex: e.detail.value
  133. })
  134. },
  135. bindPickerChange:function(e){
  136. this.setData({
  137. job: e.detail.value
  138. })
  139. },
  140. skip:function(){
  141. this.setData({
  142. page: this.data.page+2
  143. })
  144. },
  145. sure: function () {
  146. this.setData({
  147. page: this.data.page + 1
  148. })
  149. },
  150. close:function(){
  151. this.setData({
  152. show: 0
  153. })
  154. },
  155. open: function () {
  156. this.setData({
  157. show: 1
  158. })
  159. },
  160. //提交报名信息
  161. submit: function (e) {
  162. var form = e.detail.value;
  163. var list = this.data.list, index=this.data.index;
  164. form.organizer_unit = list[0][index[0]].value+list[1][index[1]].value+list[2][index[2]].value
  165. form.uid=this.data.user_id;
  166. form.conference_id=this.data.info.id;
  167. form.conference_name = this.data.info.name;
  168. if(!form.name){
  169. wx.showToast({
  170. title: '请输入姓名!',
  171. icon:'none'
  172. })
  173. return;
  174. }
  175. if (!form.job) {
  176. wx.showToast({
  177. title: '请输入职务!',
  178. icon: 'none'
  179. })
  180. return;
  181. }
  182. if (!form.phone) {
  183. wx.showToast({
  184. title: '请输入手机号!',
  185. icon: 'none'
  186. })
  187. return;
  188. }
  189. wx.showLoading({
  190. title: '正在提交',
  191. })
  192. wx.request({
  193. url: host + '/api/user/signup',
  194. method:'POST',
  195. data: form,
  196. success:(res=>{
  197. if(res.data.code == 0){
  198. wx.hideLoading()
  199. this.setData({
  200. page: 2,
  201. apply_id:res.data.data
  202. })
  203. }else{
  204. wx.showToast({
  205. title: '提交失败',
  206. icon:'none'
  207. })
  208. }
  209. })
  210. })
  211. },
  212. //提交凭证
  213. submit1:function(e){
  214. var form = e.detail.value;
  215. form.id=this.data.apply_id;
  216. form.proof_img = this.data.proof_img;
  217. wx.showLoading({
  218. title: '正在提交',
  219. })
  220. wx.request({
  221. url: host + '/api/user/signup',
  222. method: 'PUT',
  223. data: e.detail.value,
  224. success: (res => {
  225. wx.hideLoading();
  226. if (res.data.code == 0) {
  227. wx.showToast({
  228. title: '提交成功',
  229. })
  230. this.skip();
  231. }
  232. }),
  233. fail:error=>{
  234. wx.hideLoading()
  235. }
  236. })
  237. },
  238. home:function(){
  239. wx.switchTab({
  240. url: '../mine/mine',
  241. })
  242. },
  243. zk1: function () {
  244. this.setData({
  245. zk1: 1
  246. })
  247. },
  248. sq1: function () {
  249. this.setData({
  250. zk1: 0
  251. })
  252. },
  253. zk2: function () {
  254. this.setData({
  255. zk2: 1
  256. })
  257. },
  258. sq2: function () {
  259. this.setData({
  260. zk2: 0
  261. })
  262. },
  263. /**
  264. * 生命周期函数--监听页面初次渲染完成
  265. */
  266. onReady: function () {
  267. },
  268. /**
  269. * 生命周期函数--监听页面显示
  270. */
  271. onShow: function () {
  272. },
  273. /**
  274. * 生命周期函数--监听页面隐藏
  275. */
  276. onHide: function () {
  277. },
  278. /**
  279. * 生命周期函数--监听页面卸载
  280. */
  281. onUnload: function () {
  282. },
  283. /**
  284. * 页面相关事件处理函数--监听用户下拉动作
  285. */
  286. onPullDownRefresh: function () {
  287. },
  288. /**
  289. * 页面上拉触底事件的处理函数
  290. */
  291. onReachBottom: function () {
  292. },
  293. /**
  294. * 用户点击右上角分享
  295. */
  296. onShareAppMessage: function () {
  297. }
  298. })