index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. uni.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. onUnload() {
  76. if (this.$Http.updateUserInfo) {
  77. this.$Http.updateUserInfo()
  78. delete this.$Http.updateUserInfo
  79. }
  80. },
  81. methods: {
  82. getList(init = false) {
  83. if (this.paging(this.content, init)) return;
  84. this.$Http.basic({
  85. "id": "20240319104102",
  86. content: this.content
  87. }).then(res => {
  88. console.log("获取每日一签列表", res)
  89. if (this.cutoff(res.msg)) return;
  90. let dates = {};
  91. this.signList = res.data.map(v => {
  92. v.attinfos = formattedFiles(v.attinfos)
  93. v.videoIds = v.attinfos.filter(v => v.fileType == 'video').map(v => `Video${v.attachmentid}`)
  94. dates[v.ondate] = v;
  95. return { date: v.ondate }
  96. })
  97. this.dates = dates;
  98. this.record();
  99. console.log("date", this.dates[this.viewDate])
  100. })
  101. },
  102. dayChange(e) {
  103. this.viewDate = e.date;
  104. this.current = 0;
  105. const {
  106. year, month
  107. } = this.content.where;
  108. if (year != e.year || month != e.month) {
  109. this.content.where.year = e.year;
  110. this.content.where.month = e.month;
  111. this.getList(true)
  112. }
  113. console.log("date", this.dates[this.viewDate])
  114. this.record();
  115. },
  116. swiperChange(e) {
  117. this.current = e.detail.current;
  118. this.dates[this.viewDate].videoIds.forEach(v => uni.createVideoContext(v).pause())
  119. },
  120. previewImage(url) {
  121. viewImage(url)
  122. },
  123. saveVideo(file) {
  124. wxSaveFile(file)
  125. this.record(1)
  126. },
  127. notesSava(e) {
  128. this.dates[this.viewDate].notes = e.detail.value;
  129. },
  130. copyNotes(notes) {
  131. if (!notes.length) uni.showToast({
  132. title: '还未输入宣传文本',
  133. duration: 2000,
  134. icon: "none"
  135. });
  136. uni.setClipboardData({
  137. data: notes,
  138. })
  139. },
  140. //0:阅读记录 1:下载记录:2:发送邮件
  141. record(type = 0, sat_sharematerialid = 0) {
  142. try {
  143. if (sat_sharematerialid == 0) sat_sharematerialid = this.dates[this.viewDate].sat_sharematerialid;
  144. this.$Http.basic({
  145. "id": 20240319142702,
  146. "content": {
  147. sat_sharematerialid, type
  148. }
  149. }).then(res => {
  150. console.log(type, '记录', res)
  151. })
  152. } catch (error) {
  153. }
  154. },
  155. makePoster(file) {
  156. this.$Http.data = {
  157. detail: this.dates[this.viewDate],
  158. file
  159. }
  160. uni.navigateTo({
  161. url: "/packageA/dailyYttendance/makePoster",
  162. });
  163. }
  164. },
  165. }
  166. </script>
  167. <style lang="scss">
  168. .poster {
  169. height: 356px;
  170. width: 100vw;
  171. margin: 20px 0;
  172. box-sizing: border-box;
  173. .image,
  174. .video {
  175. width: 100%;
  176. height: 100%;
  177. }
  178. }
  179. .text-box {
  180. width: 100vw;
  181. background: #fff;
  182. border-radius: 8px;
  183. padding: 10px;
  184. box-sizing: border-box;
  185. .title {
  186. height: 20px;
  187. line-height: 20px;
  188. font-family: Source Han Sans SC, Source Han Sans SC;
  189. font-size: 14px;
  190. color: #333333;
  191. }
  192. .textarea {
  193. width: 100%;
  194. height: 100px;
  195. background: #FFFFFF;
  196. border-radius: 8px;
  197. border: 1px solid #CCCCCC;
  198. padding: 10px;
  199. margin-top: 10px;
  200. box-sizing: border-box;
  201. }
  202. }
  203. .bottom {
  204. display: flex;
  205. position: fixed;
  206. bottom: 0;
  207. width: 375px;
  208. height: 64px;
  209. background: #FFFFFF;
  210. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  211. padding-right: 10px;
  212. box-sizing: border-box;
  213. z-index: 9999999;
  214. .but {
  215. display: flex;
  216. align-items: center;
  217. justify-content: center;
  218. margin-left: 10px;
  219. width: 168px;
  220. height: 45px;
  221. border-radius: 5px;
  222. margin-top: 4px;
  223. box-sizing: border-box;
  224. }
  225. .up {
  226. background: #FFFFFF;
  227. border: 1px solid #999999;
  228. font-size: 16px;
  229. color: #666666;
  230. width: 82px;
  231. }
  232. .down,
  233. .submit {
  234. background: #095DE0;
  235. font-family: PingFang SC, PingFang SC;
  236. font-size: 16px;
  237. color: #FFFFFF;
  238. }
  239. .submit {
  240. flex: 1;
  241. background: #C30D23;
  242. width: 263px;
  243. }
  244. }
  245. </style>