aqyj/pages/offence/detail.js

110 lines
2.3 KiB
JavaScript

var util = require('../../utils/util.js')
const api = require("../../utils/request.js");
Page({
/**
* 页面的初始数据
*/
data: {
serverUrl: getApp().globalData.serverUrl
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.data.id = options.id
this.getWzdetail(options.id);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
// var pages = getCurrentPages()
// var prePage = pages[pages.length-2]
// if(prePage.data.wslist){
// for(var i=0;i<prePage.data.wslist;i++){
// if(prePage.data.wslist[i].offenceid == this.data.offenceid){
// }
// }
// }
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
offenceimgPreview: function (e) {
var current = e.target.dataset.src
wx.previewImage({
current: current,
urls: this.data.imgs
})
},
getWzdetail: function (offenceid) {
wx.showLoading({
title: '加载中',
}),
wx.request({
url: this.data.serverUrl + 'api/offence?a=detail&id=' + offenceid,
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
data: {
},
success: res => {
wx.hideLoading();
if (res.statusCode === 200) {
var data = res.data
for (var i = 0; i < data.imgs.length; i++) {
data.imgs[i] = this.data.serverUrl + data.imgs[i];
}
// if (data.offencetime != '') { data.offencetime = util.formatTime(new Date(data.offencetime)) }
// if (data.submittime != '') { data.submittime = util.formatTime(new Date(data.submittime)) }
this.setData(data)
}
}
});
},
})