Commit ef193272 authored by Facius's avatar Facius

feat: 邀请分享

parent 5e6e0ffb
......@@ -2,7 +2,6 @@
<script>
import { getLatestVersionNumber } from '@/api/common/index.js';
import { version } from '@/utils/config.js';
import { checkToken} from '@/utils/common.js';
export default {
onLaunch: function() {
......@@ -22,18 +21,8 @@ import { checkToken} from '@/utils/common.js';
this.appUpdateCheck()
// #endif
},
onShow: function(options) {
var options = {query:{shareUserId: 2131}}
console.log('App Show', options)
if (options && options.query && options.query.shareUserId) {
var shareUserId = options.query.shareUserId
console.log('---App Show---被邀请进来--------', shareUserId)
if (checkToken()) {
// 调接口
} else {
uni.setStorageSync('shareUserId', shareUserId);
}
}
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
......
......@@ -16,13 +16,3 @@ export function sendCode(data) {
data
})
}
export function mobileLogin(data) {
return request({
url: `/anno/mobileLogin`,
method: 'GET',
data,
noLoading:true
})
}
\ No newline at end of file
import request from "@/utils/request.js"
// 邀请有奖的分享
export async function shareInvited(data) {
return request({
url: `/rest/share`,
method: 'PUT',
data,
noLoading: true
})
}
// 被邀请者通过链接进入应用
export async function shareInto(data) {
return request({
url: `/rest/share/into`,
method: 'POST',
data,
noLoading: true
})
}
......@@ -121,6 +121,7 @@ import { checkVip, checkToken, getSetting, formatCount } from '@/utils/common.js
import { checkOpenPermission, checkOpenService } from '@/utils/app-plus-auth.js';
import { mapGetters } from 'vuex';
import { experienceVip } from '@/api/mine/pay.js';
import { shareInto } from '@/api/mine/share.js';
export default {
components: {
......@@ -271,6 +272,10 @@ export default {
const q = decodeURIComponent(options.q); // 获取到二维码原始链接内容
console.log(q);
}
if (options && options.shareUserId) { // 点别人的分享邀请进来
uni.setStorageSync('shareUserId', options.shareUserId)
}
this.freshing = false;
uni.$on('bill-list-reload', res => {
setTimeout(() => {
......@@ -280,11 +285,10 @@ export default {
this.systemInfo = uni.getSystemInfoSync();
},
onShow() {
console.log('index/index===onShow');
this.initInfo();
if (this.checkToken()) {
this.getUserInfo();
this.checkShare()
this.checkShare() // 检查是否是点别人的分享邀请进来
}
this.shareSuccessTip();
},
......@@ -507,10 +511,15 @@ export default {
checkShare() {
const shareUserId = uni.getStorageSync('shareUserId');
if (shareUserId) {
console.log('---index---被邀请进来------', shareUserId)
// 调接口
// 成功之后
// uni.setStorageSync('shareUserId', '');
shareInto({
inviter: shareUserId
})
.then(res => {
uni.setStorageSync('shareUserId', '');
})
.catch(err => {
console.log(err);
});
}
},
handleClickShare() {
......@@ -556,7 +565,6 @@ export default {
});
// #endif
},
handleShare() {},
// 朋友圈
onShareTimeline(res) {
var image = this.isVipShare ? this.shareImage : '';
......
......@@ -35,6 +35,7 @@
import NavbarRight from '@/components/navbar-right';
import { mapGetters } from 'vuex';
import { wxMiniId, webUrl } from '@/utils/config.js';
import { shareInvited } from '@/api/mine/share.js';
export default {
components: {
......@@ -77,11 +78,21 @@ export default {
},
methods: {
handleClickShare () {
shareInvited () {
shareInvited({})
.then(res => {
if (res.data) {
}
})
.catch(err => {
console.log(err);
});
},
handleClickShare () {
// #ifdef APP-PLUS
this.shareInvited()
uni.share({
provider: 'weixin',
scene: 'WXSceneSession',
......@@ -107,6 +118,7 @@ export default {
},
// 朋友圈
onShareTimeline (res) {
this.shareInvited()
return {
title: '扳手记账',
path: `/pages/index/index?shareUserId=${this.userInfo.id}`,
......@@ -115,6 +127,7 @@ export default {
},
// 好友
onShareAppMessage (res) {
this.shareInvited()
return {
title: '扳手记账',
path: `/pages/index/index?shareUserId=${this.userInfo.id}`,
......
......@@ -22,7 +22,6 @@ import {
} from "@/utils/config.js"
import {
userAuthLogin,
mobileLogin
} from "@/api/login/index.js";
import {
getUserInfo,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment