You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

282 lines
7.2 KiB

10 months ago
  1. <template>
  2. <view class="order">
  3. <view class="order-nav">
  4. <u-navbar :title="$t('page.order.myOrder')" @leftClick="leftClick()"></u-navbar>
  5. </view>
  6. <u-sticky>
  7. <view class="order-tabs">
  8. <u-tabs lineWidth="40" lineColor="#ED762F" @change="tabChange" :current="currentIndex"
  9. :list="classifyList"></u-tabs>
  10. </view>
  11. </u-sticky>
  12. <view v-if="!noOrder" class="order-list">
  13. <view v-for="(item,index) in productList" :key="index" class="order-item" v-if="item.state == currentIndex">
  14. <view class="order-item-top">
  15. <!-- <view class="order-time">
  16. {{ item.createTime }}
  17. </view> -->
  18. <text class="order-status">{{ classifyList[item.state].name }}</text>
  19. </view>
  20. <orderProductListVue :product="item"></orderProductListVue>
  21. <!-- <view class="order-bottom">TôngcÃng:<text class="total-price">5280.0</text>(baogòmcàvànchuyên¥0.0) -->
  22. <view class="order-bottom">{{ $t('page.order.total') }}:<text
  23. class="total-price">{{ item.sumPrice }}</text></view>
  24. <view class="btns">
  25. <view @click="toPayOrder(item)" v-if="currentIndex == 0" class="btn">
  26. {{ $t('page.order.immediatePayment') }}
  27. </view>
  28. <view @click="cancelOrder(item)" v-if="currentIndex == 0" class="btn">
  29. {{ $t('page.order.cancelOrder') }}
  30. </view>
  31. <view @click="confirmReceiptGoods(item)" v-if="currentIndex == 2" class="btn golden">
  32. {{ $t('page.order.confirm-receipt-goods') }}
  33. </view>
  34. <!-- <view v-if="currentIndex == 3" class="btn">{{ $t('page.order.repurchase') }}</view> -->
  35. <!-- <view v-if="currentIndex == 3" class="btn">{{ $t('page.order.deleteOrder') }}</view> -->
  36. <view @click="toOrderDetail(item.id)" class="btn">{{ $t('page.order.viewNow') }}</view>
  37. </view>
  38. </view>
  39. </view>
  40. <view v-else class="no-order">
  41. <view class="box">
  42. <view class="no-product-title">{{ $t('page.order.no-Order') }}</view>
  43. <view @click="toHome()" class="to-home">{{ $t('page.order.take-stroll')}}</view>
  44. </view>
  45. </view>
  46. <orderPanel :open.sync="orderPanenOpen" @definiteExecution="definiteExecution" @closePanel="closePanel"
  47. :title="panelTitle" :desc="panelDesc" :num="panelNum" :url="imageUrl"></orderPanel>
  48. </view>
  49. </template>
  50. <script>
  51. import orderProductListVue from '../../components/order-product/orderProductList.vue'
  52. import orderPanel from '../../components/order-panel/orderPanel.vue';
  53. import UniDateformat from '@/uni_modules/uni-dateformat/components/uni-dateformat/date-format.js'
  54. export default {
  55. components: {
  56. orderProductListVue,
  57. orderPanel,
  58. UniDateformat
  59. },
  60. data() {
  61. return {
  62. classifyList: [{
  63. name: this.$t('page.order.pendingPayment')
  64. },
  65. {
  66. name: this.$t('page.order.pendingShipment')
  67. },
  68. {
  69. name: this.$t('page.order.pendingReceipt')
  70. },
  71. {
  72. name: this.$t('page.order.completed')
  73. },
  74. ],
  75. productList: [],
  76. currentIndex: 0, //当前选择的标签index
  77. orderPanenOpen: false,
  78. panelTitle: '',
  79. panelDesc: '',
  80. panelNum: '',
  81. queryParams: {},
  82. typeGoods: '',
  83. noOrder: false,
  84. imageUrl : '',
  85. }
  86. },
  87. onShow() {
  88. this.getOrderList();
  89. this.currentIndex = localStorage.getItem('orderIndex') ?
  90. parseInt(localStorage.getItem('orderIndex')) : 0
  91. localStorage.removeItem('orderIndex')
  92. },
  93. methods: {
  94. getOrderList() { //获取订单列表
  95. this.request('getOrderPage', {}, this.queryParams).then(res => {
  96. this.productList = parseList(res.result.records);
  97. this.tabChange();
  98. })
  99. },
  100. tabChange(item) {
  101. if (item) {
  102. this.currentIndex = item.index
  103. }
  104. for (let i = 0; i < this.productList.length; i++) {
  105. if (parseInt(this.productList[i].state) === this.currentIndex) {
  106. return this.noOrder = false;
  107. }
  108. this.noOrder = true;
  109. }
  110. },
  111. toOrderDetail(id) {
  112. uni.navigateTo({
  113. url: '/pages/orderDetail/orderDetail?id=' + id
  114. })
  115. },
  116. toPayOrder(item) {
  117. uni.navigateTo({
  118. url: '/pages/payOrder/payOrder?id=' + item.id + '&quantity=' + item.num
  119. })
  120. },
  121. cancelOrder(item) { //取消订单
  122. this.panelTitle = this.$t('page.order.cancel-order-title')
  123. this.panelDesc = this.$t('page.order.cancel-order-desc')
  124. this.panelNum = this.$t('page.order.cancel-product-num')
  125. this.typeGoods = 'del'
  126. this.orderId = item.id
  127. this.imageUrl = item.image
  128. this.orderPanenOpen = true;
  129. },
  130. delOrder() {
  131. },
  132. confirmReceiptGoods(id) { //确认收货
  133. this.panelTitle = this.$t('page.order.confirm-receipt-goods-title')
  134. this.panelDesc = this.$t('page.order.confirm-receipt-goods-desc')
  135. this.panelNum = this.$t('page.order.confirm-product-num')
  136. this.typeGoods = 'confirm'
  137. this.orderId = item.id
  138. this.imageUrl = item.image
  139. this.orderPanenOpen = true;
  140. },
  141. leftClick() {
  142. uni.switchTab({
  143. url: '/pages/home/home'
  144. })
  145. },
  146. closePanel() {
  147. this.orderPanenOpen = false;
  148. },
  149. definiteExecution() {
  150. if (this.typeGoods == 'confirm') {
  151. this.request('confirm', {
  152. id: this.orderId
  153. }).then(res => {
  154. if (res.code == 200) {
  155. this.getOrderList();
  156. this.$MyToast(this.$t('page.order.success-operation'), {
  157. title: this.$t('myToactTitle'),
  158. icon: true //是否开启icon
  159. })
  160. this.orderPanenOpen = false;
  161. }
  162. })
  163. } else if (this.typeGoods == 'del') {
  164. this.request('delOrder', {
  165. id: this.orderId
  166. }).then(res => {
  167. if (res.code == 200) {
  168. this.getOrderList();
  169. this.$MyToast(this.$t('page.order.success-operation'), {
  170. title: this.$t('myToactTitle'),
  171. icon: true //是否开启icon
  172. })
  173. this.orderPanenOpen = false;
  174. }
  175. })
  176. }
  177. },
  178. toHome(){ //去首页
  179. uni.switchTab({
  180. url: '/pages/home/home'
  181. })
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .order {
  188. padding-bottom: 10px;
  189. &::v-deep .order-tabs {
  190. background: white;
  191. .u-tabs__wrapper__nav__item {
  192. flex: 1;
  193. }
  194. }
  195. .order-list {
  196. box-sizing: border-box;
  197. margin-top: 50px;
  198. .order-item {
  199. margin-top: 10px;
  200. background: white;
  201. padding: 10px;
  202. border-radius: 5px;
  203. .order-item-top {
  204. height: 70rpx;
  205. display: flex;
  206. align-items: center;
  207. justify-content: space-between;
  208. font-size: 26rpx;
  209. .order-time {
  210. color: #333333;
  211. }
  212. .order-status {
  213. color: #ED762F;
  214. }
  215. }
  216. .order-bottom {
  217. font-size: 26rpx;
  218. text-align: right;
  219. padding: 15rpx;
  220. }
  221. .btns {
  222. display: flex;
  223. justify-content: flex-end;
  224. .btn {
  225. display: flex;
  226. justify-content: center;
  227. align-items: center;
  228. box-sizing: border-box;
  229. padding: 10rpx 13rpx;
  230. border: 1px solid #ccc;
  231. border-radius: 100rpx;
  232. margin: 0px 5px;
  233. color: #333333;
  234. font-size: 22rpx;
  235. }
  236. .golden {
  237. color: #ED762F;
  238. border: 1px solid #ED762F;
  239. }
  240. }
  241. }
  242. }
  243. .no-order {
  244. height: calc(100vh - 138px);
  245. display: flex;
  246. align-items: center;
  247. justify-content: center;
  248. .box {
  249. font-size: 26rpx;
  250. text-align: center;
  251. .to-home {
  252. padding: 20rpx 140rpx;
  253. border: 1px solid #ccc;
  254. border-radius: 5px;
  255. text-align: center;
  256. margin: 20rpx 0px;
  257. }
  258. }
  259. }
  260. }
  261. </style>