new.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="content">
  3. <view class="main flex">
  4. <view class="main-font">新品通知</view>
  5. <u-switch v-model="checked" active-color="#2979ff" size="50"></u-switch>
  6. </view>
  7. <u-popup v-model="show" mode="center" border-radius="50" :closeable="true">
  8. <view class="popup-box">
  9. <view class="popup-font">长按二维码保存至本地,关注公众号即可接收消息</view>
  10. <view class="ewm"><image @longtap="bc_code" src="../../static/img/add.png" mode=""></image></view>
  11. </view>
  12. </u-popup>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. checked: false,
  20. show: true
  21. };
  22. },
  23. onLoad() {
  24. this.open();
  25. },
  26. onShow() {},
  27. onReachBottom() {},
  28. onReady() {},
  29. methods: {
  30. change(status) {
  31. console.log(status);
  32. this.open();
  33. },
  34. open() {
  35. this.show = true;
  36. },
  37. close() {
  38. this.show = false;
  39. },
  40. bc_code() {
  41. let that = this;
  42. console.log('保存二维码', this.backImg);
  43. uni.downloadFile({
  44. //获得二维码的临时地址
  45. url: this.backImg,
  46. success: res => {
  47. //console.log('获取url',res)
  48. if (res.statusCode == 200) {
  49. uni.saveImageToPhotosAlbum({
  50. filePath: res.tempFilePath, //传入临时地址
  51. success() {
  52. that.$api.msg('保存成功'); //封装的提示
  53. },
  54. fail() {
  55. that.$api.msg('保存失败');
  56. }
  57. });
  58. }
  59. }
  60. });
  61. }
  62. }
  63. };
  64. </script>
  65. <style lang="scss">
  66. page,
  67. .content {
  68. min-height: 100%;
  69. height: auto;
  70. }
  71. .main {
  72. padding: 40rpx;
  73. .main-font {
  74. font-size: 30rpx;
  75. font-family: PingFang SC;
  76. font-weight: 800;
  77. color: #000000;
  78. }
  79. }
  80. .popup-box {
  81. width: 470rpx;
  82. padding: 86rpx 40rpx 40rpx;
  83. position: relative;
  84. .popup-font {
  85. font-size: 32rpx;
  86. font-weight: 800;
  87. font-family: PingFang SC;
  88. color: #000000;
  89. }
  90. .ewm {
  91. margin: 20rpx auto;
  92. width: 390rpx;
  93. height: 390rpx;
  94. image {
  95. width: 100%;
  96. height: 100%;
  97. }
  98. }
  99. }
  100. </style>