home.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. <template>
  2. <view class="container">
  3. <!-- 头部选择房间区域 -->
  4. <view class="select-item" @click="navigateToSelect">
  5. <view class="picker-item-logol">
  6. <image class="picker-item-logo-left" src="../../static/room.png"></image>
  7. </view>
  8. <view class="picker-item-label">已选房间</view>
  9. <view class="picker-item-content" v-if="roomSelect=='请选择宿舍'">{{roomSelect}}</view>
  10. <view class="picker-item-content2" v-else>{{roomSelect}}</view>
  11. <view class="picker-item-logor">
  12. <image class="picker-item-logo-right" src="../../static/right.png"></image>
  13. </view>
  14. </view>
  15. <!-- 账单显示区域 -->
  16. <view class="bill">
  17. <!-- 筛选框区域 -->
  18. <view class="choose">
  19. <view class="time">
  20. <uni-data-select :clear="false" placeholder="请选择时间" :localdata="time_range" @change="changeTime">
  21. </uni-data-select>
  22. </view>
  23. <view class="type">
  24. <uni-data-select :clear="false" placeholder="请选择支付状态" :localdata="type_range" @change="changeType">
  25. </uni-data-select>
  26. </view>
  27. </view>
  28. <!-- 没有账单时展示的内容 -->
  29. <view class="null" v-if="!list.length">
  30. <img src="../../static/null.png">
  31. <span>暂无账单,请选择条件查询</span>
  32. </view>
  33. <!-- 有账单时展示的内容 -->
  34. <view class="has" v-else>
  35. <!-- 账单列表区域 -->
  36. <view class="has_bill">
  37. <view class="item" v-for="item in list" :key="item.id">
  38. <view class="item_header">
  39. {{item.payMonth+item.paymentItem}}
  40. </view>
  41. <view class="item_box">
  42. <view class="item_box_1">
  43. 上月表数:{{item.lastElectry}}
  44. </view>
  45. <view class="item_box_2">
  46. 本月表数:{{item.nowElectry}}
  47. </view>
  48. </view>
  49. <view class="item_box">
  50. <view class="item_box_1">
  51. 用量:{{item.nowTonnage}}吨
  52. </view>
  53. <view class="item_box_2">
  54. 补助吨数:{{item.subsidiesTonnage}}吨
  55. </view>
  56. </view>
  57. <view class="item_box" v-if="item.payItemType=='2'">
  58. <view class="item_box_1">
  59. 支付人:{{item.cardNumber}}
  60. </view>
  61. </view>
  62. <view class="item_notes">
  63. 备注:{{item.orderNotice}}
  64. </view>
  65. <view class="item_box">
  66. <view class="item_box_1 font">
  67. {{item.payCreateTime}}
  68. </view>
  69. <view class="item_box_2">
  70. 实付款:{{item.realPayAmount}}
  71. </view>
  72. </view>
  73. <view class="item_button">
  74. <button class="feedback right" type="primary" plain size="mini"
  75. @click="handleFeedback(item)">
  76. 订单反馈
  77. </button>
  78. <button class="feedback" type="warn" size="mini" disabled v-if="item.payItemType=='2'">
  79. 已支付
  80. </button>
  81. <button class="feedback" type="primary" size="mini" @click="navigateToPay(item)" v-else>
  82. 去支付
  83. </button>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 电话区域按钮 -->
  90. <view class="phone">
  91. <view class="phone_box">
  92. 咨询电话:
  93. <span @click="handlePhone">82293462</span>
  94. </view>
  95. </view>
  96. <!-- 悬浮按钮区域 -->
  97. <view class="suspend_button" @click="goBill" @touchstart="down" @touchmove.prevent="move" @touchend="end">
  98. 订单查询
  99. </view>
  100. <!-- 订单反馈弹窗区域 -->
  101. <uni-popup ref="popup_feedback" background-color="#fff" :is-mask-click="false">
  102. <view class="popup_view">
  103. <view class="title">{{popTitle}}</view>
  104. <view class="forms">
  105. <uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData">
  106. <uni-forms-item label="姓名:" required name="feedbackPersonName">
  107. <uni-easyinput v-model="valiFormData.feedbackPersonName" placeholder="请输入姓名" />
  108. </uni-forms-item>
  109. <uni-forms-item label="联系电话:" required name="feedbackPersonPhone">
  110. <uni-easyinput maxlength="11" v-model="valiFormData.feedbackPersonPhone" type="number"
  111. placeholder="请输入联系人手机号码" />
  112. </uni-forms-item>
  113. <uni-forms-item label="宿舍号:" required name="feedbackRoom">
  114. <uni-easyinput v-model="valiFormData.feedbackRoom" placeholder="请输入宿舍号" />
  115. </uni-forms-item>
  116. <uni-forms-item label="反馈信息:" required name="feedbackInfo">
  117. <uni-easyinput type="textarea" v-model="valiFormData.feedbackInfo" placeholder="请输入反馈信息" />
  118. </uni-forms-item>
  119. <uni-forms-item label="上传图片:" name="feedbackImg">
  120. <uni-file-picker limit="3" title="最多上传3张图片" v-model="valiFormData.feedbackImg"
  121. fileMediatype="image" :image-styles="imageStyles" mode="grid" @select="select"
  122. @delete="handleDelete">
  123. </uni-file-picker>
  124. </uni-forms-item>
  125. </uni-forms>
  126. <view class="form_button">
  127. <button type="primary" size="mini" @click="popSubmit('valiForm')">
  128. 提交
  129. </button>
  130. <button type="primary" plain size="mini" @click="close">
  131. 取消
  132. </button>
  133. </view>
  134. </view>
  135. </view>
  136. </uni-popup>
  137. </view>
  138. </template>
  139. <script>
  140. // 引入照片压缩js文件
  141. import * as TranslateImage from '../../util/imageZip.js'
  142. export default {
  143. data() {
  144. return {
  145. // 图片上传组件的样式
  146. imageStyles: {
  147. width: 75,
  148. height: 75,
  149. border: {
  150. color: "#ccc",
  151. width: 1,
  152. style: 'dashed',
  153. radius: '5px'
  154. }
  155. },
  156. // 选择的宿舍绑定数据
  157. roomSelect: "请选择宿舍",
  158. // 悬浮按钮移动标识
  159. flags: false,
  160. maxW: 0,
  161. maxH: 0,
  162. position: {
  163. x: 0,
  164. y: 0
  165. },
  166. nx: 0,
  167. ny: 0,
  168. // 账单数据
  169. list: [],
  170. // 时间筛选框选中值绑定数据
  171. time_value: "",
  172. // 时间筛选框列表绑定数据
  173. time_range: [],
  174. // 支付状态 0是全部 1是未支付 2是已支付
  175. pay_type: 0,
  176. // 支付状态筛选框列表绑定数据
  177. type_range: [{
  178. value: 1,
  179. text: "全部"
  180. },
  181. {
  182. value: 2,
  183. text: "未支付"
  184. },
  185. {
  186. value: 3,
  187. text: "已支付"
  188. },
  189. ],
  190. // 订单反馈弹窗 表格的验证规则
  191. rules: {
  192. feedbackPersonName: {
  193. rules: [{
  194. required: true,
  195. errorMessage: "请输入姓名",
  196. },
  197. {
  198. minLength: 2,
  199. maxLength: 8,
  200. errorMessage: "请输入正确的姓名",
  201. }
  202. ],
  203. },
  204. feedbackPersonPhone: {
  205. rules: [{
  206. required: true,
  207. errorMessage: "请输入联系人手机号码",
  208. },
  209. {
  210. pattern: /^[1]([3-9])[0-9]{9}$/,
  211. errorMessage: '请输入正确的手机号码'
  212. }
  213. ],
  214. },
  215. feedbackRoom: {
  216. rules: [{
  217. required: true,
  218. errorMessage: "请输入宿舍号",
  219. }, ],
  220. },
  221. // feedbackImg: {
  222. // rules: [{
  223. // required: true,
  224. // errorMessage: "请上传图片",
  225. // }, ],
  226. // },
  227. feedbackInfo: {
  228. rules: [{
  229. required: true,
  230. errorMessage: "请输入反馈信息",
  231. }, ],
  232. },
  233. },
  234. // 订单反馈弹窗 表格绑定数据
  235. valiFormData: {
  236. feedbackPersonName: "",
  237. feedbackPersonPhone: "",
  238. feedbackRoom: "",
  239. feedbackInfo: "",
  240. feedbackImg: []
  241. },
  242. popTitle: ""
  243. };
  244. },
  245. onLoad() {
  246. // 如果之前已经选择过宿舍,则从缓存中读取
  247. if (localStorage.room) {
  248. this.roomSelect = "黄家湖" + localStorage.room
  249. this.getData()
  250. this.getTimeList()
  251. }
  252. },
  253. methods: {
  254. // 获取账单列表数据
  255. async getData() {
  256. if (!this.time_value) {
  257. let date = new Date();
  258. this.time_value = date.getFullYear()
  259. }
  260. let res = await this.$myRequest({
  261. url: "/payableinfowater/queryWaterInfo",
  262. data: {
  263. dorm: localStorage.room,
  264. // dorm: "12栋202",
  265. year: this.time_value,
  266. payStatu: this.pay_type,
  267. },
  268. });
  269. // console.log(res);
  270. if (res.success) {
  271. this.list = res.data
  272. }
  273. },
  274. // 获取时间筛选框时间数组
  275. async getTimeList() {
  276. let res = await this.$myRequest({
  277. url: "/payableinfowater/queryAllYear",
  278. data: {
  279. dorm: localStorage.room,
  280. // dorm: "12栋202",
  281. },
  282. });
  283. // console.log(res);
  284. if (res.success) {
  285. this.time_range = res.data
  286. }
  287. },
  288. // 选择图片回调
  289. select(e) {
  290. e.tempFiles.forEach((item) => {
  291. TranslateImage.translate(item.path, ((res) => {
  292. if (Number(res.size) > 1000000) {
  293. this.valiFormData.feedbackImg = []
  294. uni.showModal({
  295. content: `图片过大,请重新上传`,
  296. showCancel: false,
  297. success() {}
  298. })
  299. return
  300. }
  301. this.valiFormData.feedbackImg.push({
  302. url: item.path
  303. })
  304. console.log(this.valiFormData.feedbackImg);
  305. // uni.showLoading({
  306. // title: '上传中'
  307. // });
  308. // uni.uploadFile({
  309. // url: `/baoxiu/repairApi/order/uploadImage`,
  310. // filePath: res.url,
  311. // name: 'orderImages',
  312. // success: (uploadFileRes) => {
  313. // this.ceshiData1.push((JSON.parse(uploadFileRes.data).data))
  314. // const path = item.path;
  315. // this.imageValue.push({
  316. // url: path,
  317. // name: ""
  318. // })
  319. // uni.hideLoading();
  320. // },
  321. // fail: () => {
  322. // uni.hideLoading();
  323. // }
  324. // });
  325. }))
  326. })
  327. },
  328. // 删除图片回调
  329. handleDelete(e) {
  330. const num = this.valiFormData.feedbackImg.findIndex(v => v.path === e.tempFilePath);
  331. this.valiFormData.feedbackImg.splice(num, 1);
  332. console.log(this.valiFormData.feedbackImg);
  333. },
  334. // 订单反馈按钮弹窗
  335. async handleFeedback(item) {
  336. console.log(item);
  337. this.popTitle = item.title
  338. this.valiFormData.feedbackPersonName = "";
  339. this.valiFormData.feedbackPersonPhone = "";
  340. this.valiFormData.feedbackRoom = "";
  341. this.valiFormData.feedbackInfo = "";
  342. this.valiFormData.feedbackImg = [];
  343. let res = await this.$myRequest({
  344. url: "/wechat/getUserNameTele",
  345. data: {
  346. cardNumber: item.cardNumber,
  347. },
  348. });
  349. // console.log(res);
  350. if (res.success) {
  351. this.valiFormData.feedbackPersonName = res.data.name
  352. this.valiFormData.feedbackPersonPhone = res.data.telephone
  353. }
  354. this.$refs.popup_feedback.open();
  355. },
  356. // 订单反馈弹窗提交按钮回调
  357. popSubmit(ref) {
  358. this.$refs[ref]
  359. .validate()
  360. .then((res) => {
  361. console.log(res);
  362. this.$refs.popup_feedback.close();
  363. uni.showToast({
  364. title: '提交成功',
  365. });
  366. })
  367. .catch((err) => {
  368. console.log("err", err);
  369. });
  370. },
  371. // 订单反馈弹窗取消按钮回调
  372. close() {
  373. this.$refs.popup_feedback.close();
  374. },
  375. // 时间筛选框数据改变回调
  376. changeTime(e) {
  377. if (e != "") {
  378. this.time_range.forEach((element) => {
  379. if (element.value == e) {
  380. this.time_value = element.text
  381. }
  382. })
  383. this.getData()
  384. }
  385. },
  386. // 支付状态筛选框数据改变回调
  387. changeType(e) {
  388. if (e == 1 || e == 2 || e == 3) {
  389. if (e == 1) {
  390. this.pay_type = 0
  391. } else if (e == 2) {
  392. this.pay_type = 1
  393. } else if (e == 3) {
  394. this.pay_type = 2
  395. }
  396. this.getData()
  397. }
  398. },
  399. // 跳转到选择宿舍页面
  400. navigateToSelect() {
  401. uni.navigateTo({
  402. url: '/pages/select/select',
  403. });
  404. },
  405. // 跳转到支付页面
  406. navigateToPay(item) {
  407. let info = JSON.stringify(item)
  408. uni.navigateTo({
  409. url: `/pages/pay/pay?info=${info}`,
  410. });
  411. },
  412. // 订单查询悬浮按钮回调
  413. goBill() {
  414. uni.navigateTo({
  415. url: "/pages/bill/bill"
  416. })
  417. },
  418. // 实现移动端拖拽
  419. down(event) {
  420. let suspend_button = document.querySelector(".suspend_button");
  421. this.flags = true;
  422. let touch;
  423. if (event.touches) {
  424. touch = event.touches[0];
  425. } else {
  426. touch = event;
  427. }
  428. this.maxW = document.body.clientWidth - suspend_button.offsetWidth;
  429. this.maxH = document.body.clientHeight - suspend_button.offsetHeight;
  430. this.position.x = touch.clientX - suspend_button.offsetLeft;
  431. this.position.y = touch.clientY - suspend_button.offsetTop;
  432. },
  433. move(event) {
  434. let suspend_button = document.querySelector(".suspend_button");
  435. if (this.flags) {
  436. let touch;
  437. if (event.touches) {
  438. touch = event.touches[0];
  439. } else {
  440. touch = event;
  441. }
  442. this.nx = touch.clientX - this.position.x;
  443. this.ny = touch.clientY - this.position.y;
  444. if (this.nx < 0) {
  445. this.nx = 0;
  446. } else if (this.nx > this.maxW) {
  447. this.nx = this.maxW;
  448. }
  449. if (this.ny < 0) {
  450. this.ny = 0;
  451. } else if (this.ny >= this.maxH) {
  452. this.ny = this.maxH;
  453. }
  454. suspend_button.style.left = this.nx + "px";
  455. suspend_button.style.top = this.ny + "px";
  456. }
  457. },
  458. end() {
  459. this.flags = false;
  460. },
  461. // 拨打电话回调
  462. handlePhone() {
  463. uni.makePhoneCall({
  464. phoneNumber: '82293462'
  465. });
  466. },
  467. // 下拉刷新回调
  468. onPullDownRefresh() {
  469. console.log('刷新');
  470. // this.getData();
  471. setTimeout(() => {
  472. uni.stopPullDownRefresh();
  473. }, 1500);
  474. },
  475. }
  476. }
  477. </script>
  478. <style lang="scss" scoped>
  479. .container {
  480. overflow: auto;
  481. height: 100vh;
  482. background-image: url(../../static/bg.png);
  483. background-size: 100% 100%;
  484. .select-item {
  485. margin: 19rpx 0;
  486. display: flex;
  487. background-color: #ffffff;
  488. height: 139rpx;
  489. .picker-item-logol {
  490. width: 88rpx;
  491. display: flex;
  492. justify-content: flex-end;
  493. align-items: center;
  494. .picker-item-logo-left {
  495. width: 58rpx;
  496. height: 58rpx;
  497. }
  498. }
  499. .picker-item-label {
  500. font-size: 30rpx;
  501. width: 161rpx;
  502. height: 139rpx;
  503. line-height: 139rpx;
  504. text-align: center;
  505. }
  506. .picker-item-content {
  507. width: 360rpx;
  508. height: 139rpx;
  509. line-height: 139rpx;
  510. font-size: 36rpx;
  511. text-align: center;
  512. color: #999999;
  513. }
  514. .picker-item-content2 {
  515. width: 360rpx;
  516. height: 139rpx;
  517. line-height: 139rpx;
  518. font-size: 36rpx;
  519. text-align: center;
  520. color: black;
  521. }
  522. .picker-item-logor {
  523. width: 91rpx;
  524. display: flex;
  525. justify-content: center;
  526. align-items: center;
  527. .picker-item-logo-right {
  528. width: 40rpx;
  529. height: 40rpx;
  530. }
  531. }
  532. }
  533. .bill {
  534. margin: 20rpx 0;
  535. min-height: 920rpx;
  536. .choose {
  537. display: flex;
  538. margin: 0 20rpx;
  539. .time {
  540. flex: 1;
  541. padding-right: 40rpx;
  542. }
  543. .type {
  544. flex: 1;
  545. }
  546. }
  547. .null {
  548. display: flex;
  549. flex-direction: column;
  550. align-items: center;
  551. margin: 0 auto;
  552. padding-top: 300rpx;
  553. width: 50%;
  554. height: 400rpx;
  555. img {
  556. height: 90%;
  557. }
  558. span {
  559. margin-top: 30rpx;
  560. }
  561. }
  562. .has {
  563. margin: 0 20rpx;
  564. .has_bill {
  565. margin-top: 20rpx;
  566. .item {
  567. margin-bottom: 20rpx;
  568. border-radius: 10rpx;
  569. background-color: #fff;
  570. .item_header {
  571. height: 96rpx;
  572. line-height: 96rpx;
  573. text-align: center;
  574. font-weight: bold;
  575. border-radius: 10rpx 10rpx 0 0;
  576. background-color: #e7eef5;
  577. }
  578. .item_box {
  579. display: flex;
  580. margin: 0 30rpx;
  581. height: 70rpx;
  582. line-height: 70rpx;
  583. font-weight: bold;
  584. .item_box_1 {
  585. flex: 1.5;
  586. }
  587. .item_box_2 {
  588. flex: 1;
  589. }
  590. .font {
  591. font-weight: normal;
  592. color: #999;
  593. }
  594. }
  595. .item_notes {
  596. margin: 0 30rpx;
  597. height: 60rpx;
  598. line-height: 60rpx;
  599. font-size: 26rpx;
  600. color: #999;
  601. }
  602. .item_button {
  603. display: flex;
  604. justify-content: flex-end;
  605. margin: 10rpx 50rpx;
  606. height: 74rpx;
  607. line-height: 74rpx;
  608. .feedback {
  609. margin: 0;
  610. padding: 0;
  611. width: 140rpx;
  612. height: 65rpx;
  613. line-height: 65rpx;
  614. font-size: 26rpx;
  615. }
  616. .right {
  617. margin-right: 50rpx;
  618. }
  619. }
  620. }
  621. }
  622. }
  623. }
  624. .phone {
  625. display: flex;
  626. justify-content: center;
  627. align-items: center;
  628. margin: 20rpx 0;
  629. height: 70rpx;
  630. .phone_box {
  631. margin-bottom: 20rpx;
  632. span {
  633. color: #4993EA;
  634. }
  635. }
  636. }
  637. .suspend_button {
  638. position: fixed;
  639. left: 80rpx;
  640. bottom: 120rpx;
  641. width: 140rpx;
  642. height: 140rpx;
  643. line-height: 140rpx;
  644. text-align: center;
  645. border-radius: 70rpx;
  646. color: #fff;
  647. background-color: rgba(0, 0, 0, 0.4);
  648. }
  649. .popup_view {
  650. width: 650rpx;
  651. .title {
  652. height: 90rpx;
  653. line-height: 90rpx;
  654. font-size: 36rpx;
  655. font-weight: bold;
  656. text-align: center;
  657. background-color: #e7eef5;
  658. }
  659. .forms {
  660. margin: 40rpx;
  661. width: 550rpx;
  662. .form_button {
  663. display: flex;
  664. text-align: center;
  665. button {
  666. width: 200rpx;
  667. }
  668. }
  669. }
  670. }
  671. }
  672. ::v-deep .uni-select__input-placeholder {
  673. color: #fff;
  674. }
  675. ::v-deep .uniui-bottom::before {
  676. color: #fff;
  677. }
  678. ::v-deep .uni-forms-item__label {
  679. width: 160rpx !important;
  680. }
  681. </style>