123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- // pages/home/correction/correction.js
- const app = getApp()
- const url = require('../../../utils/url.js')
- var call = require("../../../utils/net.js")
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- error1:true,
- error2:false,
- min:'1',
- max:'200',
- isSubmit:false,
- id: null,//内容详情的ID
- pos:'标题',//纠错的问题类型
- content:''//反馈内容
- },
- submit:function(){
- var that = this;
- let id = this.data.id;
- let uid = wx.getStorageSync('userId');
- let pos = this.data.pos;
- let content = this.data.content;
- var postData ={
- uid: uid,
- id: id,
- pos: pos,
- content: content
- }
- if (that.data.error1 == false && that.data.error2 == false){
- wx.showToast({
- icon: 'none',
- title: '请至少选择一个问题类型!',
- })
- } else if (content.match(/^\s*$/) || content == null || content == ''){
- wx.showToast({
- icon: 'none',
- title: '请输入反馈内容!',
- })
- }
- else{
- //请求
- call.request(url.host + url.postError,
- postData,
- res => {
- console.log(res)
- if (res.data.code == 200) {
- wx.showToast({
- title: '提交成功',
- icon: 'success',
- duration: 2000
- })
- setTimeout(function () {
- wx.navigateBack({
- delta: 1
- })
- }, 2000)
- } else {
- wx.showToast({
- icon: 'none',
- title: res.data.msg,
- })
- }
- },
- res => {
- console.log(res)
- })
- }
- },
- //选择出错项目
- clickTitle:function(){
- if (this.data.error1 == false) {
- this.setData({
- pos : '标题',
- error1: true,
- error2: false
- })
- }
- },
- clickMsg: function () {
- if (this.data.error2 == false) {
- this.setData({
- pos: '描述',
- error1: false,
- error2: true
- })
- }
- },
- //获取用户填写的出错内容
- getContent:function(e){
- let that = this
- if (e.detail.value){
- that.setData({
- content:e.detail.value
- })
- }
- },
- //字数限制
- inputs: function (e) {
- var value = e.detail.value;// 获取输入框的内容
- var len = parseInt(value.length);// 获取输入框内容的长度
- //最少字数限制
- if (len < this.data.min)
- this.setData({
- isSubmit: false
- })
- else if (len >= this.data.min)
- this.setData({
- isSubmit: true
- })
- if (len > this.data.max) return;//最多字数限制
- // 当输入框内容的长度大于最大长度限制(max)时,终止setData()的执行
- this.setData({
- currentWordNumber: len //当前字数
- });
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this
- that.setData({
- id:options.id
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|