From 8d68b6a1dcdf5008fba6bdac5858d1085a0e63e7 Mon Sep 17 00:00:00 2001
From: liuwh <hugeinfo123>
Date: Mon, 30 Mar 2020 23:14:04 +0800
Subject: [PATCH] 提交

---
 SunshineLnsMinApp/pages/xsjb/xsjb.js |  204 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 184 insertions(+), 20 deletions(-)

diff --git a/SunshineLnsMinApp/pages/xsjb/xsjb.js b/SunshineLnsMinApp/pages/xsjb/xsjb.js
index 269fc2e..12f1a32 100644
--- a/SunshineLnsMinApp/pages/xsjb/xsjb.js
+++ b/SunshineLnsMinApp/pages/xsjb/xsjb.js
@@ -1,42 +1,164 @@
 // pages/xsjb/xsjb.js
-import { $wuxForm } from '../../templeteDist/wuxDist/index';
-
+import {
+  $wuxForm
+} from '../../templeteDist/wuxDist/index';
+var app = getApp();
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
+    add: app.globalData.imgUrl + '/image/add.svg',
+    del: app.globalData.imgUrl + '/image/del.svg',
     meetingWayList: [{
-      value: 'HY000001',
-      title: '线下调解'
+      value: '1',
+      title: '违反犯罪暴力'
     }, {
-      value: 'HY000002',
-      title: '视频调解'
+      value: '2',
+      title: '未违反犯罪暴力'
     }],
-    displaymeetingWay: '请选择',
+    meetingWayList1: [{
+      value: '1',
+      title: '匿名'
+    }, {
+      value: '2',
+      title: '实名'
+    }],
+    uploadUrl: app.globalData.url + '/api/v1/attachment/materials',
+    displaytipoffAction: '请选择',
+    displaytipoffType: '请选择',
+    thisData: {},
+    evalList: {},
+    disabled: true,
+    showInfo: false,
+    id: ''
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function(options) {
-
+    const id = options.id || 'new';
+    let that = this;
+    var userinfo = wx.getStorageSync("user");
+    wx.showLoading();
+    wx.request({
+      url: app.globalData.url + '/api/tipoff/find',
+      method: 'GET',
+      data: {
+        id,
+      },
+      success: function(res) {
+        console.log('res', res);
+        var dataSet = res.data;
+        var evalList1000 = dataSet.attachmentList || [];
+        var evalList = {
+          evalList1000,
+        };
+        for (var i in evalList) {
+          evalList[i] = evalList[i].map(({
+            imgPath: pic,
+            id
+          }) => ({
+            pic: app.globalData.url + '/api/v1/attachment/image/' + id,
+            id
+          }))
+        }
+        console.log(evalList)
+        const data = res.data || {}
+        if (options.id) {
+          that.setData({
+            thisData: {
+              ...data,
+              createId: userinfo.id,
+              businessType: 1
+            },
+            evalList,
+            disabled: false,
+            displaytipoffAction: data.tipoffAction == 1 ? '违反犯罪暴力' : data.tipoffAction == 2 ? '未违反犯罪暴力' : '请选择',
+            displaytipoffType: data.tipoffType == 1 ? '匿名' : data.tipoffType == 2 ? '实名' : '请选择',
+            showInfo: data.tipoffType == 2 ? true : false,
+          })
+        } else {
+          that.setData({
+            thisData: {
+              ...data,
+              createId: userinfo.id,
+              businessType: 1
+            },
+            evalList,
+          })
+        }
+        wx.hideLoading();
+      }
+    })
   },
 
   formSubmit(e) {
     console.log('Default Form Submit \n', e.detail.value)
   },
 
-  onSubmit() {
-    const {
-      getFieldsValue,
-      getFieldValue,
-      setFieldsValue
-    } = $wuxForm()
-    const value = getFieldsValue()
+  inputOnchange(e) {
+    const key = e.currentTarget.dataset.key;
+    console.log(key)
+    console.log(e)
+    this.setData({
+      thisData: {
+        ...this.data.thisData,
+        [key]: e.detail.value
+      }
+    })
+  },
 
-    console.log('Wux Form Submit \n', value)
+  onSubmit() {
+    console.log(this.data.thisData)
+    if (!this.data.thisData.tipoffObject) {
+      return app.showModal("请填写举报对象!");
+    }
+    if (!this.data.thisData.tipoffAddress) {
+      return app.showModal("请填写发生地!");
+    }
+    if (!this.data.thisData.tipoffContent) {
+      return app.showModal("请填写具体事项!");
+    }
+    if (!this.data.evalList) {
+      return app.showModal("请上传证明材料!");
+    }
+    if (!this.data.thisData.tipoffType) {
+      return app.showModal("请选择方式!");
+    }
+    if (this.data.thisData.tipoffType == '2') {
+      if (!this.data.thisData.createrName) {
+        return app.showModal("请填写姓名!");
+      }
+      if (!this.data.thisData.createrMobile) {
+        return app.showModal("请填写手机号码!");
+      }
+      if (!this.data.thisData.createrAddress) {
+        return app.showModal("请填写联系方式!");
+      }
+    }
+    wx.request({
+      url: app.globalData.url + '/api/tipoff/save',
+      data: this.data.thisData,
+      method: 'POST',
+      header: {
+        "Content-Type": "application/json"
+      },
+      success: function(res) {
+        if (res.data.code == 0) {
+          wx.showToast({
+            title: '提交成功!',
+            icon: 'success',
+            duration: 2000
+          })
+          wx.navigateBack({
+            delta: 2
+          })
+        }
+      }
+    })
   },
 
   // 选择地理位置
@@ -45,19 +167,61 @@
     wx.chooseLocation({
       success: function(res) {
         console.log('res', res);
+        that.setData({
+          thisData: {
+            ...that.data.thisData,
+            tipoffAddress: res.address
+          }
+        })
       }
     })
   },
 
+  //添加图片
+  joinPicture: function(e) {
+    console.log(e)
+    var that = this;
+    console.log(that)
+    console.log('that.data.id', that.data.thisData.id)
+    app.joinPicture(e, that, e.currentTarget.dataset.associatetypeid, that.data.thisData.id);
+  },
+
+  // 删除图片
+  clearImg: function(e) {
+    var that = this;
+    app.clearImg(e, that);
+  },
+
+  //预览图片
+  previewImage: function(e) {
+    app.previewImage(e);
+  },
 
 
   onPopupSelectChange(e) {
     let _this = this;
     var key = e.currentTarget.dataset['key'];
     console.log('key', key, e);
-    this.setData({
-      [key]: e.detail.value,
-      [`display${key}`]: e.detail.label
-    });
+    if (key == 'tipoffType' && e.detail.value == '2') {
+      this.setData({
+        [key]: e.detail.value,
+        [`display${key}`]: e.detail.label,
+        showInfo: true,
+        thisData: {
+          ...this.data.thisData,
+          [key]: e.detail.value,
+        }
+      });
+    } else {
+      this.setData({
+        [key]: e.detail.value,
+        [`display${key}`]: e.detail.label,
+        thisData: {
+          ...this.data.thisData,
+          [key]: e.detail.value,
+        }
+      });
+    }
+
   }
 })
\ No newline at end of file

--
Gitblit v1.8.0