news.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. // pages/actDetail/actDetail.js
  2. const app = getApp()
  3. var host = app.globalData.host;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. text:'发送验证码',
  10. info: {},
  11. uid: '',
  12. show1:1,
  13. show2: 1,
  14. zk1: 0,
  15. zk2: 0,
  16. sex_array: ['男', '女'],
  17. sex: -1,
  18. job_array: ['非中科院单位','中科院单位'],
  19. job: 0,
  20. show: 0,
  21. list:[],
  22. index:[0,0,0],
  23. page:1,
  24. proof_img:'',
  25. user_id:'', //用户id
  26. apply_id:'', //报名ID
  27. phone:''
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad: function (options) {
  33. // options.id=35
  34. if (options.apply_id){
  35. this.setData({
  36. page: 3,
  37. show:1,
  38. apply_id: options.apply_id
  39. })
  40. }
  41. var that = this;
  42. wx.showNavigationBarLoading()
  43. var that = this;
  44. wx.getStorage({
  45. key: 'uid',
  46. success: res => {
  47. if (res.data) {
  48. this.setData({
  49. user_id: res.data
  50. })
  51. wx.request({
  52. url: host + '/api/detail',
  53. method: 'GET',
  54. data: {
  55. type: 'news',
  56. id: options.id,
  57. uid: res.data
  58. },
  59. success: function (res) {
  60. wx.hideNavigationBarLoading();
  61. const info = res.data.data
  62. if (info.sign_note) { info.sign_note = info.sign_note.replace(/\\n/, '\n') }
  63. that.setData({
  64. info: info
  65. })
  66. setTimeout(()=>{
  67. const query = wx.createSelectorQuery()
  68. query.select('#content').boundingClientRect(rect => {
  69. let height = rect.height;
  70. console.log(height)
  71. if(height<60){
  72. that.setData({
  73. show1:0
  74. })
  75. }
  76. }).exec()
  77. query.select('#content1').boundingClientRect(rect => {
  78. let height = rect.height;
  79. if (height < 60) {
  80. that.setData({
  81. show2: 0
  82. })
  83. }
  84. }).exec()
  85. },100)
  86. },
  87. fail: function () {
  88. wx.hideLoading();
  89. wx.showToast({
  90. title: '服务器开小差啦!',
  91. icon: 'none'
  92. })
  93. }
  94. })
  95. }
  96. },
  97. })
  98. //中科院单位
  99. wx.request({
  100. url: host + '/api/organization/list',
  101. method: 'GET',
  102. success: function (res) {
  103. wx.hideNavigationBarLoading();
  104. var list=[];
  105. list[0] = res.data.data;
  106. list[1] = list[0][0].children;
  107. list[2] = list[1][0].children;
  108. that.setData({
  109. list: list
  110. })
  111. },
  112. })
  113. },
  114. map:function(){
  115. const latitude = Number(this.data.info.hotel.latitude);
  116. const longitude = Number(this.data.info.hotel.longitude);
  117. wx.openLocation({
  118. latitude,
  119. longitude,
  120. scale: 18
  121. })
  122. },
  123. init: function () {
  124. const query = wx.createSelectorQuery()
  125. const that = this
  126. query.select('#editor').context(function (res) {
  127. res.context.setContents({
  128. html: that.data.info.content
  129. })
  130. })
  131. .exec()
  132. },
  133. collect: function (e) {
  134. var that = this, info = this.data.info;
  135. var data = {
  136. type: 'news',
  137. id: this.data.info.id,
  138. uid: this.data.user_id
  139. }
  140. if (e.target.dataset.id) {
  141. data.action = 'cancel'
  142. }
  143. wx.request({
  144. url: host + '/api/collect',
  145. data: data,
  146. success: function (res) {
  147. if (res.data.code == 0) {
  148. if (data.action) {
  149. wx.showToast({
  150. title: '已取消',
  151. icon: 'none'
  152. })
  153. info.is_collected = 0
  154. } else {
  155. wx.showToast({
  156. title: '已收藏',
  157. icon: 'none'
  158. })
  159. info.is_collected = 1
  160. }
  161. that.setData({
  162. info: info
  163. })
  164. }
  165. }
  166. })
  167. },
  168. upload:function(){
  169. wx.chooseImage({
  170. count:0,
  171. success: res=>{
  172. wx.showLoading({
  173. title: '正在上传',
  174. })
  175. wx.uploadFile({
  176. url: host + '/api/uploadfile',
  177. filePath: res.tempFilePaths[0],
  178. name: 'file',
  179. success:response=>{
  180. wx.hideLoading();
  181. let data = JSON.parse(response.data);
  182. this.setData({
  183. proof_img:data.data
  184. })
  185. }
  186. })
  187. },
  188. })
  189. },
  190. phoneChange:function(e){
  191. this.setData({
  192. phone: e.detail.value
  193. })
  194. },
  195. sendcode:function(){
  196. if(this.data.phone.length<11){
  197. wx.showToast({
  198. title: '请输入正确的手机号',
  199. icon: 'none'
  200. })
  201. return;
  202. }
  203. wx.request({
  204. url: host + '/api/phcode',
  205. method: 'POST',
  206. data: { phone: this.data.phone},
  207. success: res=> {
  208. if(res.data.code == 0){
  209. wx.showToast({
  210. title: '验证码已发送',
  211. })
  212. this.countdown()
  213. }else{
  214. wx.showToast({
  215. title: '发送失败',
  216. icon: 'none'
  217. })
  218. }
  219. },
  220. })
  221. },
  222. countdown:function(){
  223. var time=60,text;
  224. var timer=setInterval(()=>{
  225. if(time>0){
  226. time--;
  227. text = time+'s'
  228. }else{
  229. text='发送验证码'
  230. clearInterval(timer)
  231. }
  232. this.setData({
  233. text: text
  234. })
  235. },1000)
  236. },
  237. bindMultiPickerColumnChange:function(e){
  238. console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
  239. var list = this.data.list, i = e.detail.value, j = e.detail.column;
  240. var index=this.data.index;
  241. index[j] = i
  242. if (e.detail.column == 0){
  243. list[1] = list[i][0].children;
  244. list[2] = list[1][0].children;
  245. index[1]=0;
  246. index[2]=0;
  247. }
  248. if (e.detail.column == 1) {
  249. list[1] = list[i][0].children;
  250. list[2] = list[1][0].children;
  251. index[2] = 0;
  252. }
  253. this.setData({
  254. list: list,
  255. index: index
  256. })
  257. },
  258. bindSexChange:function(e){
  259. this.setData({
  260. sex: e.detail.value
  261. })
  262. },
  263. bindPickerChange:function(e){
  264. this.setData({
  265. job: e.detail.value
  266. })
  267. },
  268. skip:function(){
  269. wx.redirectTo({
  270. url: '../order/order'
  271. })
  272. },
  273. next: function () {
  274. this.setData({
  275. page: this.data.page+1
  276. })
  277. },
  278. close:function(){
  279. this.setData({
  280. show: 0
  281. })
  282. },
  283. open: function () {
  284. this.setData({
  285. show: 1
  286. })
  287. },
  288. //提交报名信息
  289. submit: function (e) {
  290. var form = e.detail.value;
  291. var list = this.data.list, index=this.data.index;
  292. if (this.data.info.signup_fields.indexOf('company')>=0){
  293. form.organizer_unit = list[0][index[0]].value +","+ list[1][index[1]].value +","+ list[2][index[2]].value
  294. }
  295. form.sex=this.data.sex
  296. form.uid=this.data.user_id;
  297. form.conference_id=this.data.info.id;
  298. form.conference_name = this.data.info.name;
  299. form.type = 'conference';
  300. if(!form.name){
  301. wx.showToast({
  302. title: '请输入姓名!',
  303. icon:'none'
  304. })
  305. return;
  306. }
  307. // if (!form.job) {
  308. // wx.showToast({
  309. // title: '请输入职务!',
  310. // icon: 'none'
  311. // })
  312. // return;
  313. // }
  314. if (!form.phone) {
  315. wx.showToast({
  316. title: '请输入手机号!',
  317. icon: 'none'
  318. })
  319. return;
  320. }
  321. if (!form.code) {
  322. wx.showToast({
  323. title: '请输入验证码!',
  324. icon: 'none'
  325. })
  326. return;
  327. }
  328. wx.showLoading({
  329. title: '正在提交',
  330. })
  331. wx.request({
  332. url: host + '/api/user/signup',
  333. method:'POST',
  334. data: form,
  335. success:(res=>{
  336. if(res.data.code == 0){
  337. wx.hideLoading()
  338. this.setData({
  339. page: 2,
  340. apply_id:res.data.data
  341. })
  342. }else{
  343. wx.showToast({
  344. title: res.data.message,
  345. icon:'none'
  346. })
  347. }
  348. })
  349. })
  350. },
  351. //提交凭证
  352. submit1:function(e){
  353. var form = e.detail.value;
  354. form.id=this.data.apply_id;
  355. form.proof_img = this.data.proof_img;
  356. if (!form.proof_img) {
  357. wx.showToast({
  358. title: '请上传凭证!',
  359. icon: 'none'
  360. })
  361. return;
  362. }
  363. if (!form.paytype) {
  364. wx.showToast({
  365. title: '请选择支付方式!',
  366. icon: 'none'
  367. })
  368. return;
  369. }
  370. if (!form.billtype) {
  371. wx.showToast({
  372. title: '请选择发票类型!',
  373. icon: 'none'
  374. })
  375. return;
  376. }
  377. if (!form.billhead) {
  378. wx.showToast({
  379. title: '请输入发票抬头!',
  380. icon: 'none'
  381. })
  382. return;
  383. }
  384. if (!form.billno) {
  385. wx.showToast({
  386. title: '请输入识别号!',
  387. icon: 'none'
  388. })
  389. return;
  390. }
  391. if (form.billtype == 2){
  392. if (!form.billaddress || !form.billphone || !form.billbank || !form.billbankno) {
  393. wx.showToast({
  394. title: '请填写完整的发票信息!',
  395. icon: 'none'
  396. })
  397. return;
  398. }
  399. }
  400. wx.showLoading({
  401. title: '正在提交',
  402. })
  403. wx.request({
  404. url: host + '/api/user/signup',
  405. method: 'PUT',
  406. data: e.detail.value,
  407. success: (res => {
  408. wx.hideLoading();
  409. if (res.data.code == 0) {
  410. wx.showToast({
  411. title: '提交成功',
  412. })
  413. this.setData({
  414. page:4
  415. })
  416. }
  417. }),
  418. fail:error=>{
  419. wx.hideLoading()
  420. }
  421. })
  422. },
  423. home:function(){
  424. wx.redirectTo({
  425. url: '../order/order',
  426. })
  427. },
  428. zk1: function () {
  429. this.setData({
  430. zk1: 1
  431. })
  432. },
  433. sq1: function () {
  434. this.setData({
  435. zk1: 0
  436. })
  437. },
  438. zk2: function () {
  439. this.setData({
  440. zk2: 1
  441. })
  442. },
  443. sq2: function () {
  444. this.setData({
  445. zk2: 0
  446. })
  447. },
  448. /**
  449. * 生命周期函数--监听页面初次渲染完成
  450. */
  451. onReady: function () {
  452. },
  453. /**
  454. * 生命周期函数--监听页面显示
  455. */
  456. onShow: function () {
  457. },
  458. /**
  459. * 生命周期函数--监听页面隐藏
  460. */
  461. onHide: function () {
  462. },
  463. /**
  464. * 生命周期函数--监听页面卸载
  465. */
  466. onUnload: function () {
  467. },
  468. /**
  469. * 页面相关事件处理函数--监听用户下拉动作
  470. */
  471. onPullDownRefresh: function () {
  472. },
  473. /**
  474. * 页面上拉触底事件的处理函数
  475. */
  476. onReachBottom: function () {
  477. },
  478. /**
  479. * 用户点击右上角分享
  480. */
  481. onShareAppMessage: function () {
  482. }
  483. })