完成了小程序联系上级的功能(点击手机号跳转拨号页面)
This commit is contained in:
@ -1,66 +1,55 @@
|
||||
// pages/personCenter/contactSuper/contactSuper.js
|
||||
Page({
|
||||
const { baseUrl } = require("../../../request");
|
||||
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
nickName: '', // 后端返回的昵称
|
||||
phoneNumber: '' // 后端返回的手机号
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
this.fetchSupervisorInfo();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
/**
|
||||
* 请求后端接口,获取上级联系人信息
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
fetchSupervisorInfo() {
|
||||
const token = wx.getStorageSync('token');
|
||||
wx.request({
|
||||
url: baseUrl + '/userInfo/getSuper',
|
||||
method: 'POST',
|
||||
header: {
|
||||
Authorization: token
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data.code === 1) {
|
||||
const { nickName, phoneNumber } = res.data.data;
|
||||
this.setData({ nickName, phoneNumber });
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.data.message || '获取信息失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('fetchSupervisorInfo error:', err);
|
||||
wx.showToast({
|
||||
title: '请求失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
|
||||
gotoCall() {
|
||||
wx.makePhoneCall({
|
||||
phoneNumber: this.data.phoneNumber
|
||||
})
|
||||
}
|
||||
})
|
@ -1,9 +1,11 @@
|
||||
<view class="flex-col justify-start page">
|
||||
<view class="flex-row justify-between section">
|
||||
<view class="flex-col self-center">
|
||||
<text class="self-start text">CHENXINZHI</text>
|
||||
<view class="flex-row items-center self-stretch mt-53">
|
||||
<text class="text_2">联系电话 15123967648</text>
|
||||
<!-- 绑定昵称 -->
|
||||
<text class="self-start text">{{nickName}}</text>
|
||||
<view class="flex-row items-center self-stretch mt-53" bind:tap="gotoCall">
|
||||
<!-- 绑定手机号 -->
|
||||
<text class="text_2">联系电话 {{phoneNumber}}</text>
|
||||
<image
|
||||
class="shrink-0 image_2 ml-6"
|
||||
src="./images/sjh.png"
|
||||
@ -15,4 +17,4 @@
|
||||
src="./images/logo.png"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -177,39 +177,10 @@ Page({
|
||||
onShow() {
|
||||
this.getUserMainInfo()
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
gotoCall() {
|
||||
wx.makePhoneCall({
|
||||
phoneNumber: this.data.phoneNumber
|
||||
})
|
||||
}
|
||||
|
||||
})
|
@ -3,7 +3,7 @@
|
||||
<view class="flex-row justify-between items-center group">
|
||||
<view class="flex-col">
|
||||
<text class="self-start font text">{{ nickName }}</text>
|
||||
<view class="flex-row items-center self-stretch group_2 mt-9">
|
||||
<view class="flex-row items-center self-stretch group_2 mt-9" bind:tap="gotoCall">
|
||||
<image
|
||||
class="image_3"
|
||||
src="./images/dianhua.png"
|
||||
|
Reference in New Issue
Block a user