index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view>
  3. <view class="wrap">
  4. <view class="u-tabs-box">
  5. <u-tabs activeColor="#f29100" ref="tabs" :list="list" :current="current" @change="change" :is-scroll="false"
  6. swiperWidth="750"></u-tabs>
  7. </view>
  8. <swiper class="swiper-box" :current="swiperCurrent" @animationfinish="animationfinish">
  9. <swiper-item class="swiper-item" v-for="(orderlist, index) in orderList" :key="index">
  10. <scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom"
  11. v-if="orderlist.length !== 0">
  12. <view class="page-box">
  13. <view class="order" v-for="(res, index) in orderlist" :key="res.id">
  14. <view class="top">
  15. <view class="left">
  16. <u-icon name="home" :size="30" color="rgb(94,94,94)"></u-icon>
  17. <view class="store">{{ res.store }}</view>
  18. <u-icon name="arrow-right" color="rgb(203,203,203)" :size="26"></u-icon>
  19. </view>
  20. <view class="right">{{ res.deal }}</view>
  21. </view>
  22. <view class="item" v-for="(item, index) in res.goodsList" :key="index">
  23. <view class="left">
  24. <image :src="item.goodsUrl" mode="aspectFill"></image>
  25. </view>
  26. <view class="content">
  27. <view class="title u-line-2">{{ item.title }}</view>
  28. <view class="type">{{ item.type }}</view>
  29. <view class="delivery-time">发货时间 {{ item.deliveryTime }}</view>
  30. </view>
  31. <view class="right">
  32. <view class="price">
  33. ¥{{ priceInt(item.price) }}
  34. <text class="decimal">.{{ priceDecimal(item.price) }}</text>
  35. </view>
  36. <view class="number">x{{ item.number }}</view>
  37. </view>
  38. </view>
  39. <view class="total">
  40. 共{{ totalNum(res.goodsList) }}件商品 合计:
  41. <text class="total-price">
  42. ¥{{ priceInt(totalPrice(res.goodsList)) }}.
  43. <text class="decimal">{{ priceDecimal(totalPrice(res.goodsList)) }}</text>
  44. </text>
  45. </view>
  46. <view class="bottom">
  47. <view class="more"><u-icon name="more-dot-fill" color="rgb(203,203,203)"></u-icon>
  48. </view>
  49. <view class="logistics btn">查看物流</view>
  50. <view class="exchange btn">卖了换钱</view>
  51. <view class="evaluate btn">评价</view>
  52. </view>
  53. </view>
  54. <u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore>
  55. </view>
  56. </scroll-view>
  57. <scroll-view scroll-y style="height: 100%;width: 100%;" v-else>
  58. <view class="page-box">
  59. <view>
  60. <view class="centre">
  61. <image src="https://cdn.uviewui.com/uview/template/taobao-order.png" mode=""></image>
  62. <view class="explain">
  63. 您还没有相关的订单
  64. <view class="tips">可以去看看有那些想买的</view>
  65. </view>
  66. <view class="btn">随便逛逛</view>
  67. </view>
  68. </view>
  69. </view>
  70. </scroll-view>
  71. </swiper-item>
  72. </swiper>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. export default {
  78. data() {
  79. return {
  80. orderList: [[], [], [], []],
  81. dataList: [
  82. {
  83. id: 1,
  84. store: '夏日流星限定贩卖',
  85. deal: '交易成功',
  86. goodsList: [
  87. {
  88. goodsUrl: '//img13.360buyimg.com/n7/jfs/t1/103005/7/17719/314825/5e8c19faEb7eed50d/5b81ae4b2f7f3bb7.jpg',
  89. title: '【冬日限定】现货 原创jk制服女2020冬装新款小清新宽松软糯毛衣外套女开衫短款百搭日系甜美风',
  90. type: '灰色;M',
  91. deliveryTime: '付款后30天内发货',
  92. price: '348.58',
  93. number: 2
  94. },
  95. {
  96. goodsUrl: '//img12.360buyimg.com/n7/jfs/t1/102191/19/9072/330688/5e0af7cfE17698872/c91c00d713bf729a.jpg',
  97. title: '【葡萄藤】现货 小清新学院风制服格裙百褶裙女短款百搭日系甜美风原创jk制服女2020新款',
  98. type: '45cm;S',
  99. deliveryTime: '付款后30天内发货',
  100. price: '135.00',
  101. number: 1
  102. }
  103. ]
  104. },
  105. {
  106. id: 2,
  107. store: '江南皮革厂',
  108. deal: '交易失败',
  109. goodsList: [
  110. {
  111. goodsUrl: '//img14.360buyimg.com/n7/jfs/t1/60319/15/6105/406802/5d43f68aE9f00db8c/0affb7ac46c345e2.jpg',
  112. title: '【冬日限定】现货 原创jk制服女2020冬装新款小清新宽松软糯毛衣外套女开衫短款百搭日系甜美风',
  113. type: '粉色;M',
  114. deliveryTime: '付款后7天内发货',
  115. price: '128.05',
  116. number: 1
  117. }
  118. ]
  119. },
  120. {
  121. id: 3,
  122. store: '三星旗舰店',
  123. deal: '交易失败',
  124. goodsList: [
  125. {
  126. goodsUrl: '//img11.360buyimg.com/n7/jfs/t1/94448/29/2734/524808/5dd4cc16E990dfb6b/59c256f85a8c3757.jpg',
  127. title: '三星(SAMSUNG)京品家电 UA65RUF70AJXXZ 65英寸4K超高清 HDR 京东微联 智能语音 教育资源液晶电视机',
  128. type: '4K,广色域',
  129. deliveryTime: '保质5年',
  130. price: '1998',
  131. number: 3
  132. },
  133. {
  134. goodsUrl: '//img14.360buyimg.com/n7/jfs/t6007/205/4099529191/294869/ae4e6d4f/595dcf19Ndce3227d.jpg!q90.jpg',
  135. title: '美的(Midea)639升 对开门冰箱 19分钟急速净味 一级能效冷藏双开门杀菌智能家用双变频节能 BCD-639WKPZM(E)',
  136. type: '容量大,速冻',
  137. deliveryTime: '保质5年',
  138. price: '2354',
  139. number: 1
  140. }
  141. ]
  142. },
  143. {
  144. id: 4,
  145. store: '三星旗舰店',
  146. deal: '交易失败',
  147. goodsList: [
  148. {
  149. goodsUrl: '//img10.360buyimg.com/n7/jfs/t22300/31/1505958241/171936/9e201a89/5b2b12ffNe6dbb594.jpg!q90.jpg',
  150. title: '法国进口红酒 拉菲(LAFITE)传奇波尔多干红葡萄酒750ml*6整箱装',
  151. type: '4K,广色域',
  152. deliveryTime: '珍藏10年好酒',
  153. price: '1543',
  154. number: 3
  155. },
  156. {
  157. goodsUrl: '//img10.360buyimg.com/n7/jfs/t1/107598/17/3766/525060/5e143aacE9a94d43c/03573ae60b8bf0ee.jpg',
  158. title: '蓝妹(BLUE GIRL)酷爽啤酒 清啤 原装进口啤酒 罐装 500ml*9听 整箱装',
  159. type: '一打',
  160. deliveryTime: '口感好',
  161. price: '120',
  162. number: 1
  163. }
  164. ]
  165. },
  166. {
  167. id: 5,
  168. store: '三星旗舰店',
  169. deal: '交易成功',
  170. goodsList: [
  171. {
  172. goodsUrl: '//img12.360buyimg.com/n7/jfs/t1/52408/35/3554/78293/5d12e9cfEfd118ba1/ba5995e62cbd747f.jpg!q90.jpg',
  173. title: '企业微信 中控人脸指纹识别考勤机刷脸机 无线签到异地多店打卡机WX108',
  174. type: '识别效率高',
  175. deliveryTime: '使用方便',
  176. price: '451',
  177. number: 9
  178. }
  179. ]
  180. }
  181. ],
  182. list: [
  183. {name: '待付款'},
  184. {name: '待发货'},
  185. {name: '待收货'},
  186. {name: '待评价',count: 12}
  187. ],
  188. current: 0,
  189. swiperCurrent: 0,
  190. loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore'],
  191. };
  192. },
  193. onLoad() {
  194. this.getOrderList(0);
  195. this.getOrderList(1);
  196. this.getOrderList(3);
  197. },
  198. computed: {
  199. // 价格小数
  200. priceDecimal() {
  201. return val => {
  202. if (val !== parseInt(val)) return val.slice(-2);
  203. else return '00';
  204. };
  205. },
  206. // 价格整数
  207. priceInt() {
  208. return val => {
  209. if (val !== parseInt(val)) return val.split('.')[0];
  210. else return val;
  211. };
  212. }
  213. },
  214. methods: {
  215. // 触底懒加载
  216. reachBottom() {
  217. this.loadStatus.splice(this.current, 1, "loading")
  218. setTimeout(() => {
  219. this.getOrderList(this.current);
  220. }, 1200);
  221. },
  222. // 页面数据
  223. getOrderList(idx) {
  224. // 模拟第n个页面获取数据
  225. for (let i = 0; i < 5; i++) {
  226. let index = this.$u.random(0, this.dataList.length - 1);
  227. let data = JSON.parse(JSON.stringify(this.dataList[index]));
  228. data.id = this.$u.guid();
  229. this.orderList[idx].push(data);
  230. }
  231. this.loadStatus.splice(this.current, 1, "loadmore")
  232. },
  233. // 总价
  234. totalPrice(item) {
  235. let price = 0;
  236. item.map(val => {
  237. price += parseFloat(val.price);
  238. });
  239. return price.toFixed(2);
  240. },
  241. // 总件数
  242. totalNum(item) {
  243. let num = 0;
  244. item.map(val => {
  245. num += val.number;
  246. });
  247. return num;
  248. },
  249. // tab栏切换
  250. change({ index }) {
  251. this.swiperCurrent = index;
  252. this.getOrderList(index);
  253. },
  254. animationfinish({ detail: { current } }) {
  255. this.swiperCurrent = current;
  256. this.current = current;
  257. }
  258. }
  259. };
  260. </script>
  261. <style>
  262. /* #ifndef H5 */
  263. page {
  264. height: 100%;
  265. background-color: #f2f2f2;
  266. }
  267. /* #endif */
  268. </style>
  269. <style lang="scss" scoped>
  270. .order {
  271. width: 710rpx;
  272. background-color: #ffffff;
  273. margin: 20rpx auto;
  274. border-radius: 20rpx;
  275. box-sizing: border-box;
  276. padding: 20rpx;
  277. font-size: 28rpx;
  278. .top {
  279. display: flex;
  280. justify-content: space-between;
  281. .left {
  282. display: flex;
  283. align-items: center;
  284. .store {
  285. margin: 0 10rpx;
  286. font-size: 32rpx;
  287. font-weight: bold;
  288. }
  289. }
  290. .right {
  291. color: $u-warning-dark;
  292. }
  293. }
  294. .item {
  295. display: flex;
  296. margin: 20rpx 0 0;
  297. .left {
  298. margin-right: 20rpx;
  299. image {
  300. width: 200rpx;
  301. height: 200rpx;
  302. border-radius: 10rpx;
  303. }
  304. }
  305. .content {
  306. .title {
  307. font-size: 28rpx;
  308. line-height: 50rpx;
  309. }
  310. .type {
  311. margin: 10rpx 0;
  312. font-size: 24rpx;
  313. color: $u-tips-color;
  314. }
  315. .delivery-time {
  316. color: #e5d001;
  317. font-size: 24rpx;
  318. }
  319. }
  320. .right {
  321. margin-left: 10rpx;
  322. padding-top: 20rpx;
  323. text-align: right;
  324. .decimal {
  325. font-size: 24rpx;
  326. margin-top: 4rpx;
  327. }
  328. .number {
  329. color: $u-tips-color;
  330. font-size: 24rpx;
  331. }
  332. }
  333. }
  334. .total {
  335. margin-top: 20rpx;
  336. text-align: right;
  337. font-size: 24rpx;
  338. .total-price {
  339. font-size: 32rpx;
  340. }
  341. }
  342. .bottom {
  343. display: flex;
  344. margin-top: 40rpx;
  345. padding: 0 10rpx;
  346. justify-content: space-between;
  347. align-items: center;
  348. .btn {
  349. line-height: 52rpx;
  350. width: 160rpx;
  351. border-radius: 26rpx;
  352. border: 2rpx solid $u-border-color;
  353. font-size: 26rpx;
  354. text-align: center;
  355. color: $u-info-dark;
  356. }
  357. .evaluate {
  358. color: $u-warning-dark;
  359. border-color: $u-warning-dark;
  360. }
  361. }
  362. }
  363. .centre {
  364. text-align: center;
  365. margin: 200rpx auto;
  366. font-size: 32rpx;
  367. image {
  368. width: 164rpx;
  369. height: 164rpx;
  370. border-radius: 50%;
  371. margin-bottom: 20rpx;
  372. }
  373. .tips {
  374. font-size: 24rpx;
  375. color: #999999;
  376. margin-top: 20rpx;
  377. }
  378. .btn {
  379. margin: 80rpx auto;
  380. width: 200rpx;
  381. border-radius: 32rpx;
  382. line-height: 64rpx;
  383. color: #ffffff;
  384. font-size: 26rpx;
  385. background: linear-gradient(270deg, rgba(249, 116, 90, 1) 0%, rgba(255, 158, 1, 1) 100%);
  386. }
  387. }
  388. .wrap {
  389. display: flex;
  390. flex-direction: column;
  391. height: calc(100vh - var(--window-top));
  392. width: 100%;
  393. }
  394. .swiper-box {
  395. flex: 1;
  396. }
  397. .swiper-item {
  398. height: 100%;
  399. }
  400. </style>