浏览代码

修改跳转传参问题

dev
corala 3 年前
父节点
当前提交
f69b943863
共有 6 个文件被更改,包括 81 次插入19 次删除
  1. +36
    -2
      app.js
  2. +5
    -3
      pages/index/index.js
  3. +34
    -2
      pages/login/index.js
  4. +2
    -8
      pages/middle/index.js
  5. +3
    -3
      pages/share/index.js
  6. +1
    -1
      pages/share/index.wxml

+ 36
- 2
app.js 查看文件

@@ -23,9 +23,43 @@ App({
// // 发送 res.code 到后台换取 openId, sessionKey, unionId
// }
// })
this.loginGettoken()
},
globalData: {
userInfo: null,
token: '1212121212'
}
token: '2222'
},
//登录-获取token
loginGettoken(){
let that = this
wx.login({
success (res) {
if (res.code) {
//发起网络请求
wx.request({
url:'https://cktest.2weisou.com/meta/auth/mobile/token/social?grant_type=mobil&mobile=MINI_C@'+res.code+'@'+'',
method: "POST",
data: {
},
header: {
Authorization: "Basic YXBwbGV0OmFwcGxldA==",
},
success(res1) {
if (res1.statusCode == 200) {
let userInfo = res1.data.user_info
that.globalData.token = res1.data.access_token
that.globalData.userInfo = res1.data.user_info
// console.log(that.globalData.token)
// console.log(that.globalData.userInfo)
wx.setStorageSync('token', res1.data.access_token)
wx.setStorageSync('userInfo', res1.data.user_info)
}
}
})
} else {
console.log('登录失败!' + res.errMsg)
}
}
})
},
})

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

@@ -8,10 +8,12 @@ Page({
},
onLoad() {
},
tabindex(e) {
let index= e.currentTarget.dataset.index
tabindex() {
let userInfo = getApp().globalData.userInfo
console.log(userInfo)
wx.navigateTo({
url: '../out/index?index=' +index,
url: '/pages/out/index?index=1&userid=' + userInfo.id + '&gameid=1'+ '&type=' + 1
})
},
tabsaoma() {


+ 34
- 2
pages/login/index.js 查看文件

@@ -1,7 +1,9 @@
// index.js
// 获取应用实例
const app = getApp()

let userInfo = getApp().globalData.userInfo
let token = getApp().globalData.token
console.log(userInfo)
Page({
data: {
avatarModal: false,
@@ -16,7 +18,37 @@ Page({
token: ''
},
onLoad() {
this.loginGettoken()
if (userInfo) {
this.setData({
token: token,
userid: userInfo.id,
userInfo: userInfo
})
if(!!userInfo.userWxName&&!!userInfo.phone){
this.leave()
return;
}
if(!userInfo.userWxName||!userInfo.phone){
this.setData({
showBg: true
})
}else{
this.setData({
showBg: false
})
}
this.setData({
avatarModal: !!userInfo.userWxName?false:true,
phoneModal1: !!userInfo.phone?false:true,
step: 1
})
if(!this.data.avatarModal){
this.setData({
step: 2,
phoneModal: this.data.phoneModal1
})
}
}
},
backhome(){
wx.navigateTo({


+ 2
- 8
pages/middle/index.js 查看文件

@@ -1,4 +1,4 @@
// pages/out/index.js
Page({

/**
@@ -10,17 +10,11 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// wx.navigateTo({
// url: '/pages/login/index'
// })
wx.showModal({
title: '温馨提示',
content: '确定进入该小程序吗',
showCancel: false,//是否显示取消按钮
// cancelText: "取消",//默认是“取消”
// cancelColor: '#000000',//取消文字的颜色
// confirmText: "确定",//默认是“确定”
// confirmColor: '#3cc51f',//确定文字的颜色
success: function (res) {
if (res.cancel) {
//点击取消,wx.navigateBack


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

@@ -12,13 +12,13 @@ Page({
onLoad: function (options) {
},
backGame(){
closeShare(){
// wx.navigateBack({
// delta: 1
// })
let userInfo = wx.getStorageSync('userInfo')
wx.navigateTo({
url: `/pages/login/index?index=1&userid=${userInfo.id}&gameid=1&type=2`,
url: `/pages/out/index?index=1&userid=${userInfo.id}&gameid=1&type=2`,
})
},
/**
@@ -70,7 +70,7 @@ Page({
console.log(e)
this.shareFun()
return {
title: '5.5元购新房万份好礼免费兑',
title: '万套特惠房源5折起iPhone13 Pro Max免费赢',
imageUrl: 'https://static.quhouse.com/468340e3a1374decb4fa51a172aa4f52.png',
path: '/pages/index/index'
}


+ 1
- 1
pages/share/index.wxml 查看文件

@@ -10,6 +10,6 @@
<!-- <image class="btn" src="https://static.quhouse.com/cbbbda43ce244fe39c235f59c2b1e8fa.png"></image> -->
<button class="btn" open-type="share"></button>
</view>
<image class="close" bindtap="backGame" src="https://static.quhouse.com/643b05904e17410aa568557328cf7dc1.png"></image>
<image class="close" bindtap="closeShare" src="https://static.quhouse.com/643b05904e17410aa568557328cf7dc1.png"></image>
</view>
</view>

正在加载...
取消
保存