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.
42 lines
1.1 KiB
42 lines
1.1 KiB
// pages/stock/index.js
|
|
import { likeMoment } from "../../../../pages/api/moment"
|
|
const util = require('../../../../utils/util')
|
|
const app = getApp()
|
|
|
|
Component({
|
|
options: {
|
|
addGlobalClass: true,
|
|
multipleSlots: true
|
|
},
|
|
properties: {
|
|
item: { type: Object, value: null },
|
|
mclick: { type: Boolean, value: true }
|
|
},
|
|
methods: {
|
|
toMill: function(){
|
|
if(!this.data.mclick){
|
|
return
|
|
}
|
|
util.navigateTo('/pages/agent/factory/index?tabIndex=1&id=' + this.data.item.millPaperId)
|
|
},
|
|
lookItem: function(e){
|
|
util.navigateTo('/pakageInfo/pages/article/detail/index?id=' + this.data.item.id)
|
|
},
|
|
likeItem: function(e){
|
|
if(!app.globalData.userInfo){
|
|
wx.navigateTo({ url: '/pages/login/index' })
|
|
return
|
|
}
|
|
if(this.data.item.isLiked){
|
|
util.showToast('请勿重复点赞')
|
|
return
|
|
}
|
|
// /article/like-or-cancel/article/{id}
|
|
likeMoment({articleId: this.data.item.id}).then(result => {
|
|
this.setData({ ['item.likeQuantity']: result.data.likeQuantity, ['item.isLiked']: 1 })
|
|
}).catch(error => {
|
|
util.showToast(error)
|
|
})
|
|
}
|
|
}
|
|
})
|