noteBox.vue 5.7 KB

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