diff --git a/app.json b/app.json index 1a20f02..6f1a83b 100644 --- a/app.json +++ b/app.json @@ -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" - } \ No newline at end of file diff --git a/config/config.js b/config/config.js index 89da05f..bc1c62a 100644 --- a/config/config.js +++ b/config/config.js @@ -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' } diff --git a/images/upload.png b/images/upload.png new file mode 100644 index 0000000..2ff2b00 Binary files /dev/null and b/images/upload.png differ diff --git a/pages/index/index.js b/pages/index/index.js index 63fbb82..2679f0c 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -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() { } }) \ No newline at end of file diff --git a/pages/repair/repair.js b/pages/repair/repair.js new file mode 100644 index 0000000..fc087ec --- /dev/null +++ b/pages/repair/repair.js @@ -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 + }) + + } + }) + } +}) \ No newline at end of file diff --git a/pages/repair/repair.json b/pages/repair/repair.json new file mode 100644 index 0000000..4fb451b --- /dev/null +++ b/pages/repair/repair.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "报修" +} \ No newline at end of file diff --git a/pages/repair/repair.wxml b/pages/repair/repair.wxml new file mode 100644 index 0000000..c9d830f --- /dev/null +++ b/pages/repair/repair.wxml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + {{typeArr[repairTypeIndex].label}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{date}} + + + + + + + + + + + + {{time}} + + + + + + + + + + +