index.vue 8.3 KB

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