codeinfo.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="qrcode-info">
  3. <view class="cover-bg">
  4. <image class="qrcode" :src="backImgUrl" />
  5. <qrcode-poster ref="poster" :backImagUrl="backImgUrl" :memberName="haibao.memberName"
  6. :qdImageUrl="code" :codeType="codeType"
  7. ></qrcode-poster>
  8. </view>
  9. <view class="desc">
  10. 注:可直接生成店铺专用小程序码,并可保存手机相册,用于店铺宣传。
  11. </view>
  12. <view class="save" @click="save">生成推广码</view>
  13. </view>
  14. </template>
  15. <script>
  16. import QrcodePoster from '@/components/qrcode-poster/qrcode-poster.vue';
  17. import { mapState } from 'vuex';
  18. export default {
  19. components: {
  20. QrcodePoster
  21. },
  22. data () {
  23. return {
  24. getCodeUrl: (getApp().globalData.platApiUrl || getApp().globalData.apiUrl) + '/api/storeQrCodeManage/getStoreQrCode',
  25. code: {},
  26. backImgUrl: '',
  27. codeType: ''
  28. }
  29. },
  30. computed: {
  31. ...mapState(['storeInfo'])
  32. },
  33. methods: {
  34. getCode() {
  35. var dateStr = (new Date()).getTime();
  36. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  37. uni.showLoading({
  38. title: '获取小程序码中'
  39. })
  40. this.requst({
  41. url: this.getCodeUrl,
  42. data: {
  43. timestamp: dateStr,
  44. sign: sign,
  45. storeId: this.storeInfo.storeId,
  46. storeUserId: this.storeInfo.storeUserId,
  47. code: this.storeInfo.code
  48. },
  49. success: res => {
  50. uni.hideLoading()
  51. if (res.data.rtnBean.rtnCode == 0) {
  52. this.code = res.data.obj;
  53. this.$refs.poster.showCanvas();
  54. console.log('object :>> ', this.code);
  55. }
  56. },
  57. fail: (e) => {
  58. console.log("接口调用失败:" + JSON.stringify(e));
  59. uni.hideLoading()
  60. }
  61. })
  62. },
  63. save () {
  64. this.getCode()
  65. // this.$refs.poster.showCanvas();
  66. },
  67. // downLoadImg(){
  68. // uni.downloadFile({
  69. // url: this.url,
  70. // success: (res) =>{
  71. // if (res.statusCode === 200){
  72. // uni.saveImageToPhotosAlbum({
  73. // filePath: res.tempFilePath,
  74. // success: function() {
  75. // uni.showToast({
  76. // title: "保存成功",
  77. // icon: "none"
  78. // });
  79. // },
  80. // fail: function() {
  81. // uni.showToast({
  82. // title: "保存失败,请稍后重试",
  83. // icon: "none"
  84. // });
  85. // }
  86. // });
  87. // }
  88. // }
  89. // })
  90. // },
  91. //引导用户开启权限
  92. isAuth() {
  93. uni.showModal({
  94. content: '无法进行保存,请点击确定允许授权',
  95. success: (res) => {
  96. if (res.confirm) {
  97. uni.openSetting({
  98. success: (result) => {
  99. console.log(result.authSetting);
  100. }
  101. });
  102. }
  103. }
  104. });
  105. }
  106. },
  107. onLoad (opt) {
  108. console.log('opt :>> ', opt);
  109. this.backImgUrl = opt.src
  110. this.codeType = opt.id
  111. // if (opt.id != null && opt.id != '' && opt.id != undefined){
  112. // }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .cover-bg {
  118. height: 760rpx;
  119. // background-color: #E5CB1E;
  120. margin-bottom: 100rpx;
  121. .qrcode {
  122. width: 440rpx;
  123. height: 774rpx;
  124. position: absolute;
  125. top: 50rpx;
  126. left: calc((100% - 440rpx) / 2);
  127. background-color: #fff;
  128. }
  129. }
  130. .desc {
  131. font-size: $font-base;
  132. color: $desc-color;
  133. padding: 0 30rpx;
  134. }
  135. .save {
  136. width: 80%;
  137. height: 80rpx;
  138. border-radius: 40rpx;
  139. position: fixed;
  140. left: 10%;
  141. bottom: calc(20rpx + env(safe-area-inset-bottom));
  142. bottom: calc(20rpx + constant(safe-area-inset-bottom));
  143. background-color: $light-color;
  144. color: #fff;
  145. font-size: 36rpx;
  146. @include flexCenter;
  147. }
  148. </style>