noteBox.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. refPlv: {
  83. type: Object,
  84. defaule: () => {
  85. return {};
  86. },
  87. },
  88. isPlayRebuild: {},
  89. },
  90. inject: ["paramsFn"],
  91. data() {
  92. return {
  93. noteList: [],
  94. noteId: 0,
  95. noteValue: "",
  96. inputStyle: {
  97. background: "rgba(244, 244, 244, 0.98)",
  98. borderRadius: "24rpx",
  99. padding: "8rpx",
  100. marginBottom: "10rpx",
  101. },
  102. bottomHeight: 0,
  103. };
  104. },
  105. methods: {
  106. getNoteList() {
  107. this.$api
  108. .noteList({ ...this.params, ...{ sectionId: this.playSectionId } })
  109. .then((res) => {
  110. if (res.data.code == 200) {
  111. this.noteList = res.data.rows;
  112. }
  113. });
  114. },
  115. jumpNote(item) {
  116. this.noteId = item.noteId;
  117. this.$emit("jumpNote", item);
  118. },
  119. postNote() {
  120. let self = this;
  121. if (!(this.playSectionId > 0)) {
  122. this.$u.toast("目前无播放视频");
  123. return;
  124. }
  125. if (!this.noteValue) {
  126. this.$u.toast("请输入内容");
  127. return;
  128. }
  129. if (!this.params.gradeId) {
  130. this.$u.toast("暂无班级数据");
  131. return;
  132. }
  133. let noteSecond = this.refPlv.playCurrentTime
  134. ? this.refPlv.playCurrentTime()
  135. : 0;
  136. if (!noteSecond) {
  137. this.$u.toast("视频暂未开始");
  138. return;
  139. }
  140. let data = {
  141. sectionId: this.playSectionId,
  142. noteText: this.noteValue,
  143. noteDate: this.$method.getZeroTime(),
  144. noteSecond: noteSecond,
  145. ...this.params,
  146. };
  147. this.$api.postNote(data).then((res) => {
  148. if (res.data.code == 200) {
  149. this.$u.toast("发布成功");
  150. self.getNoteList();
  151. this.noteValue = "";
  152. }
  153. });
  154. },
  155. blurNote() {
  156. this.bottomHeight = 0;
  157. },
  158. focusNote(event) {
  159. this.bottomHeight = event.detail.height;
  160. },
  161. },
  162. computed: {
  163. ...mapGetters(["playSectionId"]),
  164. params() {
  165. return this.paramsFn(["orderGoodsId", "goodsId", "courseId"]);
  166. },
  167. },
  168. watch: {
  169. playSectionId: {
  170. handler(val) {
  171. this.getNoteList();
  172. },
  173. immediate: true,
  174. },
  175. },
  176. };
  177. </script>
  178. <style lang="scss" scoped>
  179. .leftPadding {
  180. margin-left: 8rpx;
  181. }
  182. .dateBox {
  183. width: 216rpx;
  184. height: 48rpx;
  185. background: #ffffff;
  186. border-radius: 24rpx;
  187. font-size: 24rpx;
  188. color: #666666;
  189. text-align: center;
  190. line-height: 48rpx;
  191. margin: 16rpx 0rpx 8rpx;
  192. }
  193. .noteBox {
  194. width: 100%;
  195. background: #ffffff;
  196. padding: 0rpx 10rpx 20rpx;
  197. border-radius: 16rpx;
  198. overflow: hidden;
  199. .left_ti {
  200. padding-top: 14rpx;
  201. .title {
  202. font-size: 24rpx;
  203. color: #999999;
  204. }
  205. }
  206. }
  207. .t2Content {
  208. font-size: 24rpx;
  209. font-family: PingFang SC;
  210. font-weight: bold;
  211. color: #999999;
  212. line-height: 48rpx;
  213. }
  214. .tBox2 {
  215. display: flex;
  216. padding-top: 10rpx;
  217. color: #333333;
  218. font-size: 30rpx;
  219. font-weight: 400;
  220. }
  221. .inputBottom {
  222. position: fixed;
  223. left: 0;
  224. bottom: 0;
  225. background: #ffffff;
  226. height: 98rpx;
  227. display: flex;
  228. align-items: center;
  229. width: 100%;
  230. .flex_auto {
  231. flex: 1;
  232. margin-left: 10%;
  233. word-break: break-all;
  234. // .input {
  235. // height: 60rpx;
  236. // }
  237. }
  238. .btn {
  239. color: #007aff;
  240. font-size: 30rpx;
  241. font-weight: bold;
  242. width: 15%;
  243. text-align: center;
  244. }
  245. .input {
  246. background: rgba(244, 244, 244, 0.98);
  247. height: 60rpx;
  248. border-radius: 24rpx;
  249. margin-top: 12rpx;
  250. }
  251. }
  252. </style>