index.vue 8.4 KB

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