code.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view class="app-content">
  3. <view class="img_box" style="margin-top:30upx;">
  4. <image :src="gatherUrl" mode="heightFix" class="img_url"></image>
  5. </view>
  6. <view style="font-size:30upx;text-align: center;margin:30upx 0 5upx 0;">支持信用卡和花呗,打印尺寸100mmx150mm</view>
  7. <view class="confirm-btn">
  8. <button class="admin-button-com big blue" style="width:60vw;" @click="downloadImg(gatherUrl)">下载收款码</button>
  9. </view>
  10. <view class="confirm-btn">
  11. <button class="admin-button-com big blue" style="width:60vw;">购买音响</button>
  12. </view>
  13. <view style="margin-top:30upx;text-align:center;margin-bottom:30upx;">
  14. <image :src="laba" mode="widthFix" style="width:640upx;margin:0 auto;border-radius: 10upx;"></image>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import { miniGatheringCode } from '@/api/shop'
  20. export default {
  21. data() {
  22. return {
  23. gatherUrl:'',
  24. laba: `${this.$constant.hostUrl}/image/horn.jpg`
  25. }
  26. },
  27. methods: {
  28. init() {
  29. this.getImg()
  30. },
  31. downloadImg(url){
  32. // #ifdef APP-PLUS
  33. let platformType = uni.getSystemInfoSync().platform
  34. if(platformType == 'android'){
  35. let store = plus.navigator.checkPermission('android.permission.READ_EXTERNAL_STORAGE')
  36. if(store != 'authorized'){
  37. this.$util.confirmModal({content:'将申请您的存储权限,用于保存小程序码'},() => {
  38. this.downloadImg2(url)
  39. })
  40. }else{
  41. this.downloadImg2(url)
  42. }
  43. }else{
  44. this.downloadImg2(url)
  45. }
  46. // #endif
  47. // #ifdef MP-WEIXIN
  48. this.downloadImg2(url)
  49. // #endif
  50. },
  51. downloadImg2(url){
  52. uni.downloadFile({
  53. url: url,
  54. success: (res) => {
  55. if (res.statusCode === 200) {
  56. uni.saveImageToPhotosAlbum({
  57. filePath: res.tempFilePath,
  58. success: function (data) {
  59. uni.showToast({title:'下载成功!'})
  60. }
  61. });
  62. }
  63. }
  64. });
  65. },
  66. getImg() {
  67. miniGatheringCode().then(res => {
  68. this.gatherUrl = res.data.imgUrl
  69. })
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .app-content{
  76. overflow: hidden;
  77. }
  78. .img_box{
  79. height:900upx;
  80. box-sizing: border-box;
  81. &>.img_url{
  82. height:900upx;
  83. width: auto;
  84. margin: 20upx auto;
  85. }
  86. }
  87. // 按钮
  88. .confirm-btn {
  89. width: calc(100% - 60upx);
  90. margin: 30upx 30upx 20upx;
  91. text-align:center;
  92. .admin-button-com {
  93. width: 100%;
  94. }
  95. }
  96. // 按钮
  97. .confirm-btn1 {
  98. width: calc(100% - 60upx);
  99. margin: 30upx 30upx 20upx;
  100. text-align:center;
  101. .admin-button-com {
  102. width: 100%;
  103. }
  104. }
  105. </style>