Click to cancel the WeChat applet, return to the previous page, modify the parameter value of the previous page, let pages=getCurrentPages() let prevPage=pages[pages.length - 2] //Data of the previous page

Implementation function:

Personal center:
Insert image description here
List of follow-up visits:
Insert image description here
Details page of follow-up visits:
Insert image description here
1. Return to the personal center page from other pages, and you need to re-obtain data and update the page content;
2. Details page of follow-up visits, after filling in the follow-up visits, click Return to return To-be-followed-up list, re-obtain data, and update the to-be-followed-up list data.

Code:

1. Personal center page:

<view class="iconbox" bindtap="daizhuifang">
	<image class="iconimg" mode="widthFix" src="../../images/kehuxitong/xsicon04.png" />
	<view class="icontxt">待追访</view>
	<view class="daizhuikh" wx:if="{
     
     {daizhuikh}}">{
   
   {daizhuikh}}</view>  <!-- 这里是显示的未读数字 -->
</view>
	/**
     * 生命周期函数--监听页面显示
     */
    // onLoad页面加载时调用,可以获取参数,通过options。
	// onShow页面显示时调用。
    onShow: function() {
    
     //页面显示就刷新一下更新数据;
        // console.log(this.data.token);
        // console.log(this.data.type);

        wx.showLoading({
    
    
            title: '加载中...',
            mask: true,
        })
        this.getcard()
        this.getCollectiondata()
        this.gethistorydata()
        if (this.data.type == 1) {
    
    
            this.getmarketArticle(0)
            this.getmarketArticle(1)
            this.getmarketArticle(2)
            this.getmarketArticle(3)
            this.getmarketLoupanList()
                // this.getgetUserInfo();
            this.getgetCardIsStatus()
            this.getgetMemberCount()
            this.getsecondManageCount()

            console.log('onshow')
                // this.getgetManageUserList();
        }
        setTimeout(() => {
    
    
            wx.hideLoading()
        }, 500)

        // if (this.data.token != '') {
    
    
        //   this.setData({
    
    
        //     token: false
        //   })
        // }
    },

2. To-be-followed list page:

 	/**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
    
    
        wx.stopPullDownRefresh() //刷新完成后停止下拉刷新动效
        this.getgetTagsList()
        if (this.data.isaddkehu) {
    
     // isaddkehu 参数为待追访详情页传过来的,如有值就更新页面,否则不更新列表页;
            console.log('isaddkehu')
            this.setData({
    
    
                nomore: 0,
                isLoadInterface: false,
                pagecount: 1,
                page: 1,
                kehulistarr: [],
            })
            this.getgetManageUserList()
            this.setData({
    
    
                isaddkehu: false,
            })
        }
    },

3. Details page to be followed up:

	// 提交待追访后,执行
	setTimeout(() => {
    
    
	  let pages = getCurrentPages() // 当前页的数据,
	  let prevPage = pages[pages.length - 2] // 上一页的数据
	  prevPage.setData({
    
    
	    isaddkehu: true, //修改上页参数值
	  })
	  // console.log(pages);
	  // wx.navigateBack({
    
    
	  //   delta: 1
	  // })
	}, 1000)

Therefore, by judging whether the isaddkehu parameter value has been modified in onShow on the previous page, you can know whether the data has been updated.

Guess you like

Origin blog.csdn.net/ws19900201/article/details/111310181