Browse Source

评价接口联调 入住记录接口联调

epass
mk 5 months ago
parent
commit
8610a92637
  1. 18
      api/index.js
  2. 3
      api/user.js
  3. 61
      ocr.js
  4. 18
      project.private.config.json
  5. 49
      subpages/OCRCard/pages/OCR/OCR.js
  6. 15
      subpages/index/checkOutConfirm/index/index.js
  7. 5
      subpages/index/checkOutConfirm/index/index.json
  8. 6
      subpages/index/checkOutConfirm/index/index.wxml
  9. 11
      subpages/mine/checkInRecord/checkInRecord.js
  10. 3
      subpages/mine/checkInRecord/checkInRecord.json
  11. 27
      subpages/mine/checkInRecord/checkInRecord.wxml
  12. 115
      subpages/mine/evaluate/evaluate.js
  13. 14
      subpages/mine/evaluate/evaluate.wxml
  14. 1
      subpages/mine/evaluate/evaluate.wxss
  15. 4
      utils/request.js

18
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}`)
}

3
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`)
}

61
ocr.js

@ -2,26 +2,42 @@
var config = require('./utils/config')
export const ocrAction = async (filePath) => {
wx.showLoading({
title: '正在处理',
})
let img_url = ''
console.log(filePath);
const uploadFilePromise = (filePath) => {
return new Promise((resolve, reject) => {
wx.uploadFile({
url: `${config.BASEURL()}/common/upload`,
name: 'name',
name: 'file',
filePath: filePath,
success(res){
img_url = res.data
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('文件上传失败'));
}
})
// TODO 将 tempFilePath 上传到 CDN 得到 url
// 实现上传到 cdn 的代码, 将得到的 url 写到 img_url 中
},
fail(err) {
console.log(err);
reject(err);
}
});
});
};
// 调用服务市场接口 https://fuwu.weixin.qq.com/service/detail/000ce4cec24ca026d37900ed551415
export const ocrAction = async (filePath) => {
wx.showLoading({
title: '正在处理',
});
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){

18
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",

49
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,15 +97,28 @@ 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) {
@ -207,6 +208,8 @@ import {
})
},
success(e) {
console.error('success', e)
if(res.success){
this.bindIdCard(res.result.data)
}
},
})

