eventDetail.js 5.5 KB

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