diff --git a/app.js b/app.js index d7b17a4..36f91d5 100644 --- a/app.js +++ b/app.js @@ -17,18 +17,11 @@ App({ const logs = wx.getStorageSync('logs') || [] logs.unshift(Date.now()) wx.setStorageSync('logs', logs) - // 登录 - // wx.login({ - // success: res => { - // // 发送 res.code 到后台换取 openId, sessionKey, unionId - // } - // }) - this.loginGettoken() }, globalData: { userInfo: null, - token: '2222' + token: '' }, //登录-获取token loginGettoken(){ diff --git a/pages/index/index.js b/pages/index/index.js index 5a52025..5d3f50c 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -2,19 +2,47 @@ // 获取应用实例 const app = getApp() - Page({ data: { }, - onLoad() { + onLoad(option) { + console.log(option.id) + let that = this + if(option.id){ // 有ID则是通过分享链接进来的 + setTimeout(function(){ + that.inviteFun(option.id) + },1000) + } + }, + inviteFun(id){ + let token = wx.getStorageSync('token') + console.log(token) + wx.request({ + url: 'https://cktest.2weisou.com/meta/ar/user/bindNShareUserId?shareUserId='+ id, + method: "get", + data: {}, + header: { + Authorization: 'bearer '+ token + }, + success(res) { + if (res.data.code == 0) { + + }else{ + wx.showToast({ + icon: 'none', + title: res.data.msg + }) + return ; + } + } + }) }, - tabindex() { let userInfo = getApp().globalData.userInfo console.log(userInfo) let id = 0 if(userInfo.phone){ - id = userInfo.id + id = userInfo.id } wx.navigateTo({ url: '/pages/out/index?index=1&userid=' + id+ '&gameid=1&type=1' @@ -22,7 +50,7 @@ Page({ }, tabsaoma() { wx.navigateTo({ - url: '/pages/AR/index', + url: '/pages/AR/index' }) } }) \ No newline at end of file diff --git a/pages/login/index.js b/pages/login/index.js index 81da60d..94a6489 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -124,6 +124,9 @@ Page({ success: (res) => { // console.log(res) that.bindNickname(res.userInfo) + getApp().globalData.userInfo.userWxName = res.userInfo.nickName + console.log(2121212) + console.log(getApp().globalData.userInfo) } }) }, @@ -149,12 +152,14 @@ Page({ success(res) { console.log(res) if (res.data.code == 0) { - // console.log(res) + console.log(res) that.setData({ phoneModal: false, showBg: false, step: 0 }) + getApp().globalData.userInfo.phone = res.data.data + console.log(getApp().globalData.userInfo) that.leave() } } diff --git a/pages/share/index.js b/pages/share/index.js index eaa6dcc..25b3ba1 100644 --- a/pages/share/index.js +++ b/pages/share/index.js @@ -6,12 +6,13 @@ Page({ * 页面的初始数据 */ data: { + userInfo: getApp().globalData.userInfo }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + console.log(this.data.userInfo) }, closeShare(){ let userInfo = getApp().globalData.userInfo @@ -66,12 +67,12 @@ Page({ * 用户点击右上角分享 */ onShareAppMessage: function (e) { - console.log(e) + // console.log(getApp().globalData.userInfo.id) this.shareFun() return { title: '万套房源5折起iPhone13 Pro Max免费赢', imageUrl: 'https://static.quhouse.com/468340e3a1374decb4fa51a172aa4f52.png', - path: '/pages/index/index' + path: '/pages/index/index?id=' + getApp().globalData.userInfo.id } }, shareFun(){ diff --git a/project.private.config.json b/project.private.config.json index ef7e2b3..73c62ba 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -33,6 +33,42 @@ "pathName": "pages/login/index", "query": "", "scene": null + }, + { + "name": "pages/index/index", + "pathName": "pages/index/index", + "query": "id=68", + "scene": null + }, + { + "name": "pages/index/index", + "pathName": "pages/index/index", + "query": "id=83", + "scene": null + }, + { + "name": "pages/index/index", + "pathName": "pages/index/index", + "query": "", + "scene": null + }, + { + "name": "pages/index/index", + "pathName": "pages/index/index", + "query": "id=68", + "scene": null + }, + { + "name": "pages/share/index", + "pathName": "pages/share/index", + "query": "id=88", + "scene": null + }, + { + "name": "pages/index/index", + "pathName": "pages/index/index", + "query": "id=88", + "scene": null } ] }