noteBox.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view>
  3. <view v-if="noteList.length == 0" style="text-align: center">暂无笔记</view>
  4. <view v-for="(item, index) in noteList" :key="index">
  5. <view class="dateBox">{{ $method.timestampToTime(item.dateNote) }}</view>
  6. <view class="noteBox">
  7. <view v-for="(item1, index1) in item.userNotes" :key="index1" style="margin-top: 30rpx"
  8. @click="jumpNote(item1)">
  9. <view style="display: flex">
  10. <view class="left_ti">
  11. <view>
  12. <image src="/static/icon/note2.png" v-if="noteId != item1.noteId"
  13. style="width: 39rpx; height: 39rpx; margin: 0 29rpx"></image>
  14. <image src="/static/icon/note1.png" v-if="noteId == item1.noteId"
  15. style="width: 39rpx; height: 39rpx; margin: 0 29rpx"></image>
  16. </view>
  17. <view class="title" style="width: 39rpx; height: 39rpx; margin: 0 29rpx">
  18. {{ $method.secondToDate(item1.noteSecond) }}
  19. </view>
  20. </view>
  21. <view style="margin-left: 10rpx">
  22. <view class="t2Content leftPadding">{{ item1.sectionName }}</view>
  23. <view class="tBox2">{{ item1.noteText }}</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="inputBottom" v-if="isShowInput" :style="{ bottom: bottomHeight + 'px' }">
  30. <view style="width: 10%">
  31. <image src="/static/icon/note3.png" style="width: 39rpx; height: 39rpx; margin: 0 29rpx"></image>
  32. </view>
  33. <view style="width: 73%; height: 100%; padding: 10rpx 0">
  34. <input v-model="noteValue" height="60" fixed="true" placeholder="您可以在这里输入笔记内容" type="text"
  35. :custom-style="inputStyle" :adjust-position="false" class="input" @focus="focusNote"
  36. @blur="blurNote" />
  37. </view>
  38. <view style="
  39. color: #007aff;
  40. font-size: 30rpx;
  41. font-weight: bold;
  42. width: 15%;
  43. text-align: center;
  44. " @click="postNote">提交</view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. name: "SaasMiniprogramNoteBox",
  51. inject: ["paramsFn"],
  52. data() {
  53. return {
  54. noteList: [],
  55. noteId: 0,
  56. noteValue: "",
  57. inputStyle: {
  58. background: "rgba(244, 244, 244, 0.98)",
  59. borderRadius: "24rpx",
  60. padding: "8rpx",
  61. marginBottom: "10rpx",
  62. },
  63. bottomHeight: 0,
  64. };
  65. },
  66. methods: {
  67. getNoteList() {
  68. this.$api.noteList(this.params).then((res) => {
  69. if (res.data.code == 200) {
  70. this.noteList = res.data.rows;
  71. }
  72. });
  73. },
  74. jumpNote(item) {
  75. this.noteId = item.noteId;
  76. this.$emit("jumpNote", item);
  77. },
  78. postNote() {
  79. let self = this;
  80. if (!(this.sectionId > 0)) {
  81. this.$u.toast("目前无播放视频");
  82. return;
  83. }
  84. if (!this.noteValue) {
  85. this.$u.toast("请输入内容");
  86. return;
  87. }
  88. if (!this.params.gradeId) {
  89. this.$u.toast("暂无班级数据");
  90. return;
  91. }
  92. let noteSecond = this.params.playTime;
  93. if (!noteSecond) {
  94. this.$u.toast("视频暂未开始");
  95. return;
  96. }
  97. let data = {
  98. noteText: this.noteValue,
  99. noteDate: this.$method.getZeroTime(),
  100. noteSecond: noteSecond,
  101. ...this.params,
  102. };
  103. this.$api.postNote(data).then((res) => {
  104. if (res.data.code == 200) {
  105. this.$u.toast("发布成功");
  106. self.getNoteList();
  107. this.noteValue = "";
  108. }
  109. });
  110. },
  111. blurNote() {
  112. this.bottomHeight = 0;
  113. },
  114. focusNote(event) {
  115. this.bottomHeight = event.detail.height;
  116. },
  117. },
  118. computed: {
  119. params() {
  120. return this.paramsFn([
  121. "orderGoodsId",
  122. "gradeId",
  123. "goodsId",
  124. "courseId",
  125. "playTime",
  126. "isPlayRebuild",
  127. "moduleId",
  128. "chapterId",
  129. "sectionId"
  130. ]);
  131. },
  132. sectionId() {
  133. return this.params.sectionId;
  134. },
  135. isShowInput() {
  136. return this.params.isPlayRebuild;
  137. },
  138. },
  139. watch: {
  140. sectionId: {
  141. handler(val) {
  142. this.getNoteList();
  143. },
  144. immediate: true,
  145. },
  146. },
  147. };
  148. </script>
  149. <style lang="scss" scoped>
  150. .leftPadding {
  151. margin-left: 8rpx;
  152. }
  153. .dateBox {
  154. width: 216rpx;
  155. height: 48rpx;
  156. background: #ffffff;
  157. border-radius: 24rpx;
  158. font-size: 24rpx;
  159. color: #666666;
  160. text-align: center;
  161. line-height: 48rpx;
  162. margin: 16rpx 0rpx 8rpx;
  163. }
  164. .noteBox {
  165. width: 100%;
  166. background: #ffffff;
  167. padding: 0rpx 10rpx 20rpx;
  168. border-radius: 16rpx;
  169. overflow: hidden;
  170. .left_ti {
  171. padding-top: 14rpx;
  172. .title {
  173. font-size: 24rpx;
  174. color: #999999;
  175. }
  176. }
  177. }
  178. .t2Content {
  179. font-size: 24rpx;
  180. font-family: PingFang SC;
  181. font-weight: bold;
  182. color: #999999;
  183. line-height: 48rpx;
  184. }
  185. .tBox2 {
  186. display: flex;
  187. padding-top: 10rpx;
  188. color: #333333;
  189. font-size: 30rpx;
  190. font-weight: 400;
  191. }
  192. .inputBottom {
  193. position: fixed;
  194. left: 0;
  195. bottom: 0;
  196. background: #ffffff;
  197. height: 98rpx;
  198. display: flex;
  199. align-items: center;
  200. width: 100%;
  201. .flex_auto {
  202. flex: 1;
  203. margin-left: 10%;
  204. word-break: break-all;
  205. // .input {
  206. // height: 60rpx;
  207. // }
  208. }
  209. .btn {
  210. color: #007aff;
  211. font-size: 30rpx;
  212. font-weight: bold;
  213. width: 15%;
  214. text-align: center;
  215. }
  216. .input {
  217. background: rgba(244, 244, 244, 0.98);
  218. height: 60rpx;
  219. border-radius: 24rpx;
  220. margin-top: 12rpx;
  221. }
  222. }
  223. </style>