index.vue 8.2 KB

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