123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- // pages/wx_airport/problem_report/index.js
- var upload_image = require('../../../utils/upload/upload_image.js');
- var upload_video = require('../../../utils/upload/upload_video.js');
- var {
- addProblemReport
- } = require('../../../utils/api/xiaosha');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- userInfo: null,
- adminId: null,
- anonymityFlag: true, //状态
- desc: '', //问题详情
- pictureVOList: [], //图片
- video: {}, //视频
- },
- // 是否匿名
- onChange(event) {
- this.setData({
- anonymityFlag: event.detail,
- });
- },
- //获得问题详情
- descFun(e) {
- this.setData({
- desc: e.detail.value
- })
- },
- //上报
- report() {
- let {
- anonymityFlag,
- desc,
- pictureVOList,
- video
- } = this.data
- if (!desc) {
- wx.showToast({
- title: '请填写问题详情',
- icon: 'none'
- })
- return
- }
- let userInfo = wx.getStorageSync('userInfo')
- let form = {
- anonymityFlag,
- desc,
- pictureVOList,
- video,
- adminId: this.data.adminId || parseInt(userInfo.orgId),
- userId: userInfo.userId ? userInfo.userId : null,
- }
- addProblemReport(form).then(res => {
- if (res.code == 200) {
- wx.showModal({
- title: '提示',
- content: '上报成功!',
- showCancel: false,
- success: res => {
- if (userInfo.orgId) {
- wx.reLaunch({
- url: '/pages/wx_airport/rlxf_pass/rlxf_pass?orgId=' + userInfo.orgId,
- })
- } else {
- wx.reLaunch({
- url: '/pages/wx_airport/rlxf_index/rlxf_index',
- })
- }
- }
- })
- } else {
- wx.showToast({
- title: res.msg,
- icon: 'none'
- })
- }
- })
- },
- //选择照片
- ChooseImage() {
- var that = this;
- wx.chooseMedia({
- count: 4, //默认9
- mediaType: ['image'],
- sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ['album'], //从相册选择
- success: (res) => {
- var image = {
- url: res.tempFiles[0].tempFilePath
- }
- wx.showLoading({
- title: '上传中~',
- })
- upload_image(image).then((img) => {
- let data = {
- url: img.url
- }
- that.setData({
- pictureVOList: that.data.pictureVOList.concat(data)
- })
- wx.hideLoading();
- })
- },
- fail(res) {
- wx.hideLoading();
- wx.showToast({
- title: '照片上传失败,请重试',
- icon: 'none'
- })
- },
- // complete() {
- // wx.hideLoading();
- // }
- });
- },
- //查看照片
- ViewImage(e) {
- wx.previewImage({
- urls: this.data.pictureVOList,
- current: e.currentTarget.dataset.url
- });
- },
- //删除照片
- DelImg(e) {
- wx.showModal({
- title: '提示',
- content: '确定删除?',
- cancelText: '取消',
- confirmText: '确定',
- success: res => {
- if (res.confirm) {
- this.data.pictureVOList.splice(e.currentTarget.dataset.index, 1);
- this.setData({
- pictureVOList: this.data.pictureVOList,
- })
- }
- }
- })
- },
- //选择视频
- ChooseVideo() {
- var that = this;
- wx.chooseMedia({
- mediaType: ['video'],
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'], //从相册选择
- maxDuration: 15,
- success: (res) => {
- wx.showLoading({
- title: '视频上传中',
- mask: true
- })
- upload_video(res.tempFiles[0]).then((video) => {
- wx.showToast({
- title: '视频上传成功',
- })
- let data = {
- url: video.url
- }
- this.setData({
- video: data
- })
- wx.hideLoading();
- })
- },
- // complete() {
- // wx.hideLoading();
- // }
- });
- },
- //删除视频
- DelVideo() {
- wx.showModal({
- title: '提示',
- content: '确定删除?',
- cancelText: '取消',
- confirmText: '确定',
- success: res => {
- if (res.confirm) {
- this.setData({
- video: {},
- })
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- if (options) {
- this.setData({
- adminId: parseInt(options.adminId)
- })
- }
- this.setData({
- userInfo: wx.getStorageSync('userInfo')
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|