myCart.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <view class="content">
  3. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  4. <!-- 空白页 -->
  5. <!-- #ifdef H5 -->
  6. <empty src="../../../static/error/emptyMyCart.png" v-if="navList[0].loaded === true && navList[0].orderList.length === 0"></empty>
  7. <!-- #endif -->
  8. <!-- #ifndef H5 -->
  9. <empty src="../static/error/emptyMyCart.png" v-if="navList[0].loaded === true && navList[0].orderList.length === 0"></empty>
  10. <!-- #endif -->
  11. <!-- 订单列表 -->
  12. <view class="listItem" v-for="(item, index) in navList[0].orderList" :key='index'>
  13. <view v-if="item.day>0" class="topRightTip" @click="navTo('./Prepayment?id='+item.car_number)">
  14. <image src="../../../static/image/moneyPay.png" mode="widthFix"></image>
  15. </view>
  16. <view class="flex">
  17. <view class="imgbox">
  18. <image :src="item.image" mode="widthFix"></image>
  19. </view>
  20. <view class="contentDetail flex">
  21. <view class="goodsName">
  22. <view class="topName">
  23. {{item.car_name}}
  24. </view>
  25. <view class="goodsType">
  26. {{item.car_sku}}
  27. </view>
  28. <view class="goodsTime margin-t-10">
  29. 激活时间:{{item.bind_time}}
  30. </view>
  31. </view>
  32. <view class="goodsRight">
  33. <view class="status">
  34. 已授权
  35. </view>
  36. <navigator :url="'./authorizationList?id='+item.car_number">
  37. <view class="numR">
  38. {{item.auth_num}}
  39. </view>
  40. </navigator>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="address">
  45. 当前位置:{{item.address}}
  46. </view>
  47. <map @click="openMap(item.latitude,item.longitude)" class="map" :enable-zoom='false' :enable-scroll='false' :latitude="item.latitude" :longitude="item.longitude" :markers="[{
  48. latitude: item.latitude,
  49. longitude:item.longitude,
  50. iconPath: '../../../static/image/location.png',
  51. width:35,
  52. height:35
  53. }]"></map>
  54. <view class="detail flex">
  55. <view class="item">
  56. <view class="type">
  57. 剩余电量
  58. </view>
  59. <view class="num">
  60. {{item.residue}}%
  61. </view>
  62. </view>
  63. <view class="item">
  64. <view class="type">
  65. 剩余天数
  66. </view>
  67. <view class="num">
  68. {{item.day}}
  69. </view>
  70. </view>
  71. <!-- <view class="item">
  72. <view class="type">
  73. 总里程数
  74. </view>
  75. <view class="num">
  76. 200
  77. </view>
  78. </view> -->
  79. </view>
  80. <cartConfing @tab="changetab($event,item)" :item='item'></cartConfing>
  81. </view>
  82. <uni-load-more :status=" navList[0].loadingType"></uni-load-more>
  83. </scroll-view>
  84. </view>
  85. </template>
  86. <script>
  87. import cartConfing from './cartConfing.vue';
  88. import {
  89. carList,
  90. } from '@/api/user.js';
  91. export default {
  92. components: {
  93. cartConfing
  94. },
  95. data() {
  96. return {
  97. tabCurrentIndex: 0,
  98. navList: [{
  99. state: 0,
  100. text: '待付款',
  101. loadingType: 'more',
  102. orderList: [],
  103. page: 1, //当前页数
  104. limit: 10 //每次信息条数
  105. }]
  106. };
  107. },
  108. onLoad(options) {
  109. this.loadData();
  110. },
  111. methods: {
  112. // tab改变事件
  113. changetab(tab,item){
  114. item.status = tab
  115. },
  116. // 打开地图导航
  117. openMap(lat, long) {
  118. uni.openLocation({
  119. latitude: +lat,
  120. longitude: +long,
  121. complete(e){
  122. console.log(e,'地图打开');
  123. }
  124. })
  125. },
  126. navTo(url) {
  127. uni.navigateTo({
  128. url: url
  129. })
  130. },
  131. //获取列表
  132. loadData(source) {
  133. //这里是将订单挂载到tab列表下
  134. let index = this.tabCurrentIndex;
  135. let navItem = this.navList[index];
  136. if (source === 'tabChange' && navItem.loaded === true) {
  137. //tab切换只有第一次需要加载数据
  138. return;
  139. }
  140. if (navItem.loadingType === 'loading') {
  141. //防止重复加载
  142. return;
  143. }
  144. if (navItem.loadingType === 'noMore') {
  145. //防止重复加载
  146. return;
  147. }
  148. // 修改当前对象状态为加载中
  149. navItem.loadingType = 'loading';
  150. carList({
  151. page: navItem.page,
  152. limit: navItem.limit
  153. })
  154. .then(({
  155. data
  156. }) => {
  157. let arr = data.data.map(e => {
  158. return e;
  159. });
  160. navItem.orderList = navItem.orderList.concat(arr);
  161. navItem.page++;
  162. if (navItem.limit == arr.length) {
  163. //判断是否还有数据, 有改为 more, 没有改为noMore
  164. navItem.loadingType = 'more';
  165. return;
  166. } else {
  167. //判断是否还有数据, 有改为 more, 没有改为noMore
  168. navItem.loadingType = 'noMore';
  169. }
  170. uni.hideLoading();
  171. this.$set(navItem, 'loaded', true);
  172. })
  173. .catch(e => {
  174. console.log(e);
  175. });
  176. },
  177. }
  178. };
  179. </script>
  180. <style lang="scss">
  181. page,
  182. .content {
  183. height: 100%;
  184. }
  185. .list-scroll-content {
  186. padding-top: 30rpx;
  187. height: 100%;
  188. }
  189. .listItem {
  190. margin: 0rpx 20rpx 30rpx;
  191. border-radius: 20rpx;
  192. padding: 30rpx;
  193. background-color: #FFFFFF;
  194. position: relative;
  195. overflow: hidden;
  196. .topRightTip {
  197. position: absolute;
  198. top: 0;
  199. right: 0;
  200. image {
  201. width: 80rpx;
  202. }
  203. }
  204. .imgbox {
  205. width: 160rpx;
  206. height: 160rpx;
  207. border-radius: 20rpx;
  208. image {
  209. width: 100%;
  210. height: 100%;
  211. }
  212. }
  213. .contentDetail {
  214. padding-left: 30rpx;
  215. flex-grow: 1;
  216. .goodsName {
  217. .topName {
  218. color: $font-color-dark;
  219. font-size: 32rpx;
  220. font-weight: bold;
  221. margin-bottom: 30rpx;
  222. }
  223. .goodsType,
  224. .goodsTime {
  225. color: $font-color-light;
  226. font-size: 24rpx;
  227. }
  228. }
  229. }
  230. .map {
  231. width: 630rpx;
  232. height: 200rpx;
  233. font-size: 35rpx;
  234. }
  235. .goodsRight {
  236. flex-shrink: 0;
  237. .status {
  238. color: $font-color-light;
  239. font-size: 24rpx;
  240. }
  241. .numR {
  242. height: 60rpx;
  243. width: 60rpx;
  244. border-radius: 10rpx;
  245. border: 1px solid $color-green;
  246. line-height: 60rpx;
  247. font-size: 32rpx;
  248. color: $color-green;
  249. text-align: center;
  250. margin: 0 auto;
  251. margin-top: 20rpx;
  252. }
  253. }
  254. .address {
  255. color: $font-color-light;
  256. font-size: 24rpx;
  257. line-height: 1;
  258. padding: 30rpx 0;
  259. }
  260. .detail {
  261. margin-top: 30rpx;
  262. padding: 0 20rpx;
  263. justify-content: space-around;
  264. .item {
  265. color: $font-color-light;
  266. text-align: center;
  267. line-height: 1.5;
  268. .type {
  269. font-size: 24rpx;
  270. }
  271. .num {
  272. font-size: 32rpx;
  273. }
  274. }
  275. }
  276. }
  277. </style>