detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <view>
  3. <block v-if="detail.typestr == '图片' && painter.imageUrl" style="">
  4. <l-painter ref="painter" isCanvasToTempFilePath hidden :css="painter.css" @success="imageSuccess">
  5. <!-- 背景图片 -->
  6. <l-painter-image :src="painter.imageUrl" :css="painter.css" />
  7. <!-- 二维码 -->
  8. <l-painter-qrcode v-if="detail.isqrcode" :text="detail.qrcodecontent"
  9. css="width: 84px; height: 84px;position: absolute;bottom: 24px;right:24px;z-index: 2;background:#fff;" />
  10. </l-painter>
  11. </block>
  12. <view class="orientation" />
  13. <view class="head" v-if="detail.candownload_c">
  14. <view class="sendmail" hover-class="navigator-hover" @click="showUModal = true">
  15. <text class="iconfont icon-fayouxiang" />
  16. 发送文件到邮箱
  17. </view>
  18. <view class="download" hover-class="navigator-hover" @click="download">
  19. <text class="iconfont icon-xiazai" />
  20. 下载
  21. </view>
  22. </view>
  23. <swiper class="swiper" :current="current" :style="{ height: tovw(height) }" @change="swiperChange">
  24. <swiper-item class="swipeout-item" v-for="( item, index ) in detail.attinfos_pic " :key="item.attachmentid">
  25. <image v-if="detail.typestr == '图片'" class="image" :style="{ height: tovw(height - 47) }" :src="item.cover"
  26. mode="aspectFit" lazy-load="true" />
  27. <video :id="'myVideo' + index" v-else-if="detail.typestr == '视频'" class="image"
  28. :style="{ height: tovw(height - 47) }" :src="item.url" :poster="item.cover" />
  29. <view class="paging">
  30. {{ index + 1 + '/' + detail.attinfos_pic.length }}
  31. </view>
  32. </swiper-item>
  33. </swiper>
  34. <view class="bottom">
  35. {{ detail.title }}
  36. </view>
  37. <u-modal :show="showUModal" confirmColor='#C30D23' ref="uModal" showCancelButton :asyncClose="true"
  38. @confirm="onSend" @cancel="showUModal = false">
  39. <view class="slot-content">
  40. <view class="slot-title">
  41. 发送邮件
  42. </view>
  43. <view class="slot-tips">
  44. 文件将以邮件的形式发送到指定邮箱
  45. </view>
  46. <u--input :focus="focus" placeholder="请输入邮箱" v-model="eMail" border="bottom" clearable />
  47. </view>
  48. </u-modal>
  49. </view>
  50. </template>
  51. <script>
  52. import lPainter from "../../uni_modules/lime-painter/components/l-painter/l-painter.vue"
  53. import lPainterImage from "../../uni_modules/lime-painter/components/l-painter-image/l-painter-image.vue"
  54. import lPainterQrcode from "../../uni_modules/lime-painter/components/l-painter-qrcode/l-painter-qrcode.vue"
  55. import { viewMedias, wxSaveFile } from "../../utils/settleFiles";
  56. export default {
  57. components: { lPainter, lPainterImage, lPainterQrcode },
  58. data() {
  59. return {
  60. current: 0,
  61. sat_sharematerialid: 0,
  62. detail: { attinfos_pic: [], typestr: '' },
  63. height: 0,
  64. showUModal: false,
  65. eMail: "",
  66. painter: { imageUrl: "" },
  67. focus: false,
  68. }
  69. },
  70. onLoad(options) {
  71. this.sat_sharematerialid = options.id;
  72. this.getDetail();
  73. },
  74. watch: {
  75. showUModal: function (newVale) {
  76. setTimeout(() => {
  77. this.focus = newVale;
  78. }, 300)
  79. }
  80. },
  81. methods: {
  82. getDetail() {
  83. this.$Http.basic({
  84. "id": 20240407094602,
  85. "content": {
  86. "sat_sharematerialid": this.sat_sharematerialid
  87. }
  88. }).then(res => {
  89. console.log("装备资源库详情", res)
  90. if (this.cutoff(res.msg)) return;
  91. res.data.attinfos_pic = res.data.attinfos_pic.map(v => {
  92. if (res.data.typestr == '视频') {
  93. v.cover = this.getSpecifiedImage(v.attinfos[0], "cover")
  94. v.url = this.getSpecifiedImage(v.attinfos[0], "hls")
  95. } else {
  96. v.cover = this.getSpecifiedImage(v.attinfos[0], "compressed")
  97. }
  98. return v
  99. })
  100. this.detail = res.data;
  101. this.setHeight();
  102. uni.setNavigationBarTitle({
  103. title: res.data.title
  104. })
  105. })
  106. },
  107. onSend() {
  108. let { CheckEmail } = require("../../utils/basicInspection");
  109. if (!CheckEmail(this.eMail || '')) return this.$refs.uModal.loading = false;
  110. this.$Http.basic({
  111. "id": "20240408154702",
  112. "content": {
  113. "sat_sharematerialid": this.detail.sat_sharematerialid,
  114. "email": this.eMail
  115. }
  116. }).then(res => {
  117. console.log("发送邮件", res)
  118. if (this.cutoff(res.msg, '发送成功')) return this.$refs.uModal.loading = false;
  119. this.showUModal = false;
  120. })
  121. },
  122. /* 设置组件高度 */
  123. setHeight() {
  124. this.getHeight(".orientation", this).then(res => {
  125. let info = uni.getSystemInfoSync(),
  126. safeAreaBottom = info.screenHeight - info.safeArea.bottom;
  127. if (this.detail.candownload_c == 1) safeAreaBottom += 40;
  128. this.height = res - safeAreaBottom - 40
  129. });
  130. },
  131. swiperChange(e) {
  132. uni.createVideoContext('myVideo' + this.current).pause()
  133. this.current = e.detail.current;
  134. },
  135. download() {
  136. let that = this,
  137. file = that.detail.attinfos_pic[that.current].attinfos[0];
  138. uni.showModal({
  139. title: '提示',
  140. content: `是否确定将当前${this.detail.typestr}保存到相册`,
  141. success: ({ confirm }) => {
  142. if (confirm) {
  143. if (that.detail.typestr == '视频') {
  144. wxSaveFile(file)
  145. } else {
  146. uni.getImageInfo({
  147. src: file.url,
  148. success: res => {
  149. console.log("getImageInfo", res)
  150. let upperLimit = 4080;
  151. if (uni.getSystemInfoSync().platform == 'ios') upperLimit = 1360;
  152. let arr = [res.width, res.height];
  153. let maxNum = Math.max(...arr);
  154. if (maxNum > upperLimit) {
  155. let MP = (maxNum / upperLimit).toFixed(2);
  156. console.log("缩小倍率", MP)
  157. res.width = res.width / MP;
  158. res.height = res.height / MP;
  159. }
  160. that.painter = {
  161. imageUrl: file.url,
  162. css: `position: relative;width: ${res.width}px; height: ${res.height}px;object-fit:cover;`
  163. }
  164. console.log("that.painter", that.painter)
  165. }
  166. })
  167. }
  168. }
  169. },
  170. })
  171. },
  172. imageSuccess() {
  173. let that = this;
  174. that.$refs.painter.canvasToTempFilePathSync({
  175. fileType: "jpg",
  176. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  177. pathType: 'url',
  178. quality: 1,
  179. success: (res) => {
  180. console.log(res.tempFilePath);
  181. // 非H5 保存到相册
  182. // H5 提示用户长按图另存
  183. uni.saveImageToPhotosAlbum({
  184. filePath: res.tempFilePath,
  185. success: function (e) {
  186. uni.showModal({
  187. title: '提示',
  188. content: '图片已保存到系统相册',
  189. showCancel: false
  190. })
  191. that.loading = false;
  192. that.$Http.basic({
  193. "id": 20240319142702,
  194. "content": {
  195. sat_sharematerialid: that.detail.sat_sharematerialid, type: 1
  196. }
  197. }).then(res => {
  198. console.log(type, '记录', res)
  199. })
  200. },
  201. fail: ({ errMsg }) => {
  202. if (errMsg == 'saveImageToPhotosAlbum:fail auth deny') {
  203. uni.showModal({
  204. title: '提示',
  205. content: '请授权添加到相册权限后再试!',
  206. showCancel: false,
  207. complete: (complete) => {
  208. uni.openSetting({
  209. success: res => {
  210. that.loading = false;
  211. if (res.authSetting['scope.writePhotosAlbum']) {
  212. this.saveTheImage()
  213. } else {
  214. uni.showModal({
  215. title: '提示',
  216. content: '未获取授权!已取消保存',
  217. showCancel: false,
  218. })
  219. }
  220. }
  221. })
  222. },
  223. })
  224. } else {
  225. that.loading = false;
  226. uni.showModal({
  227. title: '提示',
  228. content: '已取消保存',
  229. showCancel: false,
  230. })
  231. }
  232. },
  233. });
  234. },
  235. });
  236. }
  237. }
  238. }
  239. </script>
  240. <style lang="scss" scoped>
  241. .head {
  242. display: flex;
  243. justify-content: space-between;
  244. background: #333333;
  245. width: 100vw;
  246. height: 40px;
  247. .sendmail {
  248. display: flex;
  249. align-items: center;
  250. justify-content: center;
  251. width: 160px;
  252. height: 40px;
  253. background: #C30D23;
  254. font-family: PingFang SC, PingFang SC;
  255. font-weight: 500;
  256. font-size: 14px;
  257. color: #FFFFFF;
  258. .iconfont {
  259. margin-right: 5px;
  260. }
  261. }
  262. .download {
  263. font-size: 12px;
  264. color: #FFFFFF;
  265. line-height: 40px;
  266. padding-right: 10px;
  267. .iconfont {
  268. margin-right: 5px;
  269. }
  270. }
  271. }
  272. .swiper {
  273. width: 100vw;
  274. background: #333333;
  275. .swipeout-item {
  276. width: 100%;
  277. height: 100%;
  278. .image {
  279. width: 100%;
  280. }
  281. .paging {
  282. width: 100vw;
  283. text-align: center;
  284. line-height: 17px;
  285. font-family: Source Han Sans SC, Source Han Sans SC;
  286. font-size: 12px;
  287. color: #FFFFFF;
  288. margin-top: 10px;
  289. }
  290. }
  291. }
  292. .slot-content {
  293. width: 100%;
  294. text-align: center;
  295. .slot-title {
  296. height: 26px;
  297. font-family: Source Han Sans SC, Source Han Sans SC;
  298. font-weight: bold;
  299. font-size: 18px;
  300. color: #000000;
  301. }
  302. .slot-tips {
  303. line-height: 20px;
  304. font-family: Source Han Sans SC, Source Han Sans SC;
  305. font-size: 14px;
  306. color: #666666;
  307. margin-bottom: 30px;
  308. margin-top: 10px;
  309. }
  310. }
  311. .bottom {
  312. min-height: 40px;
  313. display: flex;
  314. align-items: center;
  315. justify-content: center;
  316. width: 100vw;
  317. padding: 0 10px;
  318. box-sizing: border-box;
  319. font-size: 14px;
  320. color: #333333;
  321. }
  322. </style>