| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <template>
- <view class="goCode" :class="[AppTheme]">
- <view class="code">
- <image :src="code1" alt="" class="img" mode="widthFix"/>
- </view>
- <view class=" bcfxhb" @click="saveImg(code1)" :style="{'background-color': primary}">
- 保存分享海报
- </view>
- </view>
- </template>
- <script>
- import mineApi from '@/api/mine/index.js'
- export default {
- data() {
- return {
- primary:this.$theme.primary,
- settingFile:getApp().globalData.siteinfo,
- code1: ''
- };
- },
- onShow() {
- var that = this;
- mineApi.myqrcode({
- // #ifdef MP-WEIXIN
- apptype: 'weixin'
- // #endif
- // #ifdef H5
- apptype: 'h5'
- // #endif
- }).then(ret=>{
-
- if(ret.status == 200){
- that.code1 = ret.data.img
- }else{
- this.$u.toast(ret.msg)
- }
- })
- },
- methods: {
- saveImg(url) {
- const that = this;
- console.log('url',url)
- uni.downloadFile({
- url: url,
- success: res => {
- if (res.statusCode === 200) {
- uni.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success: function() {
- uni.showToast({
- title: '保存下载成功',
- icon: 'none',
- position: 'top'
- })
- },
- fail: function() {
- uni.showToast({
- title: '保存失败,请稍后重试',
- icon: 'none',
- position: 'top'
- })
- }
- });
- } else {
- uni.showToast({
- title: '下载失败',
- icon: 'none',
- position: 'top'
- })
- }
- }
- });
- }
- }
- }
- </script>
- <style lang="scss">
- page{
- width:100%;
- height: 100%;
- }
- .code {
- width: 100%;
- height: 100%;
- }
- .code .img {
- // position: fixed;
- // width: 100%;
- // height: 100%;
- width: 690rpx;
- display: block;
- margin: auto;
- border-radius: 20rpx;
- }
- .bcfxhb {
- width: 550rpx;
- height: 100rpx;
- color: #fff;
- border-radius: 50rpx;
- text-align: center;
- line-height: 100rpx;
- margin:20rpx auto;
- }
- </style>
|