市北人才赋能平台 --小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.1 KiB

4 years ago
// pages/topics/attract/oceanDetail/index.js
4 years ago
import {
ArticeModel
} from '../../../../models/artice.js'
4 years ago
import dayjs from '../../../../utils/dayjs/index.js'
4 years ago
import {
store
} from '../../../../utils/store.js'
4 years ago
var WxParse = require('../../../../components/wxParse/wxParse.js');
let artice = new ArticeModel()
4 years ago
const app = getApp()
4 years ago
Page({
/**
* 页面的初始数据
*/
data: {
nodes: '',
isStar: true, // 是否
showBtn: false,
image: '',
aId: '',
title: '',
date: '',
origin: '',
unStar: '/images/common/star.png',
star: '/images/common/star_light.png',
readNum: 0,
4 years ago
collectNum: 0,
associationType: ''
4 years ago
},
4 years ago
onClickCollect() {
4 years ago
// 收藏功能
if (store.hasBindUserInfo()) {
this.addOrRemoveCollectionApi()
} else {
wx.redirectTo({
url: '/pages/weChatAuth/index',
})
}
},
4 years ago
onShareAppMessage(res) {
4 years ago
return {
title: this.data.title,
path: `/pages/article/index?id=${this.data.aId}`
}
},
3 years ago
// onShareTimeline: function () {
// return {
// title: this.data.title, // 可不填
// query: `id=${this.data.aId}`, // 可不填 传递的参数,只能是这种格式
// // imageUrl: 'https://www.baidu.com/my/active3.png' // 可不填,可以是网络路径也可以是本地路径,分享到朋友圈显示的图标
// }
// },
4 years ago
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
//console.log(options)
4 years ago
const {
id
} = options
4 years ago
this.setData({
aId: id
})
this.fetchArticeApi()
},
4 years ago
fetchArticeApi() {
4 years ago
artice.getDetail(this.data.aId, (res) => {
4 years ago
console.log('海洋人才赋能中心详情-->', res)
4 years ago
const data = res.result
const date = dayjs(data.createTime).format('MM月DD日')
4 years ago
if (data.flag == 0 || data.flag == 1) {
4 years ago
var disable = false;
4 years ago
} else {
4 years ago
var disable = true;
}
this.setData({
nodes: data.content,
title: data.title,
date: date,
image: data.titlePic,
origin: data.source,
isStar: data.isCollection ? true : false,
disable: disable,
readNum: data.readNum,
collectNum: data.collectNum,
4 years ago
flag: data.flag,
associationType: data.associationType
4 years ago
}, () => {
// wx.hideLoading()
})
4 years ago
console.log(this.data.associationType)
4 years ago
WxParse.wxParse('article', 'html', this.data.nodes, this, 5);
})
4 years ago
4 years ago
},
4 years ago
addOrRemoveCollectionApi() {
4 years ago
artice.addOrRemoveCollect(this.data.aId, res => {
//console.log(res)
if (res.code == 200) {
this.setData({
isStar: !this.data.isStar
})
wx.showToast({
title: this.data.isStar ? '收藏成功' : '取消收藏成功',
icon: 'none'
})
}
})
},
4 years ago
//关联链接跳转
goLinkPage(e) {
4 years ago
4 years ago
if (e.currentTarget.dataset.association == '1') {
3 years ago
app.globalData.currentTab = "4"
4 years ago
wx.switchTab({
url: '../../../topics/index'
})
} else {
3 years ago
app.globalData.currentTab = "1"
4 years ago
wx.switchTab({
url: '../../../topics/index'
})
}
}
4 years ago
})