Kaynağa Gözat

话题列表详情

YY 2 yıl önce
ebeveyn
işleme
1caf6712f0

+ 1 - 3
app.json

@@ -1,7 +1,5 @@
 {
     "pages": [
-   
-
         "pages/my/index",
         "pages/index/index",
         "pages/register/index",
@@ -12,6 +10,7 @@
         "pages/topic/index",
         "pages/topic/mess",
         "pages/topic/messAdd",
+        "pages/topic/info",
         "pages/my/userInfo",
         "pages/matchInfo/index",
         "pages/matchInfo/sign",
@@ -41,7 +40,6 @@
         "pages/race/index",
         "pages/race/add",
         "pages/race/auto",
-        
         "pages/agree_txt/index",
         "pages/openMatch/index",
         "pages/test/index",

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 241
pages/topic/icon/icon.wxss


+ 9 - 1
pages/topic/index.js

@@ -16,12 +16,20 @@ Page({
       let { route } = e.detail.detail;
       if (route) wx.redirectTo({ url: `/${route}` })
    },
+   toJoin(e) {
+      let { id } = e.currentTarget.dataset;
+      wx.navigateTo({ url: `/pages/topic/info?id=${id}` })
+   },
    // 跳转菜单
    back(e) {
       wx.navigateBack({ delta: 1 })
    },
    // 查询
-   search: function (e) { console.log('查询'); },
+   search: function (e) {
+      const that = this;
+      that.setData({ 'searchInfo.title': e.detail.value });
+      that.watchLogin()
+   },
 
    /**
     * 生命周期函数--监听页面加载

+ 91 - 93
pages/topic/index.less

@@ -1,96 +1,94 @@
 .main {
-    height: 80.8vh;
-
-    .zero {
-        width: 96vw;
-
-        margin: 0 0 2vw 0;
-    }
-
-    .zero:nth-child(2) {
-        margin: 0;
-    }
-
-    .one {
-        display: flex;
-        flex-direction: row;
-        justify-content: space-between;
-        padding: 2vw;
-        width: 92vw;
-        background-color: #f1f1f1;
-
-        input {
-            font-size: 16px;
-        }
-    }
-
-    .two {
-        flex-grow: 1;
-        position: relative;
-        width: 96vw;
-
-
-        .scroll-view {
-            position: absolute;
-            top: 0;
-            left: 0;
-            right: 0;
-            bottom: 0;
-
-            .list-scroll-view {
-                display: flex;
-                flex-wrap: wrap;
-                align-content: flex-start;
-                justify-content: space-between;
-
-                .list {
-                    background-color: #ffffff;
-                    margin: 0 0 2vw 0;
-                    padding: 2vw;
-                    display: flex;
-                    flex-direction: column;
-                    width: 96vw;
-
-                    .list_1 {
-                        display: flex;
-                        flex-direction: row;
-                        justify-content: space-between;
-                        font-size: 14px;
-                        margin: 0 0 1vw 0;
-                        color: #858585;
-
-                        .name {
-                            width: 70vw;
-                        }
-                    }
-
-                    .list_2 {
-                        margin: 0 0 3vw 0;
-                        font-size: 18px;
-                        font-weight: bold;
-                    }
-
-                    .list_3 {
-                        display: flex;
-                        flex-direction: row;
-                        justify-content: space-between;
-                        font-size: 14px;
-                        color: #858585;
-
-                        .btn {
-                            button {
-                                font-size: 14px;
-                                background-color: transparent;
-                                color: #334790;
-                            }
-                        }
-                    }
-                }
-
-                .list:last-child {
-                    margin: 0;
-                }
+   height: 80.8vh;
+
+   .zero {
+      width: 96vw;
+
+      margin: 0 0 2vw 0;
+   }
+
+   .zero:nth-child(2) {
+      margin: 0;
+   }
+
+   .one {
+      display: flex;
+      flex-direction: row;
+      justify-content: space-between;
+      padding: 2vw;
+      width: 92vw;
+      background-color: #f1f1f1;
+
+      input {
+         font-size: 16px;
+      }
+   }
+
+   .two {
+      flex-grow: 1;
+      position: relative;
+      width: 96vw;
+
+
+      .scroll-view {
+         position: absolute;
+         top: 0;
+         left: 0;
+         right: 0;
+         bottom: 0;
+
+         .list-scroll-view {
+            display: flex;
+            flex-wrap: wrap;
+            align-content: flex-start;
+            justify-content: space-between;
+
+            .list {
+               background-color: #ffffff;
+               margin: 0 0 2vw 0;
+               padding: 2vw;
+               display: flex;
+               flex-direction: column;
+               width: 96vw;
+
+               .list_1 {
+                  display: flex;
+                  flex-direction: row;
+                  justify-content: space-between;
+                  font-size: 14px;
+                  margin: 0 0 1vw 0;
+                  color: #858585;
+
+                  .name {
+                     width: 70vw;
+                  }
+               }
+
+               .list_2 {
+                  margin: 0 0 3vw 0;
+                  font-size: 18px;
+                  font-weight: bold;
+               }
+
+               .list_3 {
+                  display: flex;
+                  flex-direction: row;
+                  justify-content: space-between;
+                  font-size: 14px;
+                  color: #858585;
+
+                  .btn {
+                     color: #334790;
+                     font-size: 14px;
+                     font-weight: 700;
+                  }
+               }
             }
-        }
-    }
+
+            .list:last-child {
+               margin: 0;
+            }
+         }
+      }
+   }
 }

+ 4 - 4
pages/topic/index.wxml

@@ -1,20 +1,20 @@
 <mobile-main frameStyle="{{frameStyle}}" bind:back="back" bind:tabPath="tabPath">
    <view slot="info" class="container main">
       <view class="zero one">
-         <input type="text" value="{{searchInfo.name}}" bindconfirm="search" placeholder="请输入关键词" />
+         <input type="text" value="{{searchInfo.title}}" bindconfirm="search" placeholder="请输入关键词" />
       </view>
       <view class="zero two">
          <scroll-view scroll-y="true" class="scroll-view">
             <view class="list-scroll-view">
-               <view class="list" wx:for="{{list}}" wx:key="item">
+               <view class="list" wx:for="{{list}}" wx:key="item" bindtap="toJoin" data-id="{{item._id}}">
                   <view class="list_1">
                      <view class="name">{{item.title}}</view>
                      <view>{{item.create_time}}</view>
                   </view>
                   <view class="list_2">{{item.title}}</view>
                   <view class="list_3">
-                     <view>已发布0个帖子</view>
-                     <view class="btn"><button type="primary" size="mini">加入话题>>></button></view>
+                     <view>已发布{{item.stick.length||0}}个帖子</view>
+                     <view class="btn">加入话题>>></view>
                   </view>
                </view>
             </view>

+ 3 - 3
pages/topic/index.wxss

@@ -68,10 +68,10 @@
   font-size: 14px;
   color: #858585;
 }
-.main .two .scroll-view .list-scroll-view .list .list_3 .btn button {
-  font-size: 14px;
-  background-color: transparent;
+.main .two .scroll-view .list-scroll-view .list .list_3 .btn {
   color: #334790;
+  font-size: 14px;
+  font-weight: 700;
 }
 .main .two .scroll-view .list-scroll-view .list:last-child {
   margin: 0;

+ 145 - 0
pages/topic/info.js

@@ -0,0 +1,145 @@
+const app = getApp()
+const moment = require("../../utils/moment.min")
+import WxValidate from '../../utils/wxValidate'
+
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        frameStyle: { useTop: true, name: '信息管理', leftArrow: true, useBar: false },
+        // dialog弹框
+        dialog: { title: '发帖', show: false, type: '1' },
+        id: '',
+        // 详情
+        info: {},
+        // 用户信息
+        user: {},
+    },
+    initValidate() {
+        const rules = { title: { required: true }, content: { required: false } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { title: { required: '请输入话题名称', }, content: { required: '请输入信息内容' } };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    // 返回
+    back: function () {
+        wx.navigateBack({ delta: 1 })
+    },
+    // 打开弹框
+    toDialog: function () {
+        const that = this;
+        that.setData({ dialog: { title: '发帖', show: true, type: '1' } })
+    },
+    // 关闭弹框
+    toClose: function () {
+        const that = this;
+        that.setData({ dialog: { title: '发帖', show: false, type: '1' } })
+    },
+    // 发帖
+    onSubmit: async function (e) {
+        const that = this;
+        const params = e.detail.value;
+        const data = that.data.info;
+        const user = that.data.user;
+        params.create_time = moment().format('YYYY-MM-DD');
+        params.openid = user.openid;
+        params.name = user.name;
+        that.setData({ form: '' })
+        data.stick.push(params)
+        if (!this.WxValidate.checkForm(params)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            let arr;
+            if (data._id) {
+                arr = await app.$post(`/newCourt/api/topic/${data._id}`, data);
+            }
+            if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.toClose(); that.watchLogin(); }
+            else wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+        }
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        const that = this;
+        that.setData({ id: options.id || '62ea3510a97c2931cbbec91e' })
+
+        //验证规则函数
+        that.initValidate();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                this.setData({ user: res.data });
+                if (that.data.id) {
+                    const arr = await app.$get(`/newCourt/api/topic/${that.data.id}`);
+                    if (arr.errcode == '0') {
+                        that.setData({ info: arr.data });
+                        console.log(arr.data);
+                        let content = arr.data.content.replace(/\<img/gi, '<img style="width:100%;height:auto;margin: 5px 0"');
+                        this.setData({ 'info.content': content });
+                    }
+                }
+            },
+            fail: res => {
+                wx.redirectTo({ url: '/pages/index/index', })
+            }
+        })
+    },
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+        // 监听用户是否登录
+        this.watchLogin();
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 7 - 0
pages/topic/info.json

@@ -0,0 +1,7 @@
+{
+   "component": true,
+   "usingComponents": {
+     "mobile-main": "/commpents/mobile-frame/index",
+     "e-dialog": "/commpents/dialog/index"
+   }
+ }

+ 171 - 0
pages/topic/info.less

@@ -0,0 +1,171 @@
+.main {
+    height: 88.8vh;
+
+    .zero {
+        width: 96vw;
+        margin: 0 0 2vw 0;
+        // background-color: #fff;
+    }
+
+    .zero:last-child {
+        margin: 0;
+    }
+
+    .one {
+        flex-grow: 1;
+        position: relative;
+        width: 96vw;
+
+        .scroll-view {
+            position: absolute;
+            top: 0;
+            left: 0;
+            right: 0;
+            bottom: 0;
+
+            .infos {
+                display: flex;
+                flex-direction: column;
+                flex-wrap: wrap;
+                align-content: flex-start;
+                justify-content: space-between;
+
+                .top {
+                    width: 96vw;
+                    border-bottom: 1px dashed #cccccc;
+
+                    .one_1 {
+                        text-align: center;
+                        font-weight: bold;
+                        font-size: 20px;
+                        padding: 6vw 0;
+                    }
+
+                    .one_2 {
+                        display: flex;
+                        justify-content: space-between;
+                        font-size: 16px;
+                        color: #666666;
+                        padding: 2vw 0;
+
+                        text {
+                            padding-right: 5px;
+                        }
+                    }
+                }
+
+                .cont {
+                    width: 96vw;
+                    padding: 2vw 0 0 0;
+                    border-bottom: 1px dashed #ffc0c0;
+
+                }
+
+                .bom {
+                    padding: 5px;
+
+                    .list {
+                        display: flex;
+                        flex-direction: column;
+                        margin: 0 0 8px 0;
+                        padding: 5px 0;
+                        border-bottom: 1px dashed #cccccc;
+
+
+                        .list_1 {
+                            display: flex;
+                            flex-direction: row;
+
+                            .name {
+                                width: 20vw;
+                            }
+
+                            .list_bom {
+                                width: 74vw;
+                                display: flex;
+                                flex-direction: column;
+
+                                .title {
+                                    font-size: 15px;
+                                }
+
+                                .content {
+                                    color: #666;
+                                    font-size: 14px;
+                                }
+                            }
+                        }
+
+                        .time {
+                            width: 93vw;
+                            font-size: 14px;
+                            text-align: right;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    .foot {
+        position: fixed;
+        width: 96vw;
+        bottom: 8vh;
+        right: 1vw;
+        text-align: right;
+
+        .mymatch {
+            display: inline-block;
+            width: 10vw;
+            padding: 1vw;
+            text-align: center;
+            background-color: green;
+            color: #fff;
+            font-size: 14px;
+            border-radius: 5px;
+        }
+
+    }
+}
+
+.two {
+    display: flex;
+    flex-direction: column;
+    border-radius: 5px;
+    background-color: #f1f1f1;
+    color: #666;
+
+    .two_1 {
+        width: 80vw;
+
+        input {
+            width: 96%;
+            height: 30px;
+            font-size: 15px;
+            margin: 5px;
+            padding: 3px;
+            background-color: #fff;
+        }
+
+
+        textarea {
+            width: 96%;
+            font-size: 15px;
+            padding: 3px;
+            margin: 5px;
+            background-color: #fff;
+        }
+    }
+
+    .two_2 {
+        width: 80vw;
+        text-align: center;
+
+        button {
+            width: 30%;
+            font-size: 14px;
+            padding: 2vw 0;
+
+        }
+    }
+}

+ 54 - 0
pages/topic/info.wxml

@@ -0,0 +1,54 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        <view class="one">
+            <scroll-view scroll-y="true" class="scroll-view">
+                <view class="infos">
+                    <view class="top">
+                        <view class="one_1">{{info.title}}</view>
+                        <view class="one_2">
+                            <view class="type"><text>来源:{{info.origin||'暂无'}}</text></view>
+                            <view class="time">{{info.create_time||'暂无'}}</view>
+                        </view>
+                    </view>
+                    <view class="cont">
+                        <rich-text nodes="{{info.content}}"></rich-text>
+                    </view>
+                    <view class="bom">
+                        <view class="list" wx:for="{{info.stick}}" wx:key="item">
+                            <view class="list_1">
+                                <view class="name">{{item.name}}</view>
+                                <view class="list_bom">
+                                    <view class="title">{{item.title}}</view>
+                                    <view class="content">{{item.content}}</view>
+                                </view>
+                            </view>
+                            <view class="time">{{item.create_time}}</view>
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
+        <view class="foot" wx:if="{{user.type=='-1'}}">
+            <text class="mymatch" bindtap="toDialog">我要发帖</text>
+        </view>
+    </view>
+</mobile-main>
+<e-dialog dialog="{{dialog}}" bind:toClose="toClose">
+    <view slot="info">
+        <view wx:if="{{dialog.type=='1'}}">
+            <form catchsubmit="onSubmit">
+                <view class="two">
+                    <view class="two_1">
+                        <input type="text" name="title" value="{{form.title}}" placeholder="请输入标题" />
+                    </view>
+                    <view class="two_1">
+                        <textarea name="content" value="{{form.content}}" maxlength="-1" placeholder="请输入发帖内容" />
+                    </view>
+                    <view class="two_2">
+                        <button type="primary" size="mini" formType="submit">发送</button>
+                    </view>
+                </view>
+            </form>
+        </view>
+    </view>
+</e-dialog>

+ 139 - 0
pages/topic/info.wxss

@@ -0,0 +1,139 @@
+.main {
+  height: 88.8vh;
+}
+.main .zero {
+  width: 96vw;
+  margin: 0 0 2vw 0;
+}
+.main .zero:last-child {
+  margin: 0;
+}
+.main .one {
+  flex-grow: 1;
+  position: relative;
+  width: 96vw;
+}
+.main .one .scroll-view {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+}
+.main .one .scroll-view .infos {
+  display: flex;
+  flex-direction: column;
+  flex-wrap: wrap;
+  align-content: flex-start;
+  justify-content: space-between;
+}
+.main .one .scroll-view .infos .top {
+  width: 96vw;
+  border-bottom: 1px dashed #cccccc;
+}
+.main .one .scroll-view .infos .top .one_1 {
+  text-align: center;
+  font-weight: bold;
+  font-size: 20px;
+  padding: 6vw 0;
+}
+.main .one .scroll-view .infos .top .one_2 {
+  display: flex;
+  justify-content: space-between;
+  font-size: 16px;
+  color: #666666;
+  padding: 2vw 0;
+}
+.main .one .scroll-view .infos .top .one_2 text {
+  padding-right: 5px;
+}
+.main .one .scroll-view .infos .cont {
+  width: 96vw;
+  padding: 2vw 0 0 0;
+  border-bottom: 1px dashed #ffc0c0;
+}
+.main .one .scroll-view .infos .bom {
+  padding: 5px;
+}
+.main .one .scroll-view .infos .bom .list {
+  display: flex;
+  flex-direction: column;
+  margin: 0 0 8px 0;
+  padding: 5px 0;
+  border-bottom: 1px dashed #cccccc;
+}
+.main .one .scroll-view .infos .bom .list .list_1 {
+  display: flex;
+  flex-direction: row;
+}
+.main .one .scroll-view .infos .bom .list .list_1 .name {
+  width: 20vw;
+}
+.main .one .scroll-view .infos .bom .list .list_1 .list_bom {
+  width: 74vw;
+  display: flex;
+  flex-direction: column;
+}
+.main .one .scroll-view .infos .bom .list .list_1 .list_bom .title {
+  font-size: 15px;
+}
+.main .one .scroll-view .infos .bom .list .list_1 .list_bom .content {
+  color: #666;
+  font-size: 14px;
+}
+.main .one .scroll-view .infos .bom .list .time {
+  width: 93vw;
+  font-size: 14px;
+  text-align: right;
+}
+.main .foot {
+  position: fixed;
+  width: 96vw;
+  bottom: 8vh;
+  right: 1vw;
+  text-align: right;
+}
+.main .foot .mymatch {
+  display: inline-block;
+  width: 10vw;
+  padding: 1vw;
+  text-align: center;
+  background-color: green;
+  color: #fff;
+  font-size: 14px;
+  border-radius: 5px;
+}
+.two {
+  display: flex;
+  flex-direction: column;
+  border-radius: 5px;
+  background-color: #f1f1f1;
+  color: #666;
+}
+.two .two_1 {
+  width: 80vw;
+}
+.two .two_1 input {
+  width: 96%;
+  height: 30px;
+  font-size: 15px;
+  margin: 5px;
+  padding: 3px;
+  background-color: #fff;
+}
+.two .two_1 textarea {
+  width: 96%;
+  font-size: 15px;
+  padding: 3px;
+  margin: 5px;
+  background-color: #fff;
+}
+.two .two_2 {
+  width: 80vw;
+  text-align: center;
+}
+.two .two_2 button {
+  width: 30%;
+  font-size: 14px;
+  padding: 2vw 0;
+}

+ 122 - 188
pages/topic/messAdd.js

@@ -1,209 +1,143 @@
 const app = getApp()
 import WxValidate from '../../utils/wxValidate'
 import { is_show_project } from '../../utils/dict';
-let util = require('../../utils/util');
+const moment = require("../../utils/moment.min")
 
 Page({
 
-   /**
-    * 页面的初始数据
-    */
-   data: {
-      frameStyle: { useTop: true, name: '信息管理', leftArrow: true, useBar: false },
-      id: '',
-      // 是否使用
-      is_showList: is_show_project,
-      form: {},
-      content: ''
-   },
-   initValidate() {
-      const rules = { title: { required: true }, create_time: { required: false }, origin: { required: true }, brief: { required: true }, content: { required: false }, is_show: { required: true } }
-      // 验证字段的提示信息,若不传则调用默认的信息
-      const messages = { title: { required: '请输入话题名称', }, create_time: { required: '请输入发布时间', }, origin: { required: '请输入信息来源', }, brief: { required: '请输入信息简介' }, content: { required: '请输入信息内容' }, is_show: { required: '请选择是否公开' } };
-      this.WxValidate = new WxValidate(rules, messages)
-   },
-
-   // 返回
-   back: function () {
-      wx.navigateBack({ delta: 1 })
-   },
-
-   /**
-   * 组件的方法列表
-   */
-   onEditorReady() {
-      const that = this
-      that.createSelectorQuery().select('#editor').context(function (res) {
-         that.editorCtx = res.context
-         if (!res) return
-         that.editorCtx.setContents({
-            html: that.data.form.content,
-         })
-      }).exec()
-   },
-   format(e) {
-      let self = this;
-      let { name, value } = e.target.dataset;
-      // 富文本编辑器格式化内容方法
-      self.editorCtx.format(name, value);
-   },
-   setContents(rechtext) {
-      this.editorCtx.setContents({
-         html: rechtext,
-         success: (res) => {
-            // 富文本内容设置成功
-            // console.log("[setContents success]", res);
-         },
-      });
-   },
-   getEditorContent() {
-      const that = this;
-      let self = this;
-      // 富文本编辑器获取内容方法
-      self.editorCtx.getContents({
-         success: (res) => {
-            let array = [];
-            array["html"] = res.html;
-            array["index"] = self.properties.index;
-            // 通过自定义事件把内容传到父组件
-            self.triggerEvent("getEditorValue", array);
-         },
-      });
-      that.editorCtx.getContents({
-         success: function (res) {
-            that.setData({ content: res.html })
-         },
-      });
-   },
-   insertImage() {
-      const that = this
-      wx.chooseImage({
-         count: 1,
-         success: function (res) {
-            that.editorCtx.insertImage({
-               src: res.tempFilePaths[0],
-               data: {
-                  id: 'abcd',
-                  role: 'god'
-               },
-               width: '80%',
-               success: function () {
-                  console.log('insert image success')
-               }
-            })
-         }
-      })
-   },
-   // 是否公开
-   is_showChange: function (e) {
-      const that = this;
-      let index = e.detail.value;
-      let value = that.data.is_showList[index];
-      that.setData({ 'form.is_show': value.value });
-   },
-
-   // 提交登录
-   onSubmit: async function (e) {
-      const that = this;
-      const params = e.detail.value;
-      const data = that.data.form;
-      if (!this.WxValidate.checkForm(params)) {
-         const error = this.WxValidate.errorList[0];
-         wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
-         return false
-      } else {
-         let arr;
-         let time = util.formatTime(new Date());
-         time = time.slice(0, -9)
-         params.content = that.data.content;
-         if (data._id) {
-            arr = await app.$post(`/newCourt/api/topic/${data._id}`, params);
-         }
-         else {
-            params.create_time = time;
-            arr = await app.$post(`/newCourt/api/topic`, params);
-         }
-         if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
-         else wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
-      }
-   },
-
-   /**
-    * 生命周期函数--监听页面加载
-    */
-   onLoad: function (options) {
-      const that = this;
-      that.setData({ id: options.id || '' })
-      //验证规则函数
-      that.initValidate();
-      // 监听用户是否登录
-      that.watchLogin();
-   },
-   // 监听用户是否登录
-   watchLogin: async function () {
-      const that = this;
-      wx.getStorage({
-         key: 'user',
-         success: async res => {
-            if (that.data.id) {
-               const arr = await app.$get(`/newCourt/api/topic/${that.data.id}`);
-               if (arr.errcode == '0') {
-                  that.setData({ form: arr.data });
-                  that.onEditorReady();
-               }
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        frameStyle: { useTop: true, name: '信息管理', leftArrow: true, useBar: false },
+        id: '',
+        // 是否使用
+        is_showList: is_show_project,
+        form: {},
+    },
+    initValidate() {
+        const rules = { title: { required: true }, create_time: { required: false }, origin: { required: true }, brief: { required: true }, content: { required: false }, is_show: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { title: { required: '请输入话题名称', }, create_time: { required: '请输入发布时间', }, origin: { required: '请输入信息来源', }, brief: { required: '请输入信息简介' }, content: { required: '请输入信息内容' }, is_show: { required: '请选择是否公开' } };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    // 返回
+    back: function () {
+        wx.navigateBack({ delta: 1 })
+    },
+    //用户输入内容
+    inputChange: function (e) {
+        const that = this;
+        let html = e.detail.html;
+        that.setData({ "form.content": html });
+    },
+    // 是否公开
+    is_showChange: function (e) {
+        const that = this;
+        let index = e.detail.value;
+        let value = that.data.is_showList[index];
+        that.setData({ 'form.is_show': value.value });
+    },
+
+    // 提交登录
+    onSubmit: async function (e) {
+        const that = this;
+        const params = e.detail.value;
+        const data = that.data.form;
+        params.content = data.content;
+        params.create_time = moment().format('YYYY-MM-DD');
+        if (!this.WxValidate.checkForm(params)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            let arr;
+            if (data._id) {
+                arr = await app.$post(`/newCourt/api/topic/${data._id}`, params);
             }
-         },
-         fail: res => {
-            wx.redirectTo({ url: '/pages/index/index', })
-         }
-      })
-   },
-   /**
-    * 生命周期函数--监听页面初次渲染完成
-    */
-   onReady: function () {
+            else {
+                arr = await app.$post(`/newCourt/api/topic`, params);
+            }
+            if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
+            else wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+        }
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        const that = this;
+        that.setData({ id: options.id || '' })
+        //验证规则函数
+        that.initValidate();
+        // 监听用户是否登录
+        that.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                if (that.data.id) {
+                    const arr = await app.$get(`/newCourt/api/topic/${that.data.id}`);
+                    if (arr.errcode == '0') {
+                        that.setData({ form: arr.data });
+                    }
+                }
+            },
+            fail: res => {
+                wx.redirectTo({ url: '/pages/index/index', })
+            }
+        })
+    },
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
 
-   },
+    },
 
-   /**
-    * 生命周期函数--监听页面显示
-    */
-   onShow: function () {
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
 
-   },
+    },
 
