123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- import {
- ApiModel
- } from "../../utils/api";
- const _Http = new ApiModel;
- import {
- TestVerify
- } from "../../utils/verify";
- const _Verify = new TestVerify();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- tnoticeid: 0, //通告id
- ftitle: "", //通告标题
- fsummary: "", //概述
- fcontent: "", //通告内容
- ftype: "", //通告类型
- popups: false,
- errTips: {
- ftitle: false,
- fsummary: false,
- fcontent: false
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- /* 提交代码 */
- submit() {
- if (!this.formVerify()) return wx.showToast({
- title: '请检查表单内容',
- icon: "error"
- });
- _Http.basic({
- "accesstoken": wx.getStorageSync('userData').token,
- "classname": "customer.noticemag.noticemag",
- "method": "insertOrModify",
- "content": {
- "tnoticeid": this.data.tnoticeid,
- "ftype": this.data.ftype,
- "ftitle": this.data.ftitle,
- "fsummary": this.data.fsummary,
- "fcontent": this.data.fcontent,
- }
- }).then(res => {
- console.log(res)
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- wx.showToast({
- title: '保存成功',
- });
- let content = {
- ownerid: res.data[0].tnoticeid,
- ownertable: "tnotice",
- tattachmentid: 0
- };
- this.selectComponent("#UploadFiles").saveTheChanges(content);
- this.selectComponent("#UpFiles").saveTheChanges(content);
- setTimeout(() => {
- wx.navigateBack()
- }, 500)
- })
- },
- /* 表单验证 */
- formVerify() {
- let errTips = this.data.errTips,
- verify = true;
- /* 验证标题 */
- if (!_Verify.required(this.data.ftitle)) {
- errTips.ftitle = true;
- verify = false;
- }
- /* 验证概述 */
- if (!_Verify.required(this.data.fsummary)) {
- errTips.fsummary = true;
- verify = false;
- }
- /* 验证内容 */
- if (!_Verify.required(this.data.fcontent)) {
- errTips.fcontent = true;
- verify = false;
- }
- this.setData({
- errTips
- })
- return verify;
- },
- /* 获取焦点 */
- inputFocus(e) {
- const {
- name
- } = e.currentTarget.dataset;
- let errTips = this.data.errTips;
- errTips[name] = false;
- this.setData({
- errTips
- })
- },
- /* 失去焦点 */
- inputBlur(e) {
- const {
- name
- } = e.currentTarget.dataset;
- const {
- value
- } = e.detail;
- if (value.trim() == "") {
- let errTips = this.data.errTips;
- errTips[name] = true;
- this.setData({
- errTips
- })
- }
- },
- /* input事件剔除特殊字符 */
- eliminate(value) {
- const {
- name
- } = value.target.dataset;
- this.setData({
- [name]: _Verify.Eliminate(value.detail)
- })
- },
- /* 发布范围回调 */
- radioChange({
- detail
- }) {
- this.setData({
- ftype: detail,
- popups: false
- })
- },
- /* 打开类目选择 */
- showPop() {
- this.setData({
- popups: !this.data.popups
- })
- },
- /* 跳转富文本 */
- toRichText() {
- const that = this;
- const fcontent = encodeURIComponent(this.data.fcontent);
- wx.navigateTo({
- url: '/pages/storeMessage/editor/editor?fintroduction=' + fcontent,
- events: {
- richTextCallBack: function (richText) {
- let fcontent = null;
- (richText.richText == '<p><br></p>') ? fcontent = "": fcontent = richText.richText;
- that.setData({
- fcontent: fcontent,
- 'errTips.fcontent': false
- })
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|