| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <template>
- <view class="content">
- <image src="../../static/img/share-card.jpg" mode="" class="bg"></image>
- <view class="">
-
- </view>
- <view class="share-user-logo">
- <image :src="userlogo" mode=""></image>
- </view>
- <view class="good">
- <image :src="goodimg" mode=""></image>
- </view>
- <view class="good-tit">
- 子臣鸭汤兑换券
- </view>
- <button class="share-btn" open-type="share" v-if="couldshare == 1">
- 立即分享
- </button>
- <view class="share-btn" v-if="couldshare == 2" @click="getGift">
- {{jsspan}}
- </view>
- </view>
- </template>
- <script>
- import { getGift } from '@/api/order.js'
- export default {
- data() {
- return {
- userlogo: '',
- shareId: '',
- nickname: '',
- goodimg: '',
- couldshare: 0,
- jsspan: '立即领取'
- }
- },
- onLoad(opt) {
- this.userlogo = opt.logo
- this.shareId = opt.shareid
- this.nickname = opt.nickname
- this.goodimg = opt.goodimg
- this.couldshare = opt.type
-
- // #ifdef MP
- if(opt.type == 2 ) {
- if (opt.scene) {
- // 存储小程序邀请人
- uni.setStorage({
- key: 'spread_code',
- data: opt.scene
- });
- }
- }
- // #endif
- },
- // 分享
- onShareAppMessage(options) {
- let obj = this
- // 设置菜单中的转发按钮触发转发事件时的转发内容
- let pages = getCurrentPages(); //获取加载的页面
- let currentPage = pages[pages.length - 1]; //获取当前页面的对象
- let url = currentPage.route; //当前页面url
- let item = currentPage.options; //如果要获取url中所带的参数可以查看options
- // let name = this.goodsObjact.store_name || this.goodsObjact.title;
- let shareObj = {
- title: obj.nickname + '分享您一张子臣鸭汤兑换券', // 默认是小程序的名称(可以写slogan等)
- path: url + '?shareid=' + item.shareid + '&scene=' + item.scene + '&goodimg=' + item.goodimg + '&logo=' + item.logo + '&type=2' + '&nickname='+ item.nickname, // 默认是当前页面,必须是以‘/’开头的完整路径
- imageUrl: item.goodimg,
- success: function(res) {
- console.log(shareObj.path, 'path+++++++++++++++++++');
- // 转发成功之后的回调
- if (res.errMsg == 'shareAppMessage:ok') {
- }
- },
- fail: function() {
- // 转发失败之后的回调
- if (res.errMsg == 'shareAppMessage:fail cancel') {
- // 用户取消转发
- } else if (res.errMsg == 'shareAppMessage:fail') {
- // 转发失败,其中 detail message 为详细失败信息
- }
- }
- };
-
- return shareObj;
- },
- methods: {
- getGift() {
- let obj = this
- console.log('ddd')
- getGift({},this.shareId).then(res => {
- console.log(res)
- uni.showToast({
- title:'领取成功',
- duration:2000
- });
- obj.jsspan = '已领取'
- setTimeout(()=> {
- uni.switchTab({
- url: '/pages/index/index'
- })
- },1500)
-
- }).catch(err => {
- console.log(err)
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- background-color: #901b21;
- width: 100%;
- height: 100%
- }
- .content {
- position: relative;
- background-color: #901b21;
- min-height: 100%;
- .bg {
- // position: absolute;
- width: 750rpx;
- height: 1334rpx;
- }
- .share-btn {
- width: 492rpx;
- height: 86rpx;
- background-color: #ebd49e;
- border-radius: 43rpx;
- text-align: center;
- line-height: 86rpx;
- color: #901b21;
- font-weight: bold;
- font-size: 36rpx;
- position: absolute;
- top: 1159rpx;
- left: 130rpx;
- }
- .share-user-logo {
- position: absolute;
- top: 400rpx;
- left: 0;
- right: 0;
- margin: auto;
- width: 118rpx;
- height: 118rpx;
- border-radius: 50%;
- image {
- width: 118rpx;
- height: 118rpx;
- border-radius: 50%;
- }
- }
- .good {
- width: 290rpx;
- height: 290rpx;
- border-radius: 20rpx;
- position: absolute;
- top: 560rpx;
- left: 0;
- right: 0;
- margin: auto;
- image {
- width: 290rpx;
- height: 290rpx;
- border-radius: 20rpx;
- }
- }
- .good-tit {
- position: absolute;
- font-size: 32rpx;
- color: #901b21;
- text-align: center;
- width: 750rpx;
- top: 880rpx;
- }
- }
- </style>
|