orderForm.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <view>
  3. <u-navbar @leftClick="rightClick" bgColor="#f4f4f4">
  4. <view class="tab" slot="center">
  5. <view
  6. style="
  7. width: 450rpx;
  8. margin-right: 150rpx;
  9. background-color: #fff;
  10. border-radius: 50rpx;
  11. "
  12. >
  13. <u--input
  14. placeholder="搜索我的订单"
  15. border="surround"
  16. shape="circle"
  17. v-model="keywords"
  18. @change="searchOrder"
  19. class="inp"
  20. ></u--input>
  21. </view>
  22. </view>
  23. </u-navbar>
  24. <view class="content">
  25. <view class="top-tab">
  26. <view
  27. :class="{ commodity: follow == '' }"
  28. class="tab"
  29. @click="tabSwitch('')"
  30. >
  31. 全部
  32. </view>
  33. <view
  34. :class="{ commodity: follow == 'unpaid' }"
  35. class="tab"
  36. @click="tabSwitch('unpaid')"
  37. >
  38. 待付款
  39. </view>
  40. <view
  41. :class="{ commodity: follow == 'unreview' }"
  42. class="tab"
  43. @click="tabSwitch('unreview')"
  44. >
  45. 拼团中
  46. </view>
  47. <view
  48. :class="{ commodity: follow == 'undelivered' }"
  49. class="tab"
  50. @click="tabSwitch('undelivered')"
  51. >
  52. 待发货
  53. </view>
  54. <view
  55. :class="{ commodity: follow == 'delivered' }"
  56. class="tab"
  57. @click="tabSwitch('delivered')"
  58. >
  59. 待收货
  60. </view>
  61. <view
  62. :class="{ commodity: follow == 'finished' }"
  63. class="tab"
  64. @click="tabSwitch('finished')"
  65. >
  66. 已完成
  67. </view>
  68. <view
  69. :class="{ commodity: follow == 'closed' }"
  70. class="tab"
  71. @click="tabSwitch('closed')"
  72. >
  73. 已取消
  74. </view>
  75. <view
  76. :class="{ commodity: follow == 'refund' }"
  77. class="tab"
  78. @click="tabSwitch('refund')"
  79. >
  80. 退款/售后
  81. </view>
  82. </view>
  83. <view v-for="(item, index) in orderList" :key="index">
  84. <view v-if="follow != 'refund'">
  85. <OrderInofrmation
  86. :itemInfo="item"
  87. @toDetail="toDetail"
  88. @cancellationOrder="cancellationOrder"
  89. @confirm="confirm"
  90. @toPay="toPay"
  91. @toEvaluate="toEvaluate"
  92. @unreviewAfter="unreviewAfter"
  93. />
  94. </view>
  95. <view v-else>
  96. <RefundCard
  97. :itemInfo="item"
  98. :refundDetail="refundDetail"
  99. @toRefundDetail="toRefundDetail"
  100. @unreviewAfter="unreviewAfter"
  101. />
  102. </view>
  103. </view>
  104. </view>
  105. <AgreePopup :agreeShow="agreeShow" @close="close" :title="title" />
  106. </view>
  107. </template>
  108. <script>
  109. import OrderInofrmation from "./component/orderInofrmation.vue";
  110. import RefundCard from "./component/refundCard.vue";
  111. import AgreePopup from "../mineComponent/agreePopup.vue";
  112. export default {
  113. components: {
  114. OrderInofrmation,
  115. RefundCard,
  116. AgreePopup,
  117. },
  118. data() {
  119. return {
  120. orderList: [],
  121. follow: "",
  122. refundDetail: {
  123. status: 1,
  124. },
  125. page: 1,
  126. total: 0,
  127. status: "",
  128. agreeShow: false,
  129. title: "",
  130. cancellation: {},
  131. keywords: "", //搜索关键字
  132. };
  133. },
  134. computed: {
  135. i18n() {
  136. return this.$t("index");
  137. },
  138. },
  139. onLoad(option) {
  140. this.follow = option.followId;
  141. },
  142. methods: {
  143. rightClick() {
  144. console.log(111);
  145. uni.switchTab({
  146. url: "/pages/mine/mine",
  147. });
  148. },
  149. //切换搜索订单状态
  150. tabSwitch(num) {
  151. this.page = 1;
  152. this.follow = num;
  153. this.getOrderList(1);
  154. },
  155. //跳转订单详情
  156. toDetail(value) {
  157. uni.navigateTo({
  158. url: `/pageC/orderFormDetail/orderFormDetail?orderId=${value.order.id}`,
  159. });
  160. },
  161. //跳转评价
  162. toEvaluate(value) {
  163. uni.navigateTo({
  164. url: `/pageD/evaluate/evaluate?orderId=${value.order.id}`,
  165. });
  166. },
  167. //拼团中售后
  168. unreviewAfter(value) {
  169. uni.navigateTo({
  170. url: `/pageC/applicationRefund/applicationRefund?orderId=${value.id}`,
  171. });
  172. },
  173. //确认收货
  174. confirm(value) {
  175. this.agreeShow = true;
  176. this.title = "是否确认收货";
  177. this.cancellation = value;
  178. },
  179. //跳转支付
  180. toPay(value) {
  181. uni.navigateTo({
  182. url: `/pageA/payorder?sum=${value.order.amount}&orderid=${value.order.id}`,
  183. });
  184. },
  185. //关闭确认弹窗
  186. close(value) {
  187. this.agreeShow = false;
  188. if (value) {
  189. if (this.title == "是否确认取消订单") {
  190. uni.$u.http
  191. .post(`/api/order/cancel/${this.cancellation.order.id}`)
  192. .then((res) => {
  193. uni.showToast({
  194. title: "订单已取消",
  195. icon: "none",
  196. });
  197. this.getOrderList(1);
  198. });
  199. } else if (this.title == "是否确认收货") {
  200. uni.$u.http
  201. .post(`/api/order/receive/${this.cancellation.order.id}`)
  202. .then((res) => {
  203. uni.showToast({
  204. title: "订单已收货",
  205. icon: "none",
  206. });
  207. this.getOrderList(1);
  208. });
  209. }
  210. }
  211. },
  212. //搜索
  213. searchOrder(e) {
  214. this.keywords = e;
  215. console.log(e);
  216. this.getOrderList(1);
  217. },
  218. //取消订单
  219. cancellationOrder(item) {
  220. this.agreeShow = true;
  221. this.cancellation = item;
  222. this.title = "是否确认取消订单";
  223. // uni.$u.http.post(`/api/order/cancel/${item.order.id}`).then((res) => {
  224. // console.log(res);
  225. // });
  226. },
  227. //售后订单详情
  228. toRefundDetail(value) {
  229. uni.navigateTo({
  230. url: `/pageC/refundDetail/refundDetail?orderId=${value.refund.id}`,
  231. });
  232. },
  233. getOrderList(value) {
  234. uni.$u.http
  235. .get(
  236. `/api/order/order_list?status=${this.follow}&page=${this.page}&limit=10&keywords=${this.keywords}`
  237. )
  238. .then((res) => {
  239. //确定是触底还是点击tab栏
  240. if (value) {
  241. this.orderList = res.data;
  242. } else {
  243. if (this.orderList.length == 0) {
  244. this.orderList = res.data;
  245. } else {
  246. this.orderList = this.orderList.concat(res.data);
  247. }
  248. }
  249. this.total = res.total;
  250. });
  251. },
  252. },
  253. onShow() {
  254. this.page = 0;
  255. this.getOrderList(1);
  256. },
  257. onReachBottom() {
  258. //商品总数量小于当前获取到的商品数量
  259. if (this.total > this.orderList.length) {
  260. this.page++;
  261. this.getOrderList(0);
  262. }
  263. },
  264. mounted() {},
  265. };
  266. </script>
  267. <style lang="scss" scoped>
  268. .inp {
  269. background-color: #fff;
  270. border-radius: 40rpx;
  271. width: 402rpx;
  272. padding: 0 20rpx;
  273. height: 68rpx;
  274. }
  275. .content {
  276. padding: 0 24rpx 50rpx;
  277. }
  278. .top-tab {
  279. margin-top: 180rpx;
  280. display: flex;
  281. justify-content: space-between;
  282. overflow-y: auto;
  283. // flex-shrink: 1;
  284. width: 100vw;
  285. .tab {
  286. margin-right: 40rpx;
  287. font-size: 26rpx;
  288. color: rgba(34, 34, 34, 0.8);
  289. flex-shrink: 0;
  290. height: 44rpx;
  291. display: flex;
  292. align-items: flex-end;
  293. }
  294. .commodity {
  295. position: relative;
  296. font-weight: 600;
  297. font-size: 32rpx;
  298. }
  299. .commodity::before {
  300. content: "";
  301. display: block;
  302. height: 8rpx;
  303. width: 100%;
  304. background: linear-gradient(to right, #f83224, #fff);
  305. position: absolute;
  306. bottom: 5rpx;
  307. opacity: 0.8;
  308. }
  309. }
  310. </style>