Commit ef193272 authored by Facius's avatar Facius

feat: 邀请分享

parent 5e6e0ffb
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
<script> <script>
import { getLatestVersionNumber } from '@/api/common/index.js'; import { getLatestVersionNumber } from '@/api/common/index.js';
import { version } from '@/utils/config.js'; import { version } from '@/utils/config.js';
import { checkToken} from '@/utils/common.js';
export default { export default {
onLaunch: function() { onLaunch: function() {
...@@ -22,18 +21,8 @@ import { checkToken} from '@/utils/common.js'; ...@@ -22,18 +21,8 @@ import { checkToken} from '@/utils/common.js';
this.appUpdateCheck() this.appUpdateCheck()
// #endif // #endif
}, },
onShow: function(options) { onShow: function() {
var options = {query:{shareUserId: 2131}} console.log('App Show')
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);
}
}
}, },
onHide: function() { onHide: function() {
console.log('App Hide') console.log('App Hide')
......
...@@ -16,13 +16,3 @@ export function sendCode(data) { ...@@ -16,13 +16,3 @@ export function sendCode(data) {
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 ...@@ -121,6 +121,7 @@ import { checkVip, checkToken, getSetting, formatCount } from '@/utils/common.js
import { checkOpenPermission, checkOpenService } from '@/utils/app-plus-auth.js'; import { checkOpenPermission, checkOpenService } from '@/utils/app-plus-auth.js';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { experienceVip } from '@/api/mine/pay.js'; import { experienceVip } from '@/api/mine/pay.js';
import { shareInto } from '@/api/mine/share.js';
export default { export default {
components: { components: {
...@@ -271,6 +272,10 @@ export default { ...@@ -271,6 +272,10 @@ export default {
const q = decodeURIComponent(options.q); // 获取到二维码原始链接内容 const q = decodeURIComponent(options.q); // 获取到二维码原始链接内容
console.log(q); console.log(q);
} }
if (options && options.shareUserId) { // 点别人的分享邀请进来
uni.setStorageSync('shareUserId', options.shareUserId)
}
this.freshing = false; this.freshing = false;
uni.$on('bill-list-reload', res => { uni.$on('bill-list-reload', res => {
setTimeout(() => { setTimeout(() => {
...@@ -280,11 +285,10 @@ export default { ...@@ -280,11 +285,10 @@ export default {
this.systemInfo = uni.getSystemInfoSync(); this.systemInfo = uni.getSystemInfoSync();
}, },
onShow() { onShow() {
console.log('index/index===onShow');
this.initInfo(); this.initInfo();
if (this.checkToken()) { if (this.checkToken()) {
this.getUserInfo(); this.getUserInfo();
this.checkShare() this.checkShare() // 检查是否是点别人的分享邀请进来
} }
this.shareSuccessTip(); this.shareSuccessTip();
}, },
...@@ -507,10 +511,15 @@ export default { ...@@ -507,10 +511,15 @@ export default {
checkShare() { checkShare() {
const shareUserId = uni.getStorageSync('shareUserId'); const shareUserId = uni.getStorageSync('shareUserId');
if (shareUserId) { if (shareUserId) {
console.log('---index---被邀请进来------', shareUserId) shareInto({
// 调接口 inviter: shareUserId
// 成功之后 })
// uni.setStorageSync('shareUserId', ''); .then(res => {
uni.setStorageSync('shareUserId', '');
})
.catch(err => {
console.log(err);
});
} }
}, },
handleClickShare() { handleClickShare() {
...@@ -556,7 +565,6 @@ export default { ...@@ -556,7 +565,6 @@ export default {
}); });
// #endif // #endif
}, },
handleShare() {},
// 朋友圈 // 朋友圈
onShareTimeline(res) { onShareTimeline(res) {
var image = this.isVipShare ? this.shareImage : ''; var image = this.isVipShare ? this.shareImage : '';
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
import NavbarRight from '@/components/navbar-right'; import NavbarRight from '@/components/navbar-right';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { wxMiniId, webUrl } from '@/utils/config.js'; import { wxMiniId, webUrl } from '@/utils/config.js';
import { shareInvited } from '@/api/mine/share.js';
export default { export default {
components: { components: {
...@@ -77,11 +78,21 @@ export default { ...@@ -77,11 +78,21 @@ export default {
}, },
methods: { methods: {
handleClickShare () { shareInvited () {
shareInvited({})
.then(res => {
if (res.data) {
}
})
.catch(err => {
console.log(err);
});
}, },
handleClickShare () { handleClickShare () {
// #ifdef APP-PLUS // #ifdef APP-PLUS
this.shareInvited()
uni.share({ uni.share({
provider: 'weixin', provider: 'weixin',
scene: 'WXSceneSession', scene: 'WXSceneSession',
...@@ -107,6 +118,7 @@ export default { ...@@ -107,6 +118,7 @@ export default {
}, },
// 朋友圈 // 朋友圈
onShareTimeline (res) { onShareTimeline (res) {
this.shareInvited()
return { return {
title: '扳手记账', title: '扳手记账',
path: `/pages/index/index?shareUserId=${this.userInfo.id}`, path: `/pages/index/index?shareUserId=${this.userInfo.id}`,
...@@ -115,6 +127,7 @@ export default { ...@@ -115,6 +127,7 @@ export default {
}, },
// 好友 // 好友
onShareAppMessage (res) { onShareAppMessage (res) {
this.shareInvited()
return { return {
title: '扳手记账', title: '扳手记账',
path: `/pages/index/index?shareUserId=${this.userInfo.id}`, path: `/pages/index/index?shareUserId=${this.userInfo.id}`,
......
...@@ -22,7 +22,6 @@ import { ...@@ -22,7 +22,6 @@ import {
} from "@/utils/config.js" } from "@/utils/config.js"
import { import {
userAuthLogin, userAuthLogin,
mobileLogin
} from "@/api/login/index.js"; } from "@/api/login/index.js";
import { import {
getUserInfo, 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