137 lines
2.3 KiB
JavaScript
137 lines
2.3 KiB
JavaScript
import { alertInfo } from "../../utils/index";
|
|
import Dialog from '@vant/weapp/dialog/dialog';
|
|
import { getUserInfo } from "../../service/user";
|
|
import { getDot } from "../../utils/system";
|
|
import request from "../../utils/request"
|
|
const { OK } = request;
|
|
|
|
// pages/my/index.js
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
user: {},
|
|
visible: false,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
jumpToQuestions() {
|
|
wx.navigateTo({
|
|
url: '/pages/questions/index',
|
|
})
|
|
},
|
|
jumpToMember() {
|
|
wx.navigateTo({
|
|
url: '/pages/member/index',
|
|
})
|
|
},
|
|
jumpToQrCode() {
|
|
wx.navigateTo({
|
|
url: '/pages/qrCode/index',
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
const user = wx.getStorageSync('user');
|
|
if (!user || !user.id) {
|
|
wx.switchTab({
|
|
url: '/pages/home/index',
|
|
})
|
|
alertInfo("请先登录");
|
|
return false;
|
|
}
|
|
this.init()
|
|
this.getUnReadNumber()
|
|
},
|
|
async init() {
|
|
const result = await getUserInfo();
|
|
if (result.code !== OK) {
|
|
alertInfo(result.message)
|
|
return;
|
|
}
|
|
this.setData({ user: result.data })
|
|
wx.setStorageSync('user', result.data)
|
|
},
|
|
jumpToUpdateInvoice() {
|
|
wx.navigateTo({
|
|
url: '/pages/updateInvoice/index',
|
|
})
|
|
},
|
|
async getUnReadNumber() {
|
|
const dot = await getDot();
|
|
this.setData({
|
|
dot
|
|
})
|
|
},
|
|
logout() {
|
|
wx.clearStorageSync()
|
|
wx.switchTab({
|
|
url: '/pages/home/index',
|
|
})
|
|
},
|
|
bindTenement() {
|
|
wx.navigateTo({
|
|
url: '/pages/handleLogin/index',
|
|
})
|
|
},
|
|
connect() {
|
|
Dialog.alert({
|
|
title: '提示',
|
|
message: '将进入咨询客服页面',
|
|
confirmButtonOpenType: "contact",
|
|
showCancelButton: true,
|
|
}).then(() => {
|
|
// on close
|
|
});
|
|
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |