order.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <!-- 页面 -->
  2. <template>
  3. <s-layout :title="$t('activity.groupon.my')">
  4. <su-sticky bgColor="#fff">
  5. <su-tabs
  6. :list="tabMaps"
  7. :scrollable="false"
  8. @change="onTabsChange"
  9. :current="state.currentTab"
  10. ></su-tabs>
  11. </su-sticky>
  12. <s-empty v-if="state.pagination.total === 0" icon="/static/goods-empty.png"> </s-empty>
  13. <view v-if="state.pagination.total > 0">
  14. <view
  15. class="order-list-card-box bg-white ss-r-10 ss-m-t-14 ss-m-20"
  16. v-for="order in state.pagination.data"
  17. :key="order.id"
  18. >
  19. <view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20">
  20. <view class="order-no">{{$t('activity.groupon.order_no')}}:{{ order.my.order.order_sn }}</view>
  21. <view
  22. class="ss-font-26"
  23. :class="
  24. order.status === 'ing'
  25. ? 'warning-color'
  26. : order.status === 'invalid'
  27. ? 'danger-color'
  28. : 'success-color'
  29. "
  30. >{{ order.status_text }}</view
  31. >
  32. </view>
  33. <view class="border-bottom">
  34. <s-goods-item
  35. :img="order.goods ? order.goods.image : order.my.order_item.goods_image"
  36. :title="order.goods ? order.goods.title : order.my.order_item.goods_title"
  37. :price="order.goods ? order.goods.price[0] : order.my.order_item.goods_price"
  38. priceColor="#E1212B"
  39. radius="20"
  40. >
  41. <template #groupon>
  42. <view class="ss-flex">
  43. <view class="sales-title"> {{ order.num }}{{$t('activity.groupon.detail.msg1')}} </view>
  44. <!-- <view class="num-title ss-m-l-20"> 已拼{{ order.goods.sales }}件 </view> -->
  45. </view>
  46. </template>
  47. </s-goods-item>
  48. </view>
  49. <view class="order-card-footer ss-flex ss-row-right ss-p-x-20">
  50. <button
  51. class="detail-btn ss-reset-button"
  52. @tap="sheep.$router.go('/pages/order/detail', { id: order.my.order_id })"
  53. >
  54. {{$t('activity.groupon.order_detail')}}
  55. </button>
  56. <button
  57. class="tool-btn ss-reset-button"
  58. :class="{ 'ui-BG-Main-Gradient': order.status === 'ing' }"
  59. @tap="sheep.$router.go('/pages/activity/groupon/detail', { id: order.id })"
  60. >
  61. {{ order.status === 'ing' ? $t('activity.groupon.inviteGroup') : $t('activity.groupon.detail') }}
  62. </button>
  63. </view>
  64. </view>
  65. </view>
  66. <uni-load-more
  67. v-if="state.pagination.total > 0"
  68. :status="state.loadStatus"
  69. :content-text="{
  70. contentdown: $t('activity.index.uploadMore'),
  71. }"
  72. @tap="loadmore"
  73. />
  74. </s-layout>
  75. </template>
  76. <script setup>
  77. import { computed, reactive } from 'vue';
  78. import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
  79. import sheep from '@/sheep';
  80. import _ from 'lodash';
  81. const pagination = {
  82. data: [],
  83. current_page: 1,
  84. total: 1,
  85. last_page: 1,
  86. };
  87. // 数据
  88. const state = reactive({
  89. currentTab: 0,
  90. pagination: {
  91. data: [],
  92. current_page: 1,
  93. total: 1,
  94. last_page: 1,
  95. },
  96. loadStatus: '',
  97. deleteOrderId: 0,
  98. });
  99. const tabMaps = [
  100. {
  101. name: $t('activity.groupon.type.all'),
  102. value: 'all',
  103. },
  104. {
  105. name: $t('activity.groupon.type.progress'),
  106. value: 'ing',
  107. },
  108. {
  109. name: $t('activity.groupon.type.success'),
  110. value: 'finish',
  111. },
  112. {
  113. name: $t('activity.groupon.type.failed'),
  114. value: 'invalid',
  115. },
  116. ];
  117. // 切换选项卡
  118. function onTabsChange(e) {
  119. state.pagination = pagination;
  120. state.currentTab = e.index;
  121. getGrouponList();
  122. }
  123. // 订单详情
  124. function onDetail(orderSN) {
  125. sheep.$router.go('/pages/order/detail', {
  126. orderSN,
  127. });
  128. }
  129. // 继续支付
  130. function onPay(orderSN) {
  131. sheep.$router.go('/pages/pay/index', {
  132. orderSN,
  133. });
  134. }
  135. // 评价
  136. function onComment(orderSN) {
  137. sheep.$router.go('/pages/order/comment/add', {
  138. orderSN,
  139. });
  140. }
  141. // 确认收货
  142. async function onConfirm(orderId) {
  143. const { code, data } = await sheep.$api.order.confirm(orderId);
  144. if (code === 1) {
  145. let index = state.pagination.data.findIndex((order) => order.id === orderId);
  146. state.pagination.data[index] = data;
  147. }
  148. }
  149. // 取消订单
  150. async function onCancel(orderId) {
  151. const { code, data } = await sheep.$api.order.cancel(orderId);
  152. if (code === 1) {
  153. let index = state.pagination.data.findIndex((order) => order.id === orderId);
  154. state.pagination.data[index] = data;
  155. }
  156. }
  157. // 获取订单列表
  158. async function getGrouponList(page = 1, list_rows = 5) {
  159. state.loadStatus = 'loading';
  160. let res = await sheep.$api.activity.myGroupon({
  161. type: tabMaps[state.currentTab].value,
  162. });
  163. if (res.code === 1) {
  164. let orderList = _.concat(state.pagination.data, res.data.data);
  165. state.pagination = {
  166. ...res.data,
  167. data: orderList,
  168. };
  169. if (state.pagination.current_page < state.pagination.last_page) {
  170. state.loadStatus = 'more';
  171. } else {
  172. state.loadStatus = 'noMore';
  173. }
  174. }
  175. }
  176. onLoad((options) => {
  177. if (options.type) {
  178. state.currentTab = options.type;
  179. }
  180. getGrouponList();
  181. });
  182. // 加载更多
  183. function loadmore() {
  184. if (state.loadStatus !== 'noMore') {
  185. getGrouponList(state.pagination.current_page + 1);
  186. }
  187. }
  188. // 上拉加载更多
  189. onReachBottom(() => {
  190. loadmore();
  191. });
  192. //下拉刷新
  193. onPullDownRefresh(() => {
  194. state.pagination = pagination;
  195. getGrouponList();
  196. setTimeout(function () {
  197. uni.stopPullDownRefresh();
  198. }, 800);
  199. });
  200. </script>
  201. <style lang="scss" scoped>
  202. .tool-btn {
  203. width: 160rpx;
  204. height: 60rpx;
  205. background: #f6f6f6;
  206. font-size: 26rpx;
  207. border-radius: 30rpx;
  208. margin-right: 10rpx;
  209. &:last-of-type {
  210. margin-right: 0;
  211. }
  212. }
  213. .swiper-box {
  214. flex: 1;
  215. .swiper-item {
  216. height: 100%;
  217. width: 100%;
  218. }
  219. }
  220. .order-list-card-box {
  221. .order-card-header {
  222. height: 80rpx;
  223. .order-no {
  224. font-size: 26rpx;
  225. font-weight: 500;
  226. }
  227. }
  228. .order-card-footer {
  229. height: 100rpx;
  230. .detail-btn {
  231. width: 210rpx;
  232. height: 66rpx;
  233. border: 2rpx solid #dfdfdf;
  234. border-radius: 33rpx;
  235. font-size: 26rpx;
  236. font-weight: 400;
  237. color: #999999;
  238. margin-right: 20rpx;
  239. }
  240. .tool-btn {
  241. width: 210rpx;
  242. height: 66rpx;
  243. border-radius: 33rpx;
  244. font-size: 26rpx;
  245. font-weight: 400;
  246. margin-right: 20rpx;
  247. background: #f6f6f6;
  248. }
  249. .invite-btn {
  250. width: 210rpx;
  251. height: 66rpx;
  252. background: linear-gradient(90deg, #fe832a, #ff6600);
  253. box-shadow: 0px 8rpx 6rpx 0px rgba(255, 104, 4, 0.22);
  254. border-radius: 33rpx;
  255. color: #fff;
  256. font-size: 26rpx;
  257. font-weight: 500;
  258. }
  259. }
  260. }
  261. .sales-title {
  262. height: 32rpx;
  263. background: rgba(#ffe0e2, 0.29);
  264. border-radius: 16rpx;
  265. font-size: 24rpx;
  266. font-weight: 400;
  267. padding: 6rpx 20rpx;
  268. color: #f7979c;
  269. }
  270. .num-title {
  271. font-size: 24rpx;
  272. font-weight: 400;
  273. color: #999999;
  274. }
  275. .warning-color {
  276. color: #faad14;
  277. }
  278. .danger-color {
  279. color: #ff3000;
  280. }
  281. .success-color {
  282. color: #52c41a;
  283. }
  284. </style>