// pages/assistMediate/index.js const $$ = require('../../utils/util'); function searchCaseApi(submitData) { return $$.request({ url: 'paCaseInfo/pageAssistCase', type: 'get', service: 'mediate', submitData }); } Page({ /** * 页面的初始数据 */ caseId: '', data: { img: `${$$.url.img}assist-bg.png`, searchValue: '', isSeach: false, // 是否搜索 caseData: {}, // 案件数据 }, // 搜索邀请码 handleSearch(e) { this.setData({ searchValue: e.detail || '' }); if (!!e.detail) { this.searchCase(e.detail); } else { this.setData({ isSeach: false }); } }, // 扫描二维码 handleScan() { let that = this; wx.scanCode({ success(res) { let caseId = $$.getQueryString(res.result, 'applyId'); that.caseId = caseId; that.searchCase(caseId); }, }); }, // 查询案件 async searchCase(submitData, type) { $$.showLoading(); const res = await searchCaseApi({ id: submitData, page: 1, size: 10 }); $$.hideLoading(); if (res.type) { this.setData({ isSeach: true, caseData: res.data.content[0] || {} }); } if (type === 'onPullDownRefresh') { $$.showToast({ title: '已是最新记录', duration: 1000 }); wx.stopPullDownRefresh(); } }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { if (this.data.isSeach) { this.searchCase(this.caseId, 'onPullDownRefresh'); } }, });