123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- const pages = require('../../mixin/pages')
- const { postDelComment } = require('../news/api/index')
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- ...pages.data(),
- listUrl: '/api/user/track/list',
- searchForm: {},
- booLock: false,
- booDeleteNews: false,
- itemData: {},
- userInfo: {},
- fans_num: 0,
- follow_num: 0
- },
- currentItem: {}, // 当前选中的动态
- ...pages.methods,
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- const { user_id } = options
- this.setData({
- 'searchForm.user_id': user_id
- }, () => {
- this.fetchOrderList()
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.setData({
- userInfo: app.globalData.userInfo
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- if (this.data.freshing) {
- return
- }
- this.setData({
- freshing: true
- })
- this.bindCallBack()
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- this.fetchOrderList()
- },
- bindCallBack() {
- this.refreshOrderList()
- },
- showDeleteNews(e) {
- const { item } = e.currentTarget.dataset
- this.setData({
- booDeleteNews: true,
- itemData: item
- })
- },
- hideDeleteNews() {
- this.setData({
- booDeleteNews: false,
- itemData: {}
- })
- },
- // 删除动态
- async confirmDeleteNews(e) {
- this.setData({
- booLock: true
- })
- try {
- const { status, msg } = await postDelComment(this.data.itemData.id)
- if (status) {
- wx.showToast({
- title: '已删除',
- icon: 'none'
- })
- this.hideDeleteNews()
- this.refreshOrderList()
- } else {
- wx.showToast({
- title: msg,
- icon: 'none'
- })
- }
- } catch (err) {}
- this.setData({
- booLock: false
- })
- },
- handlePreviewImage(e) {
- const { imgs, index } = e.currentTarget.dataset
- if (Array.isArray(imgs)) {
- wx.previewImage({
- urls: imgs,
- current: imgs[index]
- })
- }
- }
- })
|