完成对公初始操作和专区

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: { methods: {
async getData() { async getData() {
console.log(this.data.page, this.data.id, this.id)
const page = this.data.page; const page = this.data.page;
const id = this.id; const id = this.id;
const { code, data, message, total } = await getEncyclopediaList(id, page); const { code, data, message, total } = await getEncyclopediaList(id, page);

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<!--pages/encyclopedia/index.wxml--> <!--pages/encyclopedia/index.wxml-->
<navigator title="电力百科" canBack="{{true}}" /> <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}}"> <van-tab wx:for="{{categoryList}}" wx:key="id" title="{{item.name}}">
<item id="{{item.id}}" wx:if="{{index === active}}" /> <item id="{{item.id}}" wx:if="{{index === active}}" />
</van-tab> </van-tab>

View File

@ -330,7 +330,7 @@ Page({
case "对公支付": case "对公支付":
const { user, money, meter, tenement, park } = this.data; const { user, money, meter, tenement, park } = this.data;
wx.navigateTo({ 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; break;
default: default:

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@
<van-row> <van-row>
<van-col span="8" wx:for="{{ servicesList }}" wx:key="id"> <van-col span="8" wx:for="{{ servicesList }}" wx:key="id">
<view class="image" bind:tap="clickService" data-data="{{item}}"> <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> </view>
</van-col> </van-col>
</van-row> </van-row>

View File

@ -21,3 +21,23 @@ 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

@ -21,3 +21,8 @@ export const getRechargeDetail = async function(rid) {
export const returnFee = async function(data) { export const returnFee = async function(data) {
return await POST(`/wx/return`, 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(); const { code, message, data } = await getUnReadApproveNumber();
if (data > 0) { if (data > 0) {
wx.showTabBarRedDot({ wx.showTabBarRedDot({
index: 1, index: 2,
}) })
} else { } else {
wx.hideTabBarRedDot({ wx.hideTabBarRedDot({
index: 1, index: 2,
}) })
} }
return data; return data;