描述:添加邀请

This commit is contained in:
SelfRidicule 2024-03-06 20:22:33 +08:00
parent f394ce42ad
commit 2be3c7ab11
3 changed files with 96 additions and 8 deletions

View File

@ -11,6 +11,11 @@ import {
selectCoordinateRq
} from "../../../api/meeting/meetingRoom.js"
import {
loginRq,
registerPhone
} from "../../../api/login/login.js"
Page({
@ -32,6 +37,10 @@ Page({
id: null,
detail: null,
address: {},
openid: null,
authorizationShow: true,
participateShow: false,
openDoorShow: false,
},
/**
@ -46,6 +55,8 @@ Page({
_this.getDetail();
// 获取地址信息
_this.getAddress()
// 自动登录获取openid
_this.autoLogin()
},
// 获取地址信息
@ -82,6 +93,69 @@ Page({
})
},
// 打开地图
openMap(e) {
console.log('openMap', e);
let _this = this;
wx.openLocation({
name: _this.data.address.address,
latitude: _this.data.address.lat,
longitude: _this.data.address.lng,
})
},
// 自动登录获取openid
autoLogin() {
let _this = this;
wx.login({
success(wxRes) {
loginRq({
"jsCode": wxRes.code
}).then(res => {
console.log('loginRq', res);
_this.setData({
openid: res.openid
})
// 判断用户是否注册
if (res.token) {
// 用户授权成功
_this.userAuthorizationSuccess(res.openid, res.user, res.token.token)
}
})
}
})
},
// 获取手机号
getPhoneNumber(e) {
let _this = this;
console.log('getPhoneNumber', e)
registerPhone({
"code": e.detail.code,
"openid": _this.data.openid
}).then(res => {
console.log('registerPhone', res);
// 用户授权成功
_this.userAuthorizationSuccess(res.openid, res.user, res.token.token)
})
},
// 用户授权成功
userAuthorizationSuccess(openid, user, token) {
let _this = this;
_this.setData({
authorizationShow : false
})
// 清空所有缓存
wx.clearStorageSync()
// 存储用户信息
wx.setStorageSync('openid', openid)
wx.setStorageSync('user', user)
wx.setStorageSync('userId', user.id)
wx.setStorageSync('token', token)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -7,13 +7,13 @@
</view>
<!-- 地图 -->
<map class="myMap" latitude="{{mapData.latitude}}" longitude="{{mapData.longitude}}" markers="{{mapData.markers}}" show-location></map>
<map class="myMap" latitude="{{mapData.latitude}}" longitude="{{mapData.longitude}}" markers="{{mapData.markers}}" show-location bindtap="openMap"></map>
<!-- 邀请人信息 -->
<view class="personView">
<view class="label">发起人</view>
<view class="item">
<image class="headImg" src="{{IMG_NAME + '/profile/static/index/banner/1.jpg'}}" mode="aspectFill"></image>
<image class="headImg" src="{{detail.avatar ? IMG_NAME + detail.avatar : IMG_NAME + '/profile/static/user/headImg.png'}}" mode="aspectFill"></image>
<view class="dataView">
<view class="name">{{detail.userName}}</view>
<view class="phone">{{detail.phone}}</view>
@ -34,7 +34,12 @@
<view class="title">会面时间</view>
<view class="content">{{detail.timeSlot}}</view>
</view>
<!-- 确认支付 -->
<view class="submitBtn">接受邀请</view>
<!-- 授权登录 -->
<view class="submitBtn" wx:if="{{authorizationShow}}">授权登录
<button class="loginBtn" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"></button>
</view>
<!-- 接受邀请 -->
<view class="submitBtn" wx:if="{{participateShow}}">接受邀请</view>
<!-- 点击开门 -->
<view class="submitBtn" wx:if="{{openDoorShow}}">点击开门</view>
</view>

View File

@ -86,6 +86,15 @@
text-align: center;
}
.loginBtn {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
opacity: 0;
}
.br {
height: 20rpx;
}