constructsite.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. const app=getApp();
  2. var utils=require("../../../utils/http");
  3. const util=require("../../../utils/util");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. cid:'',
  10. siteobj:{},
  11. imgUrl:app.globalData.imgUrl,
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. this.setData({
  18. cid:options.cid
  19. })
  20. this.sitemdg();
  21. },
  22. sitemdg(){
  23. const that=this;
  24. utils.$post({
  25. url: app.globalData.webUrl + 'api/construction/view',
  26. header: {
  27. 'Authorization':'bearer '+app.globalData.token
  28. },
  29. data: {
  30. id:that.data.cid
  31. },
  32. success: function (res) {
  33. wx.hideLoading();
  34. if(res.data.code==0){
  35. that.setData({
  36. siteobj:res.data.data
  37. })
  38. wx.setNavigationBarTitle({
  39. title: res.data.data.name,
  40. })
  41. }
  42. }
  43. })
  44. },
  45. looktap(e){
  46. wx.previewImage({
  47. current: e.currentTarget.dataset.img, // 当前显示图片的 http 链接
  48. urls: this.data.siteobj.step_list[e.currentTarget.dataset.idx].data.img // 需要预览的图片 http 链接列表
  49. })
  50. },
  51. openVRLink(e) {
  52. let type = e.currentTarget.dataset.type;
  53. let vrlink = e.currentTarget.dataset.vr;
  54. wx.navigateTo({
  55. url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&uid=' + (app.globalData.shareuserid?app.globalData.shareuserid:app.globalData.personMsg.id) + '&cty=construction' + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.cid,
  56. })
  57. },
  58. collectap(e){
  59. const that=this;
  60. let str="";
  61. let siteobj=this.data.siteobj;
  62. if(siteobj.collect==0){
  63. str='api/construction/collect'
  64. }else{
  65. str='api/construction/collectCancel'
  66. }
  67. utils.$post({
  68. url: app.globalData.webUrl + str,
  69. header: {
  70. 'Authorization':'bearer '+app.globalData.token
  71. },
  72. data: {
  73. id:that.data.cid
  74. },
  75. success: function (res) {
  76. wx.hideLoading();
  77. if(res.data.code==0){
  78. if(str=='api/construction/collect'){
  79. siteobj.collect=1;
  80. }else{
  81. siteobj.collect=0;
  82. }
  83. that.setData({
  84. siteobj:siteobj
  85. })
  86. }
  87. }
  88. })
  89. },
  90. sharetap:function(){
  91. this.setData({
  92. wshareshow:true
  93. })
  94. },
  95. setpostertap: function () {
  96. wx.navigateTo({
  97. url: '/index/pages/setposter/setposter?type=Construction&aid='+this.data.cid+"&listshare=",
  98. })
  99. },
  100. sendfriendtap(){
  101. this.shareaddlog();
  102. },
  103. shareaddlog:function(){
  104. var that=this;
  105. utils.$post({
  106. url: app.globalData.webUrl + 'api/share/addlog',
  107. header: {
  108. 'Authorization':'bearer '+app.globalData.token
  109. },
  110. data: {
  111. id:that.data.cid,
  112. type:'Construction'
  113. },
  114. success: function (r) {
  115. }
  116. })
  117. },
  118. shareurltap:function(){
  119. wx.showLoading({
  120. title: '加载中...',
  121. })
  122. util.schemefun('/share/pages/constructsite/constructsite','cid='+this.data.cid+'&uid='+app.globalData.personMsg.id+'&ctp='+app.globalData.clientype,this.data.cid,'Construction','');
  123. this.shareaddlog();
  124. },
  125. /**
  126. * 生命周期函数--监听页面初次渲染完成
  127. */
  128. onReady: function () {
  129. },
  130. /**
  131. * 生命周期函数--监听页面显示
  132. */
  133. onShow: function () {
  134. },
  135. /**
  136. * 生命周期函数--监听页面隐藏
  137. */
  138. onHide: function () {
  139. },
  140. /**
  141. * 生命周期函数--监听页面卸载
  142. */
  143. onUnload: function () {
  144. },
  145. /**
  146. * 页面相关事件处理函数--监听用户下拉动作
  147. */
  148. onPullDownRefresh: function () {
  149. },
  150. /**
  151. * 页面上拉触底事件的处理函数
  152. */
  153. onReachBottom: function () {
  154. },
  155. /**
  156. * 用户点击右上角分享
  157. */
  158. onShareAppMessage: function () {
  159. this.shareaddlog();
  160. console.log('/share/pages/constructsite/constructsite?cid='+this.data.cid+'&uid='+app.globalData.personMsg.id+'&ctp='+app.globalData.clientype)
  161. return {
  162. title: this.data.siteobj.name,
  163. imageUrl: this.data.siteobj.cover,
  164. path: '/share/pages/constructsite/constructsite?cid='+this.data.cid+'&uid='+app.globalData.personMsg.id+'&ctp='+app.globalData.clientype
  165. }
  166. }
  167. })