-   /**
-    * 生命周期函数--监听页面隐藏
-    */
-   onHide: function () {
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
 
-   },
+    },
 
-   /**
-    * 生命周期函数--监听页面卸载
-    */
-   onUnload: function () {
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
 
-   },
+    },
 
-   /**
-    * 页面相关事件处理函数--监听用户下拉动作
-    */
-   onPullDownRefresh: function () {
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
 
-   },
+    },
 
-   /**
-    * 页面上拉触底事件的处理函数
-    */
-   onReachBottom: function () {
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
 
-   },
+    },
 
-   /**
-    * 用户点击右上角分享
-    */
-   onShareAppMessage: function () {
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
 
-   }
+    }
 })

+ 5 - 4
pages/topic/messAdd.json

@@ -1,6 +1,7 @@
 {
-  "component": true,
-  "usingComponents": {
-    "mobile-main": "/commpents/mobile-frame/index"
-  }
+   "component": true,
+   "usingComponents": {
+      "mobile-main": "/commpents/mobile-frame/index",
+      "hg-editor": "/commpents/hg-editor/hg-editor"
+   }
 }

+ 10 - 20
pages/topic/messAdd.wxml

@@ -5,41 +5,31 @@
             <view class="content">
                <view class="label">话题名称</view>
                <view class="value">
