zs 2 years ago
parent
commit
8d2eab98b4

+ 1 - 1
app.json

@@ -6,9 +6,9 @@
         "pages/news/index",
         "pages/news/mess",
         "pages/news/add",
+        "pages/news/info",
         "pages/topic/index",
         "pages/topic/mess",
-        "pages/topic/add",
         "pages/my/index",
         "pages/my/userInfo",
         "pages/matchInfo/index",

+ 108 - 0
commpents/hg-editor/hg-editor.js

@@ -0,0 +1,108 @@
+// components/hg-editor/hg-editor.js
+const app = getApp()
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    /**是否显示工具栏 */
+    showTabBar: {
+      type: 'Boolean',
+      value: true
+    },
+    placeholder: {
+      type: 'String',
+      value: '请输入相关内容'
+    },
+    name: {
+      type: 'String',
+      value: ''
+    },
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    _onEditorReady: function () {
+      const that = this;
+      that.createSelectorQuery().select('#editor').context(function (res) {
+        that.editorCtx = res.context
+        that.editorCtx.setContents({
+          html: that.data.name,
+          success: (res) => { },
+          fail: (res) => { console.log(res) }
+        })
+      }).exec()
+    },
+    //插入图片
+    _addImage: function (event) {
+      let _this = this;
+      wx.chooseImage({
+        count: 1,
+        sizeType: ['compressed'],
+        sourceType: ['album'],
+        success: function (res) {
+          _this._uploadImage(res.tempFilePaths[0]);
+        }
+      });
+    },
+    _uploadImage: function (tempFilePath) {
+      let _this = this;
+      wx.uploadFile({
+        url: `${app.globalData.fileUrl}/files/court/elimg/upload`,
+        filePath: tempFilePath,
+        name: 'file',
+        formData: {},
+        success: (res) => {
+          let arr = JSON.parse(res.data);
+          if (arr.errcode == '0') {
+            _this.editorCtx.insertImage({ src: app.globalData.fileUrl + arr.uri });
+          } else {
+            wx.showToast({ title: `${arr.errmsg}`, icon: 'fail', duration: 2000 })
+          }
+        },
+      })
+    },
+    //设置斜体
+    _addItalic: function () {
+      this.editorCtx.format("italic")
+    },
+    //添加粗体样式
+    _addBold: function () {
+      this.editorCtx.format("bold")
+    },
+    //设置标题
+    _addHeader: function (e) {
+      let headerType = e.currentTarget.dataset.header;
+      this.editorCtx.format("header", headerType)
+    },
+    //设置文字的排列方式
+    _addAlign: function (e) {
+      let alignType = e.currentTarget.dataset.align;
+      this.editorCtx.format("align", alignType);
+    },
+    //设置列表
+    _addList: function (e) {
+      let listType = e.currentTarget.dataset.list;
+      this.editorCtx.format("list", listType);
+    },
+    //撤销
+    _undo: function () {
+      this.editorCtx.undo();
+    },
+    //监控输入
+    _onInputting: function (e) {
+      let html = e.detail.html;
+      let text = e.detail.text;
+      this.triggerEvent("input", { html: html, text: text }, {});
+    }
+  }
+})

+ 4 - 0
commpents/hg-editor/hg-editor.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 40 - 0
commpents/hg-editor/hg-editor.wxml

