detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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.qrcodecontent" :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="showUModal" 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. }
  68. },
  69. onLoad(options) {
  70. this.sat_sharematerialid = options.id;
  71. this.getDetail();
  72. },
  73. methods: {
  74. getDetail() {
  75. this.$Http.basic({
  76. "id": 20240407094602,
  77. "content": {
  78. "sat_sharematerialid": this.sat_sharematerialid
  79. }
  80. }).then(res => {
  81. console.log("装备资源库详情", res)
  82. if (this.cutoff(res.msg)) return;
  83. res.data.attinfos_pic = res.data.attinfos_pic.map(v => {
  84. if (res.data.typestr == '视频') {
  85. v.cover = this.getSpecifiedImage(v.attinfos[0], "cover")
  86. v.url = this.getSpecifiedImage(v.attinfos[0], "hls")
  87. } else {
  88. v.cover = this.getSpecifiedImage(v.attinfos[0])
  89. }
  90. return v
  91. })
  92. this.detail = res.data;
  93. this.setHeight();
  94. uni.setNavigationBarTitle({
  95. title: res.data.title
  96. })
  97. })
  98. },
  99. onSend() {
  100. let { CheckEmail } = require("../../utils/basicInspection");
  101. if (!CheckEmail(this.eMail || '')) return this.$refs.uModal.loading = false;
  102. this.$Http.basic({
  103. "id": "20240408154702",
  104. "content": {
  105. "sat_sharematerialid": this.detail.sat_sharematerialid,
  106. "email": this.eMail
  107. }
  108. }).then(res => {
  109. console.log("发送邮件", res)
  110. if (this.cutoff(res.msg, '发送成功')) return this.$refs.uModal.loading = false;
  111. this.showUModal = false;
  112. })
  113. },
  114. /* 设置组件高度 */
  115. setHeight() {
  116. this.getHeight(".orientation", this).then(res => {
  117. let info = uni.getSystemInfoSync(),
  118. safeAreaBottom = info.screenHeight - info.safeArea.bottom;
  119. if (this.detail.candownload_c == 1) safeAreaBottom += 40;
  120. this.height = res - safeAreaBottom - 40
  121. });
  122. },
  123. swiperChange(e) {
  124. uni.createVideoContext('myVideo' + this.current).pause()
  125. this.current = e.detail.current;
  126. },
  127. download() {
  128. let that = this,
  129. file = that.detail.attinfos_pic[that.current].attinfos[0];
  130. uni.showModal({
  131. title: '提示',
  132. content: `是否确定将当前${this.detail.typestr}保存到相册`,
  133. success: ({ confirm }) => {
  134. if (confirm) {
  135. if (that.detail.typestr == '视频') {
  136. wxSaveFile(file)
  137. } else {
  138. uni.getImageInfo({
  139. src: file.url,
  140. success: res => {
  141. console.log("getImageInfo", res)
  142. let upperLimit = 4080;
  143. if (uni.getSystemInfoSync().platform == 'ios') upperLimit = 1360;
  144. let arr = [res.width, res.height];
  145. let maxNum = Math.max(...arr);
  146. if (maxNum > upperLimit) {
  147. let MP = (maxNum / upperLimit).toFixed(2);
  148. console.log("缩小倍率", MP)
  149. res.width = res.width / MP;
  150. res.height = res.height / MP;
  151. }
  152. that.painter = {
  153. imageUrl: file.url,
  154. css: `position: relative;width: ${res.width}px; height: ${res.height}px;object-fit:cover;`
  155. }
  156. console.log("that.painter", that.painter)
  157. }
  158. })
  159. }
  160. }
  161. },
  162. })
  163. },
  164. imageSuccess() {
  165. let that = this;
  166. that.$refs.painter.canvasToTempFilePathSync({
  167. fileType: "jpg",
  168. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  169. pathType: 'url',
  170. quality: 1,
  171. success: (res) => {
  172. console.log(res.tempFilePath);
  173. // 非H5 保存到相册
  174. // H5 提示用户长按图另存
  175. uni.saveImageToPhotosAlbum({
  176. filePath: res.tempFilePath,
  177. success: function (e) {
  178. uni.showModal({
  179. title: '提示',
  180. content: '图片已保存到系统相册',
  181. showCancel: false
  182. })
  183. that.loading = false;
  184. this.$Http.basic({
  185. "id": 20240319142702,
  186. "content": {
  187. sat_sharematerialid: that.detail.sat_sharematerialid, type: 1
  188. }
  189. }).then(res => {
  190. console.log(type, '记录', res)
  191. })
  192. },
  193. fail: ({ errMsg }) => {
  194. if (errMsg == 'saveImageToPhotosAlbum:fail auth deny') {
  195. uni.showModal({
  196. title: '提示',
  197. content: '请授权添加到相册权限后再试!',
  198. showCancel: false,
  199. complete: (complete) => {
  200. uni.openSetting({
  201. success: res => {
  202. that.loading = false;
  203. if (res.authSetting['scope.writePhotosAlbum']) {
  204. this.saveTheImage()
  205. } else {
  206. uni.showModal({
  207. title: '提示',
  208. content: '未获取授权!已取消保存',
  209. showCancel: false,
  210. })
  211. }
  212. }
  213. })
  214. },
  215. })
  216. } else {
  217. that.loading = false;
  218. uni.showModal({
  219. title: '提示',
  220. content: '已取消保存',
  221. showCancel: false,
  222. })
  223. }
  224. },
  225. });
  226. },
  227. });
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="scss" scoped>
  233. .head {
  234. display: flex;
  235. justify-content: space-between;
  236. background: #333333;
  237. width: 100vw;
  238. height: 40px;
  239. .sendmail {
  240. display: flex;
  241. align-items: center;
  242. justify-content: center;
  243. width: 160px;
  244. height: 40px;
  245. background: #C30D23;
  246. font-family: PingFang SC, PingFang SC;
  247. font-weight: 500;
  248. font-size: 14px;
  249. color: #FFFFFF;
  250. .iconfont {
  251. margin-right: 5px;
  252. }
  253. }
  254. .download {
  255. font-size: 12px;
  256. color: #FFFFFF;
  257. line-height: 40px;
  258. padding-right: 10px;
  259. .iconfont {
  260. margin-right: 5px;
  261. }
  262. }
  263. }
  264. .swiper {
  265. width: 100vw;
  266. background: #333333;
  267. .swipeout-item {
  268. width: 100%;
  269. height: 100%;
  270. .image {
  271. width: 100%;
  272. }
  273. .paging {
  274. width: 100vw;
  275. text-align: center;
  276. line-height: 17px;
  277. font-family: Source Han Sans SC, Source Han Sans SC;
  278. font-size: 12px;
  279. color: #FFFFFF;
  280. margin-top: 10px;
  281. }
  282. }
  283. }
  284. .slot-content {
  285. width: 100%;
  286. text-align: center;
  287. .slot-title {
  288. height: 26px;
  289. font-family: Source Han Sans SC, Source Han Sans SC;
  290. font-weight: bold;
  291. font-size: 18px;
  292. color: #000000;
  293. }
  294. .slot-tips {
  295. line-height: 20px;
  296. font-family: Source Han Sans SC, Source Han Sans SC;
  297. font-size: 14px;
  298. color: #666666;
  299. margin-bottom: 30px;
  300. margin-top: 10px;
  301. }
  302. }
  303. .bottom {
  304. min-height: 40px;
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. width: 100vw;
  309. padding: 0 10px;
  310. box-sizing: border-box;
  311. font-size: 14px;
  312. color: #333333;
  313. }
  314. </style>