123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- <template>
- <view>
- <!-- #ifdef MP-ALIPAY -->
- <u-navbar title="分享" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" leftIconSize="0" />
- <!-- #endif -->
- <!-- #ifndef MP-ALIPAY -->
- <u-navbar title="分享" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
- <!-- #endif -->
- <view class="flex invitation">
- <view class="flex invitation-user">
- <image src="../../static/public/share_bg.png" mode="aspectFit"></image>
- <view class="title">盲票</view>
- <image class="avatar" :src="avatar" mode="scaleToFill"></image>
- </view>
- <view class="invitation-name">{{ userInfo.nickName }}</view>
- <view class="invitation-name-tip">邀请您一起来刮盲票</view>
- <view class="flex invitation-code">
- <image :src="codeUrl" mode="aspectFill"></image>
- </view>
- <view class="invitation-code-tip">长按识别二维码</view>
- <view class="invitation-bottom-tip">盲票,玩的就是有趣</view>
- </view>
- <view class="flex btn">
- <button type="default" open-type="share">分享链接给好友</button>
- <button type="default" @click="saveImg">保存海报</button>
- </view>
- <share-code ref="shareCode" :posterData.sync="posterData" />
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- import appId from '@/config/appId.js'
- import ShareCode from "../../components/share-code/share-code.vue"
- export default {
- components: {
- ShareCode
- },
- data() {
- return {
- codeUrl: '',
- userInfo: {},
- avatar: '',
- boxId: '',
- // 图片数据
- posterData: {
- poster: {
- //根据屏幕大小自动生成图片背景大小
- url: "https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/mp.png", //图片地址
- r: 15, //圆角半径
- w: 340, //图片宽度
- h: 447, //图片高度
- p: 20 //图片内边距padding
- },
- mainImg: {
- // 头像
- url: "", //图片地址
- r: 33, //圆角半径
- w: 66, //宽度
- h: 66, //高度
- mt: 40
- },
- title: {
- // 昵称
- text: "", //文本
- fontSize: 26, //字体大小
- color: "#4F4F4F", //颜色
- lineHeight: 37, //行高#4F4F4F 100%
- mt: 30, //margin-top
- w: 300,
- align: "center"
- },
- codeImg: {
- // 小程序码
- url: "", //图片地址
- w: 124, //宽度
- h: 124, //高度
- mt: 20, //margin-top
- r: 62, //圆角半径
- mt: 55
- },
- tips: [
- ]
- }
- };
- },
- onLoad(options) {
- this.boxId = options.boxId
- },
- onShow() {
- this.getUrl()
- this.getBaseInfo()
- },
- methods: {
- getBaseInfo() {
- uni.showLoading({
- title: '加载中'
- });
- $http.post('/api/v1/mp/user/getLoginUserinfo', { appSource: appId }).then(res => {
- uni.hideLoading();
- if (res.code == 0) {
- this.userInfo = res.data
- this.avatar = this.posterData.mainImg.url = env.filePublic + res.data.avatar
- this.posterData.title.text = res.data.nickName
- }
- }).catch(() => {
- uni.hideLoading();
- })
- },
- getUrl() {
- $http.post('/api/v1/mp/user/share/code/generate', {
- boxId: this.boxId,
- type: "1",
- appSource: appId,
- }).then(res => {
- this.codeUrl = this.posterData.codeImg.url = env.filePublic + res.data
- })
- },
- saveImg() {
- this.$refs.shareCode.posterShow()
- },
- },
- onShareAppMessage(res) {
- return {
- title: '分享盲票',
- path: `/pages/ticketBox/detail?boxId=${ this.boxId }&userId=${ this.userInfo.userId }&type=1`,
- type: 2,
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .invitation {
- flex-direction: column;
- margin: 50rpx 30rpx;
- padding: 0 0 80rpx;
- border: 1px solid rgba(236, 236, 236, 100);
- border-radius: 20rpx;
- background-color: #FFFFFF;
- &-user {
- position: relative;
- width: 100%;
- margin-bottom: 80rpx;
- image {
- width: 100%;
- height: 188rpx;
- border-top-left-radius: 20rpx;
- border-top-right-radius: 20rpx;
- }
- .title {
- position: absolute;
- font-size: 52rpx;
- color: #FFFFFF;
- top: 20rpx;
- }
- .avatar {
- position: absolute;
- width: 134rpx;
- height: 134rpx;
- border-radius: 50%;
- top: 120rpx;
- }
- }
- .invitation-name {
- font-size: 52rpx;
- margin-bottom: 40rpx;
- }
- .invitation-name-tip {
- font-size: 36rpx;
- color: rgba(134, 134, 134, 100);
- margin-bottom: 20rpx;
- }
- .invitation-code {
- image {
- width: 250rpx;
- height: 250rpx;
- margin-bottom: 20rpx;
- }
- }
- .invitation-code-tip {
- font-size: 34rpx;
- color: rgba(181, 181, 181, 100);
- margin-bottom: 60rpx;
- }
- .invitation-bottom-tip {
- font-size: 28rpx;
- }
- }
- .tip {
- text-align: center;
- }
- .btn {
- padding: 40rpx 20rpx;
- .ge {
- height: 40rpx;
- }
- ::v-deep button {
- line-height: 60rpx;
- font-size: 28rpx;
- height: 60rpx;
- color: #fff;
- background-color: $uni-bg-color;
- border: none;
- border-radius: 8rpx;
- }
- }
- </style>
|