eventDetail.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. if(this.data.phone.length<11){
  117. wx.showToast({
  118. title: '请输入正确的手机号',
  119. icon: 'none'
  120. })
  121. return;
  122. }
  123. wx.request({
  124. url: host + '/api/phcode',
  125. method: 'POST',
  126. data: { phone: this.data.phone},
  127. success: function (res) {
  128. if(res.data.code == 0){
  129. wx.showToast({
  130. title: '验证码已发送',
  131. })
  132. }else{
  133. wx.showToast({
  134. title: '发送失败',
  135. icon: 'none'
  136. })
  137. }
  138. },
  139. })
  140. },
  141. bindMultiPickerColumnChange:function(e){
  142. console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
  143. var list = this.data.list, i = e.detail.value, j = e.detail.column;
  144. var index=this.data.index;
  145. index[j] = i
  146. if (e.detail.column == 0){
  147. list[1] = list[i][0].children;
  148. list[2] = list[1][0].children;
  149. index[1]=0;
  150. index[2]=0;
  151. }
  152. if (e.detail.column == 1) {
  153. list[1] = list[i][0].children;
  154. list[2] = list[1][0].children;
  155. index[2] = 0;
  156. }
  157. this.setData({
  158. list: list,
  159. index: index
  160. })
  161. },
  162. bindSexChange:function(e){
  163. this.setData({
  164. sex: e.detail.value
  165. })
  166. },
  167. bindPickerChange:function(e){
  168. this.setData({
  169. job: e.detail.value
  170. })
  171. },
  172. skip:function(){
  173. this.setData({
  174. page: this.data.page+2
  175. })
  176. },
  177. sure: function () {
  178. this.setData({
  179. page: this.data.page + 1
  180. })
  181. },
  182. close:function(){
  183. this.setData({
  184. show: 0
  185. })
  186. },
  187. open: function () {
  188. this.setData({
  189. show: 1
  190. })
  191. },
  192. //提交报名信息
  193. submit: function (e) {
  194. var form = e.detail.value;
  195. var list = this.data.list, index=this.data.index;
  196. form.organizer_unit = list[0][index[0]].value+list[1][index[1]].value+list[2][index[2]].value
  197. form.uid=this.data.user_id;
  198. form.conference_id=this.data.info.id;
  199. form.conference_name = this.data.info.name;
  200. if(!form.name){
  201. wx.showToast({
  202. title: '请输入姓名!',
  203. icon:'none'
  204. })
  205. return;
  206. }
  207. if (!form.job) {
  208. wx.showToast({
  209. title: '请输入职务!',
  210. icon: 'none'
  211. })
  212. return;
  213. }
  214. if (!form.phone) {
  215. wx.showToast({
  216. title: '请输入手机号!',
  217. icon: 'none'
  218. })
  219. return;
  220. }
  221. wx.showLoading({
  222. title: '正在提交',
  223. })
  224. wx.request({
  225. url: host + '/api/user/signup',
  226. method:'POST',
  227. data: form,
  228. success:(res=>{
  229. if(res.data.code == 0){
  230. wx.hideLoading()
  231. this.setData({
  232. page: 2,
  233. apply_id:res.data.data
  234. })
  235. }else{
  236. wx.showToast({
  237. title: '提交失败',
  238. icon:'none'
  239. })
  240. }
  241. })
  242. })
  243. },
  244. //提交凭证
  245. submit1:function(e){
  246. var form = e.detail.value;
  247. form.id=this.data.apply_id;
  248. form.proof_img = this.data.proof_img;
  249. wx.showLoading({
  250. title: '正在提交',
  251. })
  252. wx.request({
  253. url: host + '/api/user/signup',
  254. method: 'PUT',
  255. data: e.detail.value,
  256. success: (res => {
  257. wx.hideLoading();
  258. if (res.data.code == 0) {
  259. wx.showToast({
  260. title: '提交成功',
  261. })
  262. this.skip();
  263. }
  264. }),
  265. fail:error=>{
  266. wx.hideLoading()
  267. }
  268. })
  269. },
  270. home:function(){
  271. wx.switchTab({
  272. url: '../mine/mine',
  273. })
  274. },
  275. zk1: function () {
  276. this.setData({
  277. zk1: 1
  278. })
  279. },
  280. sq1: function () {
  281. this.setData({
  282. zk1: 0
  283. })
  284. },
  285. zk2: function () {
  286. this.setData({
  287. zk2: 1
  288. })
  289. },
  290. sq2: function () {
  291. this.setData({
  292. zk2: 0
  293. })
  294. },
  295. /**
  296. * 生命周期函数--监听页面初次渲染完成
  297. */
  298. onReady: function () {
  299. },
  300. /**
  301. * 生命周期函数--监听页面显示
  302. */
  303. onShow: function () {
  304. },
  305. /**
  306. * 生命周期函数--监听页面隐藏
  307. */
  308. onHide: function () {
  309. },
  310. /**
  311. * 生命周期函数--监听页面卸载
  312. */
  313. onUnload: function () {
  314. },
  315. /**
  316. * 页面相关事件处理函数--监听用户下拉动作
  317. */
  318. onPullDownRefresh: function () {
  319. },
  320. /**
  321. * 页面上拉触底事件的处理函数
  322. */
  323. onReachBottom: function () {
  324. },
  325. /**
  326. * 用户点击右上角分享
  327. */
  328. onShareAppMessage: function () {
  329. }
  330. })