eventDetail.js 6.6 KB

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