Commit 55cb233b authored by baixian's avatar baixian

打卡完成

parent d024c385
......@@ -115,6 +115,7 @@ App({
originScene: '', // 页面进去的场景值
studentSchoolId: 0,
currentSchoolStudentId: 0,
sdkVersion: 0, //基础库版本
},
getCurrentSchoolStudentId (data) {
return studentidentity({
......@@ -212,6 +213,7 @@ App({
this.globalData.navHeight = parseInt(titleBarHeight) + parseInt(statusBarHeight);
this.globalData.windowWidth = res.windowWidth || 375;
this.globalData.windowHeight = res.windowHeight;
this.globalData.sdkVersion = SDKVersion
}
} catch (err){
......
......@@ -242,6 +242,12 @@ Page({
confirmId: 0,
// has_subjects_count: 0
},
// // 测试
// change_editor: function (e) {
// this.setData({
// 'params.title': e.detail.value
// });
// },
onLoad: function(options) { // Do some initialize when page load.
const that = this;
const {
......
......@@ -9,6 +9,7 @@
"w-cell-group": "/dist/w-cell-group/index",
"w-pane": "/dist/w-pane/index",
"expiredTip": "../../components/expiredTip",
"calender":"../../components/calendar"
"calender":"../../components/calendar",
"richtext": "../../../components/richTextarea"
}
}
\ No newline at end of file
......@@ -28,6 +28,15 @@
</view>
</view>
</view>
<!-- <view class="section-wrap pdlpdr24" style="margin-bottom: 0;">
<view class="section-item" style="padding-bottom: 8px;">
<view class="form-item title" >
<view class="item-l">测试textarea</view>
</view>
</view>
</view>
<richtext value="{{params.title}}" richStyle="padding:25rpx 0;border-top:1px solid #f0f0f0;" placeholder='此处填写标题,最多100字' bindinput="change_editor" maxlength="10000" /> -->
<view class="section-wrap pdlpdr24" style="margin-bottom: 0;">
<view class="section-item" style="padding-bottom: 8px;">
<view class="form-item title" >
......
// components/richTextarea/index.js
const app = getApp();
console.log(app.globalData.sdkVersion, 'app.globalData.sdkVersion');
Component({
/**
* 组件的属性列表
*/
properties: {
text_height: {
type: String,
observer: function (newVal, oldVal) {
this.setData({
text_height: newVal ? newVal : "350rpx"
});
}
},
id: {
type: String,
observer: function (newVal, oldVal) {
this.setData({
id: newVal
});
}
},
maxlength: {
type: String,
value: '-1',
observer: function (newVal, oldVal) {
this.setData({
maxlength: newVal
});
}
},
richStyle: {
type: String,
observer: function (newVal, oldVal) {
this.setData({
richStyle: newVal
});
}
},
placeholder: {
type: String,
observer: function (newVal, oldVal) {
this.setData({
placeholder: newVal
});
}
},
value: {
type: String,
observer: function (newVal, oldVal) {
this.setData({
value: newVal
});
if (this.data.isFirst) {
this.setData({
isFirst: false
});
this.setContent(newVal);
}
}
},
},
/**
* 组件的初始数据
*/
data: {
value: null,
isFirst: true,
showType: app.globalData.sdkVersion >= 270 ? 3 : 1 //1=view;2=textarea;3=editor
},
/**
* 组件的方法列表
*/
methods: {
text_show: function () {
setTimeout(()=>{
this.setData({
showType: 2,
})
}, 50)
},
view_show: function (e) { //失去光标 view显示 textarea隐藏
this.setData({
showType: 1,
value: e.detail.value
})
},
bindinput: function (e) {
this.triggerEvent("input", e.detail)
},
editorinput: function (e) {
e.detail.value = e.detail.text;
this.triggerEvent("input", e.detail)
},
onEditorReady: function (e) {
const that = this
this.createSelectorQuery().select('#editor').context(function (res) {
that.editor = res.context;
}).exec();
},
setContent: function (value) {
let showType = this.data.showType;
if (showType == 3) {
if (this.editor) {
this.editor.setContents({
html: value
});
wx.pageScrollTo({
scrollTop: 0,
duration: 0
})
} else {
setTimeout(() => {
this.setContent(value);
}, 50)
}
}
},
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--components/richTextarea/index.wxml-->
<view style='{{richStyle}}'>
<view class='textarea placeholder-tip' style='min-height:{{text_height}}' wx:if='{{showType==1&&(value==null||value=="") }}' bindtap='text_show'>{{placeholder}}</view>
<view class='textarea' wx:if='{{showType==1&&value!=null&&value!="" }}' bindtap='text_show'>{{value}}</view>
<textarea class='textarea' style='min-height:{{text_height}}' wx:if='{{showType==2 }}' placeholder-class='placeholder-tip' maxlength='{{maxlength}}' auto-focus='{{showType==2 }}' focus='{{showType==2 }}' placeholder="{{placeholder}}" bindinput='bindinput' bindblur='view_show' value="{{value}}"></textarea>
<editor wx:if='{{showType==3}}' id="editor" class='textarea' bindinput="editorinput" bindready="onEditorReady" placeholder='{{placeholder}}' style='min-height:{{text_height}}'></editor>
</view>
\ No newline at end of file
/* components/richTextarea/index.wxss */
.textarea {
font-size: 24rpx;
color: #000;
width: 100%;
min-height: 350rpx;
height: auto;
line-height: 32rpx;
white-space: pre-wrap;
}
.placeholder-tip {
font-size: 24rpx;
color: #999;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment