123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <template>
- <view class="content">
- <image src="http://xxl.liuniu946.com/static/image/share-bg.png" mode="" class="bg"></image>
- <view class="">
- </view>
- <view class="share-user-logo">
- <image :src="userlogo" mode=""></image>
- </view>
- <view class="good">
- <image src="http://xxl.liuniu946.com/static/image/good.png" mode=""></image>
- </view>
- <view class="good-tit">
- {{goodname}}
- </view>
- <!-- #ifdef MP-WEIXIN -->
- <button class="share-btn" open-type="share" v-if="couldshare == 1">
- 立即分享
- </button>
- <!-- #endif -->
- <!-- #ifdef H5 -->
- <button class="share-btn" open-type="share" v-if="couldshare == 1" @click="imgShare = true">
- 立即分享
- </button>
- <!-- #endif -->
- <view class="share-btn" v-if="couldshare == 2" @click="getGift">
- {{jsspan}}
- </view>
- <image src="../../static/img/shareimg.png" mode="" style="position: fixed;top:0;width: 750rpx;height: 100%;"
- v-if="imgShare" @click="imgShare = !imgShare">
- </image>
- </view>
- </template>
- <script>
- // #ifdef H5
- import {
- weixindata,
- shareLoad
- } from '@/utils/wxAuthorized';
- // #endif
- import {
- getGift
- } from '@/api/shop.js'
- export default {
- data() {
- return {
- code: '',
- imgShare: false,
- userlogo: '',
- shareId: '',
- nickname: '',
- goodimg: '',
- couldshare: 0,
- jsspan: '立即领取',
- goodname: ''
- }
- },
- onLoad(opt) {
- this.code = opt.code
- this.userlogo = opt.logo
- this.shareId = opt.shareid
- this.nickname = decodeURI(opt.nickname)
- this.couldshare = opt.type
- this.goodname = decodeURI(opt.goodname)
- // #ifdef MP
- if (opt.type == 2) {
- if (opt.scene) {
- // 存储小程序邀请人
- uni.setStorage({
- key: 'spread_code',
- data: opt.scene
- });
- }
- }
- // #endif
- // #ifdef H5
- this.IndexShare()
- // #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 + '分享您' + obj.goodname, // 默认是小程序的名称(可以写slogan等)
- path: url + '?code=' + obj.code + '&type=2' +
- '&logo=' + obj.userlogo +
- '&nickname=' + encodeURI(obj.nickname) + '&goodname=' + encodeURI(obj
- .goodname), // 默认是当前页面,必须是以‘/’开头的完整路径
- imageUrl: 'http://xxl.liuniu946.com/static/image/good.png',
- 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: {
- // #ifdef H5
- IndexShare() {
- let obj = this;
- console.log(obj.Path);
- let data = {
- link: obj.$store.state.baseURL + '/index/#/pages/shop/shareF?code=' + obj.code + '&type=2' +
- '&logo=' + obj.userlogo +
- '&nickname=' + encodeURI(obj.nickname) + '&goodname=' + encodeURI(obj.goodname),
- desc: obj.nickname + '向您分享' + obj.goodname,
- title: '欢迎加入想亮',
- imgUrl: 'http://xxl.liuniu946.com/static/image/good.png',
- success() {
- console.log('分享加载完成')
- }
- };
- weixindata().then(wxOjb => {
- wxOjb.updateAppMessageShareData(data);
- // 分享朋友圈
- wxOjb.updateTimelineShareData(data)
- })
- // 保存邀请人
- console.log(data, '分享数据');
- // weixindata(data);
- },
- // #endif
- getGift() {
- let obj = this
- console.log('ddd')
- getGift({
- code: obj.code
- }).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: #f32556;
- width: 100%;
- height: 100%
- }
- .content {
- position: relative;
- background-color: #f32556;
- 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>
|