| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- import constant from '../../utils/constant';
- const app = getApp();
- var isViolate1 = false;
- var isViolate2 = false;
- Page({
- data: {
- InputValue: "",
- ToWhomIndex: 0,
- IsOpen: true,
- ArrToWhom: [{
- Name: "给孩子",
- CSS: "btn11"
- }, {
- Name: "给自己",
- CSS: ""
- }, {
- Name: "给同学",
- CSS: ""
- }],
- },
- onLoad: function (options) {
- var that = this;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- SchoolID: options.SchoolID,
- ID: 0,
- });
- if (options.type == "edit") {
- var mywish = app.globalData.MyWish;
- for (var i = 0; i < that.data.ArrToWhom.length; i++) {
- if (mywish.ToWhom == that.data.ArrToWhom[i].Name)
- that.data.ArrToWhom[i].CSS = "btn11";
- }
- that.setData({
- inputName: mywish.ToName,
- inputContent: mywish.WishContent,
- SchoolID: mywish.SchoolID,
- IsOpen: mywish.IsOpen ? true : false,
- ArrToWhom: that.data.ArrToWhom,
- ID: mywish.ID,
- });
- }
- },
- selectToWhom: function (event) {
- var index = event.currentTarget.dataset.index;
- this.data.ArrToWhom[0].CSS = "";
- this.data.ArrToWhom[1].CSS = "";
- this.data.ArrToWhom[2].CSS = "";
- this.data.ArrToWhom[index].CSS = "btn11";
- this.setData({
- ArrToWhom: this.data.ArrToWhom,
- ToWhomIndex: index,
- });
- },
- randomWish: function () {
- var list = constant.arrWishInfo[this.data.ToWhomIndex].List;
- var index = common.random(0, list.length - 1);
- this.setData({
- inputContent: list[index],
- });
- },
- bindKeyInputName: function (e) {
- var that = this;
- that.setData({
- inputName: e.detail.value,
- });
- that.onCheck(e.detail.value,1);
- },
- bindKeyInputContent: function (e) {
- var that = this;
- that.setData({
- inputContent: e.detail.value,
- });
- that.onCheck(e.detail.value,2);
- },
- clickCheckbox: function () {
- var that = this;
- that.setData({
- IsOpen: !that.data.IsOpen,
- });
- },
- onCheck: function (content,num) {
- if (num==1)
- isViolate1 = false;
- else if (num==2)
- isViolate2 = false;
- main.postData("MsgSecCheck2", {
- Content: content,
- UserID: app.globalData.userInfo.UserID,
- },
- function (data) {
- if (data && data.errcode == 0) {
-
- } else {
- if (data.errmsg) {
- wx.showToast({
- title: data.errmsg,
- duration: 2000,
- image: "../images/universalpic_wrong_white_120x120.png",
- });
- if (num==1)
- isViolate1 = true;
- else if (num==2)
- isViolate2 = true;
- }
- }
- });
- },
- onSubmit: function () {
- var that = this;
- if (isViolate1) {
- wx.showModal({
- title: '生成失败',
- content: '抱歉,您填写的名字未能通过微信敏感词检查故无法生成福帖。敏感词由微信官方功能判定,建议您调整内容多尝试几次。',
- showCancel: false,
- confirmText: '返回',
- });
- }
- else if (isViolate2) {
- wx.showModal({
- title: '生成失败',
- content: '抱歉,您填写的祝福语未能通过微信敏感词检查故无法生成福帖。敏感词由微信官方功能判定,建议您调整内容多尝试几次。',
- showCancel: false,
- confirmText: '返回',
- });
- }
- else {
- if (app.globalData.userInfo.NickName == "陌生用户") {
- wx.navigateTo({
- url: 'userinfo',
- });
- } else {
- var param = {};
- param.ID = that.data.ID;
- param.UserID = app.globalData.userInfo.UserID;
- param.SchoolID = that.data.SchoolID;
- param.ToWhom = that.data.ArrToWhom[that.data.ToWhomIndex].Name;
- param.ToName = that.data.inputName;
- param.WishContent = that.data.inputContent;
- param.IsOpen = that.data.IsOpen ? 1 : 0;
- console.log(param);
- main.postData('MPSWish', param, function (data) {
- app.globalData.MyWish = data;
- //debugger;
- wx.redirectTo({
- url: './wishinfo',
- })
- });
- }
- }
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|