15
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) {
this.getProcessingCheckOutInfo()
if(options.imgSrc){
const imgSrc = decodeURIComponent(options.imgSrc);
console.log("接收到的签名图片地址:", imgSrc);
this.setData({
signImgSrc: imgSrc,
});
}
},
getProcessingCheckOutInfo(){
getProcessingCheckOutInfo().then(res=>{
if(res.code === 200){
console.log(res);
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

5
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": "退房确认"
}

6
subpages/index/checkOutConfirm/index/index.wxml

@ -1,5 +1,4 @@
<!-- subpages/index/checkOutConfirm/index/index.wxml -->
<navigationBar title="退房确认" isSowArrow titleAlign="left"></navigationBar>
<view class="content">
<view class="content-title" id="contentTitle">
<scroll-view>
@ -71,15 +70,14 @@
</scroll-view>
</view>
</view>
<view class=" fixed-bottom">
<view class="card" style="width: calc(100vw - 20rpx);margin: 0 auto;">
<view class="sign">
<view class="sign-title">请在以下区域手写签字</view>
<view class="sign-ara flex flex-center-j items-center" bind:tap="gotoSign">
<view class="sign-img" wx:if="{{signImgSrc}}">
<van-image width="325" height="100" src="{{signImgSrc}}" />
<image style="transform: rotate(90deg);" class="w-full h-full" src="{{signImgSrc}}" />
</view>
<view class="sign-txt " wx:else>在此区域手写签字</view>
</view>
<view class="btn">
<van-button slot="button" block type="primary" round color="linear-gradient(to right, #0DC6C6 , #46DBD5)" bind:tap="submit">

11
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}`,
})
}
})

3
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": "入住记录"
}

27
subpages/mine/checkInRecord/checkInRecord.wxml

@ -1,23 +1,26 @@
<!-- bindscrolltolower="scrolltolower" wx:if="{{list.length>0}}" -->
<scroll-view scroll-y class="scroll-view" >
<!-- wx:for="{{list}}" -->
<view class="card flex" wx:key="index">
<image src="../../../images/zixun.png" style="width: 200rpx;height:152rpx;margin-right: 16rpx;border-radius: 10rpx;" mode="" />
<scroll-view scroll-y class="scroll-view" bindscrolltolower="scrolltolower" wx:if="{{list.length>0}}">
<view class="card " wx:key="index" wx:for="{{list}}">
<view class="item flex">
<image src="{{item.imageUrl}}" style="width: 200rpx;height:152rpx;margin-right: 16rpx;border-radius: 10rpx;" mode="" />
<view class="flex flex-col flex-1">
<view class="flex flex-sb">
<view class="name font-bold">国信</view>
<view class="status text-28">入住办理中</view>
<view class="name font-bold">{{item.apartmentName}}</view>
<view class="status text-28" style="color:{{item.status === '1'?'#ee952f':item.status === '4'?'#1cc9cd':item.status === '5'?'#181c18':''}}">{{item.status === '1'?'入住办理中':item.status === '4'?'入住中':item.status === '5'?'已退房':''}}</view>
</view>
<view style="margin-bottom: 22rpx;">5号楼1单元888南卧</view>
<view class="date">2028-11-11至2222-22-22</view>
<view style="margin-bottom: 22rpx;">{{item.buildingName}}-{{item.unitName}}-{{item.houseName}}-{{item.roomType}}</view>
<view class="date">{{item.inDate}}至{{item.outDate}}</view>
</view>
</view>
<van-divider dashed />
<view class="flex flex-sb px-20">
<view class="doc">
<view class="doc" wx:if="{{item.contractUrl}}">
青岛免租金租房合同.docx
</view>
<van-button round type="info" plain size="small" color="#d3d3d3">待支付</van-button>
<van-button round type="info" plain size="small" color="#f0a652" wx:if="{{item.status === '1' && item.paymentStatus === '0'}}">待支付</van-button>
<van-button round plain size="small" bind:click="toEvaluate" wx:if="{{(item.status === '4' || item.status === '5' || item.status === '6') && item.evaluateLevel === null}}" data-item="{{item}}">去评价</van-button>
<van-rate wx:if="{{item.evaluateLevel}}" value="{{ item.evaluateLevel }}" disabled="{{true}}" size="{{ 25 }}" color="#13c2c2" void-icon="star" void-color="#eee" bind:change="onChange" />
</view>
</view>
</scroll-view>
<!-- <no-data isShow="{{list.length ===0 || !list}}" ></no-data> -->
<no-data isShow="{{list.length === 0 || !list}}"></no-data>

115
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
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
@ -82,9 +84,76 @@ Page({
},
onChangeSwitch(e){
onChangeSwitch(e) {
this.setData({
releaseMethod: e.detail
})
},
handelChangTextarea(e){
this.setData({
switchFlag:e.detail
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');
},
})

14
subpages/mine/evaluate/evaluate.wxml

@ -1,12 +1,12 @@
<!--subpages/mine/evaluate/evaluate.wxml-->
<view class="flex bg-white p-24">
<image src="../../../../../../../images/zixun.png" mode="" class=" mr-10" style="width: 200rpx;height: 152rpx;"/>
<image src="{{info.coverImg}}" mode="" class=" mr-10" style="width: 200rpx;height: 152rpx;"/>
<view class="flex flex-col flex-1">
<view class="font-bold">
国信上月运抵
{{info.apartmentName}}
</view>
<view>5号楼1单元895南卧</view>
<view class="text-26 mt-24" style="color:#ee962c;">3居室</view>
<view>{{info.buildingName}}-{{info.unitName}}-{{info.houseName}}-{{info.roomTypeName}}</view>
<view class="text-26 mt-24" style="color:#ee962c;">{{info.houseTypeName}}</view>
</view>
</view>
<view class="card" style="width: calc(100vw - 40rpx);margin:14rpx auto 0;">
@ -41,14 +41,14 @@
<van-rate model:value="{{ satisfiedTy }}" size="{{ 25 }}" color="#13c2c2" void-icon="star" void-color="#eee" />
</view>
</view>
<textarea class="question-input" placeholder="请输入内容" bindinput="onInput" value="{{questionText}}" maxlength="" />
<textarea class="question-input" placeholder="请输入内容" value="{{evaluateContent}}" maxlength="" bind:input="handelChangTextarea"/>
<view class="mt-40">
<van-uploader file-list="{{ fileList }}" bind:after-read="afterRead" bind:before-read="beforeRead" bind:delete="deleteData" max-count="3" />
</view>
</view>
<view class="flex flex-sb items-center" style="width: calc(100vw - 40rpx);margin:14rpx auto 0;">
<view>匿名</view>
<van-switch checked="{{ switchFlag }}" bind:change="onChangeSwitch" active-color="#13c2c2"
inactive-color="#e2e2e3" size="32rpx"/>
<van-switch checked="{{ releaseMethod }}" bind:change="onChangeSwitch" active-color="#13c2c2"
inactive-color="#e2e2e3" size="32rpx" active-value="{{1}}" inactive-value="{{0}}" />
</view>
<view class="bsBtn" bindtap="onButtonTap">提交</view>

1
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;
}

4
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 = '未返回错误信息'

Loading…
Cancel
Save