deploy
This commit is contained in:
@ -11,7 +11,10 @@ export const login = (data: LoginForm) =>
|
|||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getInfo = () =>
|
export const getInfo = (token?: string) =>
|
||||||
httpClient.request({
|
httpClient.request({
|
||||||
url: "/getInfo",
|
url: "/getInfo",
|
||||||
|
header: {
|
||||||
|
Authorization: token ? `Bearer ${token}` : undefined,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
"pages/index/index",
|
"pages/index/index",
|
||||||
"pages/logs/logs",
|
|
||||||
"pages/add-finance/add-finance",
|
"pages/add-finance/add-finance",
|
||||||
"pages/login/login",
|
"pages/login/login",
|
||||||
"pages/stock/stock",
|
"pages/stock/stock",
|
||||||
@ -45,5 +44,6 @@
|
|||||||
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
|
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
|
||||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group"
|
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group"
|
||||||
},
|
},
|
||||||
|
"lazyCodeLoading": "requiredComponents",
|
||||||
"sitemapLocation": "sitemap.json"
|
"sitemapLocation": "sitemap.json"
|
||||||
}
|
}
|
@ -1,17 +1,26 @@
|
|||||||
import { getToken } from "./utils/settings";
|
import { getInfo } from "./api/login";
|
||||||
|
import { getToken, getUserInfo } from "./utils/settings";
|
||||||
|
|
||||||
// app.ts
|
// app.ts
|
||||||
App<IAppOption>({
|
App<IAppOption>({
|
||||||
globalData: {
|
globalData: {
|
||||||
authToken: undefined,
|
authToken: undefined,
|
||||||
permissions:[]
|
permissions: undefined,
|
||||||
|
user: undefined,
|
||||||
|
},
|
||||||
|
|
||||||
|
loadUserInfo(token: string) {
|
||||||
|
getInfo(token).then((resp: any) => {
|
||||||
|
const { user, permissions } = resp;
|
||||||
|
this.globalData.user = user;
|
||||||
|
this.globalData.permissions = permissions;
|
||||||
|
console.log(this.globalData);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onLaunch() {
|
onLaunch() {
|
||||||
// 展示本地存储能力
|
const token = getToken();
|
||||||
const logs = wx.getStorageSync("logs") || [];
|
this.globalData.authToken = token;
|
||||||
logs.unshift(Date.now());
|
this.loadUserInfo(token);
|
||||||
wx.setStorageSync("logs", logs);
|
|
||||||
this.globalData.authToken = getToken();
|
|
||||||
// 登录
|
// 登录
|
||||||
wx.login({
|
wx.login({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
BIN
miniprogram/assets/login_bg.jpg
Normal file
BIN
miniprogram/assets/login_bg.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
@ -1,7 +1,9 @@
|
|||||||
<!--components/statistics-card/index.wxml-->
|
<!--components/statistics-card/index.wxml-->
|
||||||
|
<wxs module="number" src="../../utils/number.wxs" />
|
||||||
<view class="statistcs-card">
|
<view class="statistcs-card">
|
||||||
<view wx:for="{{statisticsData}}" wx:key="key" wx:for-item="value" class="statistcs-item">
|
<view wx:for="{{statisticsData}}" wx:key="key" wx:for-item="value" class="statistcs-item">
|
||||||
<view class="value">{{value.value}}</view>
|
<view class="value" wx:if="{{value.type=='money'}}">{{number.formatAmount(value.value)}}万元</view>
|
||||||
|
<view class="value" wx:else="">{{value.value}}</view>
|
||||||
<view class="title">{{value.label}}</view>
|
<view class="title">{{value.label}}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
@ -1,6 +1,7 @@
|
|||||||
import Message from "tdesign-miniprogram/message/index";
|
import Message from "tdesign-miniprogram/message/index";
|
||||||
import { getDict } from "../../api/dict";
|
import { getDict } from "../../api/dict";
|
||||||
import { addFinance, getFinanceInfo, updateFinance } from "../../api/finance";
|
import { addFinance, getFinanceInfo, updateFinance } from "../../api/finance";
|
||||||
|
import { getInfo } from "../../api/login";
|
||||||
|
|
||||||
// pages/add-affairs/add-affairs.ts
|
// pages/add-affairs/add-affairs.ts
|
||||||
const dayjs = require("dayjs");
|
const dayjs = require("dayjs");
|
||||||
@ -9,6 +10,7 @@ Page({
|
|||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
|
permissions: [],
|
||||||
defaultTime: dayjs(dayjs().format("YYYY-MM-DD")).valueOf(),
|
defaultTime: dayjs(dayjs().format("YYYY-MM-DD")).valueOf(),
|
||||||
types: [],
|
types: [],
|
||||||
form: {
|
form: {
|
||||||
@ -56,6 +58,23 @@ Page({
|
|||||||
[`form.date`]: e.detail.value,
|
[`form.date`]: e.detail.value,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
loadUserInfo() {
|
||||||
|
const permissions = getApp().globalData.permissions;
|
||||||
|
|
||||||
|
if (permissions) {
|
||||||
|
this.setData({
|
||||||
|
permissions,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const token = getApp().globalData.authToken;
|
||||||
|
getInfo(token).then((resp: any) => {
|
||||||
|
this.setData({
|
||||||
|
permissions: resp.permissions,
|
||||||
|
});
|
||||||
|
getApp().globalData.permissions = resp.permissions;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
getTypeLabel(dictValue: string) {
|
getTypeLabel(dictValue: string) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return this.data.types.find((item: any) => item.value === dictValue)?.label;
|
return this.data.types.find((item: any) => item.value === dictValue)?.label;
|
||||||
@ -117,6 +136,7 @@ Page({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSubmitFinance() {
|
handleSubmitFinance() {
|
||||||
const { form } = this.data;
|
const { form } = this.data;
|
||||||
const result = this.validate();
|
const result = this.validate();
|
||||||
@ -208,6 +228,7 @@ Page({
|
|||||||
this.getFinanceDetail(option.financeId);
|
this.getFinanceDetail(option.financeId);
|
||||||
}
|
}
|
||||||
this.getTypeOptions();
|
this.getTypeOptions();
|
||||||
|
this.loadUserInfo();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<t-message id="t-message" />
|
<t-message id="t-message" />
|
||||||
<wxs module="times" src="../../utils/time.wxs" />
|
<wxs module="times" src="../../utils/time.wxs" />
|
||||||
<wxs module="dict" src="../../utils/dict.wxs" />
|
<wxs module="dict" src="../../utils/dict.wxs" />
|
||||||
|
<wxs module="utils" src="../../utils/utils.wxs" />
|
||||||
<view class="add-affairs">
|
<view class="add-affairs">
|
||||||
<view class="add-affairs-form">
|
<view class="add-affairs-form">
|
||||||
<t-input label="事项" bind:change="onChange" data-field="event" value="{{form.event}}" align="right" placeholder="请输入事项"></t-input>
|
<t-input label="事项" bind:change="onChange" data-field="event" value="{{form.event}}" align="right" placeholder="请输入事项"></t-input>
|
||||||
@ -10,14 +11,13 @@
|
|||||||
<t-input label="对方账户" bind:change="onChange" data-field="oppositeCompany" value="{{form.oppositeCompany}}" align="right" placeholder="请输入对方账户"></t-input>
|
<t-input label="对方账户" bind:change="onChange" data-field="oppositeCompany" value="{{form.oppositeCompany}}" align="right" placeholder="请输入对方账户"></t-input>
|
||||||
<t-input label="金额" type="number" bind:change="onChange" data-field="amount" value="{{form.amount}}" align="right" placeholder="请输入金额"></t-input>
|
<t-input label="金额" type="number" bind:change="onChange" data-field="amount" value="{{form.amount}}" align="right" placeholder="请输入金额"></t-input>
|
||||||
</view>
|
</view>
|
||||||
<view class="submit-button">
|
<view wx:if="{{utils.hasPermission('finance:detail:edit', permissions)}}" class="submit-button">
|
||||||
<t-button bind:tap="handleSubmitFinance" theme="primary" block>确认提交</t-button>
|
<t-button bind:tap="handleSubmitFinance" theme="primary" block>确认提交</t-button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 年月日 -->
|
<!-- 年月日 -->
|
||||||
<t-date-time-picker title="选择日期" visible="{{dateVisible}}" mode="date" defaultValue="{{form.date || defaultTime}}" format="YYYY-MM-DD HH:mm:ss" bindchange="handleConfirmTime" bindcancel="hideTimePicker" />
|
<t-date-time-picker title="选择日期" visible="{{dateVisible}}" mode="date" defaultValue="{{form.date || defaultTime}}" format="YYYY-MM-DD HH:mm:ss" bindchange="handleConfirmTime" bindcancel="hideTimePicker" />
|
||||||
|
|
||||||
|
|
||||||
<t-picker visible="{{pickerVisible}}" value="{{form.type}}" data-key="type" title="选择类别" cancelBtn="取消" confirmBtn="确认" bindchange="onPickerChange" bindpick="onColumnChange" bindcancel="onPickerCancel">
|
<t-picker visible="{{pickerVisible}}" value="{{form.type}}" data-key="type" title="选择类别" cancelBtn="取消" confirmBtn="确认" bindchange="onPickerChange" bindpick="onColumnChange" bindcancel="onPickerCancel">
|
||||||
<t-picker-item options="{{types}}" />
|
<t-picker-item options="{{types}}" />
|
||||||
</t-picker>
|
</t-picker>
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
{
|
{
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"t-popup": "tdesign-miniprogram/popup/popup",
|
|
||||||
"t-input": "tdesign-miniprogram/input/input",
|
"t-input": "tdesign-miniprogram/input/input",
|
||||||
"t-upload": "tdesign-miniprogram/upload/upload",
|
"t-upload": "tdesign-miniprogram/upload/upload",
|
||||||
"t-picker": "tdesign-miniprogram/picker/picker",
|
"t-picker": "tdesign-miniprogram/picker/picker",
|
||||||
"t-cascader": "tdesign-miniprogram/cascader/cascader",
|
|
||||||
"t-tree-select": "tdesign-miniprogram/tree-select/tree-select",
|
|
||||||
"t-picker-item": "tdesign-miniprogram/picker-item/picker-item",
|
"t-picker-item": "tdesign-miniprogram/picker-item/picker-item",
|
||||||
"t-date-time-picker": "tdesign-miniprogram/date-time-picker/date-time-picker"
|
"t-date-time-picker": "tdesign-miniprogram/date-time-picker/date-time-picker"
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,8 @@ Page({
|
|||||||
[`form.${field}`]: e.detail.value,
|
[`form.${field}`]: e.detail.value,
|
||||||
});
|
});
|
||||||
if (field === "total") {
|
if (field === "total") {
|
||||||
|
console.log(e.detail);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
parseInt(e.detail.value) > this.data.stockLimit &&
|
parseInt(e.detail.value) > this.data.stockLimit &&
|
||||||
this.data.form.type == 2
|
this.data.form.type == 2
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
</t-upload>
|
</t-upload>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<t-input label="数量" type="number" bind:change="onChange" data-field="total" value="{{form.total}}" placeholder="请输入数量" tips="{{totalErrMsg}}" status="{{totalErrMsg?'error':''}}" />
|
<t-input label="数量" align="right" type="number" bind:change="onChange" data-field="total" value="{{form.total}}" placeholder="请输入数量" tips="{{totalErrMsg}}" status="{{totalErrMsg?'error':''}}" />
|
||||||
</view>
|
</view>
|
||||||
<view class="submit-button">
|
<view class="submit-button">
|
||||||
<t-button bind:tap="handleSubmitStock" theme="primary" block>确认提交</t-button>
|
<t-button bind:tap="handleSubmitStock" theme="primary" block>确认提交</t-button>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"t-fab": "tdesign-miniprogram/fab/fab",
|
"t-fab": "tdesign-miniprogram/fab/fab",
|
||||||
"t-collapse": "tdesign-miniprogram/collapse/collapse",
|
"t-swipe-cell": "tdesign-miniprogram/swipe-cell/swipe-cell",
|
||||||
"t-collapse-panel": "tdesign-miniprogram/collapse-panel/collapse-panel",
|
"statistics-card": "/components/statistics-card",
|
||||||
"statistics-card": "/components/statistics-card"
|
"t-dialog": "tdesign-miniprogram/dialog/dialog"
|
||||||
},
|
},
|
||||||
"enablePullDownRefresh": true
|
"enablePullDownRefresh": true
|
||||||
}
|
}
|
@ -85,6 +85,37 @@ page {
|
|||||||
animation: shake-crazy 1s infinite linear;
|
animation: shake-crazy 1s infinite linear;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.t-swipe-cell__right {
|
||||||
|
view {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.finance-list {
|
||||||
|
.left-icon {
|
||||||
|
width: 48rpx;
|
||||||
|
height: 48rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.btn-wrapper {
|
||||||
|
// height: 100%;
|
||||||
|
.btn {
|
||||||
|
display: inline-flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 140rpx;
|
||||||
|
height: 100%;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete-btn {
|
||||||
|
background-color: #e34d59;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.to-login {
|
.to-login {
|
||||||
height: 40vh;
|
height: 40vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -4,6 +4,7 @@ import {
|
|||||||
getFinanceList,
|
getFinanceList,
|
||||||
getStatistics,
|
getStatistics,
|
||||||
} from "../../api/finance";
|
} from "../../api/finance";
|
||||||
|
import { getInfo } from "../../api/login";
|
||||||
|
|
||||||
// pages/index/index.ts
|
// pages/index/index.ts
|
||||||
Page({
|
Page({
|
||||||
@ -11,29 +12,35 @@ Page({
|
|||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
|
showConfirmDelete: false,
|
||||||
|
permissions: [],
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
},
|
},
|
||||||
authToken: undefined,
|
authToken: null,
|
||||||
statistics: {
|
statistics: {
|
||||||
amount: {
|
amount: {
|
||||||
label: "账户余额",
|
label: "账户余额",
|
||||||
value: 0,
|
value: 0,
|
||||||
|
type: "money",
|
||||||
},
|
},
|
||||||
income: {
|
income: {
|
||||||
label: "当月入账",
|
label: "当月入账",
|
||||||
value: 0,
|
value: 0,
|
||||||
|
type: "money",
|
||||||
},
|
},
|
||||||
expenditure: {
|
expenditure: {
|
||||||
label: "当月出账",
|
label: "当月出账",
|
||||||
value: 0,
|
value: 0,
|
||||||
|
type: "money",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
total: 0,
|
total: 0,
|
||||||
completed: false,
|
completed: false,
|
||||||
deleteIndex: -1,
|
deleteIndex: -1,
|
||||||
|
deleteId: null,
|
||||||
list: [],
|
list: [],
|
||||||
types: [],
|
types: [],
|
||||||
},
|
},
|
||||||
@ -71,9 +78,9 @@ Page({
|
|||||||
async getStatisticsDetail() {
|
async getStatisticsDetail() {
|
||||||
const resp: any = await getStatistics();
|
const resp: any = await getStatistics();
|
||||||
this.setData({
|
this.setData({
|
||||||
['statistics.amount.value']: resp.data.amount,
|
["statistics.amount.value"]: resp.data.amount,
|
||||||
['statistics.income.value']: resp.data.income,
|
["statistics.income.value"]: resp.data.income,
|
||||||
['statistics.expenditure.value']: resp.data.expenditure,
|
["statistics.expenditure.value"]: resp.data.expenditure,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleAddAffairs() {
|
handleAddAffairs() {
|
||||||
@ -102,9 +109,26 @@ Page({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
showDeleteDialog(e: any) {
|
||||||
|
console.log(e.currentTarget.dataset);
|
||||||
|
|
||||||
|
const { financeId } = e.currentTarget.dataset;
|
||||||
|
this.setData({
|
||||||
|
showConfirmDelete: true,
|
||||||
|
deleteId: financeId,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
closeDialog() {
|
||||||
|
this.setData({
|
||||||
|
showConfirmDelete: false,
|
||||||
|
});
|
||||||
|
},
|
||||||
handleLongTap(e: any) {
|
handleLongTap(e: any) {
|
||||||
console.log(e);
|
const { deleteIndex, permissions } = this.data;
|
||||||
const { deleteIndex } = this.data;
|
// @ts-ignore
|
||||||
|
if (!permissions.includes("finance:detail:remove")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const index = parseInt(e.currentTarget.dataset.index);
|
const index = parseInt(e.currentTarget.dataset.index);
|
||||||
|
|
||||||
let resultIndex;
|
let resultIndex;
|
||||||
@ -117,12 +141,14 @@ Page({
|
|||||||
deleteIndex: resultIndex,
|
deleteIndex: resultIndex,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleDeleteFinance(e: any) {
|
handleDeleteFinance() {
|
||||||
const { financeId } = e.currentTarget.dataset;
|
const { deleteId } = this.data;
|
||||||
deleteFinance(financeId).then(() => {
|
if (!deleteId) return;
|
||||||
|
// @ts-ignore
|
||||||
|
deleteFinance(deleteId).then(() => {
|
||||||
const { list } = this.data;
|
const { list } = this.data;
|
||||||
this.setData({
|
this.setData({
|
||||||
list: list.filter((el: any) => el.financeId !== financeId),
|
list: list.filter((el: any) => el.financeId !== deleteId),
|
||||||
deleteIndex: -1,
|
deleteIndex: -1,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -140,6 +166,23 @@ Page({
|
|||||||
url: "/pages/login/login",
|
url: "/pages/login/login",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
loadUserInfo() {
|
||||||
|
const permissions = getApp().globalData.permissions;
|
||||||
|
|
||||||
|
if (permissions) {
|
||||||
|
this.setData({
|
||||||
|
permissions,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const token = getApp().globalData.authToken;
|
||||||
|
getInfo(token).then((resp: any) => {
|
||||||
|
this.setData({
|
||||||
|
permissions: resp.permissions,
|
||||||
|
});
|
||||||
|
getApp().globalData.permissions = resp.permissions;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
loadPageData() {
|
loadPageData() {
|
||||||
const authToken = getApp().globalData.authToken;
|
const authToken = getApp().globalData.authToken;
|
||||||
this.setData({
|
this.setData({
|
||||||
@ -165,6 +208,7 @@ Page({
|
|||||||
*/
|
*/
|
||||||
onShow() {
|
onShow() {
|
||||||
this.loadPageData();
|
this.loadPageData();
|
||||||
|
this.loadUserInfo();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,11 +2,28 @@
|
|||||||
<t-message id="t-message" />
|
<t-message id="t-message" />
|
||||||
<wxs module="times" src="../../utils/time.wxs" />
|
<wxs module="times" src="../../utils/time.wxs" />
|
||||||
<wxs module="dict" src="../../utils/dict.wxs" />
|
<wxs module="dict" src="../../utils/dict.wxs" />
|
||||||
|
<wxs module="utils" src="../../utils/utils.wxs" />
|
||||||
<view class="home-page">
|
<view class="home-page">
|
||||||
<t-fab class="float-button" icon="add" aria-label="增加" bind:click="handleAddAffairs" />
|
<t-fab wx:if="{{utils.hasPermission('finance:detail:add', permissions)}}" class="float-button" icon="add" aria-label="增加" bind:click="handleAddAffairs" />
|
||||||
<statistics-card statistics-data="{{statistics}}" />
|
<statistics-card statistics-data="{{statistics}}" />
|
||||||
<view class="divider"></view>
|
<view class="divider"></view>
|
||||||
<view wx:if="{{authToken}}" class="list">
|
<view wx:if="{{authToken}}" class="finance-list">
|
||||||
|
<t-cell-group theme="card">
|
||||||
|
<t-swipe-cell wx:for="{{list}}" wx:key="account" data-finance-id="{{item.financeId}}">
|
||||||
|
<t-cell bind:tap="handleUpdateFinance" data-finance-id="{{item.financeId}}" title="{{item.event}}" hover>
|
||||||
|
<view class="left-icon" slot="left-icon" style="background: {{item.type=='finance_type_income'?'#38a169':item.type=='finance_type_expenditure'?'#dd6b20':'transparent'}};">
|
||||||
|
<text>{{item.type=='finance_type_income'?'入':item.type=='finance_type_expenditure'?'出':''}}</text>
|
||||||
|
</view>
|
||||||
|
<view slot="description">{{times.formatDate(item.date) || "-"}} | {{item.oppositeCompany}}</view>
|
||||||
|
<view slot="note" style="color: {{item.type=='finance_type_income'?'#38a169':item.type=='finance_type_expenditure'?'#dd6b20':'transparent'}};">{{item.type=='finance_type_income'?'+':item.type=='finance_type_expenditure'?'-':''}}{{item.amount}}</view>
|
||||||
|
</t-cell>
|
||||||
|
<view slot="right" class="btn-wrapper" data-finance-id="{{item.financeId}}" bind:tap="showDeleteDialog">
|
||||||
|
<view class="btn delete-btn">删除</view>
|
||||||
|
</view>
|
||||||
|
</t-swipe-cell>
|
||||||
|
</t-cell-group>
|
||||||
|
</view>
|
||||||
|
<!-- <view wx:if="{{authToken}}" class="list">
|
||||||
<view wx:for="{{list}}" wx:key="account" data-finance-id="{{item.financeId}}" bind:longpress="handleLongTap" data-index="{{index}}" bind:tap="handleUpdateFinance" class="{{ index === deleteIndex ? 'card shake' : 'card' }}">
|
<view wx:for="{{list}}" wx:key="account" data-finance-id="{{item.financeId}}" bind:longpress="handleLongTap" data-index="{{index}}" bind:tap="handleUpdateFinance" class="{{ index === deleteIndex ? 'card shake' : 'card' }}">
|
||||||
<view class="field">
|
<view class="field">
|
||||||
<view class="indicator"></view>
|
<view class="indicator"></view>
|
||||||
@ -45,8 +62,10 @@
|
|||||||
</view>
|
</view>
|
||||||
<t-icon wx:if="{{index === deleteIndex}}" name="close-circle-filled" color="red" size="56rpx" data-finance-id="{{item.financeId}}" data-index="{{index}}" catchtap="handleDeleteFinance" class="close-button"></t-icon>
|
<t-icon wx:if="{{index === deleteIndex}}" name="close-circle-filled" color="red" size="56rpx" data-finance-id="{{item.financeId}}" data-index="{{index}}" catchtap="handleDeleteFinance" class="close-button"></t-icon>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
<view wx:else class="to-login">
|
<view wx:else class="to-login">
|
||||||
<t-button icon="login" theme="primary" bind:tap="toLogin">前往登录</t-button>
|
<t-button icon="login" theme="primary" bind:tap="toLogin">前往登录</t-button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<t-dialog visible="{{showConfirmDelete}}" title="确认删除" confirm-btn="确认" cancel-btn="取消" bind:confirm="handleDeleteFinance" bind:cancel="closeDialog" />
|
||||||
</view>
|
</view>
|
@ -1,3 +1,9 @@
|
|||||||
{
|
{
|
||||||
"usingComponents": {}
|
"usingComponents": {
|
||||||
|
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||||
|
"t-image": "tdesign-miniprogram/image/image",
|
||||||
|
"t-avatar": "tdesign-miniprogram/avatar/avatar"
|
||||||
|
},
|
||||||
|
"navigationBarTitleText": "个人中心",
|
||||||
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
@ -1,11 +1,56 @@
|
|||||||
/* pages/login/login.wxss */
|
/* pages/login/login.wxss */
|
||||||
.login{
|
.t-navbar__placeholder {
|
||||||
height: 100vh;
|
--td-navbar-padding-top: 0;
|
||||||
|
--td-navbar-height: 0;
|
||||||
|
}
|
||||||
|
.t-navbar__content {
|
||||||
|
--td-navbar-bg-color: rgba(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
.nav-title {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.login-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
.login-button{
|
width: 100%;
|
||||||
margin-top: 60rpx;
|
aspect-ratio: 3/2;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 0 0 50% 50% / 0 0 4% 4%;
|
||||||
|
.login-bg {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
.avatar_login {
|
||||||
|
margin-left: 64rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.login-button {
|
||||||
|
margin-left: 24rpx;
|
||||||
|
&.t-button--primary {
|
||||||
|
--td-button-primary-text-color: #ffffff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.vip-card {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
bottom: 0;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 80%;
|
||||||
|
height: 80rpx;
|
||||||
|
background-color: #ccb88d;
|
||||||
|
border-radius: 24rpx 24rpx 0 0;
|
||||||
|
color: #ffffff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
text {
|
||||||
|
margin-left: 32rpx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.options-container {
|
||||||
|
margin-top: 32rpx;
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { login } from "../../api/login";
|
import { getInfo, login } from "../../api/login";
|
||||||
import { setToken } from "../../utils/settings";
|
import { setToken } from "../../utils/settings";
|
||||||
|
|
||||||
// pages/login/login.ts
|
// pages/login/login.ts
|
||||||
@ -7,25 +7,28 @@ Page({
|
|||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
authToken: undefined,
|
authToken: null,
|
||||||
},
|
},
|
||||||
|
|
||||||
loginWithWeChat(e: any) {
|
loginWithWeChat(e: any) {
|
||||||
login({
|
login({
|
||||||
code: e.detail.code,
|
code: e.detail.code,
|
||||||
}).then((response: any) => {
|
}).then((response: any) => {
|
||||||
|
this.setData({
|
||||||
|
authToken: response.token,
|
||||||
|
});
|
||||||
setToken(response.token);
|
setToken(response.token);
|
||||||
// setToken(response.token);
|
getInfo(response.token).then((resp: any) => {
|
||||||
wx.switchTab({
|
getApp().globalData.permissions = resp.permissions;
|
||||||
url: "/pages/index/index",
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleLogout(){
|
handleLogout() {
|
||||||
this.setData({
|
this.setData({
|
||||||
authToken: undefined
|
authToken: null,
|
||||||
})
|
});
|
||||||
setToken(undefined)
|
getApp().globalData.permissions = undefined;
|
||||||
|
setToken(undefined);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
|
@ -1,7 +1,22 @@
|
|||||||
<!--pages/login/login.wxml-->
|
<!--pages/login/login.wxml-->
|
||||||
<t-message id="t-message" />
|
<t-message id="t-message" />
|
||||||
<view class="login">
|
<view class="block">
|
||||||
<t-icon name="user-arrow-up" size="72rpx" color="#0052d9"></t-icon>
|
<t-navbar title="个人中心" t-class="nav" t-class-title="nav-title" />
|
||||||
<t-button wx:if="{{authToken}}" class="login-button" shape="round" theme="primary">退出登录</t-button>
|
</view>
|
||||||
<t-button wx:else class="login-button" shape="round" open-type="getPhoneNumber" bindgetphonenumber="loginWithWeChat" theme="primary">手机号快捷登录</t-button>
|
<view class="login-container">
|
||||||
|
<t-image class="login-bg" width="100%" height="100%" src="/assets/login_bg.jpg" />
|
||||||
|
<view class="avatar_login">
|
||||||
|
<t-avatar icon="user" />
|
||||||
|
<t-button wx:if="{{!authToken}}" open-type="getPhoneNumber" bindgetphonenumber="loginWithWeChat" class="login-button" size="medium" theme="primary" variant="text">登录</t-button>
|
||||||
|
</view>
|
||||||
|
<view class="vip-card">
|
||||||
|
<text>中科九章管理层</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="options-container">
|
||||||
|
<t-cell-group theme="card">
|
||||||
|
<t-cell title="个人设置" leftIcon="setting" hover arrow />
|
||||||
|
<t-cell title="意见反馈" leftIcon="chat-bubble-smile" hover arrow />
|
||||||
|
<t-cell wx:if="{{authToken}}" title="退出登录" bind:tap="handleLogout" leftIcon="logout" hover arrow />
|
||||||
|
</t-cell-group>
|
||||||
</view>
|
</view>
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"navigationBarTitleText": "查看启动日志",
|
|
||||||
"usingComponents": {
|
|
||||||
"t-divider": "tdesign-miniprogram/divider/divider"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
/* pages/logs/logs.wxss */
|
|
@ -1,19 +0,0 @@
|
|||||||
// logs.ts
|
|
||||||
// const util = require('../../utils/util.js')
|
|
||||||
import { formatTime } from '../../utils/util'
|
|
||||||
|
|
||||||
Page({
|
|
||||||
data: {
|
|
||||||
logs: [],
|
|
||||||
},
|
|
||||||
onLoad() {
|
|
||||||
this.setData({
|
|
||||||
logs: (wx.getStorageSync('logs') || []).map((log: string) => {
|
|
||||||
return {
|
|
||||||
date: formatTime(new Date(log)),
|
|
||||||
timeStamp: log
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
@ -1,6 +0,0 @@
|
|||||||
<!--logs.wxml-->
|
|
||||||
<view class="container log-list">
|
|
||||||
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
|
|
||||||
<text class="log-item">{{index + 1}}. {{log.date}}</text>
|
|
||||||
</block>
|
|
||||||
</view>
|
|
@ -1,8 +0,0 @@
|
|||||||
.log-list {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
padding: 40rpx;
|
|
||||||
}
|
|
||||||
.log-item {
|
|
||||||
margin: 10rpx;
|
|
||||||
}
|
|
@ -2,11 +2,13 @@
|
|||||||
.t-fab {
|
.t-fab {
|
||||||
z-index: 99;
|
z-index: 99;
|
||||||
}
|
}
|
||||||
page{
|
page {
|
||||||
padding-top: 32rpx;
|
padding-top: 32rpx;
|
||||||
}
|
}
|
||||||
.stock-tabs {
|
.stock-tabs {
|
||||||
margin: 16rpx 32rpx 0;
|
margin: 16rpx 32rpx 0;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.stock-list {
|
.stock-list {
|
||||||
padding: 16rpx 0 32rpx;
|
padding: 16rpx 0 32rpx;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { getInfo } from "../../api/login";
|
||||||
import { stockLogList, stockStatistics, storageList } from "../../api/stock";
|
import { stockLogList, stockStatistics, storageList } from "../../api/stock";
|
||||||
import httpClient from "../../utils/request";
|
import httpClient from "../../utils/request";
|
||||||
|
|
||||||
@ -7,6 +8,7 @@ Page({
|
|||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
|
permissions: [],
|
||||||
authToken: undefined,
|
authToken: undefined,
|
||||||
stockType: 0, // 库存类型
|
stockType: 0, // 库存类型
|
||||||
// 统计数据
|
// 统计数据
|
||||||
@ -262,13 +264,30 @@ Page({
|
|||||||
url: `/pages/add-stock/add-stock?type=${stockType}`,
|
url: `/pages/add-stock/add-stock?type=${stockType}`,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleUpdateStock() {},
|
loadUserInfo() {
|
||||||
|
const permissions = getApp().globalData.permissions;
|
||||||
|
|
||||||
|
if (permissions) {
|
||||||
|
this.setData({
|
||||||
|
permissions,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const token = getApp().globalData.authToken;
|
||||||
|
getInfo(token).then((resp: any) => {
|
||||||
|
this.setData({
|
||||||
|
permissions: resp.permissions,
|
||||||
|
});
|
||||||
|
getApp().globalData.permissions = resp.permissions;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.loadData();
|
this.loadData();
|
||||||
|
this.loadUserInfo();
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 刷新此页面
|
* 刷新此页面
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
<!--pages/stock/stock.wxml-->
|
<!--pages/stock/stock.wxml-->
|
||||||
<!-- 产品库存管理 -->
|
<!-- 产品库存管理 -->
|
||||||
|
<t-message id="t-message" />
|
||||||
<wxs module="times" src="../../utils/time.wxs" />
|
<wxs module="times" src="../../utils/time.wxs" />
|
||||||
|
<wxs module="utils" src="../../utils/utils.wxs" />
|
||||||
<statistics-card statistics-data="{{statisticsData}}" />
|
<statistics-card statistics-data="{{statisticsData}}" />
|
||||||
<t-tabs class="stock-tabs" defaultValue="{{0}}" value="{{stockType}}" bind:change="onTabsChange" theme="tag">
|
<view class="stock-tabs">
|
||||||
<t-tab-panel label="库存" value="{{0}}" />
|
<t-tabs defaultValue="{{0}}" value="{{stockType}}" bind:change="onTabsChange" theme="tag">
|
||||||
<t-tab-panel label="入库" value="{{1}}" />
|
<t-tab-panel label="库存" value="{{0}}" />
|
||||||
<t-tab-panel label="出库" value="{{2}}" />
|
<t-tab-panel label="入库" value="{{1}}" />
|
||||||
</t-tabs>
|
<t-tab-panel label="出库" value="{{2}}" />
|
||||||
|
</t-tabs>
|
||||||
|
</view>
|
||||||
<view class="stock-list">
|
<view class="stock-list">
|
||||||
<t-fab wx:if="{{stockType > 0}}" class="float-button" icon="add" aria-label="增加" bind:click="handleAddStock"></t-fab>
|
<t-fab wx:if="{{stockType > 0 && utils.hasPermission('product:product:add', permissions)}}" class="float-button" icon="add" aria-label="增加" bind:click="handleAddStock"></t-fab>
|
||||||
<view hidden="{{stockType!=0}}" class="scroll-container">
|
<view hidden="{{stockType!=0}}" class="scroll-container">
|
||||||
<view class="grid">
|
<view class="grid">
|
||||||
<view wx:for="{{storageList}}" wx:key="specId" class="card">
|
<view wx:for="{{storageList}}" wx:key="specId" class="card">
|
||||||
|
7
miniprogram/utils/number.wxs
Normal file
7
miniprogram/utils/number.wxs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
function formatAmount(amount) {
|
||||||
|
return (amount / 10000).toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
formatAmount: formatAmount,
|
||||||
|
};
|
@ -46,9 +46,11 @@ class HttpClient {
|
|||||||
url = `${this.baseUrl}${req.url}${paramsString}`;
|
url = `${this.baseUrl}${req.url}${paramsString}`;
|
||||||
}
|
}
|
||||||
const app = getApp();
|
const app = getApp();
|
||||||
|
|
||||||
const header: any = req.header ?? {};
|
const header: any = req.header ?? {};
|
||||||
if (!authWhitelist.includes(req.url)) {
|
|
||||||
header.Authorization = `Bearer ${app.globalData.authToken}`;
|
if (!authWhitelist.includes(req.url) && !header.Authorization) {
|
||||||
|
header.Authorization = `Bearer ${app?.globalData?.authToken}`;
|
||||||
}
|
}
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
wx.request({
|
wx.request({
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
import { getInfo } from "../api/login";
|
||||||
|
|
||||||
export const setToken = (token?: string) => {
|
export const setToken = (token?: string) => {
|
||||||
getApp().globalData.authToken = token;
|
getApp().globalData.authToken = token;
|
||||||
wx.setStorage({
|
wx.setStorage({
|
||||||
key: "auth-token",
|
key: "auth-token",
|
||||||
data: token,
|
data: token ?? "",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// 如果不存在token,则跳转到身份选择页面
|
// 如果不存在token,则跳转到身份选择页面
|
||||||
@ -17,7 +19,17 @@ export const requiredAuth = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getToken = () => {
|
export const getToken = () => {
|
||||||
const token = wx.getStorageSync("auth-token");
|
const token = wx.getStorageSync("auth-token");
|
||||||
return token;
|
return token;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getUserInfo = async () => {
|
||||||
|
const { userInfo } = getApp().globalData;
|
||||||
|
if (!userInfo) {
|
||||||
|
const token = getApp().globalData.authToken;
|
||||||
|
const resp = await getInfo(token);
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
7
miniprogram/utils/utils.wxs
Normal file
7
miniprogram/utils/utils.wxs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
function hasPermission(permission, permissions) {
|
||||||
|
return permissions.indexOf(permission) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
hasPermission: hasPermission,
|
||||||
|
};
|
@ -14,7 +14,7 @@
|
|||||||
},
|
},
|
||||||
"coverView": false,
|
"coverView": false,
|
||||||
"postcss": false,
|
"postcss": false,
|
||||||
"minified": false,
|
"minified": true,
|
||||||
"enhance": true,
|
"enhance": true,
|
||||||
"showShadowRootInWxmlPanel": false,
|
"showShadowRootInWxmlPanel": false,
|
||||||
"packNpmRelationList": [],
|
"packNpmRelationList": [],
|
||||||
|
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@ -5,6 +5,8 @@ interface IAppOption {
|
|||||||
userInfo?: WechatMiniprogram.UserInfo;
|
userInfo?: WechatMiniprogram.UserInfo;
|
||||||
authToken?: string;
|
authToken?: string;
|
||||||
permissions?: [];
|
permissions?: [];
|
||||||
|
user?: Object;
|
||||||
};
|
};
|
||||||
|
loadUserInfo: (token: string) => void;
|
||||||
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback;
|
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user