tenancyOrderList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <template>
  2. <zj-page-layout :hasFooter="true" :isScroll="true" :refresherTriggered="refresherTriggered"
  3. @refresherrefresh="refresherrefresh" @scrolltolower="scrolltolower">
  4. <template slot="header">
  5. <view class="search-container">
  6. <u-search shape="round" :showAction="false" placeholder="输入分类名称进行搜索" v-model="keyword"
  7. @search="refreshList" @clear="clearSearch">
  8. </u-search>
  9. </view>
  10. <u-tabs :scrollable="true" :list="tabList" :current="curTab" @click="changeTab" lineColor="#3D8FFD"
  11. :activeStyle="{color: '#3D8FFD'}" :inactiveStyle="{color: '#666666'}" itemStyle="height: 88rpx;">
  12. </u-tabs>
  13. </view>
  14. </template>
  15. <view class="list-container">
  16. <view v-for="(item, index) in orderList" :key='index' class="item" @tap="toOrderDetail(item.id)">
  17. <view class="top">
  18. <view class="left">{{item.id}}</view>
  19. <view class="right" :style="{'color': filterStatus(item,'color')}">{{filterStatus(item,'name')}}</view>
  20. </view>
  21. <view class="content">
  22. <image :src="item.categoryUrl" mode="aspectFill"></image>
  23. <view class="right">
  24. <view class="name">{{item.goodsLeaseName}}</view>
  25. <view class="name remark">{{item.repairRemark}}</view>
  26. <view class="text">下单日期 {{item.createTime}}</view>
  27. <view class="text date" v-if="item.startDate && (item.realEndDate || item.endDate)">租赁时间 {{item.startDate.substring(0,10) + ' 至 ' + (item.realEndDate?item.realEndDate.substring(0,10):item.endDate.substring(0,10))}}</view>
  28. </view>
  29. </view>
  30. <view class="btn" @tap.stop>
  31. <view v-if="!item.payStatus">
  32. <u-button type="primary" style="width: 180rpx;" size="small" shape="circle" color="#428dff" text="去支付" @click="payOrder(item.id)"></u-button>
  33. </view>
  34. <view class="flex" v-else>
  35. <u-button type="primary" size="small" v-if="item.status == 'LEASE' || item.status == 'OVER'" style="width: 210rpx;margin-right: 20rpx" shape="circle" color="#428dff" text="我要续租" @click="toRelet(item.id)"></u-button>
  36. <u-button type="primary" size="small" style="width: 210rpx;" shape="circle" color="#428dff" text="我要报修" v-if="item.status == 'LEASE'" @click="toRepair(item.id)"></u-button>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <Loading :loadStatus="loadStatus" :dataList="orderList" />
  42. </zj-page-layout>
  43. </template>
  44. <script>
  45. import {
  46. weixinPay,
  47. mini_env
  48. } from '@/common/utils/util.js';
  49. export default {
  50. data() {
  51. return {
  52. configInfo: {},
  53. tabList: [{
  54. key: '',
  55. status: {
  56. payStatus: '',
  57. status: ''
  58. },
  59. name: '全部'
  60. },
  61. {
  62. key: '',
  63. status: {
  64. payStatus: false,
  65. status: ''
  66. },
  67. name: '待付款'
  68. },
  69. {
  70. key: '',
  71. status: {
  72. payStatus: true,
  73. status: 'WAIT'
  74. },
  75. name: '待审核'
  76. },
  77. {
  78. key: '',
  79. status: {
  80. payStatus: true,
  81. status: 'WAIT_START'
  82. },
  83. name: '待开始'
  84. },
  85. {
  86. key: '',
  87. status: {
  88. payStatus: true,
  89. status: 'LEASE'
  90. },
  91. name: '租赁中'
  92. },
  93. {
  94. key: '',
  95. status: {
  96. payStatus: true,
  97. status: 'OVER'
  98. },
  99. name: '已到期'
  100. },
  101. ],
  102. tabCurrent: '', // 当前tab状态
  103. tabStatus: {
  104. payStatus: '',
  105. status: ''
  106. },
  107. orderList: [], // 订单列表
  108. loadStatus: 0,
  109. refresherTriggered: false, // 下拉刷新状态
  110. pageNum: 1,
  111. keyword: ''
  112. }
  113. },
  114. computed: {
  115. curTab() {
  116. return this.tabList.map(item => item.key).indexOf(this.tabCurrent) || 0;
  117. },
  118. filterStatus(){
  119. return function(item,type){
  120. if(!item.payStatus){
  121. return {name: '待付款',color: '#ce68ff'}[type]
  122. }else{
  123. if(item.status == 'WAIT'){
  124. return {name: '待审核',color: '#ff5300'}[type]
  125. }
  126. else if(item.status == 'WAIT_START'){
  127. return {name: '待开始',color: '#64c842'}[type]
  128. }else if(item.status == 'LEASE'){
  129. return {name: '租赁中',color: '#1281ff'}[type]
  130. }else if(item.status == 'OVER'){
  131. return {name: '待回收',color: '#9c84fe'}[type]
  132. }else if(item.status == 'RECOVER'){
  133. return {name: '已回收',color: '#817f7f'}[type]
  134. }
  135. }
  136. }
  137. }
  138. },
  139. async onLoad() {
  140. this.getOrderList();
  141. this.configInfo = await this.$getConfigInfo();
  142. this.crossPage.$on('refreshOrderList', (data) => {
  143. this.refreshList();
  144. })
  145. },
  146. onUnload() {
  147. this.crossPage.$off('refreshOrderList');
  148. },
  149. methods: {
  150. getOrderList() {
  151. this.loadStatus = 1;
  152. let url = '/lease/order/list/page';
  153. this.$api.post(url, {
  154. pageNum: this.pageNum,
  155. pageSize: 10,
  156. keyword: this.keyword,
  157. userId: this.$store.state.user.userId,
  158. ...this.tabStatus,
  159. }).then(res => {
  160. this.loadStatus = 0;
  161. let list = res.data.records;
  162. if (list.length < 10) {
  163. this.loadStatus = 2;
  164. }
  165. this.orderList = this.orderList.concat(list);
  166. }).catch(() => {
  167. this.loadStatus = 2;
  168. }).finally(res => {
  169. this.refresherTriggered = false;
  170. })
  171. },
  172. // 滚动到底部
  173. scrolltolower(e) {
  174. if (this.loadStatus === 0) {
  175. this.pageNum++;
  176. this.getOrderList();
  177. }
  178. },
  179. // 触发下拉刷新
  180. async refresherrefresh(e) {
  181. this.refresherTriggered = true;
  182. this.refreshList();
  183. },
  184. refreshList() {
  185. this.orderList = [];
  186. this.pageNum = 1;
  187. this.getOrderList();
  188. },
  189. getRefundNum(orderDetails) {
  190. let refundNum = 0;
  191. orderDetails.forEach(item => {
  192. if (item.refund) {
  193. refundNum = refundNum + item.refundNum;
  194. }
  195. })
  196. return refundNum;
  197. },
  198. // 搜索
  199. clearSearch() {
  200. this.keyword = ''
  201. this.refreshList();
  202. },
  203. // 切换类型
  204. changeTab(item) {
  205. this.tabCurrent = item.key;
  206. this.tabStatus = item.status
  207. this.refreshList();
  208. },
  209. // 去订单详情
  210. toOrderDetail(id) {
  211. this.$navToPage({
  212. url: '/packageWorkorder/pages/tenancyOrderDetail?id='+id
  213. })
  214. },
  215. //去续租
  216. toRelet(id){
  217. this.$navToPage({
  218. url: '/packageWorkorder/pages/tenancyReletOrder?id=' + id
  219. })
  220. },
  221. //去报修
  222. toRepair(id){
  223. this.$navToPage({
  224. url: '/packageWorkorder/pages/tenancyRepairOrder?id=' + id
  225. })
  226. },
  227. // 立即付款
  228. payOrder(id) {
  229. mini_env((bool) => {
  230. let that = this;
  231. this.$api.post('/lease/order/pay', {
  232. userId: this.$store.state.user.userId,
  233. id,
  234. ...(() => {
  235. if (bool) {
  236. return {
  237. miniPay: true,
  238. openId: this.$store.state.user.miniOpenId
  239. }
  240. }
  241. return {}
  242. })()
  243. }).then(res => {
  244. if (bool) {
  245. uniWebview.navigateTo({
  246. url: `/pages/pay/pay?${Object.entries({
  247. ...res.data,
  248. payPackage: res.data.payPackage.split("=")[0] || "",
  249. payPackageVal: res.data.payPackage.split("=")[1] || ""
  250. }).map(item => item.join("=")).join("&")}`
  251. })
  252. } else {
  253. weixinPay(res.data, function(res) {
  254. that.$successToast('支付成功');
  255. that.pageNum = 1;
  256. that.getOrderList();
  257. that.requestMessage();
  258. })
  259. }
  260. })
  261. })
  262. },
  263. // 消息推送
  264. requestMessage() {
  265. let that = this;
  266. uni.showModal({
  267. title: '温馨提示',
  268. content: '为更好的促进您与买家的交流,需要在您的订单成交时向您发送消息',
  269. confirmText: "同意",
  270. cancelText: "拒绝",
  271. success: function(res) {
  272. if (res.confirm) {
  273. let tmplIds = [that.configInfo.template];
  274. uni.requestSubscribeMessage({
  275. tmplIds: tmplIds,
  276. success(res) {
  277. let status = null;
  278. tmplIds.map((item, index) => {
  279. if (res[item] == 'accept') {
  280. status = 'accept';
  281. }
  282. })
  283. if (status == 'accept') {
  284. that.$successToast('订阅成功');
  285. } else {
  286. that.$toast('订阅取消');
  287. }
  288. },
  289. fail(res) {
  290. console.log(res);
  291. that.$toast('订阅失败');
  292. }
  293. })
  294. } else if (res.cancel) {
  295. uni.showModal({
  296. title: '温馨提示',
  297. content: '拒绝后您将无法获取实时的与卖家(买家)的交易消息',
  298. confirmText: "知道了",
  299. showCancel: false,
  300. success: function(res) {
  301. }
  302. });
  303. }
  304. }
  305. });
  306. },
  307. navToPage(url) {
  308. this.$navToPage({
  309. url
  310. })
  311. },
  312. }
  313. }
  314. </script>
  315. <style lang="scss">
  316. .tab-container {
  317. background: #ffffff;
  318. }
  319. .search-container {
  320. background: #ffffff;
  321. padding: 20rpx;
  322. margin-bottom: 20rpx;
  323. ::v-deep .u-search {
  324. height: 60rpx;
  325. input {
  326. background: #F7F8FF !important;
  327. }
  328. .u-search__content {
  329. background: #F7F8FF !important;
  330. height: 60rpx;
  331. }
  332. }
  333. }
  334. .list-container {
  335. padding: 1rpx 20rpx 0;
  336. .item {
  337. @include zj-card;
  338. margin-top: 20rpx;
  339. background: #FFFFFF;
  340. border-radius: 20rpx;
  341. padding: 20rpx;
  342. .top {
  343. display: flex;
  344. justify-content: space-between;
  345. align-items: center;
  346. margin-bottom: 20rpx;
  347. .left {
  348. font-size: 28rpx;
  349. font-weight: 500;
  350. }
  351. .right {
  352. font-size: 30rpx;
  353. }
  354. }
  355. .goods {
  356. display: flex;
  357. justify-content: space-between;
  358. margin-top: 20rpx;
  359. &.goods0 {
  360. margin-top: 0;
  361. }
  362. image {
  363. width: 140rpx;
  364. height: 140rpx;
  365. display: block;
  366. flex-shrink: 0;
  367. margin-right: 20rpx;
  368. }
  369. .main {
  370. flex: 1;
  371. display: flex;
  372. justify-content: space-between;
  373. .left {
  374. .name {
  375. font-size: 28rpx;
  376. color: #333333;
  377. line-height: 36rpx;
  378. }
  379. .des {
  380. font-size: 28rpx;
  381. color: #999999;
  382. margin-top: 10rpx;
  383. }
  384. }
  385. .right {
  386. flex-shrink: 0;
  387. margin-left: 20rpx;
  388. text-align: right;
  389. .price {
  390. font-size: 28rpx;
  391. color: #333333;
  392. line-height: 28rpx;
  393. font-weight: 600;
  394. margin-top: 6rpx;
  395. }
  396. .num {
  397. font-size: 28rpx;
  398. color: #999999;
  399. line-height: 28rpx;
  400. margin-top: 16rpx;
  401. }
  402. }
  403. }
  404. }
  405. .total {
  406. display: flex;
  407. justify-content: space-between;
  408. height: 50rpx;
  409. align-items: center;
  410. .left {
  411. font-size: 24rpx;
  412. color: #666666;
  413. }
  414. .right {
  415. font-size: 24rpx;
  416. color: #666666;
  417. text {
  418. color: $minor-color;
  419. font-size: 32rpx;
  420. font-weight: 600;
  421. margin-left: 8rpx;
  422. }
  423. }
  424. }
  425. .btn-group {
  426. border-top: 1px solid #eaeaea;
  427. height: 100rpx;
  428. display: flex;
  429. justify-content: flex-end;
  430. align-items: center;
  431. &.btn-group2 {
  432. justify-content: space-between;
  433. .tips {
  434. font-size: 28rpx;
  435. color: $minor-color;
  436. }
  437. .btns {
  438. display: flex;
  439. }
  440. }
  441. .button {
  442. width: 140rpx;
  443. height: 48rpx;
  444. border-radius: 48rpx;
  445. text-align: center;
  446. line-height: 48rpx;
  447. font-size: 24rpx;
  448. margin-left: 20rpx;
  449. flex-shrink: 0;
  450. &:first-child {
  451. margin-left: 0;
  452. }
  453. &.gray {
  454. color: #999999;
  455. border: 1px solid #999999;
  456. }
  457. &.white {
  458. color: $theme-color;
  459. border: 1px solid $theme-color;
  460. }
  461. &.red {
  462. color: #FFFFFF;
  463. border: 1px solid $theme-color;
  464. background: $theme-color;
  465. }
  466. }
  467. }
  468. }
  469. .content{
  470. display: flex;
  471. align-items: center;
  472. border-bottom: 1rpx solid #eeeeee;
  473. box-sizing: border-box;
  474. image {
  475. width: 140rpx;
  476. height: 140rpx;
  477. margin-right: 20rpx;
  478. }
  479. .right{
  480. .name{
  481. font-weight: bold;
  482. color: #000000;
  483. font-size: 32rpx;
  484. line-height: 36rpx;
  485. margin-bottom: 20rpx;
  486. }
  487. .text{
  488. font-size: 26rpx;
  489. margin-bottom: 20rpx;
  490. }
  491. .date{
  492. color: #ff5300;
  493. }
  494. .remark{
  495. font-size: 26rpx;
  496. color: #59a7ff;
  497. }
  498. }
  499. }
  500. .btn{
  501. width: 100%;
  502. display: flex;
  503. justify-content: flex-end;
  504. }
  505. }
  506. </style>