开始做充值和发票

This commit is contained in:
2024-03-20 11:10:52 +08:00
parent e5c9a96353
commit 7648ace524
59 changed files with 1091 additions and 199 deletions

View File

@@ -1,6 +1,9 @@
import { login } from "../../service/user"
import { alertError, alertInfo, loadingFunc, wxLogin } from "../../utils/index"
import { OK } from "../../utils/request"
import { login } from "../../service/user";
import { alertError, alertInfo, alertSuccess, loadingFunc, wxLogin } from "../../utils/index";
import request from "../../utils/request";
import Dialog from '@vant/weapp/dialog/dialog';
const { OK } = request;
// pages/login/index.js
Page({
@@ -8,14 +11,22 @@ Page({
* 页面的初始数据
*/
data: {
input: ""
input: "",
disabled: false,
show: false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
onLoad() {
const user = wx.getStorageSync('user')
if (!user || !user.id) {
return;
}
wx.switchTab({
url: '/pages/home/index',
})
},
/**
@@ -27,40 +38,67 @@ Page({
onClose() {
// wx.exitMiniProgram()
},
// onConfirm() {
// this.handleLogin()
// },
onConfirm() {
// this.handleLogin()
},
async handleLogin(phoneCode) {
loadingFunc(async () => {
const wxLoginCode = await wxLogin()
const { code, message, data } = await login({ code: wxLoginCode, phoneCode })
const result = await login({ code: wxLoginCode, phoneCode })
const { code, message, data } = result;
if (code !== OK) {
alertError(message)
return
}
console.log('data', data)
if (!data?.id) {
this.noPermission()
return;
}
alertSuccess("登录成功")
const { token, ...user } = data
wx.setStorageSync('user', user)
wx.setStorageSync('token', data?.token)
})
},
getPhoneNumber(e) {
const { errno, code: phoneCode } = e.detail;
console.log('errno', errno, 'phoneCode', phoneCode)
switch(errno) {
case 103:
alertInfo("已拒绝");
setTimeout(() => {
wx.exitMiniProgram()
}, 100)
return;
break;
case 1400001:
alertInfo("服务达到上限")
setTimeout(() => {
wx.exitMiniProgram()
}, 100)
return;
break;
default:
this.handleLogin(phoneCode)
return;
}
this.handleLogin(phoneCode)
},
onChangeAgree(e) {
this.setData({
agree: e.detail
})
},
beforeClose(e) {
return false;
},
noPermission() {
Dialog.confirm({
title: '提示',
message: '当前手机号不是用电管理联系账号',
confirmButtonText: '手动绑定',
cancelButtonText: '取消',
})
.then(() => {
// on confirm
wx.navigateTo({
url: '/pages/handleLogin/index',
})
})
.catch(() => {
// on cancel
});
},
/**
* 生命周期函数--监听页面显示