-                  <view class="value"><input name="title" value="{{form.title}}" placeholder="请输入话题名称" /></view>
+                  <view class="value">
+                     <textarea name="title" value="{{form.title}}" auto-height maxlength="-1" placeholder="请输入话题名称" />
+                  </view>
                </view>
             </view>
             <view class="content">
                <view class="label">信息简介:</view>
                <view class="value">
-                  <view class="value"><input name="brief" value="{{form.brief}}" placeholder="请输入信息简介" /></view>
+                  <view class="value">
+                     <textarea name="brief" value="{{form.brief}}" auto-height maxlength="-1" placeholder="请输入信息简介" />
+                  </view>
                </view>
             </view>
             <view class="content">
                <view class="label">信息来源:</view>
                <view class="value">
-                  <view class="value"><input name="origin" value="{{form.origin}}" placeholder="请输入信息来源" /></view>
+                  <view class="value">
+                     <textarea name="origin" value="{{form.origin}}" auto-height maxlength="-1" placeholder="请输入信息来源" />
+                  </view>
                </view>
             </view>
             <view class="content1">
                <view class="label">信息内容:</view>
                <view class="value">
-                  <view class="toolbar" catchtouchend="format">
-                     <i class="iconfont icon-charutupian" catchtouchend="insertImage"></i>
-                     <i class="iconfont icon-format-header-2 {{formats.header === 2 ? 'ql-active' : ''}}" data-name="header" data-value="{{2}}"></i>
-                     <i class="iconfont icon-format-header-3 {{formats.header === 3 ? 'ql-active' : ''}}" data-name="header" data-value="{{3}}"></i>
-                     <i class="iconfont icon-zitijiacu {{formats.bold ? 'ql-active' : ''}}" data-name="bold"></i>
-                     <i class="iconfont icon-zitixieti {{formats.italic ? 'ql-active' : ''}}" data-name="italic"></i>
-                     <i class="iconfont icon-zitixiahuaxian {{formats.underline ? 'ql-active' : ''}}" data-name="underline"></i>
-                     <i class="iconfont icon--checklist" data-name="list" data-value="check"></i>
-                     <i class="iconfont icon-youxupailie {{formats.list === 'ordered' ? 'ql-active' : ''}}" data-name="list" data-value="ordered"></i>
-                     <i class="iconfont icon-wuxupailie {{formats.list === 'bullet' ? 'ql-active' : ''}}" data-name="list" data-value="bullet"></i>
-
-                     <i class="iconfont icon-juzhongduiqi {{formats.align === 'center' ? 'ql-active' : ''}}" data-name="align" data-value="center"></i>
-                     <i class="iconfont icon-youduiqi {{formats.align === 'right' ? 'ql-active' : ''}}" data-name="align" data-value="right"></i>
-                     <i class="iconfont icon-zuoyouduiqi {{formats.align === 'justify' ? 'ql-active' : ''}}" data-name="align" data-value="justify"></i>
-                  </view>
-                  <editor style=" min-height:240rpx;" id="editor" class="ql-container" bindinput="getEditorContent" bindready="onEditorReady" placeholder="请输入内容">
-                  </editor>
+                  <hg-editor placeholder="请输入信息内容" name="{{form.content}}" bind:ready="onEditorReady" bind:input="inputChange"> </hg-editor>
                </view>
             </view>
             <view class="content">