index.vue 8.0 KB

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