home.vue 15 KB

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