index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <Navbar title="回购" fixed border>
  5. <template #right>
  6. <view class="nav_right" @click.stop="openAgreement">
  7. <trans _t="回购规则" />
  8. <up-icon
  9. name="question-circle"
  10. size="32rpx"
  11. color="var(--red)"
  12. class="icon"
  13. ></up-icon>
  14. </view>
  15. </template>
  16. </Navbar>
  17. <view class="content">
  18. <view class="cont_tab">
  19. <Tab
  20. :active="tabActive"
  21. :tabList="tabList"
  22. @confirm="tabConfirm"
  23. keyName="text"
  24. size="28rpx"
  25. />
  26. </view>
  27. <view class="cont">
  28. <view class="item" v-for="(item, index) in detials" :key="index">
  29. <view class="item-left">
  30. <view class="product">
  31. <image class="img" :src="item.pic_url"></image>
  32. </view>
  33. <view class="deatils">
  34. <view class="title">{{ item.orderNo }}</view>
  35. <view class="deatils_bottom">
  36. <view class="price"
  37. >{{ symbol.symbol }}&nbsp;{{ Moneyhtml(item.price) }}</view
  38. >
  39. <view class="item-right">
  40. <view
  41. class="btn"
  42. @click="buyBack(item)"
  43. v-if="tabActive == 0"
  44. >
  45. <trans _t="回购" />
  46. </view>
  47. <view
  48. class="btn"
  49. @click="writeLogistics(item)"
  50. v-if="tabActive == 1 && item.status == 1"
  51. >
  52. <trans _t="填写物流" />
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="null_warp" v-if="!detials.length">
  60. <view class="null_text">{{ t("无数据") }}</view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <buyBackModel ref="buyBackModelRef" :id="repoId" @submit="getData" />
  66. <logisticsModel ref="logisticsModelRef" @submit="getData" />
  67. <SimpleAgreementModal ref="agreementModalRef" />
  68. </Theme>
  69. </template>
  70. <script setup>
  71. import Navbar from "@/components/navbar";
  72. import { computed, ref, nextTick } from "vue";
  73. import { t } from "@/locale";
  74. import Tab from "@/components/tabs.vue";
  75. import { useSystemStore, useTabbarStore } from "@/store";
  76. import { Moneyhtml, Toast } from "@/utils";
  77. import { onShow } from "@dcloudio/uni-app";
  78. import { SHOP_BUYBACK_LISTS, SHOP_BUYBACK_ORDER } from "@/api";
  79. import buyBackModel from "./components/buyBackModel";
  80. import logisticsModel from "./components/logisticsModel";
  81. import SimpleAgreementModal from "@/components/simpleAgreementModal";
  82. const useTabbar = useTabbarStore();
  83. const useSystem = useSystemStore();
  84. const symbol = computed(() => useSystem.getSymbol);
  85. const tabActive = ref(0);
  86. const tabList = [
  87. { text: "可回购" },
  88. { text: "回购中", status: 0 },
  89. { text: "已回购", status: 3 },
  90. ];
  91. const repoId = ref("");
  92. const detials = ref([]);
  93. const orderStatus = ref(0);
  94. const buyBackModelRef = ref(null);
  95. const logisticsModelRef = ref(null);
  96. const agreementModalRef = ref(null);
  97. const tabConfirm = (item, index) => {
  98. if (!item) return;
  99. detials.value = [];
  100. tabActive.value = index;
  101. if (tabActive.value) {
  102. orderStatus.value = item.status;
  103. }
  104. nextTick(() => {
  105. getData();
  106. });
  107. };
  108. const getData = async () => {
  109. try {
  110. const res = await (tabActive.value == 0
  111. ? SHOP_BUYBACK_LISTS()
  112. : SHOP_BUYBACK_ORDER(orderStatus.value));
  113. detials.value = res.data || [];
  114. } catch (error) {
  115. Toast(error.msg);
  116. }
  117. };
  118. const buyBack = (item) => {
  119. repoId.value = item.id;
  120. buyBackModelRef.value && buyBackModelRef.value.open();
  121. };
  122. const repoSubmit = () => {
  123. getData();
  124. };
  125. const writeLogistics = (item) => {
  126. logisticsModelRef.value && logisticsModelRef.value.open(item.id);
  127. };
  128. const openAgreement = () => {
  129. agreementModalRef.value && agreementModalRef.value.open("buyback");
  130. };
  131. onShow(() => {
  132. nextTick(() => {
  133. getData();
  134. });
  135. });
  136. </script>
  137. <style lang="less" scoped>
  138. @import url("@/style.less");
  139. .wrap {
  140. background: var(--bg);
  141. min-height: 100vh;
  142. .nav_right {
  143. display: flex;
  144. color: var(--text);
  145. .size(28rpx);
  146. .icon {
  147. margin-left: 8rpx;
  148. }
  149. }
  150. .content {
  151. flex-grow: 1;
  152. height: calc(100vh - 44px);
  153. flex-direction: column;
  154. .flex();
  155. .cont_tab {
  156. background-color: var(--light);
  157. padding: 0 48rpx;
  158. }
  159. .cont {
  160. flex-grow: 1;
  161. overflow: hidden scroll;
  162. padding: 24rpx;
  163. .item {
  164. width: 100%;
  165. .flex_position(space-between);
  166. padding: 24rpx;
  167. border-radius: 20rpx;
  168. margin-bottom: 24rpx;
  169. box-shadow: 0px 8rpx 20rpx 0px var(--bor-color1);
  170. .item-left {
  171. width: 100%;
  172. display: flex;
  173. .product {
  174. flex-shrink: 0;
  175. width: 120rpx;
  176. height: 120rpx;
  177. margin-right: 14rpx;
  178. .img {
  179. width: 100%;
  180. height: 100%;
  181. border-radius: 15rpx;
  182. }
  183. }
  184. .deatils {
  185. flex: 1;
  186. .hor(space-between);
  187. flex-direction: column;
  188. .title {
  189. .size(28rpx);
  190. font-weight: 600;
  191. color: var(--text);
  192. }
  193. .deatils_bottom {
  194. width: 100%;
  195. .hor(space-between);
  196. align-items: flex-end;
  197. .price {
  198. display: flex;
  199. .size(28rpx);
  200. font-weight: 700;
  201. color: var(--red);
  202. font-family: "HarmonyOS_Sans";
  203. /deep/ div {
  204. .ver(baseline);
  205. .decimal {
  206. .size(24rpx);
  207. }
  208. }
  209. }
  210. .item-right {
  211. .btn {
  212. height: 66rpx;
  213. line-height: 66rpx;
  214. text-align: center;
  215. .size(24rpx);
  216. color: var(--light);
  217. border-radius: 10rpx;
  218. padding: 0 24rpx;
  219. background: var(--black);
  220. }
  221. }
  222. }
  223. }
  224. }
  225. }
  226. .null_warp {
  227. .null_text {
  228. min-height: 100rpx;
  229. .flex_center();
  230. .size(28rpx);
  231. color: #333;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. </style>