detail.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. console.log("res.expert==>", res.expert)
  85. if (res.code === 0) {
  86. this.setData({
  87. detailobj: res.expert
  88. })
  89. this.getTopic(res.expert.id)
  90. this.getExperience(res.expert.id)
  91. }
  92. })
  93. },
  94. // 获取擅长话题
  95. getTopic(id) {
  96. app._get('experttopic/list', {
  97. expertId: id
  98. }, res => {
  99. if (res.code === 0) {
  100. this.setData({
  101. topicList: res.list
  102. })
  103. if (res.list.length > 0) {
  104. this.setData({
  105. next: true
  106. })
  107. }
  108. }
  109. })
  110. },
  111. // // 性别
  112. // sex(code) {
  113. // app.sexList.forEach(v => {
  114. // if(code == v.itemcode){
  115. // return v.
  116. // }
  117. // })
  118. // },
  119. // 获取心得分享
  120. getExperience(id) {
  121. // && this.data.meetTotal.totalPage
  122. wx.showLoading({
  123. title: '正在加载中...',
  124. })
  125. app._get('meetevaluation/evaluatePage', {
  126. ...this.data.meetQuery,
  127. expertId: id,
  128. }, res => {
  129. if (res.code === 0) {
  130. this.setData({
  131. shareList: res.page.list,
  132. meetTotal: {
  133. currPage: res.page.currPage,
  134. totalCount: res.page.totalCount,
  135. totalPage: res.page.totalPage
  136. }
  137. })
  138. }
  139. }, err => {}, complete => {
  140. setTimeout(() => {
  141. wx.hideLoading()
  142. }, 300)
  143. })
  144. },
  145. /**
  146. * 生命周期函数--监听页面隐藏
  147. */
  148. onHide: function () {},
  149. /**
  150. * 页面相关事件处理函数--监听用户下拉动作
  151. */
  152. onPullDownRefresh: function () {
  153. },
  154. /**
  155. * 页面上拉触底事件的处理函数
  156. */
  157. onReachBottom: function () {
  158. if (this.data.meetTotal.currPage == this.data.meetTotal.totalPage || this.data.meetTotal.totalPage == 0) {
  159. wx.showToast({
  160. icon: 'none',
  161. title: '没有更多了~',
  162. })
  163. return false
  164. }
  165. this.setData({
  166. meetQuery: {
  167. page: this.data.meetQuery.page++,
  168. limit: 10
  169. }
  170. })
  171. this.getExperience(this.data.id)
  172. },
  173. showShareMenu: function () {
  174. wx.showShareMenu();
  175. },
  176. hideShareMenu() {
  177. wx.hideShareMenu();
  178. },
  179. /**
  180. * 用户点击右上角分享
  181. */
  182. onShareAppMessage() {
  183. this.addScore();
  184. return {
  185. title: '行家详情',
  186. path: `/expert/detail/detail?id=${pageid}`,
  187. desc: ''
  188. }
  189. },
  190. //统计积分(每日小程序分享)
  191. addScore: function () {
  192. if (!util.getUserId()) {
  193. return;
  194. }
  195. let _this = this;
  196. wx.showLoading({
  197. title: '努力加载中...',
  198. })
  199. app._post_form('scoreStu/share', "", {
  200. stuId: util.getUserId()
  201. }, function (res) {
  202. if (res.code === 0) {}
  203. })
  204. },
  205. })