myRent.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <view class="content">
  3. <view class="top-tit flex" v-if="currentIndex == 0 && dqtime">
  4. <view class="tit">
  5. 电池到期时间: {{dqtime}}
  6. </view>
  7. </view>
  8. <view class="top-tit flex" v-if="currentIndex == 1 && dqtimet">
  9. <view class="tit">
  10. 升压器到期时间: {{dqtimet}}
  11. </view>
  12. </view>
  13. <view class="navbar">
  14. <view v-for="(item, index) in navList" :key="index" class="nav-item"
  15. :class="{ current: currentIndex === index }" @click="tabClick(index)">{{ item.title }}</view>
  16. </view>
  17. <scroll-view scroll-y="true" :style="{'height': maxhegiht}" class="list-wrap" @scrolltolower="getMyRent">
  18. <swiper disable-touch :style="{'height': maxhegiht}" :current="currentIndex">
  19. <swiper-item v-for="ditem in navList">
  20. <view v-for="(item, index) in ditem.list" :key="index" class="order-item">
  21. <view class="i-top b-b">
  22. <text class="time">订单编号:{{ item.order_id }}</text>
  23. <text class="state">{{ item.status == 1?'待核销':(item.status == 2 ? '已核销': '') }}</text>
  24. <text v-if="item.status === 4" class="del-btn iconfont icondelete" @click="deleteOrder(index)"></text>
  25. </view>
  26. <view class="goods-box-single">
  27. <image class="goods-img" :src="currentIndex == 1?'../../static/icon/in3.png':'../../static/icon/in1.png'" mode="scaleToFill"></image>
  28. <view class="right">
  29. <view class="flex flextop">
  30. <text class="title clamp2">{{currentIndex == 0?'电池订单': '升压器订单'}}</text>
  31. <text class="price">{{ moneyNum(item.price) }}</text>
  32. </view>
  33. <view class="row flex">
  34. <text class="row_title">{{ item.month ? (item.month + '月') : '' }}</text>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="price-box">
  39. 实付款
  40. <text class="price">{{ moneyNum(item.pay_price)}}</text>(押金{{moneyNum(item.deposit)}})
  41. </view>
  42. <view class="action-box b-t">
  43. <button v-if="item.status == 0 && currentIndex == 0" class="action-btn btn-base"
  44. @click.stop="navTo('/pages/order/hxqm?id=' + item.verify_code + '&type=2&battery_number=' + (userInfo.battery_number || ''))">出示券码</button>
  45. <button v-if="item.status == 0 && currentIndex == 1" class="action-btn btn-base"
  46. @click.stop="navTo('/pages/order/hxqm?id=' + item.verify_code + '&type=3&booster_number=' + (userInfo.booster_number || ''))">出示券码</button>
  47. <!-- <button v-if="item.status == 2" class="action-btn btn-base"
  48. @click.stop="xf(item)">续费</button> -->
  49. </view>
  50. </view>
  51. <uni-load-more :status="ditem.loadingType"></uni-load-more>
  52. </swiper-item>
  53. </swiper>
  54. </scroll-view>
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. getTime
  60. } from '@/utils/rocessor.js'
  61. import {
  62. mapState
  63. } from 'vuex'
  64. import {
  65. getMyRent
  66. } from '@/api/user.js'
  67. export default {
  68. data() {
  69. return {
  70. maxhegiht: '',
  71. currentIndex: 0,
  72. navList: [{
  73. status: 1,
  74. title: '电池',
  75. page: 1,
  76. limit: 10,
  77. loadingType: 'more',
  78. loaded: false,
  79. list: []
  80. },
  81. {
  82. status: 2,
  83. title: '升压器',
  84. page: 1,
  85. limit: 10,
  86. loadingType: 'more',
  87. loaded: false,
  88. list: []
  89. }
  90. ]
  91. }
  92. },
  93. onLoad(opt) {
  94. if (opt.status) {
  95. this.currentIndex = opt.status
  96. }
  97. this.getMyRent()
  98. },
  99. onShow() {
  100. },
  101. onReachBottom() {
  102. // this.getMyRent()
  103. },
  104. onReady(res) {
  105. var that = this;
  106. uni.getSystemInfo({
  107. success: resu => {
  108. const query = uni.createSelectorQuery();
  109. query.select('.list-wrap').boundingClientRect();
  110. query.exec(function(res) {
  111. that.maxhegiht = resu.windowHeight - res[0].top + 'px';
  112. });
  113. },
  114. fail: res => {}
  115. });
  116. },
  117. computed: {
  118. ...mapState('user', ['userInfo']),
  119. dqtime() {
  120. return this.userInfo.battery_end_time ? getTime(this.userInfo.battery_end_time) : ''
  121. },
  122. dqtimet() {
  123. return this.userInfo.booster_end_time ? getTime(this.userInfo.booster_end_time) : ''
  124. }
  125. },
  126. methods: {
  127. tabClick(index) {
  128. this.currentIndex = index
  129. this.getMyRent()
  130. },
  131. xf() {
  132. // console.log(item);
  133. uni.navigateTo({
  134. url: '/pages/shop/rent?renew=1'
  135. })
  136. },
  137. navTo(url) {
  138. uni.navigateTo({
  139. url,
  140. fail() {
  141. uni.switchTab({
  142. url
  143. })
  144. }
  145. })
  146. },
  147. moneyNum(val) {
  148. return (val * 1).toFixed(2)
  149. },
  150. getMyRent(type) {
  151. let that = this
  152. let index = that.currentIndex;
  153. let item = that.navList[index]
  154. if (type == 'tab' && item.loaded) {
  155. return
  156. }
  157. if (item.loadingType == 'loading' || item.loadingType == 'noMore') {
  158. return
  159. }
  160. item.loadingType = 'loading'
  161. getMyRent({
  162. page: item.page,
  163. limit: item.limit,
  164. status: -1,
  165. type: item.status==1?'battery':'booster'
  166. }).then(res => {
  167. let arr = res.data.list
  168. item.list = item.list.concat(arr)
  169. item.page++
  170. if (arr.length == item.limit) {
  171. item.loadingType = 'more'
  172. } else {
  173. item.loadingType = 'noMore'
  174. }
  175. item.loaded = true
  176. })
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. .content {
  183. // padding-top: 20rpx;
  184. }
  185. .order-item {
  186. display: flex;
  187. flex-direction: column;
  188. padding-left: 30rpx;
  189. background: #fff;
  190. margin: 0 $page-row-spacing;
  191. margin-bottom: 30rpx;
  192. border-radius: 20rpx;
  193. padding-bottom: 10rpx;
  194. .i-top {
  195. display: flex;
  196. align-items: center;
  197. height: 80rpx;
  198. padding-right: 30rpx;
  199. font-size: $font-base;
  200. color: $font-color-dark;
  201. position: relative;
  202. .time {
  203. flex: 1;
  204. }
  205. .state {
  206. color: $base-color;
  207. }
  208. .del-btn {
  209. padding: 10rpx 0 10rpx 36rpx;
  210. font-size: $font-lg;
  211. color: $font-color-light;
  212. position: relative;
  213. &:after {
  214. content: '';
  215. width: 0;
  216. height: 30rpx;
  217. border-left: 1px solid $border-color-dark;
  218. position: absolute;
  219. left: 20rpx;
  220. top: 50%;
  221. transform: translateY(-50%);
  222. }
  223. }
  224. }
  225. /* 多条商品 */
  226. .goods-box {
  227. height: 160rpx;
  228. padding: 20rpx 0;
  229. white-space: nowrap;
  230. .goods-item {
  231. width: 120rpx;
  232. height: 120rpx;
  233. display: inline-block;
  234. margin-right: 24rpx;
  235. }
  236. .goods-img {
  237. display: block;
  238. width: 100%;
  239. height: 100%;
  240. }
  241. }
  242. /* 单条商品 */
  243. .goods-box-single {
  244. display: flex;
  245. padding: 20rpx 0;
  246. .goods-img {
  247. display: block;
  248. width: 170rpx;
  249. height: 170rpx;
  250. border-radius: 20rpx;
  251. }
  252. .right {
  253. flex: 1;
  254. display: flex;
  255. flex-direction: column;
  256. padding: 0 30rpx 0 24rpx;
  257. overflow: hidden;
  258. .flextop {
  259. align-items: flex-start;
  260. line-height: 1.3;
  261. }
  262. .row {
  263. margin-top: 10rpx;
  264. }
  265. .row_title {
  266. padding: 5rpx 10rpx;
  267. background-color: #dddddd;
  268. border-radius: 10rpx;
  269. font-size: 22rpx;
  270. color: #ffffff;
  271. }
  272. .title {
  273. font-size: $font-base + 2rpx;
  274. color: $font-color-dark;
  275. width: 80%;
  276. min-height: 2rem;
  277. }
  278. .attr-box {
  279. display: flex;
  280. justify-content: flex-end;
  281. font-size: $font-sm + 2rpx;
  282. color: $font-color-light;
  283. }
  284. .price {
  285. display: inline;
  286. font-size: $font-base + 2rpx;
  287. color: $font-color-light;
  288. &:before {
  289. content: '¥';
  290. font-size: $font-sm;
  291. }
  292. }
  293. }
  294. }
  295. .price-box {
  296. display: flex;
  297. justify-content: flex-end;
  298. align-items: baseline;
  299. padding: 20rpx 30rpx;
  300. font-size: $font-sm + 2rpx;
  301. color: $font-color-light;
  302. .num {
  303. margin: 0 8rpx;
  304. color: $font-color-dark;
  305. }
  306. .price {
  307. font-size: $font-lg;
  308. color: $font-color-dark;
  309. &:before {
  310. content: '¥';
  311. font-size: $font-sm;
  312. margin: 0 2rpx 0 8rpx;
  313. }
  314. }
  315. }
  316. .action-box {
  317. display: flex;
  318. justify-content: flex-end;
  319. align-items: center;
  320. height: 100rpx;
  321. position: relative;
  322. padding-right: 30rpx;
  323. }
  324. .action-btn {
  325. width: 160rpx;
  326. height: 60rpx;
  327. margin: 0;
  328. margin-left: 24rpx;
  329. padding: 0;
  330. text-align: center;
  331. line-height: 60rpx;
  332. font-size: $font-sm + 2rpx;
  333. color: $font-color-dark;
  334. background: #fff;
  335. border-radius: 100px;
  336. &.btn-red {
  337. color: $color-red;
  338. border: 1px solid $color-red;
  339. }
  340. &.btn-base {
  341. color: $base-color;
  342. border: 1px solid $base-color;
  343. }
  344. &:after {
  345. border-radius: 100px;
  346. }
  347. &.recom {
  348. color: $base-color;
  349. &:after {
  350. border-color: $base-color;
  351. }
  352. }
  353. &.evaluate {
  354. color: $color-yellow;
  355. &:after {
  356. border-color: $color-yellow;
  357. }
  358. }
  359. }
  360. }
  361. .top-tit {
  362. width: 750rpx;
  363. background-color: rgba(108, 217, 192, 0.4);
  364. padding: 10rpx;
  365. .tit {
  366. font-size: 28rpx;
  367. border-radius: 5rpx;
  368. padding: 10rpx;
  369. }
  370. .xf {
  371. font-size: 32rpx;
  372. padding-right: 30rpx;
  373. }
  374. }
  375. .navbar {
  376. display: flex;
  377. height: 40px;
  378. padding: 0 5px;
  379. background: #fff;
  380. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  381. position: relative;
  382. z-index: 10;
  383. margin-bottom: 20rpx;
  384. .nav-item {
  385. flex: 1;
  386. display: flex;
  387. justify-content: center;
  388. align-items: center;
  389. height: 100%;
  390. font-size: 15px;
  391. color: $font-color-dark;
  392. position: relative;
  393. &.current {
  394. color: $base-color;
  395. &:after {
  396. content: '';
  397. position: absolute;
  398. left: 50%;
  399. bottom: 0;
  400. transform: translateX(-50%);
  401. width: 44px;
  402. height: 0;
  403. border-bottom: 2px solid $base-color;
  404. }
  405. }
  406. }
  407. }
  408. </style>