完成对公初始操作和专区

This commit is contained in:
qiaomu 2024-09-09 15:57:59 +08:00
parent 9a6c4d30f4
commit 927b7a6470
12 changed files with 97 additions and 45 deletions

View File

@ -30,7 +30,6 @@ Component({
*/
methods: {
async getData() {
console.log(this.data.page, this.data.id, this.id)
const page = this.data.page;
const id = this.id;
const { code, data, message, total } = await getEncyclopediaList(id, page);

View File

@ -3,7 +3,8 @@
"usingComponents": {
"pagination": "/components/pagination/index",
"navigator": "/components/navigator/index",
"van-field": "@vant/weapp/field/index"
"van-field": "@vant/weapp/field/index",
"empty": "/components/empty/index"
},
"navigationStyle": "custom"
}

View File

@ -1,15 +1,21 @@
<!--pages/encyclopedia/components/item/index.wxml-->
<van-field
wx:for="{{list}}"
value="{{ item.title }}"
readonly
border="{{ true }}"
wx:key="id"
bind:tap="jumpToDetail"
data-data="{{item}}"
/>
<pagination
currentIndex="{{page}}"
totalPage="{{totalPage}}"
bind:pagingChange="onChangePage"
/>
<view wx:if="{{list.length}}">
<van-field
wx:for="{{list}}"
value="{{ item.title }}"
readonly
border="{{ true }}"
wx:key="id"
bind:tap="jumpToDetail"
data-data="{{item}}"
/>
<pagination
currentIndex="{{page}}"
totalPage="{{totalPage}}"
bind:pagingChange="onChangePage"
/>
</view>
<view wx:else>
<empty bind:refresh="getData" />
</view>

View File

@ -1,6 +1,6 @@
<!--pages/encyclopedia/index.wxml-->
<navigator title="电力百科" canBack="{{true}}" />
<van-tabs active="{{ active }}" bind:change="onChange">
<van-tabs active="{{ active }}" bind:change="onChange" swipeable>
<van-tab wx:for="{{categoryList}}" wx:key="id" title="{{item.name}}">
<item id="{{item.id}}" wx:if="{{index === active}}" />
</van-tab>

View File

@ -330,7 +330,7 @@ Page({
case "对公支付":
const { user, money, meter, tenement, park } = this.data;
wx.navigateTo({
url: `/pages/publicTransfer/index?money=${money}&meterId=${meter.id}&tenementId=${tenement.id}&tenementName=${tenement.name}`,
url: `/pages/publicTransfer/index?money=${money}&meterId=${meter.id}&tenementId=${tenement.id}&tenementName=${tenement.name}&park=${park.id}`,
})
break;
default:

View File

@ -1,7 +1,8 @@
// pages/publicTransfer/index.js
import { getMeterDetail, getMeterList, getTenementMeterList } from "../../service/meter";
import { uploadFile } from "../../service/public";
import { alertInfo, loadingFunc, getFileName } from "../../utils/index";
import { createPublicTopUp } from '../../service/recharge'
import { uploadFile, uploadPublicFile } from "../../service/public";
import { alertInfo, loadingFunc, getFileName, alertSuccess } from "../../utils/index";
import request from '../../utils/request';
const { OK } = request;
@ -19,11 +20,10 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const { money, meterId, tenementId, tenementName } = options;
console.log('money', money, 'meterId', meterId)
this.init({ money, meterId, tenementId, tenementName });
const { money, meterId, tenementId, tenementName, park } = options;
this.init({ money, meterId, tenementId, tenementName, park });
},
async init({ money, meterId, tenementId, tenementName }) {
async init({ money, meterId, tenementId, tenementName, park }) {
const { code, message, data } = await getMeterDetail({ tenement: tenementId, id: meterId });
if (code !== OK) {
alertInfo(message);
@ -34,36 +34,55 @@ Page({
money,
tenementName,
tenementId,
park
})
},
async upload(res) {
const result = await uploadPublicFile(res.tempFiles[0]?.tempFilePath)
if (result.statusCode !== 200) {
alertInfo("上传失败")
return;
}
const data = JSON.parse(result.data)
this.setData({
fileList: [{ url: data.data, name: getFileName(data.data) }]
})
},
onUpload() {
const that = this;
wx.chooseMedia({
count: 1, // 可以选择文件的数量
mediaType: ['image'], // 可以选择文件的类型,这里只允许上传文件
sourceType: ['album', 'camera'],
success: (res) => {
(loadingFunc(async () => {
const result = await uploadFile(res.tempFiles[0]?.tempFilePath)
console.log('result', result)
if (result.statusCode !== 200) {
alertInfo("上传失败")
return;
}
const data = JSON.parse(result.data)
this.setData({
fileList: [{ url: data.data, name: getFileName(data.data) }]
})
}))()
loadingFunc(async () => {
await this.upload(res)
})
}
});
},
handleSubmit() {
const { fileList } = this.data;
if (!fileList.length) {
async handleSubmit() {
const { fileList, meter, money, park, tenementId } = this.data;
if (!fileList?.length) {
alertInfo("请上传凭证")
return;
}
const { code, message } = await createPublicTopUp({
id: meter.id,
tenement: tenementId,
money: Number(money),
park,
vouch: fileList[0].url
})
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("已提交,待审核")
setTimeout(() => {
wx.redirectTo({
url: '/pages/home/index',
})
}, 600)
},
handleDelete() {
this.setData({ fileList: [] })

View File

@ -42,7 +42,8 @@ Page({
switch (envVersion) {
// 开发版
case 'develop':
api = `http://localhost:9001`;
// api = `http://localhost:9001`;
api = `https://zgd.hbhcbn.com/recharge-print-api-test`;
// api = `https://zgd.hbhcbn.com/recharge-print-api-test`;
break;
// 体验版

View File

@ -35,7 +35,8 @@ Page({
const [appId, path] = value.split(",")
wx.navigateToMiniProgram({
appId: appId,
path: path
path: path,
envVersion: "trial"
})
break;
case 1:

View File

@ -4,7 +4,7 @@
<van-row>
<van-col span="8" wx:for="{{ servicesList }}" wx:key="id">
<view class="image" bind:tap="clickService" data-data="{{item}}">
<van-image width="200rpx" height="200rpx" src="{{item.url}}" />
<van-image fit="cover" width="200rpx" height="200rpx" src="{{item.url}}" />
</view>
</van-col>
</van-row>

View File

@ -20,4 +20,24 @@ export const uploadFile = (filePath) => {
}
})
})
}
export const uploadPublicFile = (filePath) => {
const { api } = getConfigByEnv();
return new Promise((resolve, reject) => {
wx.uploadFile({
filePath: filePath,
name: 'file',
url: `${api}/wx/public/upload`,
header: {
authorization: wx.getStorageSync("token")
},
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
}
})
})
}

View File

@ -20,4 +20,9 @@ export const getRechargeDetail = async function(rid) {
// 退费
export const returnFee = async function(data) {
return await POST(`/wx/return`, data);
}
// 创建对公
export const createPublicTopUp = async function(data) {
return await POST(`/wx/createPublicTopUp`, data);
}

View File

@ -11,11 +11,11 @@ export const getDot = async () => {
const { code, message, data } = await getUnReadApproveNumber();
if (data > 0) {
wx.showTabBarRedDot({
index: 1,
index: 2,
})
} else {
wx.hideTabBarRedDot({
index: 1,
index: 2,
})
}
return data;