From 8610a9263783816b5644cdcd71ad8c6107cf4d0a Mon Sep 17 00:00:00 2001
From: mk <2403457699@qq.com>
Date: Fri, 6 Jun 2025 17:09:43 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E4=BB=B7=E6=8E=A5=E5=8F=A3=E8=81=94?=
=?UTF-8?q?=E8=B0=83=20=E5=85=A5=E4=BD=8F=E8=AE=B0=E5=BD=95=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=E8=81=94=E8=B0=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/index.js | 18 +++
api/user.js | 3 +
ocr.js | 65 ++++++----
project.private.config.json | 18 ++-
subpages/OCRCard/pages/OCR/OCR.js | 51 ++++----
subpages/index/checkOutConfirm/index/index.js | 23 ++--
.../index/checkOutConfirm/index/index.json | 5 +-
.../index/checkOutConfirm/index/index.wxml | 6 +-
subpages/mine/checkInRecord/checkInRecord.js | 11 +-
.../mine/checkInRecord/checkInRecord.json | 3 +-
.../mine/checkInRecord/checkInRecord.wxml | 39 +++---
subpages/mine/evaluate/evaluate.js | 119 ++++++++++++++----
subpages/mine/evaluate/evaluate.wxml | 14 +--
subpages/mine/evaluate/evaluate.wxss | 1 -
utils/request.js | 4 +-
15 files changed, 261 insertions(+), 119 deletions(-)
diff --git a/api/index.js b/api/index.js
index b49d2df..808d9e1 100644
--- a/api/index.js
+++ b/api/index.js
@@ -11,3 +11,21 @@ export function getPolicyInfo(id) {
export function chooseRoomRec(pamars) {
return fly.get(`/bysmp/chooseRoomRec/page`,pamars)
}
+// 【退房确认】查看进行中的退房信息
+export function getProcessingCheckOutInfo(pamars) {
+ return fly.get(`/bysmp/checkout/getProcessingCheckOutInfo`,pamars)
+}
+// 【退房办理】确认退房(提交交割单)
+export function checkoutConfirm(pamars) {
+ return fly.get(`/bysmp/checkout/confirm`,pamars)
+}
+
+//新增入住评价
+export function evaluateAdd(data) {
+ return fly.post(`/bysmp/evaluate/add`,data)
+}
+//获取入住评价详细信息
+export function evaluateInfo(id) {
+ return fly.get(`/bysmp/evaluate/${id}`)
+}
+
diff --git a/api/user.js b/api/user.js
index c8efdeb..b01e7f7 100644
--- a/api/user.js
+++ b/api/user.js
@@ -5,6 +5,9 @@ export function login(data) {
export function bindPhone(code) {
return fly.put(`/bysmp/user/bindPhone?code=${code}`)
}
+export function bindIdCard(query) {
+ return fly.put(`/bysmp/user/bindIdCard?name=${query.name}&icCard=${query.idCard}`,)
+}
export function getUserInfo() {
return fly.get(`/bysmp/user/wxUserInfo`)
}
diff --git a/ocr.js b/ocr.js
index 0e686dc..eb5f133 100644
--- a/ocr.js
+++ b/ocr.js
@@ -2,26 +2,42 @@
var config = require('./utils/config')
+const uploadFilePromise = (filePath) => {
+ return new Promise((resolve, reject) => {
+ wx.uploadFile({
+ url: `${config.BASEURL()}/common/upload`,
+ name: 'file',
+ filePath: filePath,
+ header: {
+ "Content-type": "multipart/form-data",
+ 'Authorization': wx.getStorageSync('token')
+ },
+ success(res) {
+ const data = JSON.parse(res.data)
+ if (data.code === 200) {
+ // 假设返回的 url 在 res.data 里,根据实际情况调整
+ resolve(data.url);
+ } else {
+ reject(new Error('文件上传失败'));
+ }
+ },
+ fail(err) {
+ console.log(err);
+ reject(err);
+ }
+ });
+ });
+};
+
export const ocrAction = async (filePath) => {
wx.showLoading({
title: '正在处理',
- })
- let img_url = ''
- console.log(filePath);
- wx.uploadFile({
- url: `${config.BASEURL()}/common/upload`,
- name: 'name',
- filePath: filePath,
- success(res){
- img_url = res.data
- }
- })
- // TODO 将 tempFilePath 上传到 CDN 得到 url
- // 实现上传到 cdn 的代码, 将得到的 url 写到 img_url 中
-
- // 调用服务市场接口 https://fuwu.weixin.qq.com/service/detail/000ce4cec24ca026d37900ed551415
+ });
try {
- await wx.serviceMarket.invokeService({
+ // 上传文件到 CDN 并获取 url
+ const img_url = await uploadFilePromise(filePath);
+ // 调用服务市场接口
+ const result = await wx.serviceMarket.invokeService({
api: 'OcrAllInOne',
service: 'wx79ac3de8be320b71',
data: {
@@ -29,13 +45,18 @@ export const ocrAction = async (filePath) => {
data_type: 3,
ocr_type: 1, // 详细见文档
}
- })
- wx.hideLoading()
- } catch (e) {
- wx.hideLoading()
- throw e
+ });
+
+ wx.hideLoading();
+ console.log(result,'调接口返回');
+ return { success: true, result };
+ } catch (error) {
+ wx.hideLoading();
+ console.error('ocrAction 失败', error);
+ return { success: false, error };
}
-}
+};
+
export const takePhoto = async (tempFilePath) => {
if(tempFilePath){
diff --git a/project.private.config.json b/project.private.config.json
index 5ad773c..62d79b9 100644
--- a/project.private.config.json
+++ b/project.private.config.json
@@ -15,12 +15,26 @@
"miniprogram": {
"list": [
{
- "name": "评价页面",
+ "name": "新增评价",
"pathName": "subpages/mine/evaluate/evaluate",
- "query": "",
+ "query": "id=6",
"scene": null,
"launchMode": "default"
},
+ {
+ "name": "入住记录",
+ "pathName": "subpages/mine/checkInRecord/checkInRecord",
+ "query": "",
+ "launchMode": "default",
+ "scene": null
+ },
+ {
+ "name": "评价页面",
+ "pathName": "subpages/mine/evaluate/evaluate",
+ "query": "",
+ "launchMode": "default",
+ "scene": null
+ },
{
"name": "报修",
"pathName": "subpages/eventAdd/add/add",
diff --git a/subpages/OCRCard/pages/OCR/OCR.js b/subpages/OCRCard/pages/OCR/OCR.js
index 79b81de..4f6e422 100644
--- a/subpages/OCRCard/pages/OCR/OCR.js
+++ b/subpages/OCRCard/pages/OCR/OCR.js
@@ -1,22 +1,10 @@
import {
ocrAction,
} from '../../../../ocr.js'
-
+ import {bindIdCard} from "../../../../api/user"
const chooseImage = async () => {
return new Promise((resolve, reject) => {
- wx.chooseMedia({
- count: 1,
- sizeType: ['original','compressed'],
- sourceType: ['album'],
- mediaType:['image'],
- success: (res) => {
- console.log(res);
- resolve(res.tempFiles[0].tempFilePath)
- },
- fail: (res) => {
- reject(new Error(`选择图片失败: ${res.errMsg}`))
- }
- })
+
})
}
@@ -109,16 +97,29 @@ import {
})
},
async chooseImg(e) {
- chooseImage()
- .then(ocrAction)
- .catch(e => {
- console.error(e)
- console.error('因为没有真的上传图片,所以走到出错的逻辑里了')
- wx.showToast({
- title: '出错啦...',
- icon: 'error'
+ const that = this
+ wx.chooseMedia({
+ count: 1,
+ sizeType: ['original','compressed'],
+ sourceType: ['album'],
+ mediaType:['image'],
+ success: (res) => {
+ ocrAction(res.tempFiles[0].tempFilePath).then(res=>{
+ if(res.success){
+ that.bindIdCard(res.result.data.idcard_res)
+ }
})
- })
+ },
+ fail: (res) => {
+ reject(new Error(`选择图片失败: ${res.errMsg}`))
+ }
+ })
+
+ },
+ bindIdCard(data){
+ bindIdCard({name:data.name.text,idCard:data.id.text}).then(res=>{
+ console.log(res);
+ })
},
takePhotoAction(e) {
this.setData({
@@ -207,6 +208,8 @@ import {
})
},
success(e) {
- console.error('success', e)
+ if(res.success){
+ this.bindIdCard(res.result.data)
+ }
},
})
\ No newline at end of file
diff --git a/subpages/index/checkOutConfirm/index/index.js b/subpages/index/checkOutConfirm/index/index.js
index f12bd74..e1a7ac6 100644
--- a/subpages/index/checkOutConfirm/index/index.js
+++ b/subpages/index/checkOutConfirm/index/index.js
@@ -1,4 +1,5 @@
// subpages/index/checkOutConfirm/index/index.js
+import {getProcessingCheckOutInfo,checkoutConfirm} from "../../../../api/index"
Page({
/**
* 页面的初始数据
@@ -14,7 +15,7 @@ Page({
},
{ type: "image", src: "https://img.yzcdn.cn/vant/cat.jpeg" },
],
- signImgSrc: "", // 签名图片路径
+ signImgSrc: null, // 签名图片路径
canvasName: 'myCanvas',
ctx: '',
canvas: '',
@@ -149,13 +150,21 @@ console.log('area',scrollArea.node);
* 生命周期函数--监听页面加载
*/
onLoad(options) {
- const imgSrc = decodeURIComponent(options.imgSrc);
- console.log("接收到的签名图片地址:", imgSrc);
- this.setData({
- signImgSrc: imgSrc,
- });
+ this.getProcessingCheckOutInfo()
+ if(options.imgSrc){
+ const imgSrc = decodeURIComponent(options.imgSrc);
+ this.setData({
+ signImgSrc: imgSrc,
+ });
+ }
+ },
+ getProcessingCheckOutInfo(){
+ getProcessingCheckOutInfo().then(res=>{
+ if(res.code === 200){
+ console.log(res);
+ }
+ })
},
-
/**
* 生命周期函数--监听页面初次渲染完成
*/
diff --git a/subpages/index/checkOutConfirm/index/index.json b/subpages/index/checkOutConfirm/index/index.json
index 070eb88..61bbb07 100644
--- a/subpages/index/checkOutConfirm/index/index.json
+++ b/subpages/index/checkOutConfirm/index/index.json
@@ -1,7 +1,5 @@
{
- "navigationStyle": "custom",
"usingComponents": {
- "navigationBar": "/components/navigationBar/navigationBar",
"van-image": "@vant/weapp/image/index",
"van-button": "@vant/weapp/button/index",
"van-tab": "@vant/weapp/tab/index",
@@ -10,5 +8,6 @@
"van-cell": "@vant/weapp/cell/index",
"van-cell-group": "@vant/weapp/cell-group/index",
"van-icon": "@vant/weapp/icon/index"
- }
+ },
+ "navigationBarTitleText": "退房确认"
}
\ No newline at end of file
diff --git a/subpages/index/checkOutConfirm/index/index.wxml b/subpages/index/checkOutConfirm/index/index.wxml
index 25cc454..c337116 100644
--- a/subpages/index/checkOutConfirm/index/index.wxml
+++ b/subpages/index/checkOutConfirm/index/index.wxml
@@ -1,5 +1,4 @@
-
@@ -71,15 +70,14 @@
-
+
请在以下区域手写签字
-
+
在此区域手写签字
-
diff --git a/subpages/mine/checkInRecord/checkInRecord.js b/subpages/mine/checkInRecord/checkInRecord.js
index 3d5f104..28f3b9f 100644
--- a/subpages/mine/checkInRecord/checkInRecord.js
+++ b/subpages/mine/checkInRecord/checkInRecord.js
@@ -6,7 +6,7 @@ Page({
* 页面的初始数据
*/
data: {
-
+ list:[]
},
/**
@@ -71,9 +71,9 @@ Page({
pageNo:1
}
chooseRoomRec(parm).then(res=>{
- if(res.code === 0){
+ if(res.code === 200){
this.setData({
- list:res.data.list
+ list:this.data.list.concat(res.data)
})
}
}).catch(err=>{
@@ -97,4 +97,9 @@ Page({
})
}
},
+ toEvaluate(e){
+ wx.navigateTo({
+ url: `/subpages/mine/evaluate/evaluate?id=${e.currentTarget.dataset.item.checkInRecId}`,
+ })
+ }
})
\ No newline at end of file
diff --git a/subpages/mine/checkInRecord/checkInRecord.json b/subpages/mine/checkInRecord/checkInRecord.json
index 086bb11..925f7c5 100644
--- a/subpages/mine/checkInRecord/checkInRecord.json
+++ b/subpages/mine/checkInRecord/checkInRecord.json
@@ -2,7 +2,8 @@
"usingComponents": {
"no-data":"../../../components/noData/nodata",
"van-divider": "@vant/weapp/divider/index",
- "van-button": "@vant/weapp/button/index"
+ "van-button": "@vant/weapp/button/index",
+ "van-rate": "@vant/weapp/rate/index"
},
"navigationBarTitleText": "入住记录"
}
\ No newline at end of file
diff --git a/subpages/mine/checkInRecord/checkInRecord.wxml b/subpages/mine/checkInRecord/checkInRecord.wxml
index 874ddf3..c984675 100644
--- a/subpages/mine/checkInRecord/checkInRecord.wxml
+++ b/subpages/mine/checkInRecord/checkInRecord.wxml
@@ -1,23 +1,26 @@
-
-
-
-
-
-
-
- 国信
- 入住办理中
+
+
+
+
+
+
+ {{item.apartmentName}}
+ {{item.status === '1'?'入住办理中':item.status === '4'?'入住中':item.status === '5'?'已退房':''}}
+
+ {{item.buildingName}}-{{item.unitName}}-{{item.houseName}}-{{item.roomType}}
+ {{item.inDate}}至{{item.outDate}}
- 5号楼1单元888南卧
- 2028-11-11至2222-22-22
-
-
-
-
- 青岛免租金租房合同.docx
+
+
+
+ 青岛免租金租房合同.docx
+
+ 待支付
+ 去评价
+
- 待支付
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/subpages/mine/evaluate/evaluate.js b/subpages/mine/evaluate/evaluate.js
index 1115e2d..ee974a6 100644
--- a/subpages/mine/evaluate/evaluate.js
+++ b/subpages/mine/evaluate/evaluate.js
@@ -1,38 +1,40 @@
// subpages/mine/evaluate/evaluate.js
+import {evaluateAdd,evaluateInfo} from '../../../api/index'
+var config = require('../../../utils/config')
+
Page({
/**
* 页面的初始数据
*/
data: {
- satisfiedZt:0,
- satisfiedHj:0,
- satisfiedFw:0,
- satisfiedTy:0,
- fileList: [{
- url: 'https://img.yzcdn.cn/vant/leaf.jpg',
- name: '图片1',
- },
- // Uploader 根据文件后缀来判断是否为图片文件
- // 如果图片 URL 中不包含类型信息,可以添加 isImage 标记来声明
- {
- url: 'http://iph.href.lu/60x60?text=default',
- name: '图片2',
- isImage: true,
- // deletable: true,
- },
- ],
- switchFlag:false,
- questionText:''
+ satisfiedZt: null,
+ satisfiedHj: null,
+ satisfiedFw: null,
+ satisfiedTy: null,
+ fileList: [],
+ releaseMethod: 0,
+ evaluateContent: '',
+ info:{}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
-
+ if (options.id) {
+ this.getInfo(options.id)
+ }
+ },
+ getInfo(id){
+ evaluateInfo(id).then(res=>{
+ if(res.code === 200){
+ this.setData({
+ info:res.data
+ })
+ }
+ })
},
-
/**
* 生命周期函数--监听页面初次渲染完成
*/
@@ -81,10 +83,77 @@ Page({
onShareAppMessage() {
},
-
- onChangeSwitch(e){
+
+ onChangeSwitch(e) {
this.setData({
- switchFlag:e.detail
+ releaseMethod: e.detail
})
- }
+ },
+ handelChangTextarea(e){
+ this.setData({
+ evaluateContent:e.detail.value
+ })
+ },
+ onButtonTap(){
+ const {evaluateContent,releaseMethod,satisfiedZt,satisfiedHj,satisfiedFw,satisfiedTy,fileList} = this.data
+ evaluateAdd({evaluateContent,releaseMethod,satisfiedZt,satisfiedHj,satisfiedFw,satisfiedTy,checkInRecId:this.data.info.checkInRecId,images:fileList}).then(res=>{
+ console.log(res);
+ if(res.data.code === 200){
+ wx.showToast({
+ title: '评价成功',
+ duration:2000,
+ success:()=>{
+ setTimeout(()=>{
+ wx.navigateBack({
+ delta: 1 // 返回上一个页面
+ });
+ },2000)
+ }
+ })
+ }
+ }).catch(err=>{
+ console.log(err);
+ })
+ },
+ deleteData(event) {
+ // 删除
+ console.log(event.detail.index)
+ let newFileList = this.data.fileList.slice();
+ newFileList.splice(event.detail.index, 1);
+ this.setData({
+ fileList: newFileList
+ });
+ },
+ afterRead(event) {
+ const that = this
+ const {
+ file
+ } = event.detail;
+ const fileName = file.url.match(/\/([^\/]+\.\w+)$/)[1];
+ // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
+ wx.uploadFile({
+ url:`${config.BASEURL()}/common/upload`, // 仅为示例,非真实的接口地址
+ filePath: file.url,
+ name: 'file',
+ header: {
+ "Content-type": "multipart/form-data",
+ 'Authorization': wx.getStorageSync('token')
+ },
+ success(res) {
+ // 上传完成需要更新 fileList
+ const images = {url:JSON.parse(res.data).url,name:fileName,type:'image'}
+ that.setData({
+ fileList:that.data.fileList.concat(images)
+ });
+ },
+ });
+ },
+ beforeRead(event) {
+ const {
+ file,
+ callback
+ } = event.detail;
+ callback(file.type === 'image');
+ },
+
})
\ No newline at end of file
diff --git a/subpages/mine/evaluate/evaluate.wxml b/subpages/mine/evaluate/evaluate.wxml
index 905bd0c..40d008e 100644
--- a/subpages/mine/evaluate/evaluate.wxml
+++ b/subpages/mine/evaluate/evaluate.wxml
@@ -1,12 +1,12 @@
-
+
- 国信上月运抵
+ {{info.apartmentName}}
- 5号楼1单元895南卧
- 3居室
+ {{info.buildingName}}-{{info.unitName}}-{{info.houseName}}-{{info.roomTypeName}}
+ {{info.houseTypeName}}
@@ -41,14 +41,14 @@
-
+
匿名
-
+
提交
\ No newline at end of file
diff --git a/subpages/mine/evaluate/evaluate.wxss b/subpages/mine/evaluate/evaluate.wxss
index 0ada479..119effe 100644
--- a/subpages/mine/evaluate/evaluate.wxss
+++ b/subpages/mine/evaluate/evaluate.wxss
@@ -12,7 +12,6 @@ page{
padding: 15rpx;
box-sizing: border-box;
background-color: rgba(246, 246, 246, 1);
- color: rgba(203, 203, 203, 1);
font-size: 28rpx;
}
diff --git a/utils/request.js b/utils/request.js
index 71276a7..6512dc3 100644
--- a/utils/request.js
+++ b/utils/request.js
@@ -8,7 +8,7 @@
*/
var global = require('./config.js')
const request = function (url, options) {
- let token = wx.getStorageSync('token')
+ let token = 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX3BhcGVydHlwZSI6MSwibG9naW5fdXNlcl90ZWxlcGhvbmUiOiIxNzY4NTkwODE1NiIsImxvZ2luX3VzZXJfY2xpZW50IjoiYnlzbXAiLCJsb2dpbl91c2VyX25hbWUiOiLmnY7puY_nqIsiLCJpZGNhcmQiOiIzNzAyODIyMDAwMDkxNjMyMTYiLCJsb2dpbl91c2VyX2tleSI6OCwibG9naW5fdXNlcl9nZW5kZXIiOjF9.Ho2cqEM7sbI6k-IODA9Ffse5LTsLskmCg7u1TtAVHbCaQ5legdAhqtURN5J_v9u3GfvXr36Qc8f2xoAJCs0-9Q'
return new Promise((resolve, reject) => {
let header = {
@@ -33,7 +33,7 @@ const request = function (url, options) {
wx.switchTab({
url: '/pages/index/index',
})
- }else if(response.data.code>8000){
+ }else if(response.data.code){
let errmsg = response.data.msg
if(errmsg==undefined || errmsg=='undefined' ){
errmsg = '未返回错误信息'