index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view>
  3. <view class='poster-poster'>
  4. <view class='tip'><text class='iconfont icon-shuoming'></text>提示:点击图片即可保存至手机相册 </view>
  5. <view class='pictrue'>
  6. <image :src='image' mode="widthFix"></image>
  7. </view>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. import { getBargainPoster, getCombinationPoster } from '../../../api/activity.js';
  13. export default {
  14. data() {
  15. return {
  16. parameter: {
  17. 'navbar': '1',
  18. 'return': '1',
  19. 'title': '拼团海报',
  20. 'color': true,
  21. 'class': '0'
  22. },
  23. type: 0,
  24. id: 0,
  25. image: '',
  26. from:''
  27. }
  28. },
  29. onLoad(options) {
  30. // #ifdef MP
  31. this.from = 'routine'
  32. // #endif
  33. // #ifdef H5
  34. this.from = 'wechat'
  35. // #endif
  36. var that = this;
  37. if (options.hasOwnProperty('type') && options.hasOwnProperty('id')) {
  38. this.type = options.type
  39. this.id = options.id
  40. if (options.type == 1) {
  41. uni.setNavigationBarTitle({
  42. title: '砍价海报'
  43. })
  44. } else {
  45. uni.setNavigationBarTitle({
  46. title: '拼团海报'
  47. })
  48. }
  49. } else {
  50. return app.Tips({
  51. title: '参数错误',
  52. icon: 'none'
  53. }, {
  54. tab: 3,
  55. url: 1
  56. });
  57. }
  58. },
  59. onShow() {
  60. this.getPosterInfo();
  61. },
  62. methods: {
  63. getPosterInfo: function() {
  64. var that = this,url = '';
  65. let data = {
  66. id: that.id,
  67. 'from': that.from
  68. };
  69. if (that.type == 1) {
  70. getBargainPoster({
  71. bargainId: that.id,
  72. 'from': that.from
  73. }).then(res => {
  74. that.image = res.data.url
  75. }).catch(err => {
  76. console.log(err)
  77. })
  78. } else {
  79. getCombinationPoster(data).then(res => {
  80. that.image = res.data.url
  81. }).catch(err => {
  82. })
  83. }
  84. },
  85. showImage: function() {
  86. var that = this;
  87. let imgArr = this.image.split(',')
  88. uni.previewImage({
  89. urls: imgArr,
  90. longPressActions: {
  91. itemList: ['发送给朋友', '保存图片', '收藏'],
  92. success: function(data) {
  93. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  94. },
  95. fail: function(err) {
  96. console.log(err.errMsg);
  97. }
  98. }
  99. });
  100. },
  101. }
  102. }
  103. </script>
  104. <style>
  105. page {
  106. background-color: #d22516 !important;
  107. }
  108. .poster-poster .tip {
  109. height: 80rpx;
  110. font-size: 26rpx;
  111. color: #e8c787;
  112. text-align: center;
  113. line-height: 80rpx;
  114. }
  115. .poster-poster .tip .iconfont {
  116. font-size: 36rpx;
  117. vertical-align: -4rpx;
  118. margin-right: 18rpx;
  119. }
  120. .poster-poster .pictrue {
  121. width: 690rpx;
  122. height: 100%;
  123. margin: 0 auto 50rpx auto;
  124. }
  125. .poster-poster .pictrue image {
  126. width: 100%;
  127. height: 100%;
  128. }
  129. </style>