123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <template>
- <view class="pages">
- <view class="invite-fans flex-col col-center">
- <image :src="path" mode="widthFix" class="poster"></image>
- <invite-poster v-if="showPoster" :config="{
- avatar: userInfo.avatar,
- nickname: userInfo.nickname,
- code: inviteCode,
- link: link,
- qrCode: qrCode,
- poster: poster
- }" @success="handleSuccess" />
- <view class="bg-white footer flex-1">
- <view class="m-b-40">
- <view class="m-b-10 sm lighter">我的邀请码</view>
- <view class="flex row-between">
- <view class="font-size-44">{{inviteCode}}</view>
- <view class="sm m-r-30 copy-btn" @tap="onCopy(inviteCode)">点击复制</view>
- </view>
- </view>
- <!-- #ifndef H5 -->
- <button class="save-btn br60" size="lg" @tap="saveImageToAlbum">保存到相册</button>
- <!-- #endif -->
- <!-- #ifdef H5 -->
- <button class="save-btn br60" size="lg">长按保存到相册</button>
- <!-- #endif -->
- </view>
- </view>
- <loading-view v-show="loading"></loading-view>
- </view>
- </template>
- <script>
- import {
- apiMnpQrCode
- } from '@/api/app'
- import {
- baseURL,
- basePath
- } from '@/config/app'
- import {
- mapGetters
- } from 'vuex'
- import {
- apiDistributionPoster
- } from '@/api/user'
- import {
- copy
- } from '@/utils/tools.js'
- export default {
- data() {
- return {
- path: '',
- qrCode: '',
- loading: true,
- showPoster: false,
- poster: ''
- };
- },
- async onLoad() {
- await this.getPoster()
- // #ifdef MP-WEIXIN
- this.getMnpQrCode()
- // #endif
- // #ifdef APP-PLUS || H5
- this.showPoster = true
- // #endif
- },
- methods: {
- onCopy(text) {
- copy(text)
- },
- async getPoster() {
- const res = await apiDistributionPoster()
- this.poster = res.data.poster
- },
- getMnpQrCode() {
- apiMnpQrCode({
- type: 0,
- url: 'pages/index/index'
- }).then(res => {
- console.log(res)
- this.qrCode = res.data.qr_code
- this.showPoster = true
- })
- },
- saveImageToAlbum() {
- // #ifndef H5
- uni.saveImageToPhotosAlbum({
- filePath: this.path,
- success: res => {
- this.$toast({
- title: "保存成功"
- });
- },
- fail: err => {
- this.$toast({
- title: '保存失败'
- });
- }
- });
- // #endif
- // #ifdef H5
- this.$toast({
- title: '请长按图片保存'
- })
- // #endif
- },
- handleSuccess(val) {
- this.path = val
- this.loading = false
- }
- },
- computed: {
- ...mapGetters(['inviteCode', 'userInfo']),
- link() {
- return `${baseURL}${basePath}/pages/register/register?invite_code=${this.inviteCode}`
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- padding: 0
- }
- .invite-fans {
- min-height: 100vh;
- overflow: hidden;
- .poster {
- width: 600rpx;
- margin: 40rpx 0;
- }
- .footer {
- padding: 30rpx;
- width: 100%;
- }
- .copy-btn {
- color: $-color-primary;
- }
- .save-btn {
- color: #fff;
- background-color: $-color-primary;
- ;
- }
- }
- </style>
|