|
@@ -2,48 +2,28 @@
|
|
|
const app = getApp()
|
|
|
const util = require("../../utils/util")
|
|
|
const urlDef = require("../../utils/urls")
|
|
|
-const urls = urlDef.urls;
|
|
|
-
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- radioList: [{
|
|
|
- name: '学校不满意',
|
|
|
- type: 'school'
|
|
|
- },
|
|
|
- {
|
|
|
- name: '课程不满意',
|
|
|
- type: 'school'
|
|
|
- },
|
|
|
- {
|
|
|
- name: '产品建议/功能优化',
|
|
|
- type: 'select'
|
|
|
- },
|
|
|
- {
|
|
|
- name: '其他问题',
|
|
|
- type: 'select'
|
|
|
- },
|
|
|
- ],
|
|
|
- curRadioIndex: '0',
|
|
|
- plateList: [
|
|
|
- '我的课表',
|
|
|
- '提交作业',
|
|
|
- '课堂点评',
|
|
|
- '成长足迹',
|
|
|
- '请假',
|
|
|
- '补课',
|
|
|
- '加课',
|
|
|
- '调课',
|
|
|
+ radioList: [
|
|
|
+ { name: '学校不满意', type: 'school', value: '8df20e39d0e94a95bc35f020cc2e4b84' },
|
|
|
+ { name: '课程不满意', type: 'school', value: '00901101530549789799899a113d46e8' },
|
|
|
+ { name: '产品建议/功能优化', type: 'select', value: '325ef70d708a46d094ef3eaefebaf254' },
|
|
|
+ { name: '其他问题', type: 'select', value: 'f9b1ecb1bd1943739082552dc68af535' },
|
|
|
],
|
|
|
+ curRadioIndex: '-1',
|
|
|
+ plateList: [],
|
|
|
plateIndex: 0,
|
|
|
- radioType: 'school',
|
|
|
- imgList:[]
|
|
|
+ radioType: '',
|
|
|
+ curStu: null,
|
|
|
+ content: '',
|
|
|
+ imgList: []
|
|
|
},
|
|
|
|
|
|
- getRadio: function (e) {
|
|
|
+ getRadio:function(e){
|
|
|
const type = this.data.radioList[e.currentTarget.dataset.index].type
|
|
|
this.setData({
|
|
|
curRadioIndex: e.currentTarget.dataset.index,
|
|
@@ -51,76 +31,26 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- bindPickerChange: function (e) {
|
|
|
+ bindPickerChange: function(e) {
|
|
|
this.setData({
|
|
|
plateIndex: e.detail.value
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- uploadTap: function () {
|
|
|
- const that = this
|
|
|
- if(that.data.imgList.length>=6){
|
|
|
- wx.showToast({
|
|
|
- title: '最多上传6张图片',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- return false
|
|
|
- }
|
|
|
- wx.chooseImage({
|
|
|
- count: 6,
|
|
|
- sourceType: ['album', 'camera'],
|
|
|
- success(res) {
|
|
|
- wx.showLoading({
|
|
|
- title: '上传中...',
|
|
|
- })
|
|
|
- for (var i in res.tempFilePaths) {
|
|
|
- wx.uploadFile({
|
|
|
- filePath: res.tempFilePaths[i],
|
|
|
- name: 'name',
|
|
|
- url: urls.file_upload,
|
|
|
- header: util.getHeaders(),
|
|
|
- success(res) {
|
|
|
- wx.showToast({
|
|
|
- title: '上传成功',
|
|
|
- })
|
|
|
- const rs = JSON.parse(JSON.parse(JSON.stringify(res.data)))
|
|
|
- const list = [{
|
|
|
- url: rs.data[0].url
|
|
|
- }]
|
|
|
- that.setData({
|
|
|
- imgList: that.data.imgList.concat(list)
|
|
|
- })
|
|
|
- },
|
|
|
- fail(res) {
|
|
|
- wx.showToast({
|
|
|
- title: '上传失败',
|
|
|
- icon: none
|
|
|
- })
|
|
|
- },
|
|
|
- complete(res) {
|
|
|
- wx.hideLoading({
|
|
|
- success: (res) => {},
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
- delImg:function(e){
|
|
|
- const index = e.currentTarget.dataset.index
|
|
|
- this.data.imgList.splice(index,1)
|
|
|
- this.setData({
|
|
|
- imgList: this.data.imgList
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
-
|
|
|
+ let stu = wx.getStorageSync('student');
|
|
|
+ this.setData({ curStu: stu })
|
|
|
+ let urls = urlDef.urls;
|
|
|
+ util.apiPost(urls.get_suggest_moudles).then((rs) => {
|
|
|
+ let list = []
|
|
|
+ rs.forEach(v => {
|
|
|
+ list.push({ id: v.id, name: v.detailName })
|
|
|
+ });
|
|
|
+ this.setData({ plateList: list })
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -170,5 +100,147 @@ Page({
|
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
- }
|
|
|
+ },
|
|
|
+ doInput: function (e) {
|
|
|
+ this.setData({ content: e.detail.value })
|
|
|
+ },
|
|
|
+ len(s) {
|
|
|
+ return (s == null ? 0 : s.length);
|
|
|
+ },
|
|
|
+ doSave: function () {
|
|
|
+ let urls = urlDef.urls
|
|
|
+ if (this.len(this.data.content) === 0) {
|
|
|
+ wx.showToast({ title: '请输入建议或投诉内容', icon: 'none' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let t = this.data.radioList[this.data.curRadioIndex]
|
|
|
+ let typeId = t ? t.value : '';
|
|
|
+ let moduleId = this.data.plateList[this.data.plateIndex].id
|
|
|
+ if ((typeId !== '8df20e39d0e94a95bc35f020cc2e4b84' && typeId !== '00901101530549789799899a113d46e8')
|
|
|
+ && (this.len(moduleId) === 0)) {
|
|
|
+ wx.showToast({ title: '请选择模块', icon: 'none' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let entity = {}
|
|
|
+ entity.studentId = this.data.curStu.studentId
|
|
|
+ entity.submitDate = new Date();
|
|
|
+ entity.status = 1;
|
|
|
+ entity.orgId = this.data.curStu.orgId
|
|
|
+ entity.remarks = this.data.content
|
|
|
+ entity.telephone = wx.getStorageSync('phone')
|
|
|
+ entity.typeId = typeId
|
|
|
+ entity.moduleId = moduleId
|
|
|
+
|
|
|
+ util.apiPost(urls.suggest_save, entity, 'application/json').then((rs) => {
|
|
|
+ wx.showToast({ title: '提交成功', icon: 'success' });
|
|
|
+ entity.id = rs.id;
|
|
|
+
|
|
|
+ const body = { 'id': rs.id, 'orgId': this.data.curStu.orgId, 'studentId': this.data.curStu.studentId }
|
|
|
+ util.apiPost(urls.suggest_send_message, body, 'application/json').then((rs) => {
|
|
|
+ console.log('发送通知 ' + JSON.stringify(rs));
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ // 保存图片
|
|
|
+ let imgs = [];
|
|
|
+ let delList = []
|
|
|
+ this.data.imgList.forEach(r => {
|
|
|
+ if (r.delete && r.delete == 1) {
|
|
|
+ delList.push(r.url.substring(r.url.lastIndexOf('/') + 1))
|
|
|
+ } else {
|
|
|
+ imgs.push({ feedbackId: rs.id, feedbackImageUrl: r.url })
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 删除文件
|
|
|
+ if (delList.length > 0) {
|
|
|
+ const params = { 'keys': delList }
|
|
|
+ util.apiPost(urls.file_delete, params).then((rs) => {
|
|
|
+ console.log('删除文件 ... ');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (imgs.length > 0) {
|
|
|
+ console.log('保存关联图片 ... ');
|
|
|
+ util.apiPost(urls.suggest_image_save, imgs, 'application/json').then((rs) => {
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1, // 返回上一级页面。
|
|
|
+ success: function () {
|
|
|
+ console.log('成功!')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }, 1000)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ uploadTap: function () {
|
|
|
+ const that = this
|
|
|
+ const urls = urlDef.urls;
|
|
|
+ wx.chooseImage({
|
|
|
+ count: 6,
|
|
|
+ sourceType: ['album', 'camera'],
|
|
|
+ success(res) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: '上传中...',
|
|
|
+ })
|
|
|
+ for (var i in res.tempFilePaths) {
|
|
|
+ wx.uploadFile({
|
|
|
+ filePath: res.tempFilePaths[i],
|
|
|
+ name: 'name',
|
|
|
+ url: urls.file_upload,
|
|
|
+ header: util.getHeaders(),
|
|
|
+ success(res) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '上传成功',
|
|
|
+ })
|
|
|
+ const rs = JSON.parse(JSON.parse(JSON.stringify(res.data)))
|
|
|
+ const list = [{ url: rs.data[0].url }]
|
|
|
+ that.setData({
|
|
|
+ imgList: that.data.imgList.concat(list)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail(res) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '上传失败',
|
|
|
+ icon: none
|
|
|
+ })
|
|
|
+ },
|
|
|
+ complete(res) {
|
|
|
+ wx.hideLoading({
|
|
|
+ success: (res) => { },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ showImg: function (e) {
|
|
|
+ const index = e.currentTarget.dataset.index
|
|
|
+ let images = this.data.imgList;
|
|
|
+ let imgs = []
|
|
|
+ images.map(i => {
|
|
|
+ imgs.push(i.url)
|
|
|
+ })
|
|
|
+ wx.previewImage({
|
|
|
+ current: images[index].url,
|
|
|
+ urls: imgs,
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ delImg: function (e) {
|
|
|
+ const index = e.currentTarget.dataset.index
|
|
|
+ let images = this.data.imgList;
|
|
|
+ let image = images[index]
|
|
|
+ image.delete = 1
|
|
|
+ this.setData({
|
|
|
+ imgList: images
|
|
|
+ })
|
|
|
+ },
|
|
|
})
|