diff --git a/app.js b/app.js index 2eff18bbc97c75456865691d71ce0b0662c18c4b..78466f64192a09ffac7b6cb56e8f15c32acd9e09 100644 --- a/app.js +++ b/app.js @@ -1,18 +1,8 @@ //app.js const API = require('utils/api.js'); const AJAX = require('utils/ajax.js'); -// 引入腾讯地图 -var QQMapWx = require('utils/qqmap-wx-jssdk.js') -var qqmapsdk; App({ onLaunch: function () { - console.log('onLaunch......初始化腾讯地图控件') - // 进行初始化腾讯地图 - // 实例化API核心类 - qqmapsdk = new QQMapWx({ - key: API.api.qqMapKey - }) - this.globalData.qqmapsdk = qqmapsdk let that = this wx.clearStorage(); // 展示本地存储能力 @@ -40,8 +30,10 @@ App({ userLoginCode: function (code) { let that = this return new Promise((resolve,reject) => { - let requestUrl = API.api.users + '?code=' + code; - AJAX.getRequest(requestUrl,false).then(function(response) { + let requestUrl = API.api.users; + let params = {} + params.code = code + AJAX.getRequest(requestUrl,params).then(function(response) { if (response.code == 200) { // 存储openId信息、用户信息 wx.setStorageSync('openId', response.data.openId) @@ -54,42 +46,7 @@ App({ }) }) }, - getSetting:function() { - return new Promise((resolve, reject) => { - wx.getSetting({ - success: res => { - if (res.authSetting['scope.userInfo']) { - // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 - wx.getUserInfo({ - success: res => { - wx.setStorageSync('nickName', res.userInfo.nickName) - wx.setStorageSync('avatarUrl', res.userInfo.avatarUrl) - // 可以将 res 发送给后台解码出 unionId - return resolve(res.userInfo) - } - }) - }else{ - return reject() - } - } - }) - }) - }, - updateUserInfo:function(userId,userInfo) { - // 如果用户没有授权信息,则不作任何操作,等到用户需要在提示 - console.log(`获取到的数据信息是:` + userId + JSON.stringify(userInfo)) - userInfo.nickName - let requestData = {} - requestData.nickName = userInfo.nickName - requestData.avatarUrl = userInfo.avatarUrl; - let requestUrl = API.api.users + '/' + Number(userId) - AJAX.postRequest(requestUrl,requestData,false).then(function(response) { - console.log('用户信息更新成功啦') - }) - }, globalData: { - token: '', - userInfo: null, - qqmapsdk: '', + token: '' } }) \ No newline at end of file diff --git a/app.json b/app.json index c725798ed57513cfff41e7a33ba6b675cc547273..b79ca5e34c54f7352d95edcb8797401ac231ea6d 100644 --- a/app.json +++ b/app.json @@ -2,17 +2,19 @@ "pages": [ "pages/index/authoriztion/authoriztion", "pages/consume/consume", + "pages/me/myBillDetail/myBillDetail", "pages/me/me", "pages/index/address/address", "pages/me/myBill/myBill", "pages/index/bookkeepingdetail/bookkeepingdetail", - "pages/index/index" - + "pages/index/index", + "pages/me/officialaccount/officialAccount", + "pages/me/feedback/feedback" ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#1E95F1", - "navigationBarTitleText": "消费明细君", + "navigationBarTitleText": "优享记账", "navigationBarTextStyle": "black" }, "tabBar": { @@ -42,5 +44,11 @@ "desc": "您的位置信息将用于寻找附近的检测点" } }, - "sitemapLocation": "sitemap.json" + "sitemapLocation": "sitemap.json", + "plugins": { + "chooseLocation": { + "version": "1.0.2", + "provider": "wx76a9a06e5b4e693e" + } + } } \ No newline at end of file diff --git a/app.wxss b/app.wxss index 304f1108b1b97614c3a288fa9b9e2db851aa11a3..6738b4acab8460842c31f7784703cc12947e8593 100644 --- a/app.wxss +++ b/app.wxss @@ -22,6 +22,9 @@ justify-content: space-between; box-sizing: border-box; } */ +page { + font-family:"DFKai-SB"; +} .loading { width: 100%; height: 100%; diff --git a/image/gongzhonghao.png b/image/gongzhonghao.png new file mode 100644 index 0000000000000000000000000000000000000000..71cbf7c981b02f32b8fb5985e008e53c034be07a Binary files /dev/null and b/image/gongzhonghao.png differ diff --git a/image/icon/beizhu.png b/image/icon/beizhu.png new file mode 100644 index 0000000000000000000000000000000000000000..8868d9c7e241d5c7e83021e5ba84199b193d0ec6 Binary files /dev/null and b/image/icon/beizhu.png differ diff --git a/image/icon/bianji.png b/image/icon/bianji.png new file mode 100644 index 0000000000000000000000000000000000000000..080aad588e916cc5a4b69eae857eac82bfe8092a Binary files /dev/null and b/image/icon/bianji.png differ diff --git a/image/icon/xiala.png b/image/icon/xiala.png new file mode 100644 index 0000000000000000000000000000000000000000..8de6bdc78e8458a181c1102fbd464975c09a291c Binary files /dev/null and b/image/icon/xiala.png differ diff --git a/pages/consume/consume.js b/pages/consume/consume.js index 9601676dc691dbe3664038325a457fff8d58ba70..face4efaaa79724eae502e3b1d218eb8010a6c6c 100644 --- a/pages/consume/consume.js +++ b/pages/consume/consume.js @@ -1,310 +1,106 @@ -// pages/consume/consume.js +// pages/consume_test/consume_test.js const API = require('../../utils/api.js'); const TOAST = require('../../utils/toast.js'); const AJAX = require('../../utils/ajax.js'); +const UTILS = require('../../utils/util.js') // 引入腾讯地图 const qqMapWxUtil = require('../../utils/qqMapWxUtil.js') +const chooseLocation = requirePlugin('chooseLocation'); Page({ + /** * 页面的初始数据 */ data: { - // 金额 - money: 0, - isShow: false, - //保存消费类型数据 - consumeTypeList: [], - //服务器图片地址 - imageHost: API.api.imageHost, - //点击的保存id - consumeTypeId: 1, - //要显示的图标信息 - consumeType: {}, - //地理位置 - address: '', - // 详情地址 - addressDetail: '', - // 省 市 区 - region: [], - // 上传保存的图片 - imagePathList: [], - //导航栏显示颜色 - showType: true, - // 计算器集合 - calculatorList:[ + current: '0', // tabs标签 + // money: '0.00', // 金额 + tmplIds: [API.api.bookkeepingSuccess, API.api.accountingBudget], // 模板id + consumeTypeList: [], //保存消费类型数据 + imageHost: API.api.imageHost, //服务器图片地址 + addCountTypeIcon: '/images/consume/icon/type/tianjia.png', // 添加默认类型 + imagePathList: [], //上传保存的图片 + imageDefault: '/images/consume/icon/add_upload.png',// 上传默认图片 + loading: false, // 加载动画 + showPriceModel: false, // 显示上传图片模态框 + animationData: {}, //动画内容 + region: ['广东省', '广州市', '海珠区'], //位置信息 + date: UTILS.formatTime(new Date(),'mm.dd'), // 记账时间 + start_time: '1997-02-09', // 记录开始时间 + end_time: new Date(), // 记录结束时间 + latitude : 0, // 经度 + longitude : 0, // 纬度 + /** + * 点击后的类型表 + */ + consumeType:{ + backgroundColor: 'white', // 消费类型颜色 + }, + /** + * 临时记账数据存储 + */ + tempBookkeepingObj: { + remarks: '', // 备注 + money: '0.00', // 金额 + address: '', //地址信息 + addressDetail: '', // 地址详情 + }, + /** + * 计算器集合 + */ + calculatorList: [ [{ "value": "7" }, { "value": "8" }, { "value": "9" }], [{ "value": "4" }, { "value": "5" }, { "value": "6" }], [{ "value": "1" }, { "value": "2" }, { "value": "3" }], - [{ "value": "C" }, { "value": "0" }, { "value": "." }]], - current: '0', - loading: false, - isShowImage: false, // 显示图片弹框 - isUploadFile: false, // 判断页面是跳转还是上传图片 - swiperHeight: 450, // 初始化的swiper高度 - imgheights: [], //所有图片的高度 - current: 0,//默认 - isShowContent: false, // 显示内容弹框 - remarks: '', // 备注 - tmplIds: [API.api.bookkeepingSuccess,API.api.accountingBudget], // 模板id + [{ "value": "C" }, { "value": "0" }, { "value": "." }]] }, /** * 生命周期函数--监听页面加载 */ - onLoad: function(options) { - console.log(`这里是onLoad`, options) - console.log(`这里是onLoad,地址来哪里` + options.form) - console.log(`这里是onLoad,地址来哪里` + options.address) - console.log(`这里是onLoad,详情地址来哪里` + options.addressDetail) - if (options.form === 'address') { - this.setData({ - address: options.address, - addressDetail: options.addressDetail - }) + onLoad: function (options) { + console.log("consume onLoad被触发了:",options) + console.log(options.form === 'edit' && options.bookkeepingid) + console.log(options.form === 'edit') + console.log(options.bookkeepingid) + if (options.form === 'edit' && options.bookkeepingid) { + // 来自修改页面 + this.getBookkeepingObj(options.bookkeepingid) + this.setData({bookkeepingid:options.bookkeepingid}) } else { // 获取到微信地理位置 this.getWxLocation() } - // 获取消费类型数据,默认值为0 - this.getConsumeType(0); + // 隐藏掉tabBar + TOAST.hideTabBar() }, /** - * 获取当前位置信息 - */ - getWxLocation() { - console.log(`我要去获取位置信息`) - let that = this - wx.getLocation({ - type: 'gcj02', - success: function(res) { - // 调用腾讯地图显示位置信息 - that.reverseGeocoder(res.latitude, res.longitude) - }, - }) - }, - /** - *调用腾讯地图显示位置信息 - * latitude:纬度 - * longitude:经度 - */ - reverseGeocoder(latitude, longitude) { - console.log(`reverseGeocoder------latitude:` + latitude + `longitude:` + longitude) - let that = this - let location = {} - location.latitude = latitude; - location.longitude = longitude; - qqMapWxUtil.reverseGeocoder(location).then(response => { - //当前位置信息 - that.setData({ - address: response.address, - region: response.region, - addressDetail: response.addressDetail - }) - }) - }, - /** - * 上传图片 + * 生命周期函数--监听页面显示 */ - uploadFile(event) { - if (this.data.imagePathList.length > 0 && event.currentTarget.dataset.upload == undefined) { + onShow: function () { + const location = chooseLocation.getLocation(); // 如果点击确认选点按钮,则返回选点结果对象,否则返回null + if (location) { + console.log("这里是从地图来的呢????", location.address) + let tempBookkeepingObj = this.data.tempBookkeepingObj + tempBookkeepingObj.address = location.address + tempBookkeepingObj.addressDetail = location.addressDetail this.setData({ - isShowImage: true + tempBookkeepingObj:tempBookkeepingObj, + latitude: location.latitude, + longitude: location.longitude }) - return; } - let that = this - wx.chooseImage({ - count: 2, - sizeType: ['compressed'], - success: function(res) { - const tempFiles = res.tempFiles; - let requestUrl = API.api.uploadFile + '/bookkeeping/bookkeeping' - var imagePathListObj = that.data.imagePathList - for (var i = 0; i < tempFiles.length; i++) { - if (tempFiles[i].size > 1048576) { - TOAST.showToastSuccess('图片大于1M') - continue; - } - that.setData({ - loading: true - }) - wx.uploadFile({ - url: requestUrl, - filePath: tempFiles[i].path, - name: 'file', - header: { - "Authorization": wx.getStorageSync('token') - }, - success: function(res) { - let resData = JSON.parse(res.data) - if (resData.code == 200) { - switch (imagePathListObj.length) { - case 0: - imagePathListObj.push(resData.data) - break; - default: - imagePathListObj[1] = imagePathListObj[0] - imagePathListObj[0] = resData.data - break; - } - that.setData({ - imagePathList: imagePathListObj - }) - TOAST.showToastSuccess('上传成功') - } - }, - complete() { - that.setData({ - loading: false - }) - } - }) - } - } - }) - }, - /** - * 上传指定图片 - * @param {*} event - */ - uploadOneFile(event) { - let that = this - wx.chooseImage({ - count: 1, - sizeType: ['original', 'compressed'], - success: function(res) { - const tempFiles = res.tempFiles[0]; - let requestUrl = API.api.uploadFile + '/bookkeeping/bookkeeping' - var imagePathListObj = that.data.imagePathList - console.log(tempFiles) - if (tempFiles.size > 1048576) { - TOAST.showToastSuccess('图片大于1M') - } - that.setData({ - loading: true - }) - wx.uploadFile({ - url: requestUrl, - filePath: tempFiles.path, - name: 'file', - header: { - "Authorization": wx.getStorageSync('token') - }, - success: function(res) { - let resData = JSON.parse(res.data) - if (resData.code == 200) { - imagePathListObj[event.currentTarget.dataset.index] = resData.data - that.setData({ - imagePathList: imagePathListObj - }) - TOAST.showToastSuccess('上传成功') - } - }, - complete() { - that.setData({ - loading: false - }) - } - }) - } - }) - }, - /** - * 跳转定位 - */ - gotoAddress() { - wx.navigateTo({ - url: '../index/address/address?form=consume&address=' + this.data.address + '&addressDetail=' + this.data.addressDetail, - }) - }, - /** - * 支出收入类型转换 - */ - tabTap: function(event) { - let showType = event.currentTarget.dataset.type == 1 ? false : true - this.setData({ - showType: showType - }) - this.getConsumeType(event.currentTarget.dataset.type) + }, - handleChange({ - detail - }) { + handleChange({ detail }) { + if (detail.key === '-1') { + wx.reLaunch({ url: '/pages/index/index' }) + return + } this.setData({ current: detail.key }); + console.log("这个是我选择的分支信息:" + detail.key) this.getConsumeType(detail.key) - }, - getConsumeType: function(type) { - let that = this; - let requestUrl = API.api.consumeTypes + '/type?type=' + type; - AJAX.getRequest(requestUrl).then(response => { - that.setData({ - consumeTypeList: response.data, - consumeType: response.data[0] - }) - }) - }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function() { - - }, - submitInfo: function(e) { - if (e.detail.formId) { - AJAX.saveFormId(e.detail.formId) - } - }, - btnIcon: function(event) { - let that = this - console.log('你是不是点击了icon' + JSON.stringify(event.currentTarget.dataset.type)) - this.data.consumeTypeList.forEach(item => { - if (item.id == event.currentTarget.dataset.type) { - // 进行保存数据信息 - console.log('匹配到了。。。。。。' + item.id) - that.setData({ - consumeType: item, - consumeTypeId: event.currentTarget.dataset.type - }) - return; - } - }) - }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function() {}, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function() {}, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function() {}, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function() { - }, /** * 添加数据 @@ -322,7 +118,7 @@ Page({ case '8': case '9': //常规数字 - this.addMunber(event) + this.addMunber(event.currentTarget.dataset.type) break; case '.': // 添加小数点 @@ -332,198 +128,443 @@ Page({ // 删除 this.deleteNumber(event) break; - // 归零 + // 归零 case 'C': this.reset(); break; + // 再记一笔 + case 'do_it_again': + this.saveBookkeeping('doItAgain'); + break; default: console.log(`键盘` + event.currentTarget.dataset.type + `匹配不到对于的类型`) } }, - addMunber: function(event) { + addMunber: function (numberValue) { + let tempBookkeepingObj = this.data.tempBookkeepingObj // 先判断是否有小数点 - let message = String(this.data.money); + let message = String(tempBookkeepingObj.money); + if (message === '0.00') { + tempBookkeepingObj.money = numberValue + this.setData({ tempBookkeepingObj: tempBookkeepingObj}) + return + } let index = message.lastIndexOf('.'); - if (index != -1) { - if (message.length - index > 2) { + if (index != -1 && message.length - index > 2) { return - } } - if (message != 0 || index != -1) { - message += event.currentTarget.dataset.type - } else { - message = event.currentTarget.dataset.type - } - this.setData({ - money: message - }) + message = message != 0 || index != -1 ? (message + numberValue) : numberValue + tempBookkeepingObj.money = message + this.setData({tempBookkeepingObj: tempBookkeepingObj}) }, - deleteNumber: function() { - let message = this.data.money; - if (message != 0 && message != '') { + deleteNumber: function () { + let tempBookkeepingObj = this.data.tempBookkeepingObj + let message = tempBookkeepingObj.money; + console.log('message:' + message.length) + if (message.length > 1 && message != 0 && message != '') { message = message.substring(0, message.length - 1) } else { - message = '0' + message = '0.00' } + tempBookkeepingObj.money = message this.setData({ - money: message + tempBookkeepingObj: tempBookkeepingObj }) }, - addSpot: function() { - let money = this.data.money + ""; + addSpot: function () { + let tempBookkeepingObj = this.data.tempBookkeepingObj + let money = tempBookkeepingObj.money + ""; console.log(money) let index = money.lastIndexOf('.'); if (index != -1) { return } + tempBookkeepingObj.money = money + '.' this.setData({ - money: money + '.' + tempBookkeepingObj: tempBookkeepingObj }) }, - reset: function() { + reset: function () { + let tempBookkeepingObj = this.data.tempBookkeepingObj + tempBookkeepingObj.money = '0.00' this.setData({ - money: 0, - isShow: false, + tempBookkeepingObj: tempBookkeepingObj + }) + }, + /** + * 获取一次性订阅信息 + */ + requestSubscribeMessage() { + let that = this; + // 用户想接收到模板消息 + if (wx.getStorageSync('sendMessage') == 0) { + that.saveBookkeeping(); + return; + } + console.log("看下模板消息IDS:",that.data.tmplIds) + wx.requestSubscribeMessage({ + tmplIds: that.data.tmplIds, + success(success) { + // 保存用户提交信息 + that.saveWxUserSubscribe(success); + }, + fail(error) { + console.error(`调用接口失败`); + }, + complete() { + that.saveBookkeeping() + } + }) + }, + /** + * 保存一次性订阅信息 + */ + saveWxUserSubscribe(resData) { + let that = this + this.data.tmplIds.forEach(item => { + console.log(`resData[item]` + resData[item]) + let requestObj = {}; + requestObj.userId = wx.getStorageSync('userId'); + if (resData[item] == 'accept') { + requestObj.type = 1; + } else if (resData[item] == 'reject') { + requestObj.type = 0; + } else { + requestObj.type = 2; + } + requestObj.subscribeId = item; + console.log('保存的数据来着', requestObj) + let requestUrl = API.api.wxusersubscribes; + AJAX.postRequest(requestUrl, requestObj).then(response => { + console.log(`保存成功`) + }) }) }, /** * 保存按钮 */ - saveBookkeeping() { + saveBookkeeping(params) { let that = this // 进行loaing if (this.data.loading) { return; } - this.setData({ - loading: true - }) - let money = Number(this.data.money); + this.setData({loading: true}) + let money = Number(this.data.tempBookkeepingObj.money); if (money == 0) { - TOAST.showToastSuccess('金额不能为0') - this.setData({ - loading: false - }) + TOAST.showToast('保存失败:金额不能为0') + this.setData({loading: false}) return } - + // 进行金额转换 - money = money * 100; - let requestObj = {}; + let requestObj = that.data.tempBookkeepingObj; + requestObj.consumeTypeId = requestObj.comsumeTypeId ? requestObj.comsumeTypeId : this.data.consumeType.id; + requestObj.money = requestObj.money * 100; requestObj.userId = wx.getStorageSync('userId'); - requestObj.consumeTypeId = this.data.consumeTypeId; - requestObj.money = money; - requestObj.address = this.data.address; - requestObj.addressDetail = this.data.addressDetail; requestObj.imageUrl = JSON.stringify(this.data.imagePathList); - requestObj.remarks = this.data.remarks console.log('保存的数据来着', requestObj) let requestUrl = API.api.bookkeepings; - AJAX.postRequest(requestUrl, requestObj).then(response => { + if (requestObj.id) { + // 更新操作 + AJAX.postRequest(requestUrl,requestObj).then(Response => { + TOAST.showToast("更新成功") + }) + } else { + // 保存操作 + AJAX.postRequest(requestUrl, requestObj).then(response => { + TOAST.showToast("保存成功") + }) + } + that.setData({loading: false}) + if (params === 'doItAgain') { + requestObj.money = '0.00' + requestObj.remarks = '' + // 再记一笔 + that.setData({ + imagePathList: [], + tempBookkeepingObj:requestObj + }) + } else { + wx.reLaunch({url: '/pages/index/index'}) + } + }, + /** + * 获取记账信息 + */ + getBookkeepingObj:function(bookkeepingId) { + let that = this; + let requestUrl = API.api.bookkeepings + '/' + bookkeepingId; + this.setData({loading: true}) + AJAX.getRequest(requestUrl).then(response => { + let tempBookkeepingObj = response.data + // 获取记账类型 + that.getConsumeType(tempBookkeepingObj.consumeType.type,tempBookkeepingObj.consumeType) + // 获取经纬度 + that.geocoder(tempBookkeepingObj.address) + // 进行金额转换 + tempBookkeepingObj.money = tempBookkeepingObj.money / 100 + that.setData({ + loading: false, + tempBookkeepingObj: tempBookkeepingObj, + current: response.data.consumeType.type + "", + imagePathList: tempBookkeepingObj.imageUrl ? JSON.parse(tempBookkeepingObj.imageUrl) : [] + }) + }) + }, + /** + * 开启动画 + */ + clickPup: function () { + // 用that取代this,防止不必要的情况发生 + var that = this; + // 创建一个动画实例 + var animation = wx.createAnimation({ + // 动画持续时间 + duration: 100, + // 定义动画效果,当前是匀速 + timingFunction: 'linear' + }) + // 将该变量赋值给当前动画 + that.animation = animation + // 先在y轴偏移,然后用step()完成一个动画 + animation.translateY(200).step() + // 用setData改变当前动画 + that.setData({ + // 通过export()方法导出数据 + animationData: animation.export(), + // 改变view里面的Wx:if + showPriceModel: true + }) + // 设置setTimeout来改变y轴偏移量,实现有感觉的滑动 + setTimeout(function () { + animation.translateY(0).step() that.setData({ - loading: false + animationData: animation.export() }) - wx.switchTab({ - url: '/pages/index/index' + }, 200) + }, + /** + * 关闭动画 + */ + hideModal: function (e) { + var that = this; + var animation = wx.createAnimation({ + duration: 1000, + timingFunction: 'linear' + }) + that.animation = animation + animation.translateY(200).step() + that.setData({ + animationData: animation.export() + + }) + setTimeout(function () { + animation.translateY(0).step() + that.setData({ + animationData: animation.export(), + showPriceModel: false }) + }, 200) + }, + /** + * 上传图片 + */ + uploadFile(event) { + let that = this + wx.chooseImage({ + count: 2, + sizeType: ['compressed'], + success: function (res) { + const tempFiles = res.tempFiles; + let requestUrl = API.api.uploadFile + '/bookkeeping/wx_' + wx.getStorageSync('userId'); + var imagePathListObj = that.data.imagePathList + for (var i = 0; i < tempFiles.length; i++) { + if (tempFiles[i].size > 1048576) { + TOAST.showToast('上传图片失败:图片大于1M') + continue; + } + that.setData({ + loading: true + }) + wx.uploadFile({ + url: requestUrl, + filePath: tempFiles[i].path, + name: 'file', + header: { + "Authorization": wx.getStorageSync('token') + }, + success: function (res) { + console.log("获取到上传信息:", res.data) + let resData = JSON.parse(res.data) + + switch (imagePathListObj.length) { + case 0: + imagePathListObj.push(resData.file) + break; + default: + imagePathListObj[1] = imagePathListObj[0] + imagePathListObj[0] = resData.file + break; + } + that.setData({ + imagePathList: imagePathListObj + }) + TOAST.showToast('上传成功') + }, + complete() { + that.setData({loading: false}) + } + }) + } + } }) }, - hideModel() { + /** + * 选择地理位置 + */ + bindRegionChange: function (e) { + console.log("我进来了") + let that = this + const key = 'GSUBZ-UACKQ-NXJ5Z-GL47V-CIVU2-7YB4X'; //使用在腾讯位置服务申请的key + const referer = '优享记账'; //调用插件的app的名称 + const location = JSON.stringify({ + latitude: that.data.latitude, + longitude: that.data.longitude + }); + console.log("准备跳转到地图那边过去了:" , location) + // POI分类关键词 + // const category = '生活服务,娱乐休闲'; + wx.navigateTo({ + url: `plugin://chooseLocation/index?key=${key}&referer=${referer}&location=${location}` + }); + }, + /** + * 选择消费时间 + */ + bindDateChange: function (e) { + console.log('picker发送选择改变,携带值为', e.detail.value) + let dateTmp = e.detail.value.split('-') this.setData({ - isShowImage: false, - isShowContent:false + date: dateTmp[1] + '.' + dateTmp[2] }) }, + /** + * 记录备注信息 + */ + bindKeyInput: function (e) { + let tempBookkeepingObj = this.data.tempBookkeepingObj + tempBookkeepingObj.remarks = e.detail.value + this.setData({ + tempBookkeepingObj:tempBookkeepingObj + }) + }, + /** + * 获取当前位置信息 + */ + getWxLocation() { + let that = this + wx.getLocation({ + type: 'gcj02', + altitude: 'true', + isHighAccuracy: true, + success: function (res) { + console.log("我的坐标位置" + JSON.stringify(res)) + // 调用腾讯地图显示位置信息 + that.reverseGeocoder(res.latitude, res.longitude) + }, + }) + }, + /** + *调用腾讯地图显示位置信息 + * latitude:纬度 + * longitude:经度 + */ + reverseGeocoder(latitude, longitude) { + qqMapWxUtil.reverseGeocoder(latitude, longitude).then(response => { + let tempBookkeepingObj = this.data.tempBookkeepingObj + tempBookkeepingObj.address = response.address + //当前位置信息 + this.setData({ + tempBookkeepingObj:tempBookkeepingObj, + region: response.region, + latitude: latitude, + longitude: longitude + }) + }) + }, + /** + * 点击tab触发操作 + */ onTabItemTap(item) { this.setData({ - money: 0, - addorDel: '+', - isShow: false, + money: '0.00', imagePathList: [], - current: 0, - isShowImage: false, - isShowContent:false, - loading:false + current: '0', + loading: false, + showPriceModel:false }) // 获取消费类型数据,默认值为0 this.getConsumeType(0); }, - // 设置高度 - imageLoad: function(e) { //获取图片真实宽度 - var imgwidth = e.detail.width; - var imgheight = e.detail.height; - //宽高比 - var ratio = imgwidth / imgheight; - console.log(imgwidth, imgheight) - //计算的高度值 - var viewHeight = 750 / ratio; - imgheight = viewHeight; - var imgheights = this.data.imgheights; - //把每一张图片的对应的高度记录到数组里 - imgheights[e.target.dataset.index] = imgheight; - this.setData({ - imgheights: imgheights + + /** + * 获取消费类型 + * type:类型 + * editConsumeType:修改传过来的参数 + */ + getConsumeType: function (type,editConsumeType) { + let that = this; + let params = {}; + params.type = Number(type); + params.userId = wx.getStorageSync('userId'); + let requestUrl = API.api.consumeTypes + '/type'; + AJAX.getRequest(requestUrl, params).then(response => { + that.setData({ + consumeTypeList: response.data, + consumeType: editConsumeType !== undefined ? editConsumeType : response.data[0] + }) }) }, - bindchange: function(e) { - this.setData({ - current: e.detail.current + /** + * 点击icon + */ + onClickIcon: function (event) { + console.log("这里点击获取到value值:", event.currentTarget.dataset.type) + let that = this; + this.data.consumeTypeList.forEach(item => { + if (item.id == event.currentTarget.dataset.type) { + // 进行保存数据信息 + console.log('匹配到了。。。。。。' + item.id) + that.setData({ + consumeType: item + }) + return; + } }) }, - showContent() { - this.setData({isShowContent: true}) - }, /** - * 填写备注 + * 添加icon */ - textareaRemark:function(e) { - console.log(`获取到数据了`,e.detail.value) - this.setData({ remarks:e.detail.value }) + addCountTypeIcon:function() { + TOAST.showToast("该功能暂未上线") }, /** - * 获取一次性订阅信息 + * 调用腾讯地图进行定位 + * address:地址信息 */ - requestSubscribeMessage() { - let that = this; - // 用户想接收到模板消息 - if(wx.getStorageSync('sendMessage') == 0) { - that.saveBookkeeping(); + geocoder: function (address) { + if (!address) { + console.log(`地址为空,重新调用接口信息` + address) + this.getWxLocation() return; } - console.log(that.data.tmplIds) - wx.requestSubscribeMessage({ - tmplIds: that.data.tmplIds, - success(success) { - // 保存用户提交信息 - that.saveWxUserSubscribe(success); - }, - fail(error) { - console.error(`调用接口失败`); - }, - complete() { - that.saveBookkeeping() - } - }) - }, - saveWxUserSubscribe(resData) { - let that = this - this.data.tmplIds.forEach(item => { - console.log(`resData[item]` + resData[item]) - let requestObj = {}; - requestObj.userId = wx.getStorageSync('userId'); - if(resData[item] == 'accept') { - requestObj.type = 1; - } else if (resData[item] == 'reject') { - requestObj.type = 0; - } else { - requestObj.type = 2; - } - requestObj.subscribeId = item; - console.log('保存的数据来着', requestObj) - let requestUrl = API.api.wxusersubscribes; - AJAX.postRequest(requestUrl, requestObj).then(response => { - console.log(`保存成功`) + + qqMapWxUtil.geocoder(address).then(response => { + this.setData({ + latitude : response.lat, // 经度 + longitude :response.lng // 纬度 }) }) - } + }, }) \ No newline at end of file diff --git a/pages/consume/consume.json b/pages/consume/consume.json index 7885d684465f8e8ee9cd7f521cf66dc21ee1e44d..393590aec94e0c60c48ca8a68f49cd9e4bf27ced 100644 --- a/pages/consume/consume.json +++ b/pages/consume/consume.json @@ -1,20 +1,21 @@ { - "navigationBarBackgroundColor": "#1E95F1", - "navigationBarTextStyle": "white", - "navigationBarTitleText": "消费记账", - "backgroundColor": "#ffffff", - "backgroundTextStyle": "light", - "usingComponents": { - "i-tabs": "../../template/dist/tabs/index", - "i-tab": "../../template/dist/tab/index", - "i-row": "../../template/dist/row/index", - "i-col": "../../template/dist/col/index", - "i-avatar": "../../template/dist/avatar/index", - "i-button": "../../template/dist/button/index", - "i-grid": "../../template/dist/grid/index", - "i-grid-item": "../../template/dist/grid-item/index", - "i-grid-icon": "../../template/dist/grid-icon/index", - "i-grid-label": "../../template/dist/grid-label/index", - "i-spin": "../../template/dist/spin/index" - } + "navigationBarBackgroundColor": "#1E95F1", + "navigationBarTextStyle": "white", + "navigationBarTitleText": "消费记账", + "backgroundColor": "#ffffff", + "backgroundTextStyle": "light", + "usingComponents": { + "i-tabs": "../../template/dist/tabs/index", + "i-tab": "../../template/dist/tab/index", + "i-row": "../../template/dist/row/index", + "i-col": "../../template/dist/col/index", + "i-avatar": "../../template/dist/avatar/index", + "i-button": "../../template/dist/button/index", + "i-grid": "../../template/dist/grid/index", + "i-grid-item": "../../template/dist/grid-item/index", + "i-grid-icon": "../../template/dist/grid-icon/index", + "i-grid-label": "../../template/dist/grid-label/index", + "i-spin": "../../template/dist/spin/index", + "i-input": "../../template/dist/input/index" + } } \ No newline at end of file diff --git a/pages/consume/consume.wxml b/pages/consume/consume.wxml index 63866c21f77447cd7ba14062d3033d6aa3c0fe0c..a09206ce2654e25b233116fe8f6d0c7b19932b91 100644 --- a/pages/consume/consume.wxml +++ b/pages/consume/consume.wxml @@ -1,86 +1,98 @@ - 加载中 + 加载中 - - + + + - - - - - - {{consumeType.name}} - - {{money}} 元 - + + + {{consumeType.name}} + {{tempBookkeepingObj.money}} - - - - - - {{item.name}} - - - - + + + + + + {{item.name}} + + + + 添加 + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 备注 - + + + + {{date}} + + + + + + + + + + 现金 + + + + + 我(待上线) + + + + + 照片({{imagePathList.length}}) + + + 照片 + + + + + + 位置 + + + + + + + + + + + + + 再记一笔 + + 保存 + - - - - - - - - - - - - - - - - 上传图片 + + + + + + 最多可添加2张图片 + + + + + + + + + 完成 - \ No newline at end of file diff --git a/pages/consume/consume.wxss b/pages/consume/consume.wxss index 4fbfed3b8603e6e520a3016117edb1b9b2c3dc38..ec6f06e4c50f45c80a715e3f1a43070cb6f31f39 100644 --- a/pages/consume/consume.wxss +++ b/pages/consume/consume.wxss @@ -1,196 +1,288 @@ -/* pages/consume/consume.wxss */ -page { - background-color: #FFFFFF -} -/* 表头 */ -.table { - border: 0px solid #FFFFFF; -} -.tr { +/* pages/consume_test/consume_test.wxss */ + +.bookkeeping { display: flex; + position: relative; + height: 104rpx; width: 100%; - justify-content: center; - height: 2.5rem; - align-items: center; + margin-top: 4rpx; } -.th { - width: 50%; - justify-content: center; - background: #1E95F1; - color: #000000; + +/* 分类 */ + +.consume_type { + text-align: center; + padding: 25rpx 10rpx; +} + +.bookkeeping_value { + padding: 28rpx 28rpx; + font-family: 'PingFang SC'; + font-size: 36rpx; + font-weight: bold; + color: #333; +} + +.bookkeeping_data { + font-family: 'DIN-Bold'; + font-weight: bold; + font-size: 44rpx; + color: #ff2121; + position: absolute; + right: 15rpx; + margin: 28rpx 0rpx; display: flex; - height: 2.5rem; - align-items: center; - /* border-right: 1rpx solid #aae6f9 */ - /* border: 1rpx solid rgba(49, 48, 48, 0.322) */ } -.th_show { - background: #FFFFFF + +.bookkeeping_data view { + font-size: 30rpx; + margin: 11rpx 5rpx; } +/* 计算器 */ + +.section { + margin: 10rpx 10rpx; + position: absolute; + bottom: 0; + left: 0; + width: 100%; +} -.consume-type-icon { +.flex-wrp_one { display: flex; flex-direction: row; - flex-wrap:wrap; - position: relative; - border-bottom:1rpx solid #ccc; } -.consume-type-icon .consume-icon { - width: 8%; - padding: 21rpx 40rpx; -} -.consume-type-icon span { + +.section_btn { display: flex; - align-items: center; - padding: 0rpx; - font-size: 35rpx; + flex-direction: row; + height: 80rpx; + border: 2rpx solid #eee; + background-color: #f7f7f7; } -.consume-type { +.section_btn image { + width: 60rpx; + height: 60rpx; + padding: 10rpx 5rpx; +} + +.section_btn_left { + flex: 8; +} + +.section_btn_right { + flex: 1; +} + +.container { + position: absolute; + bottom: 0; + left: 0; + width: 100%; +} + +.container_function { + /* display: flex; + flex-direction: row; */ + background-color: #f7f7f7; + height: 70rpx; +} + +.container_function_one { + /* display: flex; *//* flex-direction: row; */ + background-color: rgb(255, 255, 255); + border-top: 1rpx solid #f7f7f7; + line-height: 60rpx; + font-size: 23rpx; + height: 70rpx; + /* padding: 10rpx 10rpx; */ +} + +.container_calculator { display: flex; flex-direction: row; - flex-wrap:wrap; - position: relative; + height: 400rpx; } -.consume-type .consume-icon { - width: 16%; - padding: 20rpx 15rpx; - margin-top: 5rpx; - + +.left { + flex: 3; + height: 100%; } -.consume-icon image { - width: 100%; +.right { + flex: 1; height: 100%; } -.consume-type center { + +.tr { + width: 100%; + height: 25%; display: flex; - padding: 0rpx 15rpx; + align-items: center; + justify-content: center; +} + +.tr button { + height: 100%; + background-color: #fff; + flex: 1; + vertical-align: middle; text-align: center; + border: 1px solid #f7f7f7; } -.consume-money { - position: absolute; - right: 28rpx; - margin-top: 28rpx; + +.tr picker { + height: 100%; + flex: 1; + vertical-align: middle; + text-align: center; + border: 0rpx; + /* border:1px solid #fff; */ + border-right: 1rpx solid black; + font-size: 23rpx; + padding: 5rpx; + margin-top: 17rpx; } +.tr view { + height: 100%; + flex: 1; + vertical-align: middle; + text-align: center; + border: 0rpx; + border-right: 1rpx solid black; + font-size: 23rpx; + padding: 5rpx; + margin-top: 17rpx; + display: flex; + justify-content: center; + align-items: center; +} +#tr_icon{ + width: 16rpx; + height: 16rpx; +} -/* 计算器 */ -.section { - margin: 10rpx 10rpx; - position: absolute; - bottom: 0; - left: 0; +.remove { width: 100%; + height: 25%; + vertical-align: middle; + background-color: #fff; + text-align: center; + background-size: 30% 50%; + background-image: url(https://be.yangyoki.top/images/consume/icon/delete.png); + background-repeat: no-repeat; + background-position: center; } -.flex-wrp_one { - display: flex; - flex-direction: row; + +.do_it_again { + width: 100%; + height: 25%; + vertical-align: middle; + background-color: #fff; + text-align: center; + background-size: 30% 50%; + background-image: url(https://be.yangyoki.top/images/consume/icon/jilu.png); + background-repeat: no-repeat; + background-position: center; } + .fix-item { - background-color: #FFFFFF; width: 100%; - height: 75%; + height: 25%; + vertical-align: middle; + background-color: #fff; + text-align: center; + background-size: 30% 50%; + background-image: url(https://be.yangyoki.top/images/consume/icon/save_bookkeeping.png); + background-repeat: no-repeat; + background-position: center; +} + +.save_value { + text-align: center; + font-size: 20rpx; +} + +.do_it_again_value { + text-align: center; + font-size: 16rpx; +} + +.col-class input { display: flex; - /*使子项目水平居中 */ - justify-content: center; - /*使子项目垂直居中*/ align-items: center; + padding: 10rpx 20rpx; } -.section_btn { + +.col-class picker { display: flex; - flex-direction: row; - height: 80rpx; - border: 2rpx solid #eeeeee; + justify-content: center; + align-items: center; } -.section_btn image { - width: 60rpx; - height: 60rpx; - padding: 10rpx 5rpx; + +.col-class image { + width: 56rpx; + height: 56rpx; } -.section_btn_left{ - flex:8; -} -.section_btn_right{ - flex:2; -} -.container{ - position: absolute; - bottom: 0; - left: 0; - width: 100%; -} -.container1{ - display:flex; - flex-direction: row; - height:400rpx; -} -.left{ - flex: 3; - height: 100%; -} -.right{ - flex: 1; - height: 100%; -} -.tr{ - width:100%; - height:25%; - display:flex; - align-items: center; - justify-content: center; -} -.tr button{ - height:100%; - background-color:#FFFFFF; - flex:1; - vertical-align:middle; - text-align:center; - border:0rpx; - /* border:1px solid #fff; */ -} -.remove{ - width:100%; - height:25%; - vertical-align:middle; - background-color: #FFFFFF; - text-align: center; - background-size: 30% 50%; - background-image:url(https://be.yangyoki.top/images/consume/icon/delete.png); - background-repeat: no-repeat; - background-position: center; - -} - - -.model { + +.type_icon { + height: 100rpx; + width: 100rpx; + margin-bottom: 40rpx; +} + +.type_icon view { + font-size: 25rpx; + margin-top: 15rpx; +} + +/* 模态框 */ + +.choose { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background-color: rgba(0, 0, 0, 0.5); - z-index: 0; - color: #333; } -.ruleModel { - width: 600rpx; - background-color: #fff; - margin: 120rpx 75rpx; - border-radius: 20rpx; - padding: 20rpx 15rpx; +.choose_value { + height: 400rpx; + width: 100%; + position: fixed; + bottom: 0; + background-color: white; } -.close { - width: 80rpx; - height: 80rpx; - position: absolute; - top: 80rpx; - right: 20rpx; +.upload_value { + text-align: center; + padding: 10rpx; + font-size: 30rpx; +} + +.upload_data { + display: flex; + flex-direction: row; + justify-content: center; +} + +.upload_show { + width: 160rpx; + height: 160rpx; + margin: 30rpx 5rpx; } -.swiper-image { + +.upload_show view { + font-size: 16rpx; + display: flex; + justify-content: center; +} + +.upload_show image { width: 100%; height: 100%; -} \ No newline at end of file +} diff --git a/pages/consumeOld/consume.js b/pages/consumeOld/consume.js new file mode 100644 index 0000000000000000000000000000000000000000..d4102876c72f8afb707eb5d9c576d68cb1d9bdba --- /dev/null +++ b/pages/consumeOld/consume.js @@ -0,0 +1,500 @@ +// pages/consume/consume.js +const API = require('../../utils/api.js'); +const TOAST = require('../../utils/toast.js'); +const AJAX = require('../../utils/ajax.js'); +// 引入腾讯地图 +const qqMapWxUtil = require('../../utils/qqMapWxUtil.js') +Page({ + /** + * 页面的初始数据 + */ + data: { + // 金额 + money: 0, + isShow: false, + //保存消费类型数据 + consumeTypeList: [], + //服务器图片地址 + imageHost: API.api.imageHost, + //点击的保存id + consumeTypeId: 1, + //要显示的图标信息 + consumeType: {}, + //地理位置 + address: '', + // 详情地址 + addressDetail: '', + // 省 市 区 + region: [], + // 上传保存的图片 + imagePathList: [], + // 计算器集合 + calculatorList: [ + [{ "value": "7" }, { "value": "8" }, { "value": "9" }], + [{ "value": "4" }, { "value": "5" }, { "value": "6" }], + [{ "value": "1" }, { "value": "2" }, { "value": "3" }], + [{ "value": "C" }, { "value": "0" }, { "value": "." }]], + current: '0', + loading: false, + isShowImage: false, // 显示图片弹框 + isUploadFile: false, // 判断页面是跳转还是上传图片 + swiperHeight: 450, // 初始化的swiper高度 + imgheights: [], //所有图片的高度 + isShowContent: false, // 显示内容弹框 + remarks: '', // 备注 + tmplIds: [API.api.bookkeepingSuccess, API.api.accountingBudget], // 模板id + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + // 获取到微信地理位置 + this.getWxLocation() + // 获取消费类型数据,默认值为0 + // this.getConsumeType(0); + }, + /** + * 获取当前位置信息 + */ + getWxLocation() { + let that = this + wx.getLocation({ + type: 'gcj02', + altitude: 'true', + isHighAccuracy: true, + success: function (res) { + console.log("我的坐标位置" + JSON.stringify(res)) + // 调用腾讯地图显示位置信息 + that.reverseGeocoder(res.latitude, res.longitude) + }, + }) + }, + /** + *调用腾讯地图显示位置信息 + * latitude:纬度 + * longitude:经度 + */ + reverseGeocoder(latitude, longitude) { + qqMapWxUtil.reverseGeocoder(latitude, longitude).then(response => { + //当前位置信息 + this.setData({ + address: response.address, + region: response.region, + addressDetail: response.addressDetail + }) + }) + }, + /** + * 上传图片 + */ + uploadFile(event) { + if (this.data.imagePathList.length > 0 && event.currentTarget.dataset.upload == undefined) { + this.setData({ + isShowImage: true + }) + return; + } + let that = this + wx.chooseImage({ + count: 2, + sizeType: ['compressed'], + success: function (res) { + const tempFiles = res.tempFiles; + let requestUrl = API.api.uploadFile + '/bookkeeping/bookkeeping' + var imagePathListObj = that.data.imagePathList + for (var i = 0; i < tempFiles.length; i++) { + if (tempFiles[i].size > 1048576) { + TOAST.showToast('上传图片失败:图片大于1M') + continue; + } + that.setData({ + loading: true + }) + wx.uploadFile({ + url: requestUrl, + filePath: tempFiles[i].path, + name: 'file', + header: { + "Authorization": wx.getStorageSync('token') + }, + success: function (res) { + let resData = JSON.parse(res.data) + if (resData.code == 200) { + switch (imagePathListObj.length) { + case 0: + imagePathListObj.push(resData.data) + break; + default: + imagePathListObj[1] = imagePathListObj[0] + imagePathListObj[0] = resData.data + break; + } + that.setData({ + imagePathList: imagePathListObj + }) + TOAST.showToast('上传成功') + } + }, + complete() { + that.setData({ + loading: false + }) + } + }) + } + } + }) + }, + /** + * 上传指定图片 + * @param {*} event + */ + uploadOneFile(event) { + let that = this + wx.chooseImage({ + count: 1, + sizeType: ['original', 'compressed'], + success: function (res) { + const tempFiles = res.tempFiles[0]; + let requestUrl = API.api.uploadFile + '/bookkeeping/bookkeeping' + var imagePathListObj = that.data.imagePathList + console.log(tempFiles) + if (tempFiles.size > 1048576) { + TOAST.showToast('上传图片失败:图片大于1M') + } + that.setData({ + loading: true + }) + wx.uploadFile({ + url: requestUrl, + filePath: tempFiles.path, + name: 'file', + header: { + "Authorization": wx.getStorageSync('token') + }, + success: function (res) { + let resData = JSON.parse(res.data) + if (resData.code == 200) { + imagePathListObj[event.currentTarget.dataset.index] = resData.data + that.setData({ + imagePathList: imagePathListObj + }) + TOAST.showToast('上传成功') + } + }, + complete() { + that.setData({ + loading: false + }) + } + }) + } + }) + }, + + handleChange({detail}) { + this.setData({ + current: detail.key + }); + this.getConsumeType(detail.key) + }, + /** + * 获取消费类型 + */ + getConsumeType: function (type) { + let that = this; + let params = {}; + params.type = Number(type); + params.userId = wx.getStorageSync('userId'); + let requestUrl = API.api.consumeTypes + '/type'; + AJAX.getRequest(requestUrl,params).then(response => { + that.setData({ + consumeTypeList: response.data, + consumeType: response.data[0], + consumeTypeId:response.data[0].id + }) + }) + }, + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + submitInfo: function (e) { + if (e.detail.formId) { + AJAX.saveFormId(e.detail.formId) + } + }, + btnIcon: function (event) { + let that = this + console.log('你是不是点击了icon' + JSON.stringify(event.currentTarget.dataset.type)) + this.data.consumeTypeList.forEach(item => { + if (item.id == event.currentTarget.dataset.type) { + // 进行保存数据信息 + console.log('匹配到了。。。。。。' + item.id) + that.setData({ + consumeType: item, + consumeTypeId: event.currentTarget.dataset.type + }) + return; + } + }) + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + /** + * 添加数据 + */ + calculationType(event) { + switch (event.currentTarget.dataset.type) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + //常规数字 + this.addMunber(event) + break; + case '.': + // 添加小数点 + this.addSpot() + break; + case 'DEL': + // 删除 + this.deleteNumber(event) + break; + // 归零 + case 'C': + this.reset(); + break; + default: + console.log(`键盘` + event.currentTarget.dataset.type + `匹配不到对于的类型`) + } + }, + addMunber: function (event) { + // 先判断是否有小数点 + let message = String(this.data.money); + let index = message.lastIndexOf('.'); + if (index != -1) { + if (message.length - index > 2) { + return + } + } + if (message != 0 || index != -1) { + message += event.currentTarget.dataset.type + } else { + message = event.currentTarget.dataset.type + } + this.setData({ + money: message + }) + }, + deleteNumber: function () { + let message = this.data.money; + if (message != 0 && message != '') { + message = message.substring(0, message.length - 1) + } else { + message = '0' + } + this.setData({ + money: message + }) + }, + addSpot: function () { + let money = this.data.money + ""; + console.log(money) + let index = money.lastIndexOf('.'); + if (index != -1) { + return + } + this.setData({ + money: money + '.' + }) + }, + reset: function () { + this.setData({ + money: 0, + isShow: false, + }) + }, + /** + * 保存按钮 + */ + saveBookkeeping() { + let that = this + // 进行loaing + if (this.data.loading) { + return; + } + this.setData({ + loading: true + }) + let money = Number(this.data.money); + if (money == 0) { + TOAST.showToast('保存失败:金额不能为0') + this.setData({ + loading: false + }) + return + } + + // 进行金额转换 + money = money * 100; + let requestObj = {}; + requestObj.userId = wx.getStorageSync('userId'); + requestObj.consumeTypeId = this.data.consumeTypeId; + requestObj.money = money; + requestObj.address = this.data.address; + requestObj.addressDetail = this.data.addressDetail; + requestObj.imageUrl = JSON.stringify(this.data.imagePathList); + requestObj.remarks = this.data.remarks + console.log('保存的数据来着', requestObj) + let requestUrl = API.api.bookkeepings; + AJAX.postRequest(requestUrl, requestObj).then(response => { + that.setData({ + loading: false + }) + wx.switchTab({ + url: '/pages/index/index' + }) + }) + }, + hideModel() { + this.setData({ + isShowImage: false, + isShowContent: false + }) + }, + onTabItemTap(item) { + this.setData({ + money: 0, + addorDel: '+', + isShow: false, + imagePathList: [], + current: 0, + isShowImage: false, + isShowContent: false, + loading: false + }) + // 获取消费类型数据,默认值为0 + this.getConsumeType(0); + }, + // 设置高度 + imageLoad: function (e) { //获取图片真实宽度 + var imgwidth = e.detail.width; + var imgheight = e.detail.height; + //宽高比 + var ratio = imgwidth / imgheight; + console.log(imgwidth, imgheight) + //计算的高度值 + var viewHeight = 750 / ratio; + imgheight = viewHeight; + var imgheights = this.data.imgheights; + //把每一张图片的对应的高度记录到数组里 + imgheights[e.target.dataset.index] = imgheight; + this.setData({ + imgheights: imgheights + }) + }, + bindchange: function (e) { + this.setData({ + current: e.detail.current + }) + }, + showContent() { + this.setData({ isShowContent: true }) + }, + /** + * 填写备注 + */ + textareaRemark: function (e) { + console.log(`获取到数据了`, e.detail.value) + this.setData({ remarks: e.detail.value }) + }, + /** + * 获取一次性订阅信息 + */ + requestSubscribeMessage() { + let that = this; + // 用户想接收到模板消息 + if (wx.getStorageSync('sendMessage') == 0) { + that.saveBookkeeping(); + return; + } + console.log(that.data.tmplIds) + wx.requestSubscribeMessage({ + tmplIds: that.data.tmplIds, + success(success) { + // 保存用户提交信息 + that.saveWxUserSubscribe(success); + }, + fail(error) { + console.error(`调用接口失败`); + }, + complete() { + that.saveBookkeeping() + } + }) + }, + saveWxUserSubscribe(resData) { + let that = this + this.data.tmplIds.forEach(item => { + console.log(`resData[item]` + resData[item]) + let requestObj = {}; + requestObj.userId = wx.getStorageSync('userId'); + if (resData[item] == 'accept') { + requestObj.type = 1; + } else if (resData[item] == 'reject') { + requestObj.type = 0; + } else { + requestObj.type = 2; + } + requestObj.subscribeId = item; + console.log('保存的数据来着', requestObj) + let requestUrl = API.api.wxusersubscribes; + AJAX.postRequest(requestUrl, requestObj).then(response => { + console.log(`保存成功`) + }) + }) + } +}) \ No newline at end of file diff --git a/pages/consumeOld/consume.json b/pages/consumeOld/consume.json new file mode 100644 index 0000000000000000000000000000000000000000..7885d684465f8e8ee9cd7f521cf66dc21ee1e44d --- /dev/null +++ b/pages/consumeOld/consume.json @@ -0,0 +1,20 @@ +{ + "navigationBarBackgroundColor": "#1E95F1", + "navigationBarTextStyle": "white", + "navigationBarTitleText": "消费记账", + "backgroundColor": "#ffffff", + "backgroundTextStyle": "light", + "usingComponents": { + "i-tabs": "../../template/dist/tabs/index", + "i-tab": "../../template/dist/tab/index", + "i-row": "../../template/dist/row/index", + "i-col": "../../template/dist/col/index", + "i-avatar": "../../template/dist/avatar/index", + "i-button": "../../template/dist/button/index", + "i-grid": "../../template/dist/grid/index", + "i-grid-item": "../../template/dist/grid-item/index", + "i-grid-icon": "../../template/dist/grid-icon/index", + "i-grid-label": "../../template/dist/grid-label/index", + "i-spin": "../../template/dist/spin/index" + } +} \ No newline at end of file diff --git a/pages/consumeOld/consume.wxml b/pages/consumeOld/consume.wxml new file mode 100644 index 0000000000000000000000000000000000000000..11cf38e5d3ab0b1532fda9e8368f86acc3927ff2 --- /dev/null +++ b/pages/consumeOld/consume.wxml @@ -0,0 +1,86 @@ + + + 加载中 + + + + + + + + + + + + {{consumeType.name}} + + {{money}} 元 + + + + + + + + {{item.name}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 备注 + + + + + + + + + + + + + + + + + + + + 上传图片 + + + \ No newline at end of file diff --git a/pages/consumeOld/consume.wxss b/pages/consumeOld/consume.wxss new file mode 100644 index 0000000000000000000000000000000000000000..a89c4248883507c66400ca01b57619aebb3ef3a9 --- /dev/null +++ b/pages/consumeOld/consume.wxss @@ -0,0 +1,196 @@ +/* pages/consume/consume.wxss */ +page { + background-color: #FFFFFF +} +/* 表头 */ +.table { + border: 0px solid #FFFFFF; +} +.tr { + display: flex; + width: 100%; + justify-content: center; + height: 2.5rem; + align-items: center; +} +.th { + width: 50%; + justify-content: center; + background: #1E95F1; + color: #000000; + display: flex; + height: 2.5rem; + align-items: center; + /* border-right: 1rpx solid #aae6f9 */ + /* border: 1rpx solid rgba(49, 48, 48, 0.322) */ +} +.th_show { + background: #FFFFFF +} + + +.consume-type-icon { + display: flex; + flex-direction: row; + flex-wrap:wrap; + position: relative; + border-bottom:1rpx solid #ccc; +} +.consume-type-icon .consume-icon { + width: 8%; + padding: 21rpx 40rpx; +} +.consume-type-icon span { + display: flex; + align-items: center; + padding: 0rpx; + font-size: 35rpx; +} + +.consume-type { + display: flex; + flex-direction: row; + flex-wrap:wrap; + position: relative; +} +.consume-type .consume-icon { + width: 16%; + padding: 20rpx 15rpx; + margin-top: 5rpx; + +} + +.consume-icon image { + width: 100%; + height: 100%; +} +.consume-type center { + display: flex; + padding: 0rpx 15rpx; + text-align: center; +} +.consume-money { + position: absolute; + right: 28rpx; + margin-top: 28rpx; +} + + +/* 计算器 */ +.section { + margin: 10rpx 10rpx; + position: absolute; + bottom: 0; + left: 0; + width: 100%; +} +.flex-wrp_one { + display: flex; + flex-direction: row; +} +.fix-item { + background-color: #FFFFFF; + width: 100%; + height: 75%; + display: flex; + /*使子项目水平居中 */ + justify-content: center; + /*使子项目垂直居中*/ + align-items: center; +} +.section_btn { + display: flex; + flex-direction: row; + height: 80rpx; + border: 2rpx solid #eeeeee; +} +.section_btn image { + width: 60rpx; + height: 60rpx; + padding: 10rpx 5rpx; +} +.section_btn_left{ + flex:8; +} +.section_btn_right{ + flex:1; +} +.container{ + position: absolute; + bottom: 0; + left: 0; + width: 100%; +} +.container1{ + display:flex; + flex-direction: row; + height:400rpx; +} +.left{ + flex: 3; + height: 100%; +} +.right{ + flex: 1; + height: 100%; +} +.tr{ + width:100%; + height:25%; + display:flex; + align-items: center; + justify-content: center; +} +.tr button{ + height:100%; + background-color:#FFFFFF; + flex:1; + vertical-align:middle; + text-align:center; + border:0rpx; + /* border:1px solid #fff; */ +} +.remove{ + width:100%; + height:25%; + vertical-align:middle; + background-color: #FFFFFF; + text-align: center; + background-size: 30% 50%; + background-image:url(https://be.yangyoki.top/images/consume/icon/delete.png); + background-repeat: no-repeat; + background-position: center; + +} + + +.model { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + background-color: rgba(0, 0, 0, 0.5); + z-index: 0; + color: #333; +} + +.ruleModel { + width: 600rpx; + background-color: #fff; + margin: 120rpx 75rpx; + border-radius: 20rpx; + padding: 20rpx 15rpx; +} + +.close { + width: 80rpx; + height: 80rpx; + position: absolute; + top: 80rpx; + right: 20rpx; +} +.swiper-image { + width: 100%; + height: 100%; +} \ No newline at end of file diff --git a/pages/index/address/address.js b/pages/index/address/address.js index a3ad511cb61b8dff18fd47ef0d32d77be4724a37..c9b91ed4ae60ee839f200b56b93fb4b245334921 100644 --- a/pages/index/address/address.js +++ b/pages/index/address/address.js @@ -85,32 +85,11 @@ Page({ let that = this if (!address) { console.log(`地址为空,不进行操作了!!!!` + address) - retrun; + return; } qqMapWxUtil.geocoder(address).then(response => { - that.reverseGeocoder(response.result.location.lat, response.result.location.lng) - let region = []; - region.push(response.result.address_components.province) - region.push(response.result.address_components.city) - region.push(response.result.address_components.district) - that.setData({ - region: region - }) - }) - }, - /** - *调用腾讯地图显示位置信息 - * latitude:纬度 - * longitude:经度 - */ - reverseGeocoder: function (latitude, longitude) { - let that = this - let location = {} - location.latitude = latitude; - location.longitude = longitude; - qqMapWxUtil.reverseGeocoder(location).then(response => { - console.log(`从腾讯文档中获取到的地图坐标是:`, response) that.setData({ + region: response.region, markers: response.markers }) }) diff --git a/pages/index/bookkeepingdetail/bookkeepingdetail.js b/pages/index/bookkeepingdetail/bookkeepingdetail.js index ca806ef0b08172bba3448488b96e688cf08582c9..7c4c50e391113759902d0af493a7b44319c2c672 100644 --- a/pages/index/bookkeepingdetail/bookkeepingdetail.js +++ b/pages/index/bookkeepingdetail/bookkeepingdetail.js @@ -1,199 +1,74 @@ +// pages/other/income_detail.js const API = require('../../../utils/api.js'); const FormatUtil = require('../../../utils/util.js'); const TOAST = require('../../../utils/toast.js'); const AJAX = require('../../../utils/ajax.js') -// 引入腾讯地图 -const qqMapWxUtil = require('../../../utils/qqMapWxUtil.js') Page({ /** * 页面的初始数据 */ data: { - bookkeepingId: '', - bookkeepingObj: {}, - updateShow: false, - // 标记点 - markers: [], - imageHost: API.api.imageHost, - tempFilePaths: '', - loading:false + bookkeepingId: '', // 记账id + bookkeepingObj: {}, // 记账对象 + loading: false, // 加载动画 + imageHost: API.api.imageHost, //服务器图片地址 + /** + * 删除异步提示框 + */ + actions2: [ + {name: '删除',color: '#ed3f14'} + ], + showActionsheet: false // 是否删除 }, - /** * 生命周期函数--监听页面加载 */ - onLoad: function(options) { + onLoad: function (options) { // 获取到记账id,判断是从哪个页面跳转过来的 if (options.form === 'index') { console.log(`从记账页面跳转过来的!!!携带的id为:`, options.bookkeepingid) - this.setData({ - bookkeepingId: options.bookkeepingid - }) // 获取用户记账信息 this.getBookkeepingById(options.bookkeepingid); - } else if(options.form === 'address'){ - let bookkeepingObj = wx.getStorageSync('bookkeepingObj') - bookkeepingObj.address = options.address - bookkeepingObj.addressDetail = options.addressDetail - this.setData({ - bookkeepingObj: bookkeepingObj, - updateShow: true - }) - this.geocoder(options.address + options.addressDetail) - } else{ - console.log(`来自其他消息` + options.form) - } - }, - /** - * 显示保存 - */ - updateShowData: function() { - let bookkeepingObj = this.data.bookkeepingObj; - if (!this.data.updateShow) { - // 格式化金额信息Int - let money = FormatUtil.intFormatMoney(this.data.bookkeepingObj.moneyView) - console.log(money) - bookkeepingObj.moneyView = money } else { - // 格式化金额信息String - let money = FormatUtil.formatMoney(this.data.bookkeepingObj.moneyView) - bookkeepingObj.moneyView = money - console.log(money) + console.log(`来自其他消息`, options) } - - this.setData({ - updateShow: !this.data.updateShow, - bookkeepingObj:bookkeepingObj - }) }, /** - * 填写备注 - */ - textareaRemark:function(e) { - console.log(`获取到数据了`,e.detail.value) - let bookkeepingObj = this.data.bookkeepingObj; - bookkeepingObj.remarks = e.detail.value - this.setData({ - bookkeepingObj:bookkeepingObj - }) - }, - inputMoney:function(e) { - console.log(`获取到数据了`, e.detail.value) - let bookkeepingObj = this.data.bookkeepingObj; - bookkeepingObj.moneyView = e.detail.value - this.setData({ - bookkeepingObj: bookkeepingObj - }) - }, - /** - * 更新保存数据 - */ - updateData: function() { - let that = this - console.log('这里是保存数据的') - let requestUrl = API.api.bookkeepings + '/' + this.data.bookkeepingObj.id; - // 金额格式化 - let requestData = this.data.bookkeepingObj - requestData.money = Number(requestData.moneyView) * 100; - requestData.imageUrl = JSON.stringify(requestData.imageUrl) - this.setData({ - loading:true - }) - AJAX.putRequest(requestUrl,requestData).then(response => { - // that.updateShowData() - that.setData({ - loading:false - }) - wx.switchTab({ - url: '/pages/index/index' - }) - }); - - }, - /** - * 删除数据 + * 获取用户记账信息 */ - deleteData: function() { - console.log(`准备删除一条数据`) - let that = this - let requestUrl = API.api.bookkeepings + '/' + this.data.bookkeepingObj.id + getBookkeepingById: function (bookkeepingId) { + let that = this; + let requestUrl = API.api.bookkeepings + '/' + bookkeepingId; this.setData({ - loading:true + loading: true }) - AJAX.delRequest(requestUrl).then(response => { - console.log(`删除成功,返回主页面`) + AJAX.getRequest(requestUrl).then(response => { + let resultData = response.data + resultData.createTimeView = FormatUtil.formatTime(new Date(resultData.createTime),"mm月dd日 mm:yy") + resultData.moneyView = FormatUtil.formatMoney(resultData.money / 100) + resultData.imageUrl = resultData.imageUrl ? JSON.parse(resultData.imageUrl) : [] + resultData.addressDetail = resultData.addressDetail ? resultData.addressDetail : '' + if (new Date().getTime() - 720000 < resultData.createTime) { + // 小于半个小时 + resultData.existsTimeView = '刚刚' + } else if (resultData.consumeTimeDay + 86309000 >= new Date().getTime()) { + // 今天 + resultData.existsTimeView = '今天' + } else { + resultData.existsTimeView = FormatUtil.formatTime(new Date(resultData.createTime), "mm月dd日") + } that.setData({ - loading:false - }) - wx.switchTab({ - url: '/pages/index/index' + bookkeepingObj: resultData, + loading: false, + bookkeepingId: bookkeepingId }) }) }, /** - * 上传图片 - */ - uploadImag: function(e) { - let that = this - let imagePath = ""; - wx.chooseImage({ - count: 1, - sizeType: ['compressed'], - success: function(res) { - console.log(`获取到list`, res.tempFiles) - const tempFiles = res.tempFiles; - that.setData({ - tempFilePaths: tempFiles[0].path - }) - let requestUrl = API.api.uploadFile + '/bookkeeping/bookkeeping' - for (var i = 0; i < tempFiles.length;i++) { - if (tempFiles[i].size > 1048576) { - TOAST.showToastSuccess('图片大于1M') - continue; - } - that.setData({ - loading:true - }) - wx.uploadFile({ - url: requestUrl, - filePath: tempFiles[i].path, - name: 'file', - header: { - "Authorization": wx.getStorageSync('token') - }, - success: function (res) { - console.log(`这边是小程序上传文件返回回来的数据信息`) - let resData = JSON.parse(res.data) - let bookkeepingObj = that.data.bookkeepingObj; - if (resData.code == 200) { - console.log(`index:` + e.currentTarget.dataset.index) - let index = e.currentTarget.dataset.index - console.log(`imageUrl:` + bookkeepingObj.imageUrl.length) - if(bookkeepingObj.imageUrl.length >= 2) { - index > bookkeepingObj.imageUrl ? bookkeepingObj.imageUrl.push(resData.data) : bookkeepingObj.imageUrl[index] = resData.data - } else{ - bookkeepingObj.imageUrl.push(resData.data) - } - that.setData({ - bookkeepingObj: bookkeepingObj - }) - } - console.log(`bookkeepingObj:`, that.data.bookkeepingObj) - },complete() { - that.setData({ - loading:false - }) - } - }) - } - } - }) - }, - /** - * 预览图片 - */ - previewImage:function(e) { + * 预览图片 + */ + previewImage: function (e) { let imageUrl = []; this.data.bookkeepingObj.imageUrl.forEach(item => { imageUrl.push(this.data.imageHost + item) @@ -207,139 +82,46 @@ Page({ }) }, /** - * 跳转到gps定位 + * 取消删除 */ - gotoAddress: function(e) { - // 缓存对于的数据信息 - wx.setStorageSync('bookkeepingObj', this.data.bookkeepingObj) - wx.navigateTo({ - url: '../address/address?form=bookkeepingDetail&address=' + this.data.bookkeepingObj.address + '&addressDetail=' + this.data.bookkeepingObj.addressDetail, - }) + handleCancel2() { + this.setData({ + showActionsheet: false + }); }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function() { - + handleOpen2() { + this.setData({ + showActionsheet: true + }); }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function() {}, - /** - * 获取用户记账信息 - */ - getBookkeepingById: function(bookkeepingId) { - let that = this; - let requestUrl = API.api.bookkeepings + '/' + bookkeepingId; + * 删除数据 + */ + deleteData: function () { + console.log(`准备删除一条数据`) + let that = this + let requestUrl = API.api.bookkeepings + '/' + this.data.bookkeepingObj.id this.setData({ - loading:true + loading: true }) - AJAX.getRequest(requestUrl).then(response => { - let resultData = response.data - resultData.createTimeView = FormatUtil.formatTime(new Date(resultData.createTime)) - resultData.moneyView = FormatUtil.formatMoney(resultData.money / 100) - resultData.imageUrl = resultData.imageUrl ? JSON.parse(resultData.imageUrl) : [] + AJAX.delRequest(requestUrl).then(response => { + TOAST.showToast("删除成功") that.setData({ - bookkeepingObj: resultData, - loading:false + loading: false, + showActionsheet: false }) - // TODO 这里后期加判断,如果位置为空则重新定位还是什么的 通过位置定位信息 - that.geocoder(resultData.address + resultData.addressDetail) - }) - }, - /** - *调用腾讯地图显示位置信息 - * latitude:纬度 - * longitude:经度 - */ - reverseGeocoder: function(latitude, longitude) { - let that = this - let location = {} - location.latitude = latitude; - location.longitude = longitude; - qqMapWxUtil.reverseGeocoder(location).then(response => { - console.log(`从腾讯文档中获取到的地图坐标是:`, response) - that.setData({ - markers: response.markers + wx.switchTab({ + url: '/pages/index/index' }) }) }, /** - * 调用腾讯地图进行定位 - * address:地址信息 + * 修改 */ - geocoder: function(address) { - let that = this - if (!address) { - console.log(`地址为空,不进行操作了!!!!` + address) - return; - } - qqMapWxUtil.geocoder(address).then(response => { - that.reverseGeocoder(response.result.location.lat, response.result.location.lng) + editConsume:function() { + console.log("我准备跳转到记账页") + wx.reLaunch({ + url: '/pages/consume/consume?form=edit&bookkeepingid=' + this.data.bookkeepingId }) - }, - /** - * 下拉触发 - */ - bindRegionChange: function(e) { - let that = this - console.log('picker发送选择改变,携带值为', e.detail.value) - this.setData({ - region: e.detail.value - }) - let address = e.detail.value[0] + e.detail.value[1] + e.detail.value[2] - console.log(`获取到的地址是:` + address) - - that.geocoder(address) - }, - /** - * 图片预览 - */ - queryImg: function(e) { - let urls = []; - urls.push(e.target.dataset.list) - wx.previewImage({ - urls: urls, - success: function(res) { - console.log("成功了") - } - }) - }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function() { - } }) \ No newline at end of file diff --git a/pages/index/bookkeepingdetail/bookkeepingdetail.json b/pages/index/bookkeepingdetail/bookkeepingdetail.json index f95124734fad88627a5ee88785c817b47cf34aad..fc56bdb29a0d59091bf42c972360741d0d72ddf7 100644 --- a/pages/index/bookkeepingdetail/bookkeepingdetail.json +++ b/pages/index/bookkeepingdetail/bookkeepingdetail.json @@ -1,5 +1,11 @@ { + "navigationBarTitleText": "收入详情", + "enablePullDownRefresh": true, + "backgroundTextStyle": "dark", + "navigationBarBackgroundColor": "#15ace3", "usingComponents": { - "i-spin": "../../template/dist/spin/index" + "i-spin": "../../template/dist/spin/index", + "i-button": "../../template/dist/button/index", + "i-action-sheet": "../../template/dist/action-sheet/index" } } \ No newline at end of file diff --git a/pages/index/bookkeepingdetail/bookkeepingdetail.wxml b/pages/index/bookkeepingdetail/bookkeepingdetail.wxml index 558ad22e9ffa835e49475c99f536de637a6a1857..5cfc83ca39a52bdf8799cef2ae01bdcc70efe7a2 100644 --- a/pages/index/bookkeepingdetail/bookkeepingdetail.wxml +++ b/pages/index/bookkeepingdetail/bookkeepingdetail.wxml @@ -1,78 +1,80 @@ - - - 加载中 + 加载中 - - - 消费时间 - {{bookkeepingObj.createTimeView}} - - - 消费金额 - {{bookkeepingObj.moneyView}} 元 - - - 消费地点 {{bookkeepingObj.address}}{{bookkeepingObj.addressDetail}} - - + + + + + + + {{bookkeepingObj.consumeType.name}} + + ¥{{bookkeepingObj.moneyView}} - - - 消费记录 - - - + + + + 编辑 - - + + {{bookkeepingObj.existsTimeView}} - - 备注 - {{bookkeepingObj.remarks}} - - - - - - 消费时间 - {{bookkeepingObj.createTimeView}} - - - 消费金额 - - + + + 收款人 - - - 消费地点 {{bookkeepingObj.address}}{{bookkeepingObj.addressDetail}} - - - + + + + {{bookkeepingObj.wxUser.nickName}} + + + ¥{{bookkeepingObj.moneyView}} + - - 消费记录 - - - + + 描述 + + {{bookkeepingObj.remarks}} + + + + - - + + + + + + {{bookkeepingObj.address}} + {{bookkeepingObj.addressDetail}} + - - 备注 - + + + + + {{bookkeepingObj.wxUser.nickName}} + + + {{bookkeepingObj.createTimeView}} + + + + 删除 - - - - - \ No newline at end of file + + + + + 确定吗? + 删除后无法恢复哦 + + \ No newline at end of file diff --git a/pages/index/bookkeepingdetail/bookkeepingdetail.wxss b/pages/index/bookkeepingdetail/bookkeepingdetail.wxss index 92c7b47a181c454d4ebef36ccbf7e6c0e34ffbf4..0388e6a7016f5cf80dd10ed292a39258013138c6 100644 --- a/pages/index/bookkeepingdetail/bookkeepingdetail.wxss +++ b/pages/index/bookkeepingdetail/bookkeepingdetail.wxss @@ -1,123 +1,170 @@ -/* pages/index/bookkeepingdetail/bookkeepingdetail.wxss */ -/* 地图样式 */ -.map-style { - width: 100%; - height: 240rpx; - margin-bottom: 20rpx; - padding: 10rpx 0rpx; - margin-right: 1.5rem; -} - -.add-growers { - width: 100%; - min-height: 100vh; -} - -.add-growers-form-group { - width: 100%; - height: 3rem; - background: rgba(255, 255, 255, 1); +.main{ + background-color: #fff; +} +.income_info{ + display: flex; + border-bottom: 10rpx solid #f5f4f9; + padding: 40rpx 40rpx 80rpx 40rpx; +} +.icome_cate{ + flex: 5; +} +icome_date{ + flex: 3; +} +.icome_cate_wrap{ display: flex; align-items: center; - border-bottom: 0.05rem solid rgba(235, 235, 235, 1); - padding: 0 0.75rem; } - -.add-growers-form-group .add-growers-form-label { - width: 20%; +.icome_cate_wrap image{ + width:70rpx; + margin-right: 15rpx; } - -.add-growers-form-label_more { - width: 30%; +.icome_edit image{ + width:40rpx; + margin-right: 15rpx; } - -.add-growers-form-input { - width: 70%; +.icome_edit{ display: flex; align-items: center; - margin-left: 1.5rem; -} - -.add-growers-form-input input { - width: 13rem; - height: 1.55rem; - border-radius: 0.15rem; - font-size: 0.9rem; - font-family: PingFangSC-Medium; - font-weight: 500; - background-color: #fff; } - -.add-id-form-group { - height: 10rem; +.icome_cate_text{ + color: #7e7e7e; + font-size: 35rpx; +} +.icome_edit{ + font-size: 35rpx; + color:#19374f; +} +.icome_cate_num{ + font-size: 60rpx; + color:#00335b; + padding-top: 30rpx; + font-weight: bold; + font-family: 'PingFang SC'; +} +.icome_date_info{ + text-align: right; + color:#767676; + font-size: 30rpx; + padding-top: 74rpx; +} +.income_people{ + border-bottom: 18rpx solid #f5f4f9; +} +.icome_people_info{ + display: flex; + justify-content: space-between; + padding:15rpx 40rpx; + border-bottom: 2rpx solid #f3f3f3; +} +.icome_people_title{ + font-size: 30rpx; + color: #2f5268; + padding: 35rpx 40rpx; + border-bottom: 2rpx solid #f3f3f3; +} +.icome_people_wrap{ + display: flex; + + align-items: center; +} +.icome_people_num{ + color:#777777; + font-size: 30rpx; + align-items: center; + display: flex; +} +.icome_people_wrap image{ + width: 80rpx; + margin-right: 20rpx; + border-radius: 50%; + height: 40rpx; +} +.icome_people_name{ + font-size: 30rpx; + color:#2f5268; +} +.icome_detail_info{ + display: flex; + padding:50rpx 40rpx 60rpx 40rpx; + border-bottom: 20rpx solid #f3f3f3; +} +.detail_info_title{ + flex: 1; + color:#0e304b; + font-size: 30rpx; +} +.detail_info_content{ + flex: 8; +} +.detail_info_text{ + color:#8c8c8c; + font-size: 30rpx; +} +.detail_info_img{ display: flex; - flex-flow: column wrap; - padding: 1.25rem 0.75rem; + align-items: center; + padding:20rpx 0 40rpx 0; +} +.detail_info_itemImg{ + /* flex: 1; */ + height: 150rpx; + width: 150rpx; + padding: 0rpx 15rpx 0rpx 0rpx; +} +.detail_info_img image{ + width: 100%; + height: 100%; } - -.upload-wrap { +.detail_address{ + display: flex; align-items: center; +} +.address_icon image{ + width:50rpx; + margin-right: 20rpx; +} +.address_detail{ + font-size: 25rpx; + color:#0e304b; +} +.address_quyu{ + font-size: 32rpx; + color:#737373; +} +.more_info{ + display: flex; justify-content: space-between; + padding-bottom: 90rpx; +} +.info_text{ display: flex; - flex-flow: row wrap; - width: 100%; - height: 7rem; -} -.upload-address { - width: 100%; - height: 2.5rem; -} -.cert-front-upload { - width: 41%; - height: 100%; - margin-top: 0.5rem; - margin-right: 1.5rem; -} - -.cert-front-upload image { - width: 100%; - height: 100%; -} - -.add-growers-form-group_more { - width: 100%; - height: 8rem; - background: rgba(255, 255, 255, 1); -} - -.add-growers-form-group_more .add-growers-form-label { - padding: 0.5rem 0.5rem; -} - -textarea { - display: inline-block; - width: 100%; - padding: 0.75rem; - font-size: 0.7rem; - font-family: PingFangSC-Medium; - font-weight: 500; - border-radius: 0.15rem; -} -/* 底层按钮 */ -.detail-button { - z-index: 9999; + align-items: center; +} +.info_text image{ + width: 35rpx; + margin-right: 20rpx; +} +.user_name,.create_time{ + font-size: 25rpx; + color: #737373; +} +.more_info_wrap{ display: flex; + align-items: center; } -.detail-button .btn-left { - width: 45%; - padding: 10rpx 0rpx; - line-height: 60rpx; - position: fixed; - left: 4%; - bottom: 0; - margin-bottom: 20rpx; -} -.detail-button .btn-right { - width: 45%; - padding: 10rpx 0rpx; - line-height: 60rpx; - position: fixed; - right: 4%; - bottom: 0; - margin-bottom: 20rpx; +.more_info_wrap image{ + width: 23rpx; + margin-left: 50rpx; +} +button{ + width:90%!important; + border:1rpx solid #4bb6c8; + color: #4bb6c8; + font-weight: lighter!important; + background-color: #fff; } +.icome_active{ + padding:50rpx 40rpx 70rpx 40rpx; +} \ No newline at end of file diff --git a/pages/index/bookkeepingdetailOld/bookkeepingdetail.js b/pages/index/bookkeepingdetailOld/bookkeepingdetail.js new file mode 100644 index 0000000000000000000000000000000000000000..53f831cca4c437999ba7176939acf758a9fe77d2 --- /dev/null +++ b/pages/index/bookkeepingdetailOld/bookkeepingdetail.js @@ -0,0 +1,334 @@ +const API = require('../../../utils/api.js'); +const FormatUtil = require('../../../utils/util.js'); +const TOAST = require('../../../utils/toast.js'); +const AJAX = require('../../../utils/ajax.js') +// 引入腾讯地图 +const qqMapWxUtil = require('../../../utils/qqMapWxUtil.js') +Page({ + + /** + * 页面的初始数据 + */ + data: { + bookkeepingId: '', + bookkeepingObj: {}, + updateShow: false, + // 标记点 + markers: [], + imageHost: API.api.imageHost, + tempFilePaths: '', + loading: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + // 获取到记账id,判断是从哪个页面跳转过来的 + if (options.form === 'index') { + console.log(`从记账页面跳转过来的!!!携带的id为:`, options.bookkeepingid) + this.setData({ + bookkeepingId: options.bookkeepingid + }) + // 获取用户记账信息 + this.getBookkeepingById(options.bookkeepingid); + } else if (options.form === 'address') { + let bookkeepingObj = wx.getStorageSync('bookkeepingObj') + bookkeepingObj.address = options.address + bookkeepingObj.addressDetail = options.addressDetail + this.setData({ + bookkeepingObj: bookkeepingObj, + updateShow: true + }) + this.geocoder(options.address + options.addressDetail) + } else { + console.log(`来自其他消息` + options.form) + } + }, + /** + * 显示保存 + */ + updateShowData: function () { + let bookkeepingObj = this.data.bookkeepingObj; + if (!this.data.updateShow) { + // 格式化金额信息Int + let money = FormatUtil.intFormatMoney(this.data.bookkeepingObj.moneyView) + console.log(money) + bookkeepingObj.moneyView = money + } else { + // 格式化金额信息String + let money = FormatUtil.formatMoney(this.data.bookkeepingObj.moneyView) + bookkeepingObj.moneyView = money + console.log(money) + } + + this.setData({ + updateShow: !this.data.updateShow, + bookkeepingObj: bookkeepingObj + }) + }, + /** + * 填写备注 + */ + textareaRemark: function (e) { + console.log(`获取到数据了`, e.detail.value) + let bookkeepingObj = this.data.bookkeepingObj; + bookkeepingObj.remarks = e.detail.value + this.setData({ + bookkeepingObj: bookkeepingObj + }) + }, + inputMoney: function (e) { + console.log(`获取到数据了`, e.detail.value) + let bookkeepingObj = this.data.bookkeepingObj; + bookkeepingObj.moneyView = e.detail.value + this.setData({ + bookkeepingObj: bookkeepingObj + }) + }, + /** + * 更新保存数据 + */ + updateData: function () { + let that = this + console.log('这里是保存数据的') + let requestUrl = API.api.bookkeepings + '/' + this.data.bookkeepingObj.id; + // 金额格式化 + let requestData = this.data.bookkeepingObj + requestData.money = Number(requestData.moneyView) * 100; + requestData.imageUrl = JSON.stringify(requestData.imageUrl) + this.setData({ + loading: true + }) + AJAX.putRequest(requestUrl, requestData).then(response => { + // that.updateShowData() + that.setData({ + loading: false + }) + wx.switchTab({ + url: '/pages/index/index' + }) + }); + + }, + /** + * 删除数据 + */ + deleteData: function () { + console.log(`准备删除一条数据`) + let that = this + let requestUrl = API.api.bookkeepings + '/' + this.data.bookkeepingObj.id + this.setData({ + loading: true + }) + AJAX.delRequest(requestUrl).then(response => { + console.log(`删除成功,返回主页面`) + that.setData({ + loading: false + }) + wx.switchTab({ + url: '/pages/index/index' + }) + }) + }, + /** + * 上传图片 + */ + uploadImag: function (e) { + let that = this + let imagePath = ""; + wx.chooseImage({ + count: 1, + sizeType: ['compressed'], + success: function (res) { + console.log(`获取到list`, res.tempFiles) + const tempFiles = res.tempFiles; + that.setData({ + tempFilePaths: tempFiles[0].path + }) + let requestUrl = API.api.uploadFile + '/bookkeeping/wx_' + wx.getStorageSync('userId') + for (var i = 0; i < tempFiles.length; i++) { + if (tempFiles[i].size > 1048576) { + TOAST.showToast('上传图片失败:图片大于1M') + continue; + } + that.setData({ + loading: true + }) + wx.uploadFile({ + url: requestUrl, + filePath: tempFiles[i].path, + name: 'file', + header: { + "Authorization": wx.getStorageSync('token') + }, + success: function (res) { + console.log(`这边是小程序上传文件返回回来的数据信息`,res) + let resData = JSON.parse(res.data) + let bookkeepingObj = that.data.bookkeepingObj; + console.log(`index:` + e.currentTarget.dataset.index) + let index = e.currentTarget.dataset.index + console.log(`imageUrl:` + bookkeepingObj.imageUrl.length) + if (bookkeepingObj.imageUrl.length >= 2) { + index > bookkeepingObj.imageUrl ? bookkeepingObj.imageUrl.push(resData.file) : bookkeepingObj.imageUrl[index] = resData.file + } else { + bookkeepingObj.imageUrl.push(resData.file) + } + that.setData({ + bookkeepingObj: bookkeepingObj + }) + console.log(`bookkeepingObj:`, that.data.bookkeepingObj) + }, + complete() { + that.setData({ + loading: false + }) + } + }) + } + } + }) + }, + /** + * 预览图片 + */ + previewImage: function (e) { + let imageUrl = []; + this.data.bookkeepingObj.imageUrl.forEach(item => { + imageUrl.push(this.data.imageHost + item) + }) + console.log(e.currentTarget.dataset.imageUrl) + console.log(e.currentTarget.dataset.imageurl) + console.log(`这个是当前的url:` + this.data.imageHost + e.currentTarget.dataset.imageurl) + wx.previewImage({ + current: this.data.imageHost + e.currentTarget.dataset.imageurl, + urls: imageUrl, + }) + }, + /** + * 跳转到gps定位 + */ + gotoAddress: function (e) { + // 缓存对于的数据信息 + this.setData({ + loading:true + }) + wx.setStorageSync('bookkeepingObj', this.data.bookkeepingObj) + wx.navigateTo({ + url: '../address/address?form=bookkeepingDetail&address=' + this.data.bookkeepingObj.address + '&addressDetail=' + this.data.bookkeepingObj.addressDetail, + }) + }, + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + this.setData({ + loading:false + }) + }, + + /** + * 获取用户记账信息 + */ + getBookkeepingById: function (bookkeepingId) { + let that = this; + let requestUrl = API.api.bookkeepings + '/' + bookkeepingId; + this.setData({ + loading: true + }) + AJAX.getRequest(requestUrl).then(response => { + let resultData = response.data + resultData.createTimeView = FormatUtil.formatTime(new Date(resultData.createTime)) + resultData.moneyView = FormatUtil.formatMoney(resultData.money / 100) + resultData.imageUrl = resultData.imageUrl ? JSON.parse(resultData.imageUrl) : [] + that.setData({ + bookkeepingObj: resultData, + loading: false + }) + that.geocoder(resultData.address + resultData.addressDetail) + }) + }, + /** + * 调用腾讯地图进行定位 + * address:地址信息 + */ + geocoder: function (address) { + if (!address) { + console.log(`地址为空,不进行操作了!!!!` + address) + return; + } + qqMapWxUtil.geocoder(address).then(response => { + this.setData({ + markers: response.markers + }) + }) + }, + /** + * 下拉触发 + */ + bindRegionChange: function (e) { + let that = this + console.log('picker发送选择改变,携带值为', e.detail.value) + this.setData({ + region: e.detail.value + }) + let address = e.detail.value[0] + e.detail.value[1] + e.detail.value[2] + console.log(`获取到的地址是:` + address) + + that.geocoder(address) + }, + /** + * 图片预览 + */ + queryImg: function (e) { + let urls = []; + urls.push(e.target.dataset.list) + wx.previewImage({ + urls: urls, + success: function (res) { + console.log("成功了") + } + }) + }, + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/index/bookkeepingdetailOld/bookkeepingdetail.json b/pages/index/bookkeepingdetailOld/bookkeepingdetail.json new file mode 100644 index 0000000000000000000000000000000000000000..f95124734fad88627a5ee88785c817b47cf34aad --- /dev/null +++ b/pages/index/bookkeepingdetailOld/bookkeepingdetail.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "i-spin": "../../template/dist/spin/index" + } +} \ No newline at end of file diff --git a/pages/index/bookkeepingdetailOld/bookkeepingdetail.wxml b/pages/index/bookkeepingdetailOld/bookkeepingdetail.wxml new file mode 100644 index 0000000000000000000000000000000000000000..01b2303fa69c093a3eba49ec7679347d02df538f --- /dev/null +++ b/pages/index/bookkeepingdetailOld/bookkeepingdetail.wxml @@ -0,0 +1,81 @@ + + + + + 加载中 + + + + 消费时间 + {{bookkeepingObj.createTimeView}} + + + 消费金额 + {{bookkeepingObj.moneyView}} 元 + + + 消费地点 + {{bookkeepingObj.address}}{{bookkeepingObj.addressDetail}} + + + + + + + 消费记录 + + + + + + + + + + + 备注 + {{bookkeepingObj.remarks}} + + + + + + 消费时间 + {{bookkeepingObj.createTimeView}} + + + 消费金额 + + + + + + 消费地点 + {{bookkeepingObj.address}}{{bookkeepingObj.addressDetail}} + + + + + + + 消费记录 + + + + + + + + + + + 备注 + + + + + + + + \ No newline at end of file diff --git a/pages/index/bookkeepingdetailOld/bookkeepingdetail.wxss b/pages/index/bookkeepingdetailOld/bookkeepingdetail.wxss new file mode 100644 index 0000000000000000000000000000000000000000..a05fd4ae32fa235ad16cca97dfd9ba9ac9df6bf8 --- /dev/null +++ b/pages/index/bookkeepingdetailOld/bookkeepingdetail.wxss @@ -0,0 +1,123 @@ +/* pages/index/bookkeepingdetail/bookkeepingdetail.wxss */ +/* 地图样式 */ +.map-style { + width: 100%; + height: 240rpx; + margin-bottom: 20rpx; + padding: 10rpx 10rpx; + margin-right: 3rpx; +} + +.add-growers { + width: 100%; + min-height: 100vh; +} + +.add-growers-form-group { + width: 100%; + height: 3rem; + background: rgba(255, 255, 255, 1); + display: flex; + align-items: center; + border-bottom: 0.05rem solid rgba(235, 235, 235, 1); + padding: 0 0.75rem; +} + +.add-growers-form-group .add-growers-form-label { + width: 20%; +} + +.add-growers-form-label_more { + width: 30%; +} + +.add-growers-form-input { + width: 70%; + display: flex; + align-items: center; + margin-left: 1.5rem; +} + +.add-growers-form-input input { + width: 13rem; + height: 1.55rem; + border-radius: 0.15rem; + font-size: 0.9rem; + font-family: PingFangSC-Medium; + font-weight: 500; + background-color: #fff; +} + +.add-id-form-group { + height: 10rem; + display: flex; + flex-flow: column wrap; + padding: 1.25rem 0.75rem; +} + +.upload-wrap { + align-items: center; + justify-content: space-between; + display: flex; + flex-flow: row wrap; + width: 100%; + height: 7rem; +} +.upload-address { + width: 100%; + height: 2.5rem; +} +.cert-front-upload { + width: 41%; + height: 100%; + margin-top: 0.5rem; + margin-right: 1.5rem; +} + +.cert-front-upload image { + width: 100%; + height: 100%; +} + +.add-growers-form-group_more { + width: 100%; + height: 8rem; + background: rgba(255, 255, 255, 1); +} + +.add-growers-form-group_more .add-growers-form-label { + padding: 0.5rem 0.5rem; +} + +textarea { + display: inline-block; + width: 100%; + padding: 0.75rem; + font-size: 0.7rem; + font-family: PingFangSC-Medium; + font-weight: 500; + border-radius: 0.15rem; +} +/* 底层按钮 */ +.detail-button { + z-index: 9999; + display: flex; +} +.detail-button .btn-left { + width: 45%; + padding: 10rpx 0rpx; + line-height: 60rpx; + position: fixed; + left: 4%; + bottom: 0; + margin-bottom: 20rpx; +} +.detail-button .btn-right { + width: 45%; + padding: 10rpx 0rpx; + line-height: 60rpx; + position: fixed; + right: 4%; + bottom: 0; + margin-bottom: 20rpx; +} diff --git a/pages/index/index.js b/pages/index/index.js index 43badb61af81b83cefd8a691ef256c2dcff9e5f6..5d099770f1839e4648e68dc75d72bb79b225a10f 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -15,26 +15,14 @@ Page({ bookkeepingList: [], assetsDetail: {}, totalElements: 0, - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function() { - + showScrollTop: false, // 判断是否隐藏tab }, /** * 生命周期函数--监听页面显示 */ onShow: function() { + console.log("主页面的onShow触发了...") // 初始化数据信息 this.setData({ bookkeepingList: [], @@ -45,23 +33,58 @@ Page({ this.getBookkeeping(); // 获取用户本月消费情况 this.getAssetsDetail(); + // 显示tab标签 + TOTAS.showTabBar(); }, /** - * 跳转到记账详情页 + * 页面上拉触底事件的处理函数 */ - gotoDetail: function(e) { + onReachBottom: function() { + // 触发到底部。进行加载数据信息 + this.getBookkeeping(); + }, + + //监听屏幕滚动 判断上下滚动 + onPageScroll: function (ev) { + var _this = this; + //当滚动的top值最大或者最小时,为什么要做这一步是由于在手机实测小程序的时候会发生滚动条回弹,所以为了解决回弹,设置默认最大最小值 + if (ev.scrollTop <= 0) { + ev.scrollTop = 0; + } else if (ev.scrollTop > wx.getSystemInfoSync().windowHeight) { + ev.scrollTop = wx.getSystemInfoSync().windowHeight; + } + //判断浏览器滚动条上下滚动 + if (ev.scrollTop > 150 && !(_this.data.showScrollTop)) { + TOTAS.hideTabBar(); + _this.setData({ showScrollTop:true}) + } else if(ev.scrollTop <= 150 && _this.data.showScrollTop){ + TOTAS.showTabBar(); + _this.setData({ showScrollTop: false }) + } + }, + + + /** + * 用户点击右上角分享 待定 + */ + onShareAppMessage: function() { + }, + /** + * 跳转到记账详情页 + */ + gotoDetail: function (e) { let bookkeepingId = e.currentTarget.dataset.id console.log(`当前获取到的id是:` + bookkeepingId) wx.navigateTo({ url: '/pages/index/bookkeepingdetail/bookkeepingdetail?form=index&bookkeepingid=' + bookkeepingId }) - }, - getAssetsDetail: function() { + + getAssetsDetail: function () { let that = this let userId = wx.getStorageSync('userId'); let requestUrl = API.api.assetsDetails + '/' + userId - AJAX.getRequest(requestUrl).then(function(response) { + AJAX.getRequest(requestUrl).then(function (response) { let resData = response.data; // 金额转换 resData.monthTotalExpenditure = FormatUtil.formatMoney(resData.monthTotalExpenditure / 100); @@ -70,22 +93,24 @@ Page({ that.setData({ assetsDetail: resData }) + }).catch(err => { + // no doing }) }, - getBookkeeping: function() { - console.log(`pageNumber:` + this.data.pageNumber) + + getBookkeeping: function () { if ((this.data.pageNumber * this.data.pageSize) > this.data.totalElements && this.data.pageNumber != 0) { - TOTAS.showToastSuccess("已经加载到底了....") + TOTAS.showToast("已经加载到底了....") return } let that = this; - let userId = wx.getStorageSync('userId'); - let pageNumber = this.data.pageNumber; - let pageSize = this.data.pageSize; - let requestUrl = API.api.bookkeepings + '?userId=' + userId + '&pageNumber=' + pageNumber + '&pageSize=' + pageSize; - AJAX.getRequest(requestUrl).then(response => { + let params = {}; + params.userId = wx.getStorageSync('userId'); + params.pageNumber = this.data.pageNumber; + params.pageSize = this.data.pageSize; + AJAX.getRequest(API.api.bookkeepings, params).then(response => { if (response.data.content.length == 0 && this.data.pageNumber != 0) { - TOTAS.showToastSuccess("已经加载到底了....") + TOTAS.showToast("已经加载到底了....") return } // 格式化数据 @@ -105,45 +130,11 @@ Page({ } that.setData({ bookkeepingList: bookkeepingList, - pageNumber: pageNumber + 1, + pageNumber: params.pageNumber + 1, totalElements: response.data.totalElements }) + }).catch(err => { + // no doing }) }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function() { - // 触发到底部。进行加载数据信息 - this.getBookkeeping(); - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function() { - - } }) \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 09de6b924fff30b833cff910c01cbeb3fa2e326f..6ee5883a15a11c58e23400254f9a55b047d44551 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -2,17 +2,17 @@ - {{assetsDetail.monthTotalMoney}} - 本月收支结余 + {{assetsDetail.monthTotalMoney}} + 本月收支结余 - {{assetsDetail.monthTotalIncome}} - 本月收入 + {{assetsDetail.monthTotalIncome}} + 本月收入 - {{assetsDetail.monthTotalExpenditure}} - 本月支出 + {{assetsDetail.monthTotalExpenditure}} + 本月支出 @@ -25,10 +25,13 @@ {{item.consumeType.name}} - {{item.money}} 元 + {{item.money}} + {{item.money}} - + + diff --git a/pages/index/index.wxss b/pages/index/index.wxss index f73117d5679181135201ef572308a32fd61ec77d..bbbb06dfa76ef439e4609e54caad565dea81f98e 100644 --- a/pages/index/index.wxss +++ b/pages/index/index.wxss @@ -12,9 +12,6 @@ page { height: 300rpx; background: #1E95F1; } -.head view{ - color: #FFFFFFFF; -} .profit { height: 150rpx; display: flex; @@ -38,18 +35,21 @@ page { flex-direction: column; font-size: 28rpx; } +.income_white { + color: white; +} .total { position: relative; margin: 15rpx 0rpx } .total .expenditure_time { - font-size: 30rpx; + font-size: 24rpx; padding: 20rpx 20rpx; color: #979797 } .total .expenditure_money { float: right; - font-size: 30rpx; + font-size: 24rpx; padding: 8rpx 20rpx; color: #979797 } @@ -70,10 +70,30 @@ page { margin-left: 10rpx; color: #020202; } -.expenditure_type .money { +.te_money { + position: absolute; + right: 30rpx; + font-size: 32rpx; + padding-top: 30rpx; + color: red; +} +.ti_money { position: absolute; right: 30rpx; font-size: 32rpx; padding-top: 30rpx; - + color: green; +} +.logo { + min-height: 500rpx; + display: flex; + /*使子项目水平居中 */ + justify-content: center; + /*使子项目垂直居中*/ + align-items: center; + color: #979797; + font-size: 40rpx; + font-weight: 300; + font-style: oblique; + font-family: SimSun; } \ No newline at end of file diff --git a/pages/me/feedback/feedback.js b/pages/me/feedback/feedback.js new file mode 100644 index 0000000000000000000000000000000000000000..3492a607cf7f9a2d1c5b7e1b96d95a169c63e200 --- /dev/null +++ b/pages/me/feedback/feedback.js @@ -0,0 +1,92 @@ +// pages/me/feedback/feedback.js +const API = require('../../../utils/api.js'); +const AJAX = require('../../../utils/ajax.js'); +const Totst = require('../../../utils/toast.js'); +Page({ + + /** + * 页面的初始数据 + */ + data: { + textareaValue: '', + value:'' + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + textareablur:function(e) { + this.setData({ + textareaValue:e.detail.value + }) + }, + submit: function (e) { + let that = this; + if (this.data.textareaValue == '') { + Totst.showToast("抱歉,您好像并没有说什么话"); + } + let params = {}; + params.content = this.data.textareaValue; + params.userId = wx.getStorageSync("userId") + let url = API.api.feedbacks; + + AJAX.postRequest(url,params).then(response => { + Totst.showToast("反馈成功,感谢您的反馈"); + that.setData({ + value:'' + }) + }) + } +}) \ No newline at end of file diff --git a/pages/me/feedback/feedback.json b/pages/me/feedback/feedback.json new file mode 100644 index 0000000000000000000000000000000000000000..8835af0699ccec004cbe685ef938cd2d63ea7037 --- /dev/null +++ b/pages/me/feedback/feedback.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/me/feedback/feedback.wxml b/pages/me/feedback/feedback.wxml new file mode 100644 index 0000000000000000000000000000000000000000..c93f1dae266c14ebc45f7307ba9e6a0c0137fb8e --- /dev/null +++ b/pages/me/feedback/feedback.wxml @@ -0,0 +1,8 @@ + +