123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- const app = require('../../utils/util.js');
- const tools = require('../../utils/tools.js');
- Page({
- data: {
- isshow1: false,
- isshow2: true,
- activebg: "#ffeae9",
- unactivebg: "#f2f2f2",
- mytip: "",
- listArr: []
- },
- // tab1
- tab1Show() {
- this.setData({
- isshow1: false,
- isshow2: true,
- activebg: "#ffeae9",
- unactivebg: "#f2f2f2"
- })
- },
- //tab2
- async tab2Show() {
- const sessionKey = await tools.checkSessionAndLogin();
- wx.request({
- url: app.globalData.publicUrl + '/wx/board/list',
- method: "post",
- data: {
- sessionKey: sessionKey
- },
- success: (res) => {
- if (res.data.code == 0) {
- if (res.data.list.length == 0) {
- wx.showModal({
- showCancel: false,
- content: "您还没有提问哦"
- })
- } else {
- this.setData({
- listArr: res.data.list,
- isshow1: true,
- isshow2: false,
- activebg: "#f2f2f2",
- unactivebg: "#ffeae9"
- })
- }
- } else {
- wx.showModal({
- showCancel: false,
- content: "您还没有提问哦"
- })
- }
- }
- })
- },
- // 去解答的详情页
- gojjDetails(e) {
- let id = e.currentTarget.dataset.item.id
- if (e.currentTarget.dataset.item.replyContent == "" || e.currentTarget.dataset.item.replyContent == null) {
- wx.showModal({
- showCancel: false,
- content: "您还没收到回复哦"
- })
- } else {
- wx.navigateTo({
- url: '/pages/myInteractionsDetais/myInteractionsDetais?id=' + id,
- })
- }
- },
- // 禁止input框输入表情
- regStrFn(str) {
- // 转换一下编码
- let reg = /([^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n])|(\s)/g,
- indexArr = reg.exec(str);
- if (str.match(reg)) {
- str = str.replace(reg, '');
- }
- let obj = {
- val: str,
- index: indexArr
- }
- return obj
- },
- bindinput(e) {
- // let name = 'form.' + e.target.dataset.name
- let val = e.detail.value,
- pos = e.detail.cursor;
- let reg = /([^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n])|(\s)/g
- if (!reg.test(val)) {
- return
- }
- let obj = this.regStrFn(val)
- if (pos != -1 && obj.index) {
- //计算光标的位置
- pos = obj.index.index
- }
- return {
- value: obj.val,
- cursor: pos
- }
- },
- // 提交内容
- async bindFormSubmit(e) {
- wx.showLoading({
- mask: true,
- title: '加载中',
- })
- let input_val = e.detail.value.textarea;
- const sessionKey = await tools.checkSessionAndLogin();
- if (input_val == "" || input_val == undefined) {
- wx.hideLoading();
- wx.showToast({
- title: '反馈不能为空',
- icon: 'none',
- duration: 1000
- })
- return false;
- }
- wx.request({
- url: app.globalData.publicUrl + '/wx/board/add',
- method: "post",
- data: {
- content: input_val,
- sessionKey: sessionKey
- },
- success: (res) => {
- console.log(res,"00000000000")
- if (res.data.code == 0) {
- wx.hideLoading()
- wx.showModal({
- showCancel: false,
- content: "提交成功",
- success: (res) => {
- if (res.confirm) {
- this.setData({
- mytip: ""
- })
- }
- }
- })
- } else {
- wx.hideLoading()
- wx.showModal({
- showCancel: false,
- content: res.data.msg
- })
- }
- }
- })
- }
- })
|