Bladeren bron

代码提交

zhaoxiaohai 4 jaren geleden
bovenliggende
commit
cc95ba54bf

+ 2 - 1
app.json

@@ -44,7 +44,8 @@
         "pages/businessPartner/applyFor",
         "pages/storeMessage/select",
         "pages/storeMessage/join",
-        "pages/storeMessage/storehomepage"
+        "pages/storeMessage/storehomepage",
+        "pages/storeMessage/rich-text"
     ],
     "usingComponents": {
         "van-button": "@vant/weapp/button/index",

+ 1 - 1
pages/announceDemand/index.wxml

@@ -9,7 +9,7 @@
         <My_GreyRectangleForm title="需求内容" required>
             <van-field model:value="{{ fcontent }}" data-name="fcontent" bind:focus='inputFocus' bindblur='inputBlur' error="{{errTips.fcontent}}" input-class="input-class" placeholder="点击填写" border="{{ false }}" />
         </My_GreyRectangleForm>
-        <My_GreyRectangleForm title="产品图">
+        <My_GreyRectangleForm title="图">
             <My_UploadFiles id="UploadFiles" fileList="{{attinfos}}" upType="SupplyAndDemand" UploadShow="2" previewSize="60px" maxCount="3" tsupplyanddemand="{{tsupplyanddemand}}" previewSize="65px" bindimageChange="imageChange"></My_UploadFiles>
         </My_GreyRectangleForm>
         <My_GreyRectangleForm title="下架日期">

+ 1 - 1
pages/storeMessage/index.wxml

@@ -37,7 +37,7 @@
         </My_GreyRectangleForm>
 
         <My_GreyRectangleForm title="地址" required>
-            <van-field disabled="{{isDisabled}}" model:value="{{ faddress }}" data-name="faddress" bind:focus='inputFocus' bindblur='inputBlur' error="{{errTips.faddress}}" input-class="input-class" placeholder="点击填写" border="{{ false }}" />
+            <van-field autosize type="textarea" disabled="{{isDisabled}}" model:value="{{ faddress }}" data-name="faddress" bind:focus='inputFocus' bindblur='inputBlur' error="{{errTips.faddress}}" input-class="input-class" placeholder="点击填写" border="{{ false }}" />
         </My_GreyRectangleForm>
         <My_GreyRectangleForm title="统一社会代码">
             <van-field disabled="{{isDisabled}}" model:value="{{ fdutyparagraph }}" input-class="input-class" placeholder="点击填写" border="{{ false }}" />

+ 139 - 0
pages/storeMessage/rich-text.js

@@ -0,0 +1,139 @@
+Page({
+  data: {
+    formats: {},
+    readOnly: false,
+    placeholder: '在这里尽情创作吧!',
+    editorHeight: 300,
+    keyboardHeight: 0,
+    isIOS: false
+  },
+  readOnlyChange() {
+    this.setData({
+      readOnly: !this.data.readOnly
+    })
+  },
+  onLoad() {
+    const platform = wx.getSystemInfoSync().platform
+    const isIOS = platform === 'ios'
+    this.setData({
+      isIOS
+    })
+    const that = this
+    this.updatePosition(0)
+    let keyboardHeight = 0
+    wx.onKeyboardHeightChange(res => {
+      if (res.height === keyboardHeight) return
+      const duration = res.height > 0 ? res.duration * 1000 : 0
+      keyboardHeight = res.height
+      setTimeout(() => {
+        wx.pageScrollTo({
+          scrollTop: 0,
+          success() {
+            that.updatePosition(keyboardHeight)
+            that.editorCtx.scrollIntoView()
+          }
+        })
+      }, duration)
+
+    })
+  },
+  updatePosition(keyboardHeight) {
+    const toolbarHeight = 50
+    const {
+      windowHeight,
+      platform
+    } = wx.getSystemInfoSync()
+    let editorHeight = keyboardHeight > 0 ? (windowHeight - keyboardHeight - toolbarHeight) : windowHeight
+    this.setData({
+      editorHeight,
+      keyboardHeight
+    })
+  },
+  calNavigationBarAndStatusBar() {
+    const systemInfo = wx.getSystemInfoSync()
+    const {
+      statusBarHeight,
+      platform
+    } = systemInfo
+    const isIOS = platform === 'ios'
+    const navigationBarHeight = isIOS ? 44 : 48
+    return statusBarHeight + navigationBarHeight
+  },
+  onEditorReady() {
+    const that = this
+    wx.createSelectorQuery().select('#editor').context(function (res) {
+      that.editorCtx = res.context
+    }).exec()
+  },
+  blur() {
+    this.editorCtx.blur()
+  },
+  format(e) {
+    let {
+      name,
+      value
+    } = e.target.dataset
+    if (!name) return
+    // console.log('format', name, value)
+    this.editorCtx.format(name, value)
+
+  },
+  onStatusChange(e) {
+    const formats = e.detail
+    this.setData({
+      formats
+    })
+  },
+  insertDivider() {
+    this.editorCtx.insertDivider({
+      success: function () {
+        console.log('insert divider success')
+      }
+    })
+  },
+  clickLogText(e) {
+    that.editorCtx.getContents({
+      success: function (res) {
+        console.log(res.html)
+        wx.setStorageSync("content", res.html); // 缓存本地
+        console.log(res.html)
+      }
+    })
+  },
+  clear() {
+    this.editorCtx.clear({
+      success: function (res) {
+        // console.log("clear success")
+      }
+    })
+  },
+  removeFormat() {
+    this.editorCtx.removeFormat()
+  },
+  insertDate() {
+    const date = new Date()
+    const formatDate = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`
+    this.editorCtx.insertText({
+      text: formatDate
+    })
+  },
+  insertImage() {
+    const that = this
+    wx.chooseImage({
+      count: 1,
+      success: function (res) {
+        that.editorCtx.insertImage({
+          src: res.tempFilePaths[0],
+          data: {
+            id: 'abcd',
+            role: 'god'
+          },
+          width: '100%',
+          success: function () {
+            console.log('insert image success')
+          }
+        })
+      }
+    })
+  }
+})

+ 3 - 0
pages/storeMessage/rich-text.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 25 - 0
pages/storeMessage/rich-text.wxml

@@ -0,0 +1,25 @@
+<view class="container" style="height:{{editorHeight}}px;">
+  <editor id="editor" class="ql-container" placeholder="{{placeholder}}" bindstatuschange="onStatusChange" bindready="onEditorReady">
+  </editor>
+</view>
+
+<scroll-view scroll-x="{{true}}">
+  <view class="toolbar" catchtouchend="format" hidden="{{keyboardHeight > 0 ? false : true}}" style="bottom: {{isIOS ? keyboardHeight : 0}}px">
+    <i class="iconfont icon-charutupian" catchtouchend="insertImage"></i>
+    <i class="iconfont icon-format-header-1 {{formats.header === 1 ? 'ql-active' : ''}}" data-name="header" data-value="{{1}}"></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-clearedformat" bindtap="removeFormat"></i>
+    <i class="iconfont icon-shanchu" bindtap="clear"></i>
+    <i class="iconfont icon-undo" bindtap="undo"></i>
+    <i class="iconfont icon-redo" bindtap="redo"></i>
+    <i class="iconfont icon-date" bindtap="redo"></i>
+  </view>
+</scroll-view>

+ 0 - 0
pages/storeMessage/rich-text.wxss


+ 2 - 2
pages/tabbar-pages/supplyAndDemand/index.wxml

@@ -17,7 +17,7 @@
                 </view>
             </view>
             <!-- 列表 -->
-            <My_SupplyAndDemandItemBox data-index="{{index}}" bindtap="jumpForDetails" wx:for="{{productList}}" title="【{{item.ftitle}}】{{item.fcontent}}" time="{{item.checkdate}}" imageList="{{item.attinfos}}" bindstopOnShow="stopOnShow">
+            <My_SupplyAndDemandItemBox data-index="{{index}}" bindtap="jumpForDetails" wx:for="{{productList}}" title="【{{item.ftype}}】{{item.ftitle}}" time="{{item.checkdate}}" imageList="{{item.attinfos}}" bindstopOnShow="stopOnShow">
                 <!-- 内容信息插槽 -->
                 <view slot="dataAndBut">
                     <view class="dataAndBut">
@@ -53,7 +53,7 @@
                 </view>
             </view>
             <!-- 列表 -->
-            <My_SupplyAndDemandItemBox wx:for="{{productList}}" title="【{{item.ftitle}}】{{item.fcontent}}" time="{{item.checkdate}}" imageList="{{item.attinfos}}" data-index="{{index}}" bindtap="jumpForDetails" bindstopOnShow="stopOnShow">
+            <My_SupplyAndDemandItemBox wx:for="{{productList}}" title="【{{item.ftype}}】{{item.ftitle}}" time="{{item.checkdate}}" imageList="{{item.attinfos}}" data-index="{{index}}" bindtap="jumpForDetails" bindstopOnShow="stopOnShow">
                 <!-- 我的需求左上状态插槽 -->
                 <view slot="myState" class="myState">
                     <view class="myShowState {{item.fstatus=='正在对接'?'myNoSoldOut':''}} {{item.fstatus=='待对接'?'myNoSoldOut':''}}">

+ 7 - 0
project.private.config.json

@@ -137,6 +137,13 @@
                     "pathName": "pages/tabbar-pages/message/index",
                     "query": "",
                     "scene": null
+                },
+                {
+                    "name": "富文本",
+                    "pathName": "pages/storeMessage/rich-text",
+                    "query": "",
+                    "scene": null,
+                    "launchMode": "default"
                 }
             ]
         }