@@ -0,0 +1,40 @@
+<view class="editor-box">
+  <view class="editor-box-header" wx:if="{{showTabBar}}">
+    <view class="operate-box" data-uploadImageURL="{{uploadImageURL}}" bind:tap="_addImage">
+      <text class="iconfont icon-image"></text>
+    </view>
+    <view class="operate-box" bind:tap="_addItalic">
+      <text class="iconfont icon-italic"></text>
+    </view>
+    <view class="operate-box" bind:tap="_addBold">
+      <text class="iconfont icon-bold"></text>
+    </view>
+    <view class="operate-box" data-header="h1" bind:tap="_addHeader">
+      <text class="iconfont icon-h1"></text>
+    </view>
+    <view class="operate-box" data-header="h2" bind:tap="_addHeader">
+      <text class="iconfont icon-h2"></text>
+    </view>
+    <view class="operate-box" data-header="h3" bind:tap="_addHeader">
+      <text class="iconfont icon-h3"></text>
+    </view>
+    <view class="operate-box" data-align="left" bind:tap="_addAlign">
+      <text class="iconfont icon-alignLeft"></text>
+    </view>
+    <view class="operate-box" data-align="right" bind:tap="_addAlign">
+      <text class="iconfont icon-alignRight"></text>
+    </view>
+    <view class="operate-box" data-list="ordered" bind:tap="_addList">
+      <text class="iconfont icon-orderedList"></text>
+    </view>
+    <view class="operate-box" data-list="bullet" bind:tap="_addList">
+      <text class="iconfont icon-unorderedList"></text>
+    </view>
+    <view class="operate-box" bind:tap="_undo">
+      <text class="iconfont icon-undo"></text>
+    </view>
+  </view>
+  <view class="editor-box-content">
+    <editor id="editor" name="{{name}}" placeholder="{{placeholder}}" bind:ready="_onEditorReady" bind:input="_onInputting" show-img-resize="{{true}}"></editor>
+  </view>
+</view>

+ 39 - 0
commpents/hg-editor/hg-editor.wxss

@@ -0,0 +1,39 @@
+/* components/hg-editor/hg-editor.wxss */
+@import "iconfont.wxss";
+
+.editor-box {
+  width: 100%;
+  padding: 0;
+  box-sizing: border-box;
+  background-color: #fff;
+  border:2px solid #f6f6f6;
+}
+
+.editor-box-header,
+.editor-box-content {
+  width: 100%;
+}
+
+.editor-box-header {
+  display: flex;
+  flex-flow: row nowrap;
+  align-items: center;
+  justify-content:flex-start;
+  padding: 20rpx 20rpx;
+  box-sizing: border-box;
+  border-bottom: 2rpx solid #f6f6f6;
+  background-color: #f6f6f6;
+}
+
+.editor-box-header>.operate-box {
+  margin-right: 20rpx;
+  width: 40rpx;
+  height: 40rpx;
+  overflow: hidden;
+  color:gray;
+}
+
+.editor-box-content{
+  padding:20rpx;
+  box-sizing: border-box;
+}

+ 67 - 0
commpents/hg-editor/iconfont.wxss

@@ -0,0 +1,67 @@
+@font-face {
+  font-family: 'iconfont';  /* Project id 2549449 */
+  src: url('//at.alicdn.com/t/font_2549449_hxmflg4qsr6.woff2?t=1621002720450') format('woff2'),
+       url('//at.alicdn.com/t/font_2549449_hxmflg4qsr6.woff?t=1621002720450') format('woff'),
+       url('//at.alicdn.com/t/font_2549449_hxmflg4qsr6.ttf?t=1621002720450') format('truetype');
+}
+
+.iconfont {
+  font-family: "iconfont" !important;
+  font-size: 38rpx;
+  font-style: normal;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+}
+
+.icon-undo:before {
+  content: "\e609";
+}
+
+.icon-hr:before {
+  content: "\e60a";
+}
+
+.icon-h3:before {
+  content: "\e60b";
+}
+
+.icon-quote:before {
+  content: "\e60c";
+}
+
+.icon-bold:before {
+  content: "\e60e";
+}
+
+.icon-orderedList:before {
+  content: "\e612";
+}
+
+.icon-h2:before {
+  content: "\e61a";
+}
+
+.icon-italic:before {
+  content: "\e61c";
+}
+
+.icon-unorderedList:before {
+  content: "\e620";
+}
+
+.icon-alignLeft:before {
+  content: "\e621";
+}
+
+.icon-alignRight:before {
+  content: "\e622";
+}
+
+.icon-h1:before {
+  content: "\e623";
+}
+
+.icon-image:before {
+  content: "\e629";
+}
+

+ 49 - 28
pages/news/add.js

@@ -1,7 +1,8 @@
 const app = getApp()
 import WxValidate from '../../utils/wxValidate'
-import { is_use_project } from '../../utils/dict';
-
+const moment = require("../../utils/moment.min")
+import { is_show_project } from '../../utils/dict';
+import { news_type } from '../../utils/dict';
 Page({
 
     /**
@@ -10,51 +11,76 @@ Page({
     data: {
         frameStyle: { useTop: true, name: '信息管理', leftArrow: true, useBar: false },
         id: '',
-        // 裁判列表
-        referee_idList: [],
+        // 图片
+        icon: [],
+        form: {},
         // 是否使用
-        is_useList: is_use_project,
-        form: {}
-
+        is_showList: is_show_project,
+        typeList: news_type,
     },
     initValidate() {
-        const rules = { name: { required: true }, referee_id: { required: false }, remark: { required: false }, is_use: { required: false } }
+        const rules = { title: { required: true }, type: { required: true }, origin: { required: true }, brief: { required: true }, is_show: { required: true } }
         // 验证字段的提示信息,若不传则调用默认的信息
-        const messages = { name: { required: '请输入场地名称', }, referee_id: { required: '请选择裁判', }, remark: { required: '请输入备注', }, is_use: { required: '请选择是否使用' } };
+        const messages = { title: { required: '请输入资讯名称', }, type: { required: '请输入资讯类型', }, origin: { required: '请输入来源', }, brief: { required: '请输入内容' }, is_show: { required: '请选择是否公开' } };
         this.WxValidate = new WxValidate(rules, messages)
     },
     // 返回
     back: function () {
         wx.navigateBack({ delta: 1 })
     },
-    // 选择裁判
-    referee_idChange: function (e) {
+    //用户输入内容
+    inputChange: function (e) {
+        const that = this;
+        let html = e.detail.html;
+        that.setData({ "form.content": html });
+    },
+    // 选择类型
+    typeChange: function (e) {
         const that = this;
-        let index = e.detail.value;
-        let value = that.data.referee_idList[index];
-        that.setData({ 'form.referee_id': value.openid });
-        that.setData({ 'form.referee_name': value.name });
+        let data = that.data.typeList[e.detail.value];
+        if (data) that.setData({ 'form.type': data.value })
     },
     // 是否使用
-    is_useChange: function (e) {
+    is_showChange: function (e) {
+        const that = this;
+        let data = that.data.is_showList[e.detail.value];
+        that.setData({ 'form.is_show': data.value });
+    },
+    // 上傳圖片
+    imgUpload: function (e) {
         const that = this;
-        let index = e.detail.value;
-        let value = that.data.is_useList[index];
-        that.setData({ 'form.is_use': value.value });
+        let data = that.data.icon;
+        data.push(e.detail)
+        that.setData({ icon: data })
+    },
+    // 删除图片
+    imgDel: function (e) {
+        const that = this;
+        let list = that.data.icon;
+        let arr = list.filter((i, index) => index != e.detail.index)
+        that.setData({ icon: arr })
     },
     // 提交登录
     onSubmit: async function (e) {
         const that = this;
         const params = e.detail.value;
+        params.create_time = moment().format('YYYY-MM-DD');
         const data = that.data.form;
+        params.content = data.content;
         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/ground/${data._id}`, params);
-            else arr = await app.$post(`/newCourt/api/ground`, params);
+            if (data._id) {
+                if (!params.icon) params.home_url = that.data.icon;
+                arr = await app.$post(`/newCourt/api/news/${data._id}`, params);
+            }
+            else {
+                params.home_url = that.data.icon;
+                arr = await app.$post(`/newCourt/api/news`, params);
+            }
             if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
             else wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
 
@@ -77,18 +103,13 @@ Page({
         wx.getStorage({
             key: 'user',
             success: async res => {
-                const arr = await app.$get(`/newCourt/api/user`, { type: 1, skip: 0, limit: 1000 });
-                if (arr.errcode == '0') { that.setData({ referee_idList: arr.data }); }
                 if (that.data.id) {
-                    const arr = await app.$get(`/newCourt/api/ground/${that.data.id}`);
+                    const arr = await app.$get(`/newCourt/api/news/${that.data.id}`);
                     if (arr.errcode == '0') {
-                        let user = that.data.referee_idList.find((i) => i.openid == arr.data.referee_id);
-                        if (user) arr.data.referee_name = user.name;
+                        if (arr.data.home_url) that.setData({ icon: arr.data.home_url });
                         that.setData({ form: arr.data });
                     }
                 }
-
-
             },
             fail: res => {
                 wx.redirectTo({ url: '/pages/index/index', })

+ 3 - 1
pages/news/add.json

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

+ 0 - 4
pages/news/add.less

@@ -21,10 +21,6 @@
                 color: #666;
                 font-size: 16px;
                 text-align: right;
-
-                textarea {
-                    max-width: 220px;
-                }
             }
         }
 

+ 25 - 12
pages/news/add.wxml

@@ -1,29 +1,42 @@
-<mobile-main frameStyle="{{frameStyle}}" bind:back="back" bind:tabPath="tabPath">
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
     <view slot="info" class="container main">
         <view class="one">
             <form catchsubmit="onSubmit">
                 <view class="content">
-                    <view class="label">场地名称</view>
+                    <view class="label">资讯标题</view>
+                    <view class="value"><textarea name="title" value="{{form.title}}" auto-height placeholder="请输入资讯标题" /></view>
+                </view>
+                <view class="content">
+                    <view class="label">资讯图片</view>
                     <view class="value">
-                        <view class="value"><input name="name" value="{{form.name}}" placeholder="请输入比赛场地名称" /></view>
+                        <vanupload list="{{icon}}" count="{{1}}" previewSize="{{50}}" bind:imgUpload="imgUpload" bind:imgDel="imgDel"></vanupload>
                     </view>
                 </view>
                 <view class="content">
-                    <view class="label">裁判:</view>
-                    <picker name="referee_id" bindchange="referee_idChange" value="{{form.referee_id}}" range-key='name' range="{{referee_idList}}">
-                        <view class="input">{{form.referee_name||'请选择裁判'}}</view>
-                    </picker>
+                    <view class="label">资讯类型</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="typeChange" value="{{form.type}}" name="type" range-key='label' range="{{typeList}}">
+                            <view class="input">{{form.type=='0'?'其他':form.type=='1'?'羽毛球':'请选择资讯类型'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">信息来源</view>
+                    <view class="value"><input name="origin" value="{{form.origin}}" placeholder="请输入信息来源" /></view>
+                </view>
+                <view class="content">
+                    <view class="label">信息简介</view>
+                    <view class="value"><textarea name="brief" value="{{form.brief}}" auto-height placeholder="请输入信息简介" /></view>
                 </view>
                 <view class="content">
-                    <view class="label">备注:</view>
                     <view class="value">
-                        <view class="value"><input name="remark" value="{{form.remark}}" placeholder="请输入备注" /></view>
+                        <hg-editor placeholder="请输入信息内容" name="{{form.content}}" bind:ready="onEditorReady" bind:input="inputChange"> </hg-editor>
                     </view>
                 </view>
                 <view class="content">
-                    <view class="label">是否使用:</view>
-                    <picker name="is_use" bindchange="is_useChange" value="{{form.is_use}}" range-key='label' range="{{is_useList}}">
-                        <view class="input">{{form.is_use=='0'?'启用':form.is_use=='1'?'禁用':'选择是否使用'}}</view>
+                    <view class="label">是否公开</view>
+                    <picker name="is_show" bindchange="is_showChange" value="{{form.is_show}}" range-key='label' range="{{is_showList}}">
+                        <view class="input">{{form.is_show=='0'?'公开':form.is_show=='1'?'不公开':'是否公开'}}</view>
                     </picker>
                 </view>
                 <view class="btn">

+ 0 - 3
pages/news/add.wxss

@@ -21,9 +21,6 @@
   font-size: 16px;
   text-align: right;
 }
-.main .one .content .value textarea {
-  max-width: 220px;
-}
 .main .one .btn {
   width: 96vw;
   margin: 2vw 0 0 0;

+ 37 - 16
pages/news/index.js

@@ -1,4 +1,5 @@
 const app = getApp()
+import { news_type } from '../../utils/dict';
 Page({
 
     /**
@@ -7,38 +8,38 @@ Page({
     data: {
         frameStyle: { useTop: true, name: '资讯', leftArrow: false, useBar: true },
         tabs: {
-            active: 'a',
+            active: '0',
             list: [
-                { title: '推荐', name: 'a' },
-                { title: '羽毛球', name: 'b' },
+                { title: '推荐', name: '0' },
+                { title: '羽毛球', name: '1' },
             ],
         },
         //查询条件
         searchInfo: {},
-        list: [
-            {
-                id: "1",
-                name: '辽源市第一届青少年羽毛球公开赛暨“小虎杯”羽毛球争霸赛',
-                brief: '辽源市第一届青少年羽毛球公开赛暨“小虎杯”羽毛球争霸赛辽源市第一届青少年羽毛球公开赛暨“小虎杯”羽毛球争霸赛辽源市第一届青少年羽毛球公开赛暨“小虎杯”羽毛球争霸赛',
-                type: '其他',
-                origin: '网络',
-                img_url: [{ url: '/image/icon.jpg' }]
-            }
-        ],
+        list: [],
+        typeList: news_type,
     },
     // 跳转菜单
     tabPath(e) {
         let { route } = e.detail.detail;
         if (route) wx.redirectTo({ url: `/${route}` })
     },
+    // 详情页
+    toView: function (e) {
+        let { id } = e.currentTarget.dataset;
+        wx.navigateTo({ url: `/pages/news/info?id=${id}` })
+    },
     // 选项卡
     tabsChange: function (e) {
         const that = this;
         that.setData({ 'tabs.active': e.detail.name });
+        that.watchLogin();
     },
     //搜索
-    onSearch() {
-        console.log("搜索");
+    onSearch: function (e) {
+        const that = this;
+        that.setData({ 'searchInfo.name': e.detail.value });
+        that.watchLogin()
     },
     /**
      * 生命周期函数--监听页面加载
@@ -47,6 +48,26 @@ Page({
         const that = this;
 
     },
+    watchLogin: function () {
+        const that = this;
+        let searchInfo = that.data.searchInfo;
+        let type = that.data.tabs.active;
+        wx.getStorage({
+            key: 'user',
+            success: async (res) => {
+                let info = { skip: 0, limit: 1000 };
+                if (searchInfo && searchInfo.name) info.title = searchInfo.name;
+                info.type = type; info.is_show = "0";
+                const arr = await app.$get(`/newCourt/api/news`, { ...info });
+                if (arr.errcode == '0') {
+                    that.setData({ list: arr.data })
+                } else { wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 }); }
+            },
+            fail: async (res) => {
+                wx.redirectTo({ url: '/pages/index/index' });
+            },
+        });
+    },
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
@@ -58,7 +79,7 @@ Page({
      * 生命周期函数--监听页面显示
      */
     onShow: function () {
-
+        this.watchLogin();
     },
 
     /**

+ 12 - 12
pages/news/index.wxml

@@ -4,48 +4,48 @@
             <e-tabs tabs="{{tabs}}" bind:tabsChange="tabsChange"></e-tabs>
         </view>
         <view class="zero two">
-            <view class="a" wx:if="{{tabs.active=='a'}}">
+            <view class="a" wx:if="{{tabs.active=='0'}}">
                 <view class="two_1">
-                    <input type="text" value="{{searchInfo.name}}" placeholder="请输入关键词" />
+                    <input type="text" value="{{searchInfo.name}}" bindconfirm="onSearch" placeholder="请输入关键词" />
                 </view>
                 <view class="two_2">
                     <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="toView" data-id="{{item._id}}">
                                 <view class="list_1">
-                                    <view class="name">{{item.name}}</view>
+                                    <view class="name">{{item.title}}</view>
                                     <view class="brief">{{item.brief}}</view>
                                     <view class="other">
-                                        <text>{{item.type}}</text>
+                                        <text>{{typeList[item.type].label||'暂无'}}</text>
                                         <text>来源:{{item.origin}}</text>
                                     </view>
                                 </view>
                                 <view class="list_2">
-                                    <image class="image" src="{{item.img_url&&item.img_url.length>0?item.img_url[0].url:''}}"></image>
+                                    <image class="image" src="{{item.home_url&&item.home_url.length>0?item.home_url[0].url:''}}"></image>
                                 </view>
                             </view>
                         </view>
                     </scroll-view>
                 </view>
             </view>
-            <view class="a" wx:elif="{{tabs.active=='b'}}">
+            <view class="a" wx:elif="{{tabs.active=='1'}}">
                 <view class="two_1">
-                    <input type="text" value="{{searchInfo.name}}" placeholder="请输入关键词" />
+                    <input type="text" value="{{searchInfo.name}}" bindconfirm="onSearch" placeholder="请输入关键词" />
                 </view>
                 <view class="two_2">
                     <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="toView" data-id="{{item._id}}">
                                 <view class="list_1">
-                                    <view class="name">{{item.name}}</view>
+                                    <view class="name">{{item.title}}</view>
                                     <view class="brief">{{item.brief}}</view>
                                     <view class="other">
-                                        <text>{{item.type}}</text>
+                                        <text>{{typeList[item.type].label||'暂无'}}</text>
                                         <text>来源:{{item.origin}}</text>
                                     </view>
                                 </view>
                                 <view class="list_2">
-                                    <image class="image" src="{{item.img_url&&item.img_url.length>0?item.img_url[0].url:''}}"></image>
+                                    <image class="image" src="{{item.home_url&&item.home_url.length>0?item.home_url[0].url:''}}"></image>
                                 </view>
                             </view>
                         </view>

+ 95 - 0
pages/news/info.js

@@ -0,0 +1,95 @@
+const app = getApp()
+import { news_type } from '../../utils/dict';
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        frameStyle: { useTop: true, name: '详情信息', leftArrow: true, useBar: false },
+        id: '',
+        form: {},
+        typeList: news_type,
+    },
+    // 返回
+    back: function () {
+        wx.navigateBack({ delta: 1 })
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        const that = this;
+        that.setData({ id: options.id || '' })
+        // 监听用户是否登录
+        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/news/${that.data.id}`);
+                    if (arr.errcode == '0') {
+                        that.setData({ form: arr.data });
+                        let content = arr.data.content.replace(/\<img/gi, '<img style="width:100%;height:auto;margin: 5px 0"');
+                        this.setData({ 'form.content': content });
+                    }
+                }
+            },
+            fail: res => {
+                wx.redirectTo({ url: '/pages/index/index', })
+            }
+        })
+    },
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 6 - 0
pages/news/info.json

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

+ 33 - 0
pages/news/info.less

@@ -0,0 +1,33 @@
+.main {
+    height: 88.8vh;
+
+    .one {
+        width: 96vw;
+        border-bottom: 1px dashed #cccccc;
+
+        .one_1 {
+            text-align: center;
+            font-weight: 500;
+            font-size: 18px;
+            padding: 5px 0;
+        }
+
+        .one_2 {
+            display: flex;
+            justify-content: space-between;
+            font-size: 16px;
+            color: #666666;
+            padding: 5px 0;
+
+            text {
+                padding-right: 5px;
+            }
+        }
+    }
+
+    .two {
+        width: 96vw;
+        padding: 5px;
+    }
+
+}

+ 17 - 0
pages/news/info.wxml

@@ -0,0 +1,17 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        <view class="one">
+            <view class="one_1">{{form.title}}</view>
+            <view class="one_2">
+                <view class="type">
+                    <text>{{typeList[form.type].label||'暂无'}}</text>
+                    <text>来源:{{form.origin||'暂无'}}</text>
+                </view>
+                <view class="time">{{form.create_time||'暂无'}}</view>
+            </view>
+        </view>
+        <view class="two">
+            <rich-text nodes="{{form.content}}"></rich-text>
+        </view>
+    </view>
+</mobile-main>

+ 27 - 0
pages/news/info.wxss

@@ -0,0 +1,27 @@
+.main {
+  height: 88.8vh;
+}
+.main .one {
+  width: 96vw;
+  border-bottom: 1px dashed #cccccc;
+}
+.main .one .one_1 {
+  text-align: center;
+  font-weight: 500;
+  font-size: 18px;
+  padding: 5px 0;
+}
+.main .one .one_2 {
+  display: flex;
+  justify-content: space-between;
+  font-size: 16px;
+  color: #666666;
+  padding: 5px 0;
+}
+.main .one .one_2 text {
+  padding-right: 5px;
+}
+.main .two {
+  width: 96vw;
+  padding: 5px;
+}

+ 11 - 4
pages/news/mess.js

@@ -1,5 +1,5 @@
 const app = getApp()
-
+import { news_type } from '../../utils/dict';
 Page({
 
     /**
@@ -9,12 +9,14 @@ Page({
         frameStyle: { useTop: true, name: '资讯信息管理', leftArrow: true, useBar: false },
         searchInfo: {},
         list: [],
+        typeList: news_type,
     },
     // 跳转菜单
     back(e) {
         wx.navigateBack({ delta: 1 });
     },
-    search: function (e) {
+    //查询
+    onSearch: function (e) {
         const that = this;
         that.setData({ 'searchInfo.name': e.detail.value });
         that.watchLogin()
@@ -37,7 +39,7 @@ Page({
             content: '是否确认删除该条数据?',
             async success(res) {
                 if (res.confirm) {
-                    const arr = await app.$delete(`/newCourt/api/ground/${id}`);
+                    const arr = await app.$delete(`/newCourt/api/news/${id}`);
                     if (arr.errcode == '0') {
                         wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
                         that.watchLogin()
@@ -48,6 +50,11 @@ Page({
             }
         })
     },
+    // 关闭弹框
+    toClose: function () {
+        const that = this;
+        that.setData({ dialog: { title: '详细信息', show: false, type: '1' } })
+    },
     /**
      * 生命周期函数--监听页面加载
      */
@@ -64,7 +71,7 @@ Page({
             success: async (res) => {
                 let info = { skip: 0, limit: 1000 };
                 if (searchInfo && searchInfo.name) info.name = searchInfo.name;
-                const arr = await app.$get(`/newCourt/api/ground`, { ...info });
+                const arr = await app.$get(`/newCourt/api/news`, { ...info });
                 if (arr.errcode == '0') {
                     that.setData({ list: arr.data })
                 } else { wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 }); }

+ 14 - 10
pages/news/mess.wxml

@@ -2,7 +2,7 @@
     <view slot="info" class="container main">
         <view class="zero one">
             <view class="one_1">
-                <input type="text" value="{{searchInfo.name}}" bindconfirm="search" placeholder="请输入资讯名称" />
+                <input type="text" value="{{searchInfo.name}}" bindconfirm="onSearch" placeholder="请输入资讯名称" />
             </view>
             <view class="one_2">
                 <button type="primary" bindtap="toAdd">添加</button>
@@ -16,26 +16,30 @@
                             <view class="list_2">
                                 <view class="other">
                                     <view class="other_1">
-                                        <text>比赛场地名称:</text>
-                                        <text>{{item.name||'暂无'}}</text>
+                                        <text>资讯标题:</text>
+                                        <text>{{item.title||'暂无'}}</text>
                                     </view>
                                     <view class="other_1">
-                                        <text>裁判:</text>
-                                        <text>{{item.referee_name||'暂无'}}</text>
+                                        <text>资讯类型:</text>
+                                        <text>{{typeList[item.type].label}}</text>
                                     </view>
                                     <view class="other_1">
-                                        <text>备注:</text>
-                                        <text>{{item.remark||'暂无'}}</text>
+                                        <text>信息来源:</text>
+                                        <text>{{item.origin||'暂无'}}</text>
                                     </view>
                                     <view class="other_1">
-                                        <text>是否使用:</text>
-                                        <text>{{item.is_use=='0'?'启用':'禁用'}}</text>
+                                        <text>发布时间:</text>
+                                        <text>{{item.create_time||'暂无'}}</text>
+                                    </view>
+                                    <view class="other_1">
+                                        <text>是否公开:</text>
+                                        <text>{{item.is_show=='0'?'公开':'不公开'}}</text>
                                     </view>
                                 </view>
                             </view>
                         </view>
                         <view class="btn">
-                            <button type="primary" bindtap="toEdit" data-id="{{item._id}}" size="mini">信息维护</button>
+                            <button size="mini" type="primary" bindtap="toEdit" data-id="{{item._id}}">信息维护</button>
                             <button size="mini" type="warn" bindtap="toDel" data-id="{{item._id}}">信息删除</button>
                         </view>
                     </view>

+ 0 - 42
pages/topic/add.less

@@ -1,42 +0,0 @@
-.main {
-    height: 88.8vh;
-
-    .one {
-        width: 96vw;
-
-        .content {
-            display: flex;
-            flex-direction: row;
-            justify-content: space-between;
-            align-items: center;
-            margin: 0 10px;
-            padding: 10px 5px;
-            border-bottom: 1px solid #cccccc;
-
-            .label {
-                font-size: 15px;
-            }
-
-            .value {
-                color: #666;
-                font-size: 16px;
-                text-align: right;
-
-                textarea {
-                    max-width: 220px;
-                }
-            }
-        }
-
-        .btn {
-            width: 96vw;
-            margin: 2vw 0 0 0;
-            text-align: center;
-
-            button {
-                font-size: 14px;
-            }
-        }
-    }
-
-}

+ 0 - 35
pages/topic/add.wxml

@@ -1,35 +0,0 @@
-<mobile-main frameStyle="{{frameStyle}}" bind:back="back" bind:tabPath="tabPath">
-    <view slot="info" class="container main">
-        <view class="one">
-            <form catchsubmit="onSubmit">
-                <view class="content">
-                    <view class="label">场地名称</view>
-                    <view class="value">
-                        <view class="value"><input name="name" value="{{form.name}}" placeholder="请输入比赛场地名称" /></view>
-                    </view>
-                </view>
-                <view class="content">
-                    <view class="label">裁判:</view>
-                    <picker name="referee_id" bindchange="referee_idChange" value="{{form.referee_id}}" range-key='name' range="{{referee_idList}}">
-                        <view class="input">{{form.referee_name||'请选择裁判'}}</view>
-                    </picker>
-                </view>
-                <view class="content">
-                    <view class="label">备注:</view>
-                    <view class="value">
-                        <view class="value"><input name="remark" value="{{form.remark}}" placeholder="请输入备注" /></view>
-                    </view>
-                </view>
-                <view class="content">
-                    <view class="label">是否使用:</view>
-                    <picker name="is_use" bindchange="is_useChange" value="{{form.is_use}}" range-key='label' range="{{is_useList}}">
-                        <view class="input">{{form.is_use=='0'?'启用':form.is_use=='1'?'禁用':'选择是否使用'}}</view>
-                    </picker>
-                </view>
-                <view class="btn">
-                    <button type="primary" size="mini" formType="submit">提交保存</button>
-                </view>
-            </form>
-        </view>
-    </view>
-</mobile-main>

+ 0 - 34
pages/topic/add.wxss

@@ -1,34 +0,0 @@
-.main {
-  height: 88.8vh;
-}
-.main .one {
-  width: 96vw;
-}
-.main .one .content {
-  display: flex;
-  flex-direction: row;
-  justify-content: space-between;
-  align-items: center;
-  margin: 0 10px;
-  padding: 10px 5px;
-  border-bottom: 1px solid #cccccc;
-}
-.main .one .content .label {
-  font-size: 15px;
-}
-.main .one .content .value {
-  color: #666;
-  font-size: 16px;
-  text-align: right;
-}
-.main .one .content .value textarea {
-  max-width: 220px;
-}
-.main .one .btn {
-  width: 96vw;
-  margin: 2vw 0 0 0;
-  text-align: center;
-}
-.main .one .btn button {
-  font-size: 14px;
-}

+ 5 - 0
utils/dict.js

@@ -148,4 +148,9 @@ export const paystatusList = [
     { label: '支付失败', value: '-1' },
     { label: '申请退款', value: '-2' },
     { label: '已退款', value: '-3' },
+]
+//资讯类型
+export const news_type = [
+    { label: '其他', value: '0' },
+    { label: '羽毛球', value: '1' },
 ]