eventDetail.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. if(!form.name){
  162. wx.showToast({
  163. title: '请输入姓名!',
  164. icon:'none'
  165. })
  166. return;
  167. }
  168. if (!form.job) {
  169. wx.showToast({
  170. title: '请输入职务!',
  171. icon: 'none'
  172. })
  173. return;
  174. }
  175. if (!form.phone) {
  176. wx.showToast({
  177. title: '请输入手机号!',
  178. icon: 'none'
  179. })
  180. return;
  181. }
  182. wx.showLoading({
  183. title: '正在提交',
  184. })
  185. wx.request({
  186. url: host + '/api/user/signup',
  187. method:'POST',
  188. data: form,
  189. success:(res=>{
  190. if(res.data.code == 0){
  191. wx.hideLoading()
  192. this.setData({
  193. page: 2,
  194. apply_id:res.data.data
  195. })
  196. }else{
  197. wx.showToast({
  198. title: '提交失败',
  199. icon:'none'
  200. })
  201. }
  202. })
  203. })
  204. },
  205. //提交凭证
  206. submit1:function(e){
  207. var form = e.detail.value;
  208. form.id=this.data.apply_id;
  209. form.proof_img = this.data.proof_img;
  210. wx.showLoading({
  211. title: '正在提交',
  212. })
  213. wx.request({
  214. url: host + '/api/user/signup',
  215. method: 'PUT',
  216. data: e.detail.value,
  217. success: (res => {
  218. wx.hideLoading();
  219. if (res.data.code == 0) {
  220. wx.showToast({
  221. title: '提交成功',
  222. })
  223. this.skip();
  224. }
  225. }),
  226. fail:error=>{
  227. wx.hideLoading()
  228. }
  229. })
  230. },
  231. home:function(){
  232. wx.switchTab({
  233. url: '../mine/mine',
  234. })
  235. },
  236. zk1: function () {
  237. this.setData({
  238. zk1: 1
  239. })
  240. },
  241. sq1: function () {
  242. this.setData({
  243. zk1: 0
  244. })
  245. },
  246. zk2: function () {
  247. this.setData({
  248. zk2: 1
  249. })
  250. },
  251. sq2: function () {
  252. this.setData({
  253. zk2: 0
  254. })
  255. },
  256. /**
  257. * 生命周期函数--监听页面初次渲染完成
  258. */
  259. onReady: function () {
  260. },
  261. /**
  262. * 生命周期函数--监听页面显示
  263. */
  264. onShow: function () {
  265. },
  266. /**
  267. * 生命周期函数--监听页面隐藏
  268. */
  269. onHide: function () {
  270. },
  271. /**
  272. * 生命周期函数--监听页面卸载
  273. */
  274. onUnload: function () {
  275. },
  276. /**
  277. * 页面相关事件处理函数--监听用户下拉动作
  278. */
  279. onPullDownRefresh: function () {
  280. },
  281. /**
  282. * 页面上拉触底事件的处理函数
  283. */
  284. onReachBottom: function () {
  285. },
  286. /**
  287. * 用户点击右上角分享
  288. */
  289. onShareAppMessage: function () {
  290. }
  291. })