// pages/classicCase/index.js const $$ = require('../../utils/util'); function getCaseInfoApi(submitData) { return $$.request({ url: 'guide/getCaseCpwsDetai', submitData, type: 'get', v1: true, service: 'mediate' }); } // 评价 function rateApi(submitData) { return $$.request({ url: 'guideRatings/saveGuideRatings', submitData, type: 'post', v1: true, service: 'mediate' }); } Page({ /** * 页面的初始数据 */ data: { region:'', guideCaseTitle: '', guideText: '', judgmentDate:'', caseSimilarity: '', showModal: false, rate: '', NewguideId: '' }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(options,'options') const cpwsCaseInfoId = options.guideInfoId; const cpwsCaseTextId = options.guideId; this.setData({ NewguideId: cpwsCaseTextId }); this._classicCase(cpwsCaseInfoId, cpwsCaseTextId); }, async _classicCase(cpwsCaseInfoId, cpwsCaseTextId) { $$.showLoading(); const res = await getCaseInfoApi({ cpwsCaseInfoId, cpwsCaseTextId }); $$.hideLoading(); if (res.type) { let data = res.data || {}; console.log('Data:', data); this.setData({ ...data, guideText: data.fullText || '', guideCaseTitle: data.caseName || '', region:data.region||'', judgmentDate:data.judgmentDate||'', caseSimilarity: data.caseSimilarity || '', }); } }, openPopup() { if (this.data.hasEvaluated) { $$.showToast({ title: "不可重复评价" }); } else { this.setData({ showModal: !this.data.showModal // 显示弹出框 }); } }, // _r() { // this.setData({ // showModal: false, // hasEvaluated: true // }); // $$.showToast({ // title: "评价完成" // }); // }, onRateChange(event) { console.log('event', event.detail); this.setData({ rate: event.detail }) }, async submitCase() { $$.showLoading(); const res = await rateApi({ serviceId: this.data.NewguideId, rating: this.data.rate, }); $$.hideLoading(); if (res.type) { $$.showToast({ icon: 'success', title: '感谢您的评价' }); this.setData({ showModal: !this.data.showModal // 显示弹出框 }); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })