pic.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template name="pic">
  2. <view class="cover">
  3. <image :src="item.pic" mode="widthFix" :class="['default', 'slide-image-'+item.type]"></image>
  4. <block v-for="(v, k) in item.text">
  5. <view :class="['abs-tag', config.position[v.text-1]]" v-if="v.name">
  6. <view v-for="(v1, k1) in v.name_array">
  7. <text v-bind:style="{backgroundColor:(v.bgcolor || 'transparent'),color:v.color,fontSize:v.size+'px'}" v-if="v1">{{v1}}</text>
  8. </view>
  9. </view>
  10. </block>
  11. <view class="btn-save-img" :data-url="item.pic" @click="download" v-if="item.is_button == 1"></view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name: "pic",
  17. props: {
  18. config : {
  19. type : Object,
  20. value : null
  21. },
  22. item : {
  23. type : Object,
  24. value : null
  25. },
  26. },
  27. methods:{
  28. download : function(e) {
  29. var url = e.target.dataset.url;
  30. var self = this;
  31. uni.downloadFile({
  32. url,
  33. success: res => {
  34. if (res.statusCode === 200) {
  35. console.info(res);
  36. uni.saveImageToPhotosAlbum({
  37. filePath: res.tempFilePath,
  38. success: function() {
  39. self.alert('保存成功');
  40. },
  41. fail: function() {
  42. self.alert('保存失败,请稍后重试');
  43. }
  44. });
  45. } else {
  46. self.alert('下载失败');
  47. }
  48. }
  49. });
  50. }
  51. },
  52. }
  53. </script>
  54. <style>
  55. .cover{
  56. position: relative;
  57. overflow: hidden;
  58. width: 100%;
  59. height: 100%;
  60. }
  61. .slide-image-1 {
  62. width: 750rpx;
  63. height: 1386rpx;
  64. display: block;
  65. }
  66. .slide-image-2 {
  67. width: 750rpx;
  68. height: 100%;
  69. display: block;
  70. }
  71. .slide-image-3 {
  72. width: 100%;
  73. height: 1386rpx;
  74. display: block;
  75. }
  76. .slide-image-4 {
  77. width: 100%;
  78. height: 100%;
  79. display: block;
  80. }
  81. .long-wrapper {
  82. position: relative;
  83. }
  84. </style>