index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view class="aaa">
  3. <u-navbar title="我的订单" @leftClick="back" :border="true" :placeholder="true" :autoBack="false"
  4. leftIconColor="#fff" bgColor="#E96737" />
  5. <view class="order">
  6. <view class="flex order-state-search">
  7. <u-tabs @change="changeTab" :scrollable="false" :list="statusArr" lineWidth="30" lineHeight="1"
  8. lineColor="#E96737" :activeStyle="{
  9. color: '#E96737',
  10. transform: 'scale(1)'
  11. }" :inactiveStyle="{
  12. color: '#333',
  13. transform: 'scale(1)'
  14. }" itemStyle="padding-left: 25px; padding-right: 25px; height: 44px;">
  15. </u-tabs>
  16. <view class="test"></view>
  17. </view>
  18. <view class="order-list">
  19. <view class="order-list-data">
  20. <view class="order-list-data-item" v-for="(item, index) in list" :key="index">
  21. <view class="order-list-data-item__info">
  22. <view class="flex order-list-data-item__info__title">
  23. <view class="number">
  24. <text>订单编号:</text>
  25. <text>{{ item.orderId }}</text>
  26. </view>
  27. <view class="success" v-if="item.status.value == 1">{{ item.status.desc }}</view>
  28. <view v-else>{{ item.status.desc }}</view>
  29. </view>
  30. <navigator :url="`/pages/order/detail?id=${ item.orderId }`" hover-class="navigator-hover">
  31. <view class="flex order-list-data-item__info__detail"
  32. v-for="(items, index) in item.items" :key="index">
  33. <view class="order-list-data-item__info__detail__left">
  34. <view class="img">
  35. <image class="img" :src="items.picUrl" mode="aspectFill">
  36. </image>
  37. </view>
  38. <view class="info">
  39. <text>{{ items.title }}</text>
  40. <text>面值:{{ $numberFormat(items.facePrice) }}元</text>
  41. <text>规格:{{ items.pkgUnit }}张/包 </text>
  42. </view>
  43. </view>
  44. <view class="order-list-data-item__info__detail__right">
  45. <text>¥{{ $numberFormat(items.pkgSalePrice) }}</text>
  46. <text>x {{ items.orderNum }}</text>
  47. </view>
  48. </view>
  49. </navigator>
  50. <view class="order-list-data-item__info__total">
  51. <view>共{{ item.pkgNum }}个票包</view>
  52. <view class="money">
  53. <text>实付:</text>
  54. <text>¥{{ $numberFormat(item.payAmt) }}</text>
  55. </view>
  56. </view>
  57. <view class="order-list-data-item__info__btn" v-if="item.status.value == 0">
  58. <text @click="cancelOrder(item.orderId)">取消订单</text>
  59. <text @click="payOrder">去支付</text>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="flex empty" v-if="!list.length">
  65. <u-empty text="订单为空" mode="order" />
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import env from '../../config/env.js'
  73. import $http from '@/utils/request.js'
  74. export default {
  75. data() {
  76. return {
  77. loading: false,
  78. days: '1',
  79. pageNum: 1,
  80. total: 100,
  81. list: [],
  82. status: null,
  83. top: '',
  84. statusArr: [{
  85. name: '全部'
  86. }, {
  87. name: '待付款',
  88. }, {
  89. name: '待发货'
  90. }, {
  91. name: '已发货'
  92. }, ],
  93. backNum: ''
  94. };
  95. },
  96. onLoad(opthios) {
  97. this.backNum = opthios.back
  98. },
  99. onShow() {
  100. this.getList()
  101. },
  102. methods: {
  103. back() {
  104. if (this.backNum) {
  105. uni.navigateBack({
  106. delta: 2
  107. })
  108. } else {
  109. uni.navigateBack({
  110. delta: 1
  111. })
  112. }
  113. },
  114. getList(flag) {
  115. let data = {
  116. status: this.status
  117. }
  118. $http.post(`/api/v1/mp/channel/mall/order/list?pageNum=${ this.pageNum }&pageSize=15`,
  119. data).then(res => {
  120. console.log(res);
  121. if (res.code == 0) {
  122. res.rows.forEach(item => {
  123. let items = item.items
  124. items.forEach(item => {
  125. let picUrlArr = item.picUrl.split(',')
  126. item.picUrl = env.filePublic + picUrlArr[0]
  127. })
  128. item.status = JSON.parse(item.status)
  129. })
  130. this.total = res.total
  131. this.list = this.list.concat(res.rows)
  132. console.log(this.list);
  133. }
  134. })
  135. },
  136. cancelOrder(id) {
  137. $http.post('/api/v1/mp/channel/mall/order/cancel', {
  138. orderId: id
  139. }).then(res => {
  140. if (res.code == 0) {
  141. uni.$u.toast('订单取消成功');
  142. this.pageNum = 1
  143. this.list = []
  144. this.getList()
  145. }
  146. })
  147. },
  148. payOrder() {
  149. },
  150. changeTab(e) {
  151. if (e.index == 0) {
  152. this.status = null
  153. } else if (e.index == 1) {
  154. this.status = 0
  155. } else if (e.index == 2) {
  156. this.status = 1
  157. } else {
  158. this.status = 2
  159. }
  160. this.pageNum = 1
  161. this.list = []
  162. this.getList()
  163. },
  164. },
  165. onReachBottom() {
  166. console.log(111);
  167. // 判断是否有数据
  168. console.log(this.total);
  169. if (this.total >= this.pageNum * 15) {
  170. setTimeout(() => {
  171. ++this.pageNum
  172. this.getList()
  173. }, 500)
  174. } else {
  175. uni.$u.toast('没有更多数据了')
  176. }
  177. },
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. /deep/ .u-navbar__content__title.u-navbar__content__title {
  182. color: #FFFFFF;
  183. }
  184. </style>
  185. <style lang="scss" scoped>
  186. .order {
  187. padding-bottom: 40rpx;
  188. &-state-search {
  189. position: relative;
  190. width: 100%;
  191. position: fixed;
  192. z-index: 100;
  193. background-color: #FFFFFF;
  194. box-shadow: 0 5rpx 5rpx #ececec;
  195. }
  196. &-list {
  197. background-color: #F8F8F8;
  198. margin: 0rpx 10rpx 0;
  199. padding-top: 100rpx;
  200. &-data {
  201. navigator {
  202. margin-bottom: 10rpx;
  203. }
  204. navigator:last-child {
  205. margin-bottom: 0;
  206. }
  207. &-item {
  208. margin-bottom: 10rpx;
  209. padding: 20rpx 30rpx;
  210. background-color: #FFFFFF;
  211. justify-content: space-between;
  212. background-color: #FFFFFF;
  213. }
  214. &-item {
  215. &__info {
  216. &__title {
  217. justify-content: space-between;
  218. .number {
  219. line-height: 40rpx;
  220. }
  221. .success {
  222. color: $uni-text-color;
  223. }
  224. }
  225. &__detail {
  226. padding: 20rpx 0;
  227. justify-content: space-between;
  228. border-bottom: 1px solid rgba(236, 236, 236, 100);
  229. &__left {
  230. display: flex;
  231. height: 170rpx;
  232. .img {
  233. image {
  234. width: 134rpx;
  235. height: 170rpx;
  236. margin-right: 20rpx;
  237. }
  238. }
  239. .info {
  240. display: flex;
  241. flex-direction: column;
  242. justify-content: space-between;
  243. text {
  244. font-size: 24rpx;
  245. color: #9D9D9D;
  246. }
  247. text:first-child {
  248. color: rgba(16, 16, 16, 100);
  249. font-size: 28rpx;
  250. }
  251. }
  252. }
  253. &__right {
  254. display: flex;
  255. height: 170rpx;
  256. flex-direction: column;
  257. justify-content: space-between;
  258. align-items: flex-end;
  259. text:first-child {
  260. font-size: 32rpx;
  261. color: $uni-text-color;
  262. }
  263. }
  264. }
  265. &__detail:last-child {
  266. border: none;
  267. }
  268. &__total {
  269. display: flex;
  270. align-items: center;
  271. justify-content: flex-end;
  272. padding: 10rpx 0;
  273. .money {
  274. font-weight: bold;
  275. margin-left: 54rpx;
  276. }
  277. }
  278. &__btn {
  279. display: flex;
  280. align-items: center;
  281. justify-content: flex-end;
  282. padding-top: 10rpx;
  283. border-top: 1px solid rgba(236, 236, 236, 100);
  284. text {
  285. display: block;
  286. box-sizing: border-box;
  287. margin: 0 0 0 40rpx;
  288. width: 160rpx;
  289. height: 60rpx;
  290. line-height: 60rpx;
  291. text-align: center;
  292. font-size: 24rpx;
  293. border-radius: 8rpx;
  294. border: none;
  295. }
  296. text:first-child {
  297. background-color: #fff;
  298. line-height: 56rpx;
  299. border: 2rpx solid $uni-bg-color;
  300. }
  301. text:last-child {
  302. background-color: $uni-bg-color;
  303. color: #FFFFFF;
  304. }
  305. }
  306. }
  307. }
  308. }
  309. }
  310. .empty {
  311. height: 60vh;
  312. }
  313. }
  314. </style>