myOrder.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="my__order">
  3. <view class="my__order-tabs">
  4. <u-tabs :list="list1" @change='changeTab' :scrollable="false" lineWidth="63"
  5. :activeStyle="{ color: '#4C96FF',}" :inactiveStyle="{color: '#626066',}"
  6. itemStyle=" height: 44px;"></u-tabs>
  7. </view>
  8. <view class="my__order-content">
  9. <view class="order_item" v-for="(item,index) in data" :key="index" @click="handleOrder(item.id)">
  10. <view class="item-top">
  11. <view class="time">下单时间:{{item.createTime}}</view>
  12. <view class="status" :style="{color:formatStatus(item.orderStatus).color}">
  13. {{formatStatus(item.orderStatus).name}}
  14. </view>
  15. </view>
  16. <view class="item-cnetent">
  17. <image class="order__ok-img" :src="item.productImages[0]"></image>
  18. <view class="order_info">
  19. <view>
  20. <view class="info-1">{{item.productName}}</view>
  21. <view class="info-2">{{item.productDesc}}</view>
  22. </view>
  23. <view class="num">
  24. <u-icon name="close" color="#606266" size="14"></u-icon>
  25. <text>{{item.tradeCount}}</text>
  26. </view>
  27. <view class="img-jiaoluo">
  28. <image src="../../../static/jiaoluo.png" mode=""></image>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="line" style="margin-top: 30px;">
  35. <u-loadmore loadmoreText="没有更多了" line />
  36. </view>
  37. <view class="footer">
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. getOrderList,
  44. } from '@/api/goods.js'
  45. export default {
  46. onLoad() {
  47. if (this.type != 2) {
  48. this.fetchData()
  49. }
  50. // this.fetchData()
  51. },
  52. onShow() {
  53. const app = getApp();
  54. let type = JSON.parse(JSON.stringify(app.globalData.type));
  55. app.globalData.type = null
  56. this.type = type
  57. if (this.type == 2) {
  58. this.searchData.pageNum = 1
  59. this.data = []
  60. this.fetchData()
  61. }
  62. },
  63. onReachBottom() {
  64. const {
  65. total,
  66. searchData: {
  67. pageNum,
  68. pageSize
  69. }
  70. } = this
  71. if (total <= (pageNum - 1) * pageSize) {
  72. return uni.$u.toast('没有更多了')
  73. }
  74. if (this.isLoading) return
  75. this.fetchData()
  76. },
  77. data() {
  78. return {
  79. type: '', //判断是否是取消返回
  80. isLoading: false,
  81. searchData: {
  82. data: {},
  83. pageNum: 1, // 页码
  84. pageSize: 10 // 每页条数
  85. },
  86. total: 0,
  87. data: [],
  88. list1: [{
  89. name: '全部',
  90. // orderStatus: 4
  91. }, {
  92. name: '待处理',
  93. orderStatus: 0,
  94. color: '#FFA133',
  95. }, {
  96. name: '已接单',
  97. orderStatus: 1,
  98. color: '#24C8DE;',
  99. }, {
  100. name: '已发货',
  101. orderStatus: 2,
  102. color: '#3E8DFF',
  103. }, {
  104. name: '已取消',
  105. orderStatus: 3,
  106. color: '#7F8696',
  107. }]
  108. };
  109. },
  110. methods: {
  111. formatStatus(type) {
  112. const value = this.list1.find(item => item.orderStatus == type)
  113. return {
  114. name: value.name,
  115. color: value.color
  116. }
  117. },
  118. // 获取列表
  119. async fetchData() {
  120. uni.showLoading({
  121. title: '加载中...',
  122. icon: 'loading',
  123. mask: true
  124. })
  125. this.isLoading = true
  126. try {
  127. const res = await getOrderList(this.searchData)
  128. uni.hideLoading()
  129. // console.log(res, 8787);
  130. if (res.data.list && res.data.list.length > 0) {
  131. this.data = [...this.data, ...res.data.list]
  132. }
  133. this.total = res.data.total
  134. this.searchData.pageNum++
  135. } finally {
  136. this.isLoading = false
  137. uni.hideLoading()
  138. }
  139. },
  140. changeTab(item) {
  141. // console.log(item)
  142. // this.data = this.list.filter(v => {
  143. // return item.orderStatus != 4 ? v.orderStatus == item.orderStatus : v
  144. // })
  145. // this.total = 0
  146. this.searchData.pageNum = 1
  147. this.searchData.data.orderStatus = item.orderStatus
  148. this.data = []
  149. this.fetchData()
  150. },
  151. handleOrder(id) {
  152. uni.navigateTo({
  153. url: `/pages/my/myOrderDetail/myOrderDetail?id=${id}`,
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang="scss" scoped>
  160. .my__order-tabs {
  161. background-color: #fff;
  162. position: sticky;
  163. top: 0;
  164. z-index: 99;
  165. }
  166. .my__order-content {
  167. padding: 0 12px;
  168. .order_item {
  169. background: #fff;
  170. padding: 12px 8px;
  171. margin-top: 14px;
  172. &:last-child {
  173. margin-bottom: 40px;
  174. }
  175. .item-top {
  176. display: flex;
  177. align-items: center;
  178. justify-content: space-between;
  179. margin-bottom: 7.5px;
  180. .time {
  181. color: #495B7D;
  182. font-size: 13px;
  183. font-weight: 500;
  184. }
  185. .status {
  186. padding: 0 6px;
  187. border-radius: 4px;
  188. background: #F0F8FF;
  189. height: 20px;
  190. line-height: 20px;
  191. font-size: 13px;
  192. }
  193. }
  194. .item-cnetent {
  195. display: flex;
  196. .order__ok-img {
  197. width: 90px;
  198. height: 90px;
  199. border-radius: 8px;
  200. }
  201. .order_info {
  202. margin-left: 12px;
  203. width: calc(100% - 102px);
  204. display: flex;
  205. flex-direction: column;
  206. justify-content: space-between;
  207. position: relative;
  208. .ellipsis {
  209. white-space: nowrap;
  210. text-overflow: ellipsis;
  211. overflow: hidden;
  212. margin-top: 4px;
  213. }
  214. .info-1 {
  215. color: #333;
  216. font-size: 17px;
  217. font-weight: 700;
  218. @extend .ellipsis
  219. }
  220. .info-2 {
  221. color: #606266;
  222. font-size: 13px;
  223. font-weight: 400;
  224. @extend .ellipsis
  225. }
  226. .num {
  227. color: #606266;
  228. font-size: 14px;
  229. font-weight: 500;
  230. display: flex;
  231. align-items: center;
  232. }
  233. .img-jiaoluo {
  234. width: 75px;
  235. height: 75px;
  236. position: absolute;
  237. right: -8px;
  238. bottom: -12px;
  239. image {
  240. width: 100%;
  241. height: 100%;
  242. object-fit: cover;
  243. }
  244. }
  245. }
  246. }
  247. }
  248. }
  249. .footer {
  250. height: 40px;
  251. }
  252. </style>
  253. </view>