| | |
| | | // pages/consult/detail.js |
| | | import { actionDo, getProductNewsInfo, getMemberInfo } from '../../api/index' |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | navTitle: '详情' |
| | | bottomLift: 0, |
| | | info: {}, |
| | | detail: {}, |
| | | |
| | | origin: '', |
| | | showShare: false |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoadLogin(options) { |
| | | this.getDetail(options.id, options.userId || '') |
| | | }, |
| | | onShow(){ |
| | | this.setData({ member: wx.getStorageSync('member') }) |
| | | }, |
| | | onLoad(options) { |
| | | |
| | | var app = getApp().globalData |
| | | this.setData({ |
| | | bottomLift: app.bottomLift |
| | | }) |
| | | if(options.origin && options.origin == 'b'){ |
| | | this.setData({ origin: 'b' }) |
| | | } |
| | | // this.getDetail(options.id, options.userId || '') |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | handleDesign() { |
| | | const { member, origin, info } = this.data |
| | | let path = '/pages/design/design' |
| | | if(origin != 'b' && info.users && info.users.id){ |
| | | path = `/pages/design/design?name=${info.users.iamUsername}` |
| | | } |
| | | if (!member.phone) { |
| | | wx.setStorageSync('tempPath', path) |
| | | return wx.navigateTo({ |
| | | url: '/pages/auth/auth', |
| | | }) |
| | | } |
| | | wx.navigateTo({ |
| | | url: path, |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | onShareAppMessage() { |
| | | let { info } = this.data |
| | | console.log('点击了分享') |
| | | return { |
| | | path: '/pages/consult/detail?id=' + info.id + '&userId=' + info.users.id |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | getDetail(id, userId) { |
| | | getProductNewsInfo({ id, salesId: userId || null }).then(res => { |
| | | this.setData({ info: res.data }) |
| | | wx.setNavigationBarTitle({ |
| | | title: res.data.title |
| | | }) |
| | | if (userId) { |
| | | getMemberInfo().then(res => { |
| | | this.setData({ |
| | | member: res.data |
| | | }) |
| | | wx.setStorageSync('member', res.data) |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | openShare() { |
| | | this.setData({showShare: true}) |
| | | }, |
| | | handleShare() { |
| | | console.log('点击了分享'); |
| | | actionDo({ |
| | | actionType: 'share', |
| | | id: this.data.info.id |
| | | }) |
| | | }, |
| | | onClose() { |
| | | this.setData({showShare: false}) |
| | | }, |
| | | onHide() { |
| | | |
| | | }, |
| | |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | } |
| | | }) |