浏览代码

修改被分享进来的ID

dev
corala 3 年前
父节点
当前提交
bd955a2cfe
共有 5 个文件被更改,包括 80 次插入17 次删除
  1. +1
    -8
      app.js
  2. +33
    -5
      pages/index/index.js
  3. +6
    -1
      pages/login/index.js
  4. +4
    -3
      pages/share/index.js
  5. +36
    -0
      project.private.config.json

+ 1
- 8
app.js 查看文件

@@ -17,18 +17,11 @@ App({
const logs = wx.getStorageSync('logs') || [] const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now()) logs.unshift(Date.now())
wx.setStorageSync('logs', logs) wx.setStorageSync('logs', logs)
// 登录
// wx.login({
// success: res => {
// // 发送 res.code 到后台换取 openId, sessionKey, unionId
// }
// })
this.loginGettoken() this.loginGettoken()
}, },
globalData: { globalData: {
userInfo: null, userInfo: null,
token: '2222'
token: ''
}, },
//登录-获取token //登录-获取token
loginGettoken(){ loginGettoken(){


+ 33
- 5
pages/index/index.js 查看文件

@@ -2,19 +2,47 @@
// 获取应用实例 // 获取应用实例
const app = getApp() const app = getApp()



Page({ Page({
data: { 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() { tabindex() {
let userInfo = getApp().globalData.userInfo let userInfo = getApp().globalData.userInfo
console.log(userInfo) console.log(userInfo)
let id = 0 let id = 0
if(userInfo.phone){ if(userInfo.phone){
id = userInfo.id
id = userInfo.id
} }
wx.navigateTo({ wx.navigateTo({
url: '/pages/out/index?index=1&userid=' + id+ '&gameid=1&type=1' url: '/pages/out/index?index=1&userid=' + id+ '&gameid=1&type=1'
@@ -22,7 +50,7 @@ Page({
}, },
tabsaoma() { tabsaoma() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/AR/index',
url: '/pages/AR/index'
}) })
} }
}) })

+ 6
- 1
pages/login/index.js 查看文件

@@ -124,6 +124,9 @@ Page({
success: (res) => { success: (res) => {
// console.log(res) // console.log(res)
that.bindNickname(res.userInfo) 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) { success(res) {
console.log(res) console.log(res)
if (res.data.code == 0) { if (res.data.code == 0) {
// console.log(res)
console.log(res)
that.setData({ that.setData({
phoneModal: false, phoneModal: false,
showBg: false, showBg: false,
step: 0 step: 0
}) })
getApp().globalData.userInfo.phone = res.data.data
console.log(getApp().globalData.userInfo)
that.leave() that.leave()
} }
} }


+ 4
- 3
pages/share/index.js 查看文件

@@ -6,12 +6,13 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
userInfo: getApp().globalData.userInfo
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
console.log(this.data.userInfo)
}, },
closeShare(){ closeShare(){
let userInfo = getApp().globalData.userInfo let userInfo = getApp().globalData.userInfo
@@ -66,12 +67,12 @@ Page({
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function (e) { onShareAppMessage: function (e) {
console.log(e)
// console.log(getApp().globalData.userInfo.id)
this.shareFun() this.shareFun()
return { return {
title: '万套房源5折起iPhone13 Pro Max免费赢', title: '万套房源5折起iPhone13 Pro Max免费赢',
imageUrl: 'https://static.quhouse.com/468340e3a1374decb4fa51a172aa4f52.png', imageUrl: 'https://static.quhouse.com/468340e3a1374decb4fa51a172aa4f52.png',
path: '/pages/index/index'
path: '/pages/index/index?id=' + getApp().globalData.userInfo.id
} }
}, },
shareFun(){ shareFun(){


+ 36
- 0
project.private.config.json 查看文件

@@ -33,6 +33,42 @@
"pathName": "pages/login/index", "pathName": "pages/login/index",
"query": "", "query": "",
"scene": null "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
} }
] ]
} }


正在加载...
取消
保存