detail.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. var app = getApp();
  2. var util = require("../../utils/util.js")
  3. let pageid = ""
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. // 约见id
  10. id: null,
  11. appAssetsUrl2: app.appAssetsUrl2,
  12. detailobj: {},
  13. topicList: [],
  14. shareList: [],
  15. meetQuery: {
  16. page: 1,
  17. limit: 10
  18. },
  19. meetTotal: {
  20. currPage: null,
  21. totalCount: null,
  22. totalPage: null
  23. },
  24. bottomLeft: app.bottomLeft,
  25. next: false
  26. },
  27. showTime() {
  28. this.popup.showPopup();
  29. },
  30. know() {
  31. this.popup.hidePopup();
  32. },
  33. consult(e) {
  34. if (this.data.detailobj.memberId == util.getUserId()) {
  35. wx.showToast({
  36. icon: 'none',
  37. title: '不能请教自己',
  38. })
  39. return false
  40. }
  41. if (!this.data.next) {
  42. return
  43. }
  44. wx.navigateTo({
  45. url: `/expert/consult/consult?id=${e.currentTarget.dataset.id}&price=${e.currentTarget.dataset.topicprice}`
  46. })
  47. },
  48. //取消事件
  49. _error(e) {
  50. this[e.currentTarget.dataset.name].hidePopup();
  51. // this.setData({
  52. // maskShow: false,
  53. // isDjs: false,
  54. // time: 5
  55. // })
  56. },
  57. /**
  58. * 生命周期函数--监听页面加载
  59. */
  60. onLoad: function (options) {
  61. console.log(options)
  62. pageid = options.id
  63. this.setData({
  64. id: options.id
  65. })
  66. this.getDetail(options.id)
  67. // console.log(util.getSex())
  68. },
  69. /**
  70. * 生命周期函数--监听页面初次渲染完成
  71. */
  72. onReady: function () {
  73. //获得popup组件
  74. this.popup = this.selectComponent("#popup");
  75. },
  76. /**
  77. * 生命周期函数--监听页面显示
  78. */
  79. onShow: function () {
  80. },
  81. // 获取详情
  82. getDetail(id) {
  83. app._get(`expert/info/${id}`, {}, res => {
  84. if (res.code === 0) {
  85. this.setData({
  86. detailobj: res.expert
  87. })
  88. this.getTopic(res.expert.id)
  89. this.getExperience(res.expert.id)
  90. }
  91. })
  92. },
  93. // 获取擅长话题
  94. getTopic(id) {
  95. app._get('experttopic/list', {
  96. expertId: id
  97. }, res => {
  98. if (res.code === 0) {
  99. this.setData({
  100. topicList: res.list
  101. })
  102. if (res.list.length > 0) {
  103. this.setData({
  104. next: true
  105. })
  106. }
  107. }
  108. })
  109. },
  110. // // 性别
  111. // sex(code) {
  112. // app.sexList.forEach(v => {
  113. // if(code == v.itemcode){
  114. // return v.
  115. // }
  116. // })
  117. // },
  118. // 获取心得分享
  119. getExperience(id) {
  120. // && this.data.meetTotal.totalPage
  121. wx.showLoading({
  122. title: '正在加载中...',
  123. })
  124. app._get('meetevaluation/evaluatePage', {
  125. ...this.data.meetQuery,
  126. expertId: id,
  127. }, res => {
  128. if (res.code === 0) {
  129. this.setData({
  130. shareList: res.page.list,
  131. meetTotal: {
  132. currPage: res.page.currPage,
  133. totalCount: res.page.totalCount,
  134. totalPage: res.page.totalPage
  135. }
  136. })
  137. }
  138. }, err => {}, complete => {
  139. setTimeout(() => {
  140. wx.hideLoading()
  141. }, 300)
  142. })
  143. },
  144. /**
  145. * 生命周期函数--监听页面隐藏
  146. */
  147. onHide: function () {},
  148. /**
  149. * 页面相关事件处理函数--监听用户下拉动作
  150. */
  151. onPullDownRefresh: function () {
  152. },
  153. /**
  154. * 页面上拉触底事件的处理函数
  155. */
  156. onReachBottom: function () {
  157. if (this.data.meetTotal.currPage == this.data.meetTotal.totalPage || this.data.meetTotal.totalPage == 0) {
  158. wx.showToast({
  159. icon: 'none',
  160. title: '没有更多了~',
  161. })
  162. return false
  163. }
  164. this.setData({
  165. meetQuery: {
  166. page: this.data.meetQuery.page++,
  167. limit: 10
  168. }
  169. })
  170. this.getExperience(this.data.id)
  171. },
  172. showShareMenu: function () {
  173. wx.showShareMenu();
  174. },
  175. hideShareMenu() {
  176. wx.hideShareMenu();
  177. },
  178. /**
  179. * 用户点击右上角分享
  180. */
  181. onShareAppMessage() {
  182. this.addScore();
  183. return {
  184. title: '行家详情',
  185. path: `/expert/detail/detail?id=${pageid}`,
  186. desc: ''
  187. }
  188. },
  189. //统计积分(每日小程序分享)
  190. addScore: function () {
  191. if (!util.getUserId()) {
  192. return;
  193. }
  194. let _this = this;
  195. wx.showLoading({
  196. title: '努力加载中...',
  197. })
  198. app._post_form('scoreStu/share', "", {
  199. stuId: util.getUserId()
  200. }, function (res) {
  201. if (res.code === 0) {}
  202. })
  203. },
  204. })