鍍金池/ 問答/PHP  網(wǎng)絡安全  HTML/ 微信小程序二次開發(fā)添加評論功能報錯

微信小程序二次開發(fā)添加評論功能報錯

問題描述

點擊留言,提交評論報錯。

相關代碼

var app = getApp(), WxParse = require("../../public/wxParse/wxParse.js"), article = null;
var input_value;
var actid;
var user_id;
Page({

data: {
    syscfg: {},
    user: {},
    actid: null,
    actdata: null,
    setcont: "0",
    barTitle: "",
    input_value: '',
    msg_data: '',
    to_open: 'none',
    to_cover: 'none',
    user_id:''
},
open_all: function () {
  var that = this;
  that.setData({
    to_open: 'block',
    to_cover: 'block'
  })
},
to_cover_over: function () {
  var that = this;
  that.setData({
    to_open: 'none',
    to_cover: 'none'
  })
},
btn_send: function () {
  var that = this
  var fetch1
  var fetch
  //添加評論
  console.log(actid);
  wx.request({
    url: 'https://m.yishushe.net/addons/slwl_fitment/remark.php?action=add_com',
    method: 'POST',
    header: {
      'content-Type': 'application/x-www-form-urlencoded',
      'Accept': 'application/json'
    },
    data: {
      act_id: actid,
      user_id: user_id,
      input_value: input_value
    },
    success: function (result) {
      that.setData({
        input_value: "",
        to_open: 'none',
        to_cover: 'none'
      })
      // 查詢評論fetch
      wx.request({
        url: 'https://m.yishushe.net/addons/slwl_fitment/remark.php?action=fetch_com',
        method: 'POST',
        header: {
          'content-Type': 'application/x-www-form-urlencoded',
          'Accept': 'application/json'
        },
        data: {
          id: actid
        },
        success: result => {
          if (result.data.result == 'success') {
            fetch = result.data.msg
            console.log(fetch)
            that.setData({
              msg_data: fetch
            })
          } else if (result.data.msg == 'session已過期') {
            //添加重新登錄模塊
            wx.showToast({
              title: '請重試',
              image: '/image/wrong.png',
              duration: 3000
            })
          } else if (result.data.msg == '無評論') {
            //do nothing
          } else {
            wx.showToast({
              title: result.data.msg,
              image: '/image/wrong.png',
              duration: 3000
            })
          }
        },
        fail: res => {
          wx.showToast({
            title: '網(wǎng)絡不好喲',
            image: '/image/wrong.png',
            duration: 3000
          })
        }
      })
    },
    fail: res => {
      wx.showToast({
        title: '網(wǎng)絡不好喲',
        image: '/image/wrong.png',
        duration: 3000
      })
    }
  })
},
bindLinkClick: function(a) {
    app.sitefun.clickObjectLink(a, app);
},
bindCopyrightClick: function(a) {
    app.sitefun.clickCopyright(a, app);
},
suspendCloseClick: function() {
    "0" == app.sys.suspend.suspend_show ? this.setData({
        "syscfg.suspend.suspend_show": "1"
    }) : this.setData({
        "syscfg.suspend.suspend_show": "0"
    });
},
onLoad: function(a) {
  var that = this
  var fetch
  wx.getStorage({
    key: 'appUserInfo',
    success: function (res) {
      user_id = res.data.id
      that.setData({
        user_id: user_id
      })
    }
  })
  // 查詢評論fetch
  wx.request({
    url: 'https://m.yishushe.net/addons/slwl_fitment/remark.php?action=fetch_com',
    method: 'POST',
    header: {
      'content-Type': 'application/x-www-form-urlencoded',
      'Accept': 'application/json'
    },
    data: {
      id: actid
    },
    success: result => {
      if (result.data.result == 'success') {
        fetch = result.data.msg
        console.log(fetch)
        that.setData({
          msg_data: fetch
        })
      } else if (result.data.msg == 'session已過期') {
        //添加重新登錄模塊
        wx.showToast({
          title: '請重試',
          image: '/image/wrong.png',
          duration: 3000
        })
      } else if (result.data.msg == '無評論') {
        //do nothing
      } else {
        wx.showToast({
          title: result.data.msg,
          image: '/image/wrong.png',
          duration: 3000
        })
      }
    },
    fail: res => {
      wx.showToast({
        title: '網(wǎng)絡不好喲',
        image: '/image/wrong.png',
        duration: 3000
      })
    }
  })


    if (this.setData({
        actid: a.id
    }), null == app.globalData.userInfo || "undefined" == app.globalData.userInfo) {
        var t = app.sitefun.getCurrentPageUrlWithArgs();
        wx.redirectTo({
            url: "/pages/auth/auth?rb=" + encodeURIComponent(t)
        });
    } else wx.showNavigationBarLoading(), app.info.isLoadInterval = setInterval(this.checkInfo, 500);
},
checkInfo: function() {
    null != app.sys && (clearInterval(app.info.isLoadInterval), wx.hideNavigationBarLoading(), 
    this.setConfig(), this.setActContent(), this.checkPop());
},
setConfig: function() {
    this.setData({
        syscfg: app.sys,
        user: app.globalData.userInfo
    }), app.sitefun.appConfig(app);
},
setActContent: function() {
    var t = this, a = t.data.actid;
    wx.request({
        url: app.siteInfo.siteroot + "?i=" + app.siteInfo.uniacid + "&c=entry&a=wxapp&do=smk_actnews_one&m=" + app.moduleName,
        data: {
            aid: a
        },
        success: function(a) {
            t.setData({
                actdata: a.data.data.one,
                barTitle: a.data.data.one.newsname
            }), wx.setNavigationBarTitle({
                title: a.data.data.one.newsname
            }), article = a.data.data.one.detail, WxParse.wxParse("article", "html", article, t);
        },
        error: function(a) {
            wx.showToast({
              title: a,
                image: "/public/images/icon_error.png"
            });
        }
    });
},
checkPop: function() {
    var t = this;
    wx.request({
        url: app.siteInfo.siteroot + "?i=" + app.siteInfo.uniacid + "&c=entry&a=wxapp&do=smk_get_adpop&m=" + app.moduleName,
        data: {
            uid: app.globalData.userInfo.uid
        },
        header: {
            "content-type": "application/json"
        },
        success: function(a) {
            t.setData({
                myadpop: a.data.data
            });
        },
        error: function(a) {
            wx.showToast({
                title: a,
                image: "/public/images/icon_error.png"
            });
        }
    });
},
adpopClose: function() {
    0 == this.data.myadpop.adpop_show ? this.setData({
        "myadpop.adpop_show": "1"
    }) : this.setData({
        "myadpop.adpop_show": "0"
    });
},
onReady: function() {},
onShow: function() {},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {},
onReachBottom: function() {},
onShareAppMessage: function() {
    return {
        title: app.sys.appname,
        success: function(a) {},
        fail: function(a) {}
    };
}

});

