报修代码

This commit is contained in:
shil 2019-12-18 10:02:07 +08:00
parent e5dc9dd5e2
commit a5fd9683f1
16 changed files with 602 additions and 36 deletions

View File

@ -9,9 +9,11 @@
"pages/myBooks/myBooks",
"pages/detail/detail",
"pages/comment/comment",
"pages/notice/index",
"pages/notice/detail/detail"
"pages/notice/detail/detail",
"pages/repairList/repairList",
"pages/repair/repair",
"pages/repairList/detail/detail"
],
"window": {
"navigationBarTextStyle": "white",
@ -49,9 +51,8 @@
},
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"sitemapLocation": "sitemap.json"
}

View File

@ -20,8 +20,11 @@ const appInfo = {
const urlInfo = {
areaUrl: baseUrl +"appApi/area.listAreas",
GetNoticeListUrl: baseUrl + 'appApi/api.queryNotices'
GetNoticeListUrl: baseUrl + 'appApi/api.queryNotices',
//报修接口
saveOwnerRepair: baseUrl + 'appApi/ownerRepair.saveOwnerRepair',
//查看报修
listOwnerRepairs: baseUrl + 'appApi/ownerRepair.listOwnerRepairs'
}

BIN
images/upload.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,25 +1,25 @@
// pages/index/index.js
const {appInfo} = require("../../config/config.js")
const {
appInfo
} = require("../../config/config.js")
Page({
/**
* 页面的初始数据
*/
data: {
ad:[
{
imageUrl:"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573966727205&di=66965e182c0d2efd0818a7d9b8c2629a&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fcf482ffb4f3fc6d941664e1cba8ca3ca6e9c0a9443f84-AsGU9b_fw658",
url:"http://www.homecommunity.cn/"
ad: [{
imageUrl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573966727205&di=66965e182c0d2efd0818a7d9b8c2629a&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fcf482ffb4f3fc6d941664e1cba8ca3ca6e9c0a9443f84-AsGU9b_fw658",
url: "http://www.homecommunity.cn/"
},
{
imageUrl: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573966727205&di=66965e182c0d2efd0818a7d9b8c2629a&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fcf482ffb4f3fc6d941664e1cba8ca3ca6e9c0a9443f84-AsGU9b_fw658",
url: "http://www.homecommunity.cn/"
}
],
notices:[
{
name:"今日8:00-00:00 停电,请各位知晓",
src:"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573966727205&di=66965e182c0d2efd0818a7d9b8c2629a&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fcf482ffb4f3fc6d941664e1cba8ca3ca6e9c0a9443f84-AsGU9b_fw658",
notices: [{
name: "今日8:00-00:00 停电,请各位知晓",
src: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573966727205&di=66965e182c0d2efd0818a7d9b8c2629a&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fcf482ffb4f3fc6d941664e1cba8ca3ca6e9c0a9443f84-AsGU9b_fw658",
},
{
name: "今日8:00-00:00 停电,请各位知晓,测试测试测测人吃吃吃吃吃吃吃吃吃吃吃吃吃吃",
@ -45,7 +45,8 @@ Page({
src: "/images/4.png"
}, {
name: "报修",
src: "/images/5.png"
src: "/images/5.png",
href: "/pages/repair/repair"
}, {
name: "房屋出租",
src: "/images/6.png"
@ -54,7 +55,7 @@ Page({
src: "/images/7.png",
href: "/pages/notice/index"
}]
},
selected: 0,
mask1Hidden: true,
@ -66,10 +67,10 @@ Page({
selectedNumb: 0,
sortSelected: "综合排序"
},
finish: function () {
finish: function() {
var that = this;
},
sortSelected: function (e) {
sortSelected: function(e) {
var that = this;
// wx.request({
// url: "https://www.easy-mock.com/mock/596257bc9adc231f357c4664/restaurant/overAll",
@ -82,19 +83,19 @@ Page({
// }
// });
},
onGotUserInfo: function (e) {
onGotUserInfo: function(e) {
console.log(e.detail.errMsg)
console.log(e.detail.userInfo)
console.log(e.detail.rawData)
},
clearSelectedNumb: function () {
clearSelectedNumb: function() {
this.setData({
characteristicSelected: [false],
discountSelected: null,
selectedNumb: 0
})
},
characteristicSelected: function (e) {
characteristicSelected: function(e) {
var info = this.data.characteristicSelected;
info[e.currentTarget.dataset.index] = !info[e.currentTarget.dataset.index];
this.setData({
@ -103,7 +104,7 @@ Page({
})
console.log(e.currentTarget.dataset.index);
},
discountSelected: function (e) {
discountSelected: function(e) {
if (this.data.discountSelected != e.currentTarget.dataset.index) {
this.setData({
discountSelected: e.currentTarget.dataset.index,
@ -116,27 +117,27 @@ Page({
})
}
},
onTapTag: function (e) {
onTapTag: function(e) {
this.setData({
selected: e.currentTarget.dataset.index
});
},
mask1Cancel: function () {
mask1Cancel: function() {
this.setData({
mask1Hidden: true
})
},
mask2Cancel: function () {
mask2Cancel: function() {
this.setData({
mask2Hidden: true
})
},
onOverallTag: function () {
onOverallTag: function() {
this.setData({
mask1Hidden: false
})
},
onFilter: function () {
onFilter: function() {
this.setData({
mask2Hidden: false
})
@ -144,21 +145,21 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
console.log(appInfo);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
var that = this;
// wx.request({
// url: "https://www.easy-mock.com/mock/596257bc9adc231f357c4664/restaurant/info",
@ -179,35 +180,35 @@ Page({
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
}
})

216
pages/repair/repair.js Normal file
View File

@ -0,0 +1,216 @@
// pages/enterCommunity/enterCommunity.js
const {
appInfo,
urlInfo
} = require("../../config/config.js");
const util = require('../../utils/util.js');
Page({
/**
* 页面的初始数据
*/
data: {
typeArr: [{
label: "卧室报修",
value: 10001
}, {
label: "管道报修",
value: 10002
}, {
label: "客厅报修",
value: 10003
}],
repairType: 10001,
repairTypeIndex:0,
repairName: "",
tel: "",
communityId:"",
roomId: "",
appointmentTime: "",
context: "",
date: "",
time: "",
photos: [],
imgUrl: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
bindDateChange: function(e) {
this.setData({
date: e.detail.value
})
},
bindTimeChange: function(e) {
this.setData({
time: e.detail.value
})
},
bindTypeChange: function(e) {
let value = e.detail.value;
this.setData({
repairType: this.data.typeArr[value].value,
repairTypeIndex: value
})
},
bindRepairName: function(e) {
this.setData({
repairName: e.detail.value
})
},
bindTel: function(e) {
this.setData({
tel: e.detail.value
})
},
bindCommunity: function (e) {
this.setData({
communityId: e.detail.value
})
},
bindRoom: function(e) {
this.setData({
roomId: e.detail.value
})
},
bindContent: function(e) {
console.log(e, 9999999);
this.setData({
context: e.detail.value
})
},
submitRepair: function(e) {
let obj = {
appointmentTime: this.data.date + " " + this.data.time + ":00",
repairType: this.data.repairType,
repairName: this.data.repairName,
tel: this.data.tel,
communityId: this.data.communityId,
roomId: this.data.roomId,
context: this.data.context,
photos: [this.data.photos[1]]
}
let msg = "";
if (obj.repairName == "") {
msg = "请填写报修人";
} else if (obj.tel == "") {
msg = "请填写联系方式";
} else if (obj.communityId == ""){
msg = "请填写小区信息";
} else if (obj.roomId == "") {
msg = "请填写房屋信息";
} else if (this.data.date == "") {
msg = "请填写预约日期";
} else if (this.data.time == "") {
msg = "请填写预约时间";
} else if (obj.content == "") {
msg = "请填写报修内容";
} else if (this.data.photos == "") {
msg = "请上传图片";
}
if (msg != "") {
wx.showToast({
title: msg,
icon: 'none',
duration: 2000
})
} else {
console.log("提交数据", obj);
wx.request({
url: urlInfo.saveOwnerRepair, // http://hc.demo.winqi.cn:8012/appApi/ownerRepair.saveOwnerRepair
header: util.getHeaders(),
method: "POST",
data: {
"repairType": "10001",
"roomId": "752019100758260005",
"communityId": "7020181217000001",
"repairName": "吴学文",
"tel": "17797173942",
"context": "服务太差",
"appointmentTime": "2019-12-14 18:30:30",
"photos": ['base64....']
},
// data:obj, //动态数据
success: function(res) {
console.log(res, 99999);
}
});
}
},
uploadImg: function() {
let that = this;
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(res.tempFilePaths);
const photos = [];
for (var x = 0; x < res.tempFilePaths.length; x++) {
wx.getFileSystemManager().readFile({
filePath: res.tempFilePaths[x], //选择图片返回的相对路径
encoding: "base64", //这个是很重要的
success: res => { //成功的回调
//返回base64格式
console.log('data:image/png;base64,' + res.data)
photos[x] = res.data;
}
})
}
that.setData({
photos: photos,
imgUrl: tempFilePaths
})
}
})
}
})

3
pages/repair/repair.json Normal file
View File

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "报修"
}

118
pages/repair/repair.wxml Normal file
View File

@ -0,0 +1,118 @@
<view class="page">
<view class="weui-form">
<view class="">
<view class="weui-cells__group weui-cells__group_form">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell_select weui-cell ">
<view class="weui-cell__hd ">
<label class="weui-label" style="margin-left:64rpx">报修类型</label>
</view>
<view class="weui-cell__bd">
<picker bindchange="bindTypeChange" value="{{repairTypeIndex}}" range="{{typeArr}}" range-key="label">
<view class="weui-select" style="margin-left:-48rpx">
{{typeArr[repairTypeIndex].label}}
</view>
</picker>
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__hd">
<label class="weui-label">报
<text decode="{{true}}">&nbsp;</text>修
<text decode="{{true}}">&nbsp;</text>人</label>
</view>
<view class="weui-cell__bd">
<input bindinput="bindRepairName" class="weui-input" type="text" placeholder="请输入报修人" value="{{repairName}}" />
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__hd">
<label class="weui-label">
联系方式
</label>
</view>
<view class="weui-cell__bd">
<input bindinput="bindTel" class="weui-input" type="text" placeholder="请输入联系方式" value="{{tel}}" />
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__hd">
<label class="weui-label">
小区信息
</label>
</view>
<view class="weui-cell__bd">
<input bindinput="bindCommunity" class="weui-input" type="text" placeholder="请输入小区信息" value="{{communityId}}" />
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__hd">
<label class="weui-label">
房屋信息
</label>
</view>
<view class="weui-cell__bd">
<input bindinput="bindRoom" class="weui-input" type="text" placeholder="请输入房屋信息" value="{{roomId}}" />
</view>
</view>
<view class="weui-cell_select weui-cell ">
<view class="weui-cell__hd ">
<label class="weui-label" style="margin-left:64rpx">预约日期</label>
</view>
<view class="weui-cell__bd">
<picker mode="date" bindchange="bindDateChange" value="{{date}}">
<view class="weui-select" style="margin-left:-48rpx">
{{date}}
</view>
</picker>
</view>
</view>
<view class="weui-cell_select weui-cell ">
<view class="weui-cell__hd ">
<label class="weui-label" style="margin-left:64rpx">预约时间</label>
</view>
<view class="weui-cell__bd">
<picker mode="time" bindchange="bindTimeChange" value="{{time}}">
<view class="weui-select" style="margin-left:-48rpx">
{{time}}
</view>
</picker>
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__hd">
<label class="weui-label">
报修内容
</label>
</view>
<view class="weui-cell__bd">
<textarea bindblur="bindContent" class="repair_textarea" value="{{content}}" rows="3" placeholder="报修内容" />
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__hd">
<label class="weui-label">
上传图片
</label>
</view>
<view class="weui-cell__bd">
<image wx:if="{{imgUrl.length!=0}}" src="{{imgUrl}}" class="repair_image" catchtap="uploadImg"></image>
<image src="/images/upload.png" class="repair_image" catchtap="uploadImg"></image>
</view>
</view>
</view>
</view>
</view>
<view class="">
<button type="primary" catchtap="submitRepair">确认报修</button>
</view>
</view>
</view>

17
pages/repair/repair.wxss Normal file
View File

@ -0,0 +1,17 @@
.user-container {
padding: 25rpx 10rpx;
background-color: #F0F0F0;
/*border: 1px solid black;*/
}
.form{
background-color: #fff;
margin: 10rpx 7rpx;
}
.repair_textarea{
width: 100%;
height: 150rpx;
}
.repair_image{
width: 150rpx;
height: 150rpx;
}

View File

@ -0,0 +1,22 @@
/** index.js **/
const { appInfo, urlInfo } = require("../../../config/config.js");
const util = require('../../../utils/util.js');
//获取app实例
const app = getApp();
Page({
data: {
obj:{}
},
onLoad: function (e) {
let that = this
console.log(JSON.parse(e.item),99999)
this.setData({
obj: JSON.parse(e.item)
})
},
onShow: function () {
let that = this;
},
})

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,14 @@
<view class="user-container">
<view class="notice">
<view>
<view class="text"> 姓
<text decode="{{true}}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</text>名: {{obj.repairName}}</view>
<view class="text"> 联系方式: {{obj.tel}}</view>
<view class="text"> 报修类型: {{obj.repairTypeName}}</view>
<view class="text"> 状
<text decode="{{true}}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</text>态: {{obj.stateName}}</view>
<!-- <view class="text"> 报修时间: 2019-10-20 21:59:39</view> -->
<view class="text"> 预约时间: {{obj.appointmentTime}}</view>
</view>
</view>
</view>

View File

@ -0,0 +1,31 @@
.user-container {
padding: 25rpx 10rpx;
background-color: #F0F0F0;
/*border: 1px solid black;*/
}
.notice {
margin: 10rpx 7rpx;
padding: 25rpx;
background-color: #ffffff;
border-radius: 7rpx;
/* display: flex;
justify-content: space-between;
align-items: flex-end; */
}
.title {
border-bottom: 1rpx solid #dedede;
font-weight: 700;
font-size: 34rpx;
color: #5f5e5e;
display: flex;
justify-content: space-between;
}
.text{
padding: 8rpx 0;
font-size: 30rpx;
}
.button{
/* width: 160rpx; */
/* font-size: 30rpx; */
}

View File

@ -0,0 +1,81 @@
/** index.js **/
const {
appInfo,
urlInfo
} = require("../../config/config.js");
const util = require('../../utils/util.js');
//获取app实例
const app = getApp();
Page({
data: {
tableData: [],
page: 1,
totalPage: 0,
loading: false
},
onLoad: function() {
this.getTable(1);
},
onShow: function() {
let that = this;
},
getTable: function(page, override) {
let that = this;
this.setData({
loading:true
})
return this.request({
"roomId": "752019100758260005",
"communityId": "7020181217000001",
"page": page,
"row": 10
}).then(res => {
that.setData({
tableData: override ? res.data.ownerRepairs : this.data.tableData.concat(res.data.ownerRepairs),
totalPage: res.data.records,
page:page,
loading:false
})
})
},
gotoDetail: function(e) {
wx.navigateTo({
url: "/pages/repairList/detail/detail?item=" + JSON.stringify(e.currentTarget.dataset.item)
})
},
onPullDownRefresh: function() {
// 上拉刷新
if (!this.data.loading) {
this.getTable(1, true).then(() => {
// 处理完成后,终止下拉刷新
wx.stopPullDownRefresh()
})
}
},
onReachBottom: function() {
// 下拉触底,先判断是否有请求正在进行中
// 以及检查当前请求页数是不是小于数据总页数,如符合条件,则发送请求
if (!this.data.loading && this.data.page < this.data.totalPage) {
this.getTable(this.data.page + 1)
}
},
//封装请求
request: function(data) {
return new Promise((resolve, reject) => {
wx.request({
url: urlInfo.listOwnerRepairs,
header: util.getHeaders(),
method: "GET",
data: data,
success: function(res) {
if (res.statusCode == 200) {
resolve(res);
}
}
})
})
},
})

View File

@ -0,0 +1,3 @@
{
"enablePullDownRefresh": true
}

View File

@ -0,0 +1,19 @@
<view class="user-container">
<view wx:for="{{tableData}}" wx:for-index="idx" wx:for-item="item" class="notice" data-item="{{item}}" bindtap="gotoDetail">
<view class="title">
<view>{{item.repairName}}</view>
<view>{{item.tel}}</view>
</view>
<view class="main">
<view>
<view class="text"> 报修类型: {{item.repairTypeName}}</view>
<view class="text"> 状
<text decode="{{true}}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</text>态: {{item.stateName}}</view>
<view class="text"> 预约时间: {{item.appointmentTime}}</view>
</view>
<view>
<button class="button" size="mini" type="default" catchtap="gotoDetail" data-item="{{item}}">查看</button>
</view>
</view>
</view>
</view>

View File

@ -0,0 +1,36 @@
.user-container {
padding: 25rpx 10rpx;
background-color: #F0F0F0;
/*border: 1px solid black;*/
}
.notice {
margin: 10rpx 7rpx;
padding: 25rpx;
background-color: #ffffff;
border-radius: 7rpx;
/* display: flex;
justify-content: space-between;
align-items: flex-end; */
}
.title {
border-bottom: 1rpx solid #dedede;
font-weight: 700;
font-size: 34rpx;
color: #5f5e5e;
display: flex;
justify-content: space-between;
}
.text{
padding: 4rpx 0;
font-size: 30rpx;
}
.main{
display: flex;
justify-content: space-between;
align-items: flex-end;
}
.button{
/* width: 160rpx; */
/* font-size: 30rpx; */
}