detail.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. const app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. id: 0,
  8. info: {},
  9. is_scan: 0,
  10. modalName: '',
  11. comment: '',
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. let id = options.id;
  18. let is_scan = 0;
  19. if (options.is_scan) {
  20. is_scan = options.is_scan;
  21. }
  22. this.setData({id:id,is_scan:is_scan});
  23. this.getInfo();
  24. },
  25. //获取详情
  26. getInfo() {
  27. let self = this;
  28. app.post('business/business/detail',{id:self.data.id},function(res){
  29. if (res.talent_discount) {
  30. res.talent_discount = res.talent_discount.replace(/\<img/gi, '<img style="max-width:100%;display:block;" ');
  31. }
  32. if (res.content) {
  33. res.content = res.content.replace(/\<img/gi, '<img style="max-width:100%;display:block;" ');
  34. }
  35. self.setData({info:res});
  36. });
  37. },
  38. //导航
  39. nav() {
  40. let info = this.data.info;
  41. wx.openLocation({
  42. latitude: info.latitude - 0, //维度
  43. longitude: info.longitude - 0, //经度
  44. name: info.title, //目的地定位名称
  45. scale: 15, //缩放比例
  46. address: info.address //导航详细地址
  47. })
  48. },
  49. //按钮
  50. join() {
  51. app.post('business/business/join',{status:1,business_id:this.data.id},function(res){
  52. if (res.code == 1001) {
  53. app.msg('请完善信息','/pages/my/info/info');
  54. } else {
  55. app.msg('参加成功');
  56. }
  57. });
  58. },
  59. unjoin() {
  60. let self = this;
  61. app.post('business/business/join',{status:2,business_id:this.data.id,comment:this.data.comment},function(res){
  62. self.setData({modalName: ''});
  63. if (res.code == 1001) {
  64. app.msg('请完善信息','/pages/my/info/info');
  65. } else {
  66. app.msg('提交成功');
  67. }
  68. });
  69. },
  70. inputComment(e) {
  71. this.setData({comment:e.detail.value});
  72. },
  73. showModal() {
  74. this.setData({modalName: 'DialogModal1'});
  75. },
  76. hideModal() {
  77. this.setData({modalName: ''});
  78. },
  79. /**
  80. * 用户点击右上角分享
  81. */
  82. onShareAppMessage: function () {
  83. let info = this.data.info
  84. return {
  85. title: info.title,
  86. path: "/pages/activity/detail/detail?id="+info.id,
  87. imageUrl: info.main_image,
  88. };
  89. }
  90. })