morecase.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. // mycustomer/pages/morecase/morecase.js
  2. const app = getApp();
  3. var utils = require("../../../utils/http");
  4. const util = require("../../../utils/util");
  5. var pageNum = 1;
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. bType: '',
  12. curId: "",
  13. shareId: "",
  14. shareType: "",
  15. shareImage: "",
  16. shareTitle: "",
  17. shareUrl: "",
  18. caseArray: [],
  19. datashow: false,
  20. wshareshow: false,
  21. showTask: true,
  22. imgUrl:app.globalData.imgUrl
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad(options) {
  28. pageNum = 1;
  29. wx.showLoading({
  30. title: '加载中...',
  31. })
  32. if (options.hid) {
  33. this.setData({
  34. curId: options.hid
  35. })
  36. this.getCaselist();
  37. }
  38. if (!!options.ty) {
  39. wx.hideShareMenu();
  40. this.setData({
  41. bType: options.ty
  42. })
  43. }
  44. },
  45. getCaselist() {
  46. var that = this;
  47. utils.$get({
  48. url: app.globalData.webUrl + 'api/building/material_case',
  49. header: {
  50. 'Authorization': 'bearer ' + app.globalData.token
  51. },
  52. data: {
  53. housetype_id: that.data.curId,
  54. page: 1
  55. },
  56. success: function (res) {
  57. if (res.data.code == '0') {
  58. that.setData({
  59. caseArray: res.data.data.list,
  60. datashow: true
  61. })
  62. wx.hideLoading();
  63. }
  64. },
  65. })
  66. },
  67. jumpCaseView(e) {
  68. let cid = e.currentTarget.dataset.cid;
  69. wx.navigateTo({
  70. url: '/index/pages/casemsg/casemsg?cid=' + cid + '&ty=' + this.data.bType,
  71. })
  72. },
  73. openVRLink(e) {
  74. let type = e.currentTarget.dataset.type;
  75. if (type == 1) {
  76. let vrlink = this.data.casemsgobj.vr_case;
  77. wx.navigateTo({
  78. url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.casemsgobj.id,
  79. })
  80. } else {
  81. let vrlink = e.currentTarget.dataset.vrlink;
  82. let aid = e.currentTarget.dataset.id;
  83. wx.navigateTo({
  84. url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&aid=' + aid,
  85. })
  86. }
  87. },
  88. //案例分享
  89. bindShareCase(e) {
  90. let cid = e.currentTarget.dataset.cid;
  91. let title = e.currentTarget.dataset.title;
  92. let shareImage = e.currentTarget.dataset.img;
  93. this.setData({
  94. shareTitle: title,
  95. shareImage: shareImage,
  96. shareId: cid,
  97. shareType: "materialCase",
  98. wshareshow: true,
  99. shareUrl: "/share/pages/materialcase/materialcase"
  100. })
  101. },
  102. //生成海报
  103. setpostertap: function () {
  104. if (this.data.bType == 'b') {
  105. wx.navigateTo({
  106. url: '/index/pages/setposter/setposter?type=' + this.data.shareType + '&aid=' + this.data.shareId + "&ty=b&listshare=",
  107. })
  108. } else {
  109. wx.navigateTo({
  110. url: '/index/pages/setposter/setposter?type=' + this.data.shareType + '&aid=' + this.data.shareId + "&listshare=",
  111. })
  112. }
  113. },
  114. //发朋友圈
  115. sendfriendtap() {
  116. this.sharelogtap();
  117. },
  118. //发朋友圈接口
  119. sharelogtap: function () {
  120. var that = this;
  121. utils.$post({
  122. url: app.globalData.webUrl + 'api/share/addlog',
  123. header: {
  124. 'Authorization': 'bearer ' + app.globalData.token
  125. },
  126. data: {
  127. id: that.data.shareId,
  128. type: that.data.shareType
  129. },
  130. success: function (r) {
  131. }
  132. })
  133. },
  134. //复制链接
  135. shareurltap: function () {
  136. let that = this;
  137. wx.showLoading({
  138. title: '加载中...',
  139. })
  140. if (this.data.bType == 'b') {
  141. util.schemefun(that.data.shareUrl, 'uid=' + app.globalData.agentEmployeEid + '&cid=' + this.data.shareId + '&ctp=' + app.globalData.clientype + "&agid=" + app.globalData.brokeruserId, this.data.shareId, this.data.shareType, '');
  142. } else {
  143. if (this.data.shareType == 'housetype') {
  144. util.schemefun(that.data.shareUrl, 'u=' + app.globalData.personMsg.id + '&d=' + this.data.shareId + '&c=' + app.globalData.clientype, this.data.shareId, this.data.shareType, '');
  145. } else {
  146. util.schemefun(that.data.shareUrl, 'uid=' + app.globalData.personMsg.id + '&cid=' + this.data.shareId + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id, this.data.shareId, this.data.shareType, '');
  147. }
  148. }
  149. this.sharelogtap();
  150. },
  151. /**
  152. * 生命周期函数--监听页面初次渲染完成
  153. */
  154. onReady() {
  155. },
  156. /**
  157. * 生命周期函数--监听页面显示
  158. */
  159. onShow() {
  160. },
  161. /**
  162. * 生命周期函数--监听页面隐藏
  163. */
  164. onHide() {
  165. },
  166. /**
  167. * 生命周期函数--监听页面卸载
  168. */
  169. onUnload() {
  170. },
  171. /**
  172. * 页面相关事件处理函数--监听用户下拉动作
  173. */
  174. onPullDownRefresh() {
  175. wx.showLoading({
  176. title: '加载中...',
  177. })
  178. this.getCaselist();
  179. setTimeout(() => {
  180. wx.stopPullDownRefresh();
  181. },1500)
  182. },
  183. /**
  184. * 页面上拉触底事件的处理函数
  185. */
  186. onReachBottom() {
  187. pageNum = pageNum * 1 + 1;
  188. var that = this;
  189. utils.$get({
  190. url: app.globalData.webUrl + 'api/building/material_case',
  191. header: {
  192. 'Authorization': 'bearer ' + app.globalData.token
  193. },
  194. data: {
  195. housetype_id: that.data.curId,
  196. page: pageNum
  197. },
  198. success: function (res) {
  199. if (res.data.code == '0') {
  200. that.data.caseArray = that.data.caseArray.concat(res.data.data.list);
  201. that.setData({
  202. caseArray: that.data.caseArray,
  203. datashow: true
  204. })
  205. }
  206. },
  207. })
  208. },
  209. /**
  210. * 用户点击右上角分享
  211. */
  212. onShareAppMessage() {
  213. if (this.data.shareType == 'materialCase') {
  214. this.sharelogtap();
  215. return {
  216. title: this.data.shareTitle,
  217. imageUrl: this.data.shareImage,
  218. path: '/share/pages/materialcase/materialcase?cid=' + this.data.shareId + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
  219. }
  220. }
  221. }
  222. })