noteBox.vue 5.9 KB

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