123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- var app = getApp();
- var util = require("../../utils/util.js")
- let pageid = ""
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- // 约见id
- id: null,
- appAssetsUrl2: app.appAssetsUrl2,
- detailobj: {},
- topicList: [],
- shareList: [],
- meetQuery: {
- page: 1,
- limit: 10
- },
- meetTotal: {
- currPage: null,
- totalCount: null,
- totalPage: null
- },
- bottomLeft: app.bottomLeft,
- next: false
- },
- showTime() {
- this.popup.showPopup();
- },
- know() {
- this.popup.hidePopup();
- },
- consult(e) {
- if (this.data.detailobj.memberId == util.getUserId()) {
- wx.showToast({
- icon: 'none',
- title: '不能请教自己',
- })
- return false
- }
- if (!this.data.next) {
- return
- }
- wx.navigateTo({
- url: `/expert/consult/consult?id=${e.currentTarget.dataset.id}&price=${e.currentTarget.dataset.topicprice}`
- })
- },
- //取消事件
- _error(e) {
- this[e.currentTarget.dataset.name].hidePopup();
- // this.setData({
- // maskShow: false,
- // isDjs: false,
- // time: 5
- // })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log(options)
- pageid = options.id
- this.setData({
- id: options.id
- })
- this.getDetail(options.id)
- // console.log(util.getSex())
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- //获得popup组件
- this.popup = this.selectComponent("#popup");
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- // 获取详情
- getDetail(id) {
- app._get(`expert/info/${id}`, {}, res => {
- if (res.code === 0) {
- this.setData({
- detailobj: res.expert
- })
- this.getTopic(res.expert.id)
- this.getExperience(res.expert.id)
- }
- })
- },
- // 获取擅长话题
- getTopic(id) {
- app._get('experttopic/list', {
- expertId: id
- }, res => {
- if (res.code === 0) {
- this.setData({
- topicList: res.list
- })
- if (res.list.length > 0) {
- this.setData({
- next: true
- })
- }
- }
- })
- },
- // // 性别
- // sex(code) {
- // app.sexList.forEach(v => {
- // if(code == v.itemcode){
- // return v.
- // }
- // })
- // },
- // 获取心得分享
- getExperience(id) {
- // && this.data.meetTotal.totalPage
- wx.showLoading({
- title: '正在加载中...',
- })
- app._get('meetevaluation/evaluatePage', {
- ...this.data.meetQuery,
- expertId: id,
- }, res => {
- if (res.code === 0) {
- this.setData({
- shareList: res.page.list,
- meetTotal: {
- currPage: res.page.currPage,
- totalCount: res.page.totalCount,
- totalPage: res.page.totalPage
- }
- })
- }
- }, err => {}, complete => {
- setTimeout(() => {
- wx.hideLoading()
- }, 300)
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- if (this.data.meetTotal.currPage == this.data.meetTotal.totalPage || this.data.meetTotal.totalPage == 0) {
- wx.showToast({
- icon: 'none',
- title: '没有更多了~',
- })
- return false
- }
- this.setData({
- meetQuery: {
- page: this.data.meetQuery.page++,
- limit: 10
- }
- })
- this.getExperience(this.data.id)
- },
- showShareMenu: function () {
- wx.showShareMenu();
- },
- hideShareMenu() {
- wx.hideShareMenu();
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- this.addScore();
- return {
- title: '行家详情',
- path: `/expert/detail/detail?id=${pageid}`,
- desc: ''
- }
- },
- //统计积分(每日小程序分享)
- addScore: function () {
- if (!util.getUserId()) {
- return;
- }
- let _this = this;
- wx.showLoading({
- title: '努力加载中...',
- })
- app._post_form('scoreStu/share', "", {
- stuId: util.getUserId()
- }, function (res) {
- if (res.code === 0) {}
- })
- },
- })
|