order.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <template>
  2. <div class="list-box">
  3. <div class="titleBox">
  4. <div class="titleBox_l">My order</div>
  5. <div class="titleBox_r">
  6. <div class="titleBox_r_l">
  7. <n-input v-model:value="keyword" type="text" class="custom-placeholder" clearable placeholder="Please enter your order number for inquiry" />
  8. </div>
  9. <div class="titleBox_r_r">
  10. Search
  11. </div>
  12. </div>
  13. </div>
  14. <div class="list">
  15. <div class="item" v-for="(v,i) in 3" :key="i">
  16. <div class="item_title">Order Number:2145878541</div>
  17. <div class="item_content">
  18. <img src="" alt="">
  19. <div>
  20. <div class="item_content_title">
  21. <img src="" alt="">
  22. <div>
  23. China Industrial Park Industry Market In-depth Research andInvestment Strategy Planning Report 2024-2030
  24. </div>
  25. </div>
  26. <div class="item_content_time">Order placement time:<span>December 21, 2014, 15:11</span></div>
  27. <div class="item_content_method">Payment method:<span>Alipay payment</span></div>
  28. <div class="item_content_amount">Payment amount:<span>$4.950.00</span></div>
  29. </div>
  30. </div>
  31. <div class="btnBox">
  32. <div class="blue">PDF download</div>
  33. <div class="green">PPT Download</div>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script lang="ts" setup>
  40. import { useI18n } from "#imports";
  41. import { ref, reactive, onMounted, watch, onUnmounted } from "vue";
  42. import {
  43. NButton,
  44. NPagination,
  45. createDiscreteApi,
  46. NEmpty,
  47. NModal,
  48. NSpin,
  49. } from "naive-ui";
  50. import QrcodeVue from "qrcode.vue";
  51. import { useUserStore } from "@/store/user";
  52. const config = useRuntimeConfig();
  53. const BaseUrl = ref(config.public.baseUrl);
  54. const { t, locale, setLocale } = useI18n();
  55. const pageSize = 10;
  56. const userStore = useUserStore();
  57. const pcShow = ref(true);
  58. const props = defineProps({
  59. isMobile: {
  60. type: Boolean,
  61. default: false,
  62. },
  63. });
  64. const queryParams = reactive({
  65. pageNo: 1,
  66. pageSize: 5,
  67. orderNumber: "",
  68. });
  69. const pageData = ref({});
  70. const wxQRCode = ref("");
  71. const payVisible = ref<boolean>(false);
  72. const payTitle = ref<string>("");
  73. const count = ref(0);
  74. const timer = ref();
  75. const spinShow = ref(false);
  76. const description = ref(t("myInfo.loading"));
  77. const payShow = ref(false);
  78. const closePayVisible = ref(false);
  79. const closePayId = ref(null);
  80. const emailShow = ref(false);
  81. const activeItem = ref();
  82. // const Message = createDiscreteApi(["message"]);
  83. const model = ref({
  84. email: "",
  85. affirmEmail: "",
  86. });
  87. const openInpEmail = (item) => {
  88. activeItem.value = item;
  89. emailShow.value = true;
  90. };
  91. const getList = async () => {
  92. spinShow.value = true;
  93. description.value = t("myInfo.loading");
  94. let apiFun = getMyOrder_Api;
  95. if (userStore.getLang != "zh-CN") {
  96. apiFun = websiteUserResearchOrderList;
  97. }
  98. const { code, data } = await apiFun(queryParams);
  99. if (code === 200) {
  100. pageData.value = data;
  101. }
  102. spinShow.value = false;
  103. };
  104. // 提交邮箱
  105. const submitEmit = () => {
  106. if (model.value.affirmEmail != model.value.email) {
  107. message.message.error("The email addresses are inconsistent.");
  108. return;
  109. }
  110. let param = {
  111. id: activeItem.value.id,
  112. email: model.value.email,
  113. };
  114. websiteUserResearchOrderUpdateEmail(param).then((res) => {
  115. if (res.code == 200) {
  116. message.message.success(t("report.demand.submitSuccess"));
  117. close();
  118. queryParams.pageNo = 1;
  119. getList();
  120. }
  121. });
  122. };
  123. const close = () => {
  124. emailShow.value = false;
  125. };
  126. // onMounted(() => {
  127. getList();
  128. // });
  129. onBeforeMount(async () => {
  130. pcShow.value = !isMobile();
  131. });
  132. onUnmounted(() => {
  133. payEnd();
  134. });
  135. watch(
  136. () => payVisible.value,
  137. (newVal, oldVal) => {
  138. if (newVal === false) {
  139. payEnd();
  140. }
  141. }
  142. );
  143. const searchData = (val: string | any) => {
  144. queryParams.orderNumber = val;
  145. getList();
  146. };
  147. const goPay = (item) => {
  148. window.open(item.orderPayUrl);
  149. };
  150. const message = createDiscreteApi(["message"]);
  151. // 下载
  152. const handleTools = async (item: Object, fileType: string) => {
  153. if (fileType == "pay") {
  154. if (props.isMobile) {
  155. if (item.payMethod == "zfb" || item.payMethod == "wx") {
  156. return message.message.info("请前往PC端个人中心支付订单");
  157. }
  158. } else {
  159. if (item.payMethod == "zfb_h5" || item.payMethod == "wx_h5") {
  160. return message.message.info("请前往H5端个人中心支付订单");
  161. }
  162. }
  163. toPay(item);
  164. } else {
  165. const { code, data } = await getDownUrl_Api({
  166. researchBriefReportId: item.researchBriefReportId,
  167. fileType: fileType,
  168. });
  169. if (code === 200) {
  170. let url = `${BaseUrl}/fileupload/${data.filePath}${data.fileName}`;
  171. if (typeof window !== "undefined") {
  172. window.open(url);
  173. }
  174. }
  175. }
  176. };
  177. const toPay = (item) => {
  178. if (item.payMethod == "wx") {
  179. payVisible.value = true;
  180. wxQRCode.value = item.orderPayUrl;
  181. setTimeout(() => {
  182. payDetail(item);
  183. }, 500);
  184. } else {
  185. downloadFile(item.orderPayUrl);
  186. }
  187. };
  188. const payDetail = async (item) => {
  189. payShow.value = true;
  190. const { code, data } = await bulletinDetailPay_Api({
  191. researchBriefReportId: item.researchBriefReportId,
  192. orderNumber: item.orderNumber,
  193. });
  194. if (code === 200) {
  195. if (data.payStatus == 1) {
  196. message.message.success("支付成功");
  197. payEnd();
  198. } else if (data.payStatus != 1) {
  199. if (payVisible.value) {
  200. if (count.value >= 5) {
  201. payEnd();
  202. message.message.error("请检查是否支付完成");
  203. } else {
  204. timer.value = setTimeout(() => {
  205. count.value++;
  206. payDetail(item);
  207. }, 10 * 1000);
  208. }
  209. }
  210. }
  211. }
  212. };
  213. const payEnd = () => {
  214. count.value = 0;
  215. payVisible.value = false;
  216. clearTimeout(timer.value);
  217. };
  218. const handleClosePay = async (item) => {
  219. closePayId.value = item.id;
  220. closePayVisible.value = true;
  221. };
  222. const submitClosePayCallback = async () => {
  223. let apiFun = closePay_Api;
  224. if (userStore.getLang == "en-US") {
  225. // 英文 取消订单
  226. apiFun = websiteUserResearchCancelOrder;
  227. }
  228. const { code } = await apiFun({
  229. id: closePayId.value,
  230. });
  231. if (code === 200) {
  232. getList();
  233. message.message.success(t("myInfo.PaymentOrderCancelledSuccessfully"));
  234. }
  235. closePayId.value = null;
  236. closePayVisible.value = false;
  237. };
  238. const cancelClosePayCallback = () => {
  239. closePayId.value = null;
  240. closePayVisible.value = false;
  241. };
  242. // 改变页数
  243. const changePage = (page: number) => {
  244. document.documentElement.scrollTop = 0;
  245. queryParams.pageNo = page;
  246. getList();
  247. };
  248. defineExpose({
  249. searchData,
  250. });
  251. </script>
  252. <style lang="scss" scoped>
  253. @import "~/assets/css/tool.scss";
  254. .list-box {
  255. .titleBox {
  256. display: flex;
  257. justify-content: space-between;
  258. padding-bottom: 7px;
  259. border-bottom: 1px solid #e6e6e6;
  260. .titleBox_l {
  261. font-size: 24px;
  262. font-family: Arial, Arial-Bold;
  263. font-weight: 700;
  264. color: #1a1a1a;
  265. line-height: 44px;
  266. }
  267. .titleBox_r {
  268. display: flex;
  269. align-items: center;
  270. width: 500px;
  271. height: var(--size-44);
  272. background: #f5f5f5;
  273. border-radius: 8px;
  274. overflow: hidden;
  275. .titleBox_r_l {
  276. flex-grow: 1;
  277. .n-input {
  278. --n-height: var(--size-26) !important;
  279. line-height: var(--size-26) !important;
  280. background: #f5f5f5 !important;
  281. font-size: 14px !important;
  282. }
  283. }
  284. .titleBox_r_r {
  285. width: var(--size-105);
  286. font-size: var(--size-16);
  287. color: #ffffff;
  288. text-align: center;
  289. height: var(--size-44);
  290. background: linear-gradient(0deg, #7b9c4f 0%, #2da19d 100%), #1a1a1a;
  291. line-height: var(--size-44);
  292. cursor: pointer;
  293. }
  294. }
  295. }
  296. .list {
  297. margin-top: 45px;
  298. .item {
  299. border: 1px solid #e6e6e6;
  300. position: relative;
  301. margin-bottom: 30px;
  302. &:last-child {
  303. margin-bottom: 0;
  304. }
  305. .item_title {
  306. font-size: 20px;
  307. font-family: Arial, Arial-Bold;
  308. font-weight: 700;
  309. text-align: left;
  310. color: #1a1a1a;
  311. line-height: 44px;
  312. letter-spacing: 0.06px;
  313. padding: 14px 25px;
  314. background: #f5f5f5;
  315. }
  316. .item_content {
  317. padding: 20px 25px 23px;
  318. display: flex;
  319. align-items: center;
  320. > img {
  321. width: 148px;
  322. height: 216px;
  323. object-fit: contain;
  324. }
  325. > div {
  326. margin-left: 40px;
  327. .item_content_title {
  328. font-size: 21px;
  329. font-family: Arial, Arial-Regular;
  330. color: #1a1a1a;
  331. line-height: 28px;
  332. img {
  333. display: none;
  334. }
  335. }
  336. .item_content_time,
  337. .item_content_method {
  338. display: flex;
  339. font-size: 16px;
  340. font-family: Arial, Arial-Regular;
  341. color: #1a1a1a;
  342. letter-spacing: 0.05px;
  343. span {
  344. color: #808080;
  345. }
  346. }
  347. .item_content_time {
  348. margin: 20px 0 0;
  349. }
  350. .item_content_method {
  351. margin: 6px 0 10px;
  352. }
  353. .item_content_amount {
  354. display: flex;
  355. font-size: 16px;
  356. font-family: Arial, Arial-Regular;
  357. color: #1a1a1a;
  358. line-height: 44px;
  359. letter-spacing: 0.05px;
  360. align-items: baseline;
  361. span {
  362. font-size: 30px;
  363. color: #ee001f;
  364. }
  365. }
  366. }
  367. }
  368. .btnBox {
  369. display: flex;
  370. position: absolute;
  371. right: 20px;
  372. bottom: 45px;
  373. > div {
  374. width: 144px;
  375. height: 48px;
  376. border-radius: 8px;
  377. font-size: 14px;
  378. font-family: Arial, Arial-Regular;
  379. text-align: center;
  380. color: #ffffff;
  381. line-height: 48px;
  382. margin-right: 14px;
  383. cursor: pointer;
  384. &:last-child {
  385. margin-right: 0;
  386. }
  387. }
  388. .blue {
  389. background: #60ac92;
  390. }
  391. .green {
  392. background: #84a86c;
  393. }
  394. }
  395. }
  396. }
  397. }
  398. @include responseTo("phone") {
  399. .list-box {
  400. .titleBox {
  401. padding-bottom: 20px;
  402. display: block;
  403. .titleBox_r {
  404. width: 100%;
  405. }
  406. }
  407. .list {
  408. margin-top: 20px;
  409. .item {
  410. .item_title {
  411. padding: 10px 15px;
  412. font-size: 18px;
  413. line-height: 24px;
  414. }
  415. .item_content {
  416. padding: 10px;
  417. > img {
  418. display: none;
  419. }
  420. > div {
  421. margin: 0;
  422. .item_content_title {
  423. display: flex;
  424. > div {
  425. font-size: 18px;
  426. line-height: 26px;
  427. overflow: hidden;
  428. text-overflow: ellipsis;
  429. display: -webkit-box;
  430. -webkit-line-clamp: 4;
  431. -webkit-box-orient: vertical;
  432. }
  433. > img {
  434. width: 74px;
  435. height: 108px;
  436. object-fit: contain;
  437. margin-right: 10px;
  438. }
  439. }
  440. .item_content_time,
  441. .item_content_method {
  442. font-size: 14px;
  443. }
  444. .item_content_amount {
  445. font-size: 14px;
  446. line-height: 30px;
  447. span {
  448. font-size: 26px;
  449. }
  450. }
  451. }
  452. }
  453. .btnBox {
  454. position: static;
  455. width: 100%;
  456. justify-content: center;
  457. padding-bottom: 20px;
  458. }
  459. }
  460. }
  461. }
  462. }
  463. </style>