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.
83 lines
2.7 KiB
83 lines
2.7 KiB
const util = require('../../../utils/util')
|
|
const event = require('../../../utils/event')
|
|
import { userPushFollowMill } from "../../../api/ztb"
|
|
import { getMillPaperList } from "../../../api/moment"
|
|
const app = getApp()
|
|
|
|
Component({
|
|
options: {
|
|
addGlobalClass: true,
|
|
multipleSlots: true
|
|
},
|
|
properties: {
|
|
keyword: { type: String, value: null },
|
|
item: { type: Object, value: null },
|
|
mclick: { type: Boolean, value: true }
|
|
},
|
|
data: {
|
|
unflod: false,
|
|
loading: false,
|
|
requesting: false,
|
|
itemList: []
|
|
},
|
|
methods: {
|
|
onFlodTap: function(){
|
|
if(!app.globalData.userInfo){
|
|
wx.navigateTo({ url: '/pages/login/index' })
|
|
return
|
|
}
|
|
if(this.data.item.isCooperate === 1 && !app.globalData.userInfo.isVIP) {
|
|
this.triggerEvent('vip', null)
|
|
return
|
|
}
|
|
this.setData({ unflod: !this.data.unflod })
|
|
if(!this.data.itemList.length && this.data.unflod){
|
|
this.fetchItemList()
|
|
}
|
|
},
|
|
attention: function(){
|
|
if (this.data.loading) {
|
|
return
|
|
}
|
|
if(!app.globalData.userInfo){
|
|
util.navigateTo('/pages/login/index')
|
|
return
|
|
}
|
|
this.setData({ loading: true })
|
|
userPushFollowMill({ paperMillId: this.data.item.paperMillId, follow: !this.data.item.hasFollowed }).then(result => {
|
|
this.data.item.hasFollowed = !this.data.item.hasFollowed
|
|
this.setData({ loading: false, ['item.hasFollowed']: this.data.item.hasFollowed })
|
|
setTimeout(() => { this.triggerEvent("attention", this.data.item) }, 100)
|
|
}).catch(err => {
|
|
this.setData({ loading: false })
|
|
})
|
|
},
|
|
lookItem: function(e){
|
|
util.navigateTo('/pages/agent/factory/index?id=' + this.data.item.paperMillId)
|
|
},
|
|
fetchItemList: function(){
|
|
if (this.data.requesting) {
|
|
return
|
|
}
|
|
this.setData({ requesting: true })
|
|
var date = this.data.item.latestQuoteTime.length > 10 ? this.data.item.latestQuoteTime.substring(0, 10) : this.data.item.latestQuoteTime
|
|
getMillPaperList({ paperMillId: this.data.item.paperMillId, date }).then(result => {
|
|
if (result.data.length) {
|
|
this.setData({ requesting: false, itemList: result.data })
|
|
} else {
|
|
this.setData({ requesting: false })
|
|
}
|
|
}).catch(err => {
|
|
this.setData({ requesting: false })
|
|
})
|
|
},
|
|
agentOrder: function(e){
|
|
if(!this.data.item.isOperations){
|
|
util.showToast(this.data.item.manageNotifyMessage)
|
|
return
|
|
}
|
|
var element = this.data.itemList[e.currentTarget.dataset.index]
|
|
util.navigateTo(`/pages/agent/edit/index?id=${this.data.item.paperMillId}&categoryId=${element.categoryId}`)
|
|
}
|
|
}
|
|
})
|