在微信開發(fā)者工具提示錯誤信息是?

showToast:fail parameter error: parameter.title should be String instead of Undefined;

console.error @ VM6812:1
Y @ WAService.js:6
z @ WAService.js:6
vs @ WAService.js:10
(anonymous) @ WAService.js:6
(anonymous) @ WAService.js:7
(anonymous) @ WAService.js:14
(anonymous) @ WAService.js:6
success @ actnews.js? [sm]:85
function.a.(anonymous function) @ WAService.js:7
(anonymous) @ WAService.js:6
(anonymous) @ WAService.js:4
(anonymous) @ WAService.js:7
L.emit @ WAService.js:8
(anonymous) @ WAService.js:12
(anonymous) @ WAService.js:6
a @ appservice?t=1536166881574:10965
(anonymous) @ appservice?t=1536166881574:10965
b.emit @ appservice?t=1536166881574:10965
callback @ appservice?t=1536166881574:10965
setTimeout @ appservice?t=1536166881574:10965
(anonymous) @ WAService.js:4
(anonymous) @ WAService.js:4
setTimeout (async)
setTimeout @ WAService.js:4
n @ appservice?t=1536166881574:10965
c @ appservice?t=1536166881574:10965
v.onreadystatechange @ appservice?t=1536166881574:10965
XMLHttpRequest.send (async)
q @ appservice?t=1536166881574:10965
createRequestTask @ appservice?t=1536166881574:10965
invoke @ appservice?t=1536166881574:10965
invoke @ WAService.js:4
U @ WAService.js:6
H @ WAService.js:6
Rt @ WAService.js:7
e @ WAService.js:12
(anonymous) @ WAService.js:13
(anonymous) @ WAService.js:6
(anonymous) @ WAService.js:7
(anonymous) @ WAService.js:14
(anonymous) @ WAService.js:6
success @ actnews.js? [sm]:58
function.a.(anonymous function) @ WAService.js:7
(anonymous) @ WAService.js:6
(anonymous) @ WAService.js:4
(anonymous) @ WAService.js:7
L.emit @ WAService.js:8
(anonymous) @ WAService.js:12
(anonymous) @ WAService.js:6
a @ appservice?t=1536166881574:10965
(anonymous) @ appservice?t=1536166881574:10965
b.emit @ appservice?t=1536166881574:10965
callback @ appservice?t=1536166881574:10965
setTimeout @ appservice?t=1536166881574:10965
(anonymous) @ WAService.js:4
(anonymous) @ WAService.js:4
setTimeout (async)
setTimeout @ WAService.js:4
n @ appservice?t=1536166881574:10965
c @ appservice?t=1536166881574:10965
v.onreadystatechange @ appservice?t=1536166881574:10965
XMLHttpRequest.send (async)
q @ appservice?t=1536166881574:10965
createRequestTask @ appservice?t=1536166881574:10965
invoke @ appservice?t=1536166881574:10965
invoke @ WAService.js:4
U @ WAService.js:6
H @ WAService.js:6
Rt @ WAService.js:7
e @ WAService.js:12
(anonymous) @ WAService.js:13
(anonymous) @ WAService.js:6
(anonymous) @ WAService.js:7
(anonymous) @ WAService.js:14
(anonymous) @ WAService.js:6
btn_send @ actnews.js? [sm]:39
(anonymous) @ WAService.js:19
l @ WAService.js:18
Dt @ WAService.js:19
ln @ WAService.js:20
(anonymous) @ WAService.js:20
(anonymous) @ WAService.js:19
(anonymous) @ WAService.js:10
n @ WAService.js:6
a @ appservice?t=1536166881574:10965
e.registerCallback @ appservice?t=1536166881574:10965
n.forEach @ appservice?t=1536166881574:10965
d @ appservice?t=1536166881574:10965
k.onmessage @ appservice?t=1536166881574:10965

問題出現(xiàn)的環(huán)境

二次開發(fā),給原程序添加評論功能

回答
編輯回答
無標題

看圖
clipboard.png

2018年7月27日 03:09