index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view>
  3. <calendar :date="date" showShrink shrinkState="week" weekType="" :signList="signList" @dayChange="dayChange" />
  4. <view v-if="dates[viewDate] && dates[viewDate].attinfos.length">
  5. <swiper class="poster" :current="current" circular v-if="dates[viewDate].attinfos.length" indicator-dots
  6. indicator-active-color="#fff" @change="swiperChange">
  7. <swiper-item v-for="item in dates[viewDate].attinfos" :key="item.attachmentid">
  8. <image class="image" v-if="item.fileType == 'image'" :src="item.url" mode="aspectFit" lazy-load="true"
  9. @click="previewImage(item.url)" />
  10. <video class="video" :id="'Video' + item.attachmentid" v-if="item.fileType == 'video'"
  11. :poster="item.subfiles[0].url" :src="item.url" />
  12. </swiper-item>
  13. </swiper>
  14. <view class="text-box">
  15. <view class="title">分享海报宣传文本,例如:</view>
  16. <textarea class="textarea" :value="dates[viewDate].notes" @input="notesSava" maxlength="499"
  17. placeholder="分享海报宣传文本" />
  18. </view>
  19. </view>
  20. <view v-else style="padding-top: 50px;">
  21. <u-empty mode="data" text="暂无数据" />
  22. </view>
  23. <view style="height: 80px;" />
  24. <view class="bottom" v-if="dates[viewDate] && dates[viewDate].attinfos.length">
  25. <view class="but up" @click="copyNotes(dates[viewDate].notes)" hover-class="navigator-hover">
  26. 复制文本
  27. </view>
  28. <view v-if="dates[viewDate].attinfos[current].fileType == 'image'" class="but submit"
  29. hover-class="navigator-hover" @click="makePoster(dates[viewDate].attinfos[current])">
  30. 自定义海报及保存
  31. </view>
  32. <view v-else class="but submit" hover-class="navigator-hover"
  33. @click="saveVideo(dates[viewDate].attinfos[current])">
  34. 保存视频
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import calendar from "../../uni_modules/lunc-calendar/components/lunc-calendar/lunc-calendar.vue";
  41. import { formattedFiles, viewImage, wxSaveFile } from "../../utils/settleFiles";
  42. export default {
  43. components: { calendar },
  44. data() {
  45. return {
  46. current: 0,
  47. date: new Date(),
  48. signList: [],
  49. "content": {
  50. "pageNumber": 1,
  51. "pageSize": 9999,
  52. "where": {
  53. "condition": "",
  54. "year": "",
  55. "month": ""
  56. }
  57. },
  58. viewDate: "",
  59. dates: {}
  60. }
  61. },
  62. onLoad() {
  63. wx.setNavigationBarTitle({
  64. title: this.getApps('资料库', '/packageA/dailyYttendance/index').remark || '每日一签',
  65. });
  66. this.viewDate = this.formatTime().split(" ")[0]
  67. const time = this.viewDate.split("-")
  68. this.content.where.year = time[0];
  69. this.content.where.month = time[1];
  70. this.getList(true)
  71. },
  72. onShow() {
  73. if (this.content.pageNumber && this.content.pageNumber >= 2) this.getList(true)
  74. },
  75. methods: {
  76. getList(init = false) {
  77. if (this.paging(this.content, init)) return;
  78. this.$Http.basic({
  79. "id": "20240319104102",
  80. content: this.content
  81. }).then(res => {
  82. console.log("获取每日一签列表", res)
  83. if (this.cutoff(res.msg)) return;
  84. let dates = {};
  85. this.signList = res.data.map(v => {
  86. v.attinfos = formattedFiles(v.attinfos)
  87. v.videoIds = v.attinfos.filter(v => v.fileType == 'video').map(v => `Video${v.attachmentid}`)
  88. dates[v.ondate] = v;
  89. return { date: v.ondate }
  90. })
  91. this.dates = dates;
  92. this.record();
  93. console.log("date", this.dates[this.viewDate])
  94. })
  95. },
  96. dayChange(e) {
  97. this.viewDate = e.date;
  98. this.current = 0;
  99. const {
  100. year, month
  101. } = this.content.where;
  102. if (year != e.year || month != e.month) {
  103. this.content.where.year = e.year;
  104. this.content.where.month = e.month;
  105. this.getList(true)
  106. }
  107. console.log("date", this.dates[this.viewDate])
  108. this.record();
  109. },
  110. swiperChange(e) {
  111. this.current = e.detail.current;
  112. this.dates[this.viewDate].videoIds.forEach(v => uni.createVideoContext(v).pause())
  113. },
  114. previewImage(url) {
  115. viewImage(url)
  116. },
  117. saveVideo(file) {
  118. wxSaveFile(file)
  119. this.record(1)
  120. },
  121. notesSava(e) {
  122. this.dates[this.viewDate].notes = e.detail.value;
  123. },
  124. copyNotes(notes) {
  125. if (!notes.length) uni.showToast({
  126. title: '还未输入宣传文本',
  127. duration: 2000,
  128. icon: "none"
  129. });
  130. uni.setClipboardData({
  131. data: notes,
  132. })
  133. },
  134. //0:阅读记录 1:下载记录:2:发送邮件
  135. record(type = 0, sat_sharematerialid = 0) {
  136. try {
  137. if (sat_sharematerialid == 0) sat_sharematerialid = this.dates[this.viewDate].sat_sharematerialid;
  138. this.$Http.basic({
  139. "id": 20240319142702,
  140. "content": {
  141. sat_sharematerialid, type
  142. }
  143. }).then(res => {
  144. console.log(type, '记录', res)
  145. })
  146. } catch (error) {
  147. }
  148. },
  149. makePoster(file) {
  150. this.$Http.data = {
  151. detail: this.dates[this.viewDate],
  152. file
  153. }
  154. uni.navigateTo({
  155. url: "/packageA/dailyYttendance/makePoster",
  156. });
  157. }
  158. },
  159. }
  160. </script>
  161. <style lang="scss">
  162. .poster {
  163. height: 356px;
  164. width: 100vw;
  165. margin: 20px 0;
  166. box-sizing: border-box;
  167. .image,
  168. .video {
  169. width: 100%;
  170. height: 100%;
  171. }
  172. }
  173. .text-box {
  174. width: 100vw;
  175. background: #fff;
  176. border-radius: 8px;
  177. padding: 10px;
  178. box-sizing: border-box;
  179. .title {
  180. height: 20px;
  181. line-height: 20px;
  182. font-family: Source Han Sans SC, Source Han Sans SC;
  183. font-size: 14px;
  184. color: #333333;
  185. }
  186. .textarea {
  187. width: 100%;
  188. height: 100px;
  189. background: #FFFFFF;
  190. border-radius: 8px;
  191. border: 1px solid #CCCCCC;
  192. padding: 10px;
  193. margin-top: 10px;
  194. box-sizing: border-box;
  195. }
  196. }
  197. .bottom {
  198. display: flex;
  199. position: fixed;
  200. bottom: 0;
  201. width: 375px;
  202. height: 64px;
  203. background: #FFFFFF;
  204. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  205. padding-right: 10px;
  206. box-sizing: border-box;
  207. z-index: 9999999;
  208. .but {
  209. display: flex;
  210. align-items: center;
  211. justify-content: center;
  212. margin-left: 10px;
  213. width: 168px;
  214. height: 45px;
  215. border-radius: 5px;
  216. margin-top: 4px;
  217. box-sizing: border-box;
  218. }
  219. .up {
  220. background: #FFFFFF;
  221. border: 1px solid #999999;
  222. font-size: 16px;
  223. color: #666666;
  224. width: 82px;
  225. }
  226. .down,
  227. .submit {
  228. background: #095DE0;
  229. font-family: PingFang SC, PingFang SC;
  230. font-size: 16px;
  231. color: #FFFFFF;
  232. }
  233. .submit {
  234. flex: 1;
  235. background: #C30D23;
  236. width: 263px;
  237. }
  238. }
  239. </style>