PersonalCenter.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <div class="personal-center-container">
  3. <qrCode :loading="false" :testNum="testNum" :trade_state_closed="trade_state_closed"
  4. :centerDialogVisible.sync="centerDialogVisible" :wxPayCode="wxPayCode" @closePayDialogs="closePayDialogs"
  5. :price="price" @getReacquireCodes="getReacquireCodes" />
  6. <div class="flex-row top-line">
  7. <el-breadcrumb separator="/">
  8. <!-- :to="{ path: '/welcome/MainTable' }" -->
  9. <el-breadcrumb-item style="cursor: pointer" @click.native="goBack()">首页</el-breadcrumb-item>
  10. <el-breadcrumb-item style="cursor: pointer"><a href="#">测试记录</a></el-breadcrumb-item>
  11. </el-breadcrumb>
  12. <el-input placeholder="请输入测试名称" clearable v-model="searchKey" class="input-with-select"
  13. @keyup.enter="searchRecord" @clear="searchRecord">
  14. <el-button slot="append" icon="el-icon-search" @click="searchRecord"></el-button>
  15. </el-input>
  16. </div>
  17. <div class="card-list" v-loading="loading" element-loading-background="rgba(255, 255, 255, 0.3)">
  18. <ul>
  19. <li v-for="(item, index) in dataList" :key="index">
  20. <img src="../assets/60e9526e0b432@2x(0).png" alt="" />
  21. <div style="display: block">
  22. <h2>{{ item.name }}</h2>
  23. <!-- <p :title=item.testResult class="view-text">{{ item.testResult }}</p> -->
  24. <div class="content">
  25. {{ item.testDate }}
  26. </div>
  27. <div class="goDetail" @click="detailP(item)">
  28. 查看详情
  29. <i class="el-icon-arrow-right" />
  30. </div>
  31. </div>
  32. </li>
  33. </ul>
  34. </div>
  35. <div class="flex-center">
  36. <el-pagination background layout="prev, pager, next" :total="total" :current-page="pageNum"
  37. @current-change="handleCurrentChange">
  38. </el-pagination>
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. var systemVersion = process.env.VUE_APP_VERSION;
  44. export default {
  45. data() {
  46. return {
  47. trade_state_closed: "",
  48. testNum: "",
  49. baseUrl: baseUrl,
  50. pageSize: 12,
  51. pageNum: 1,
  52. dataList: [],
  53. total: 0,
  54. userBid: "",
  55. institutionNo: "",
  56. persionDetailData: null,
  57. centerDialogVisible: false,
  58. wxPayCode: "",
  59. timer: "",
  60. price: "",
  61. searchKey: "",
  62. itemList: {},
  63. loading: false
  64. };
  65. },
  66. //页面初始化函数
  67. created() {
  68. this.$parent.searchShow = false;
  69. },
  70. mounted() {
  71. this.getPhoneNo();
  72. this.getRecordList();
  73. },
  74. destroyed() {
  75. clearInterval(this.timer);
  76. },
  77. methods: {
  78. getReacquireCodes() {
  79. let _this = this;
  80. clearInterval(_this.timer);
  81. _this.detailP(_this.itemList);
  82. },
  83. closePayDialogs() {
  84. let _this = this;
  85. _this.centerDialogVisible = false;
  86. clearInterval(_this.timer);
  87. // this.$router.go(0);
  88. },
  89. getPhoneNo() {
  90. //取非空的参数
  91. let phoneNo = this.$route.query.phone;
  92. this.institutionNo = sessionStorage.getItem(
  93. "f7a42fe7211f98ac7a60a285ac3a9527"
  94. );
  95. if (phoneNo != null && phoneNo != "" && phoneNo != "undifine") {
  96. //管理员账号进来之后通过url参数获取,若url参数不空则是普通用户,通过session获取
  97. this.userBid = phoneNo;
  98. } else {
  99. this.userBid = sessionStorage.getItem(
  100. "f7a42fe7211f98ac7a60a285ac3a9e87"
  101. );
  102. }
  103. },
  104. handleCurrentChange(val) {
  105. this.pageNum = val;
  106. this.getRecordList();
  107. },
  108. // 获取测试记录列表
  109. getRecordList() {
  110. this.loading = true
  111. this.$http.get(
  112. `mineTest/${this.userBid}/${this.institutionNo}?pageSize=${this.pageSize}&pageNum=${this.pageNum}&searchKey=${this.searchKey}`,
  113. {},
  114. (res) => {
  115. this.persionDetailData = res.data;
  116. this.total = res.data.allNum;
  117. this.dataList = res.data.userRecordEntityList;
  118. setTimeout(() => {
  119. this.loading = false
  120. }, 350)
  121. }, (err) => {
  122. console.log(err)
  123. this.loading = false
  124. }
  125. );
  126. },
  127. // 搜索测试记录
  128. searchRecord() {
  129. this.pageNum = 1;
  130. this.getRecordList();
  131. },
  132. detailP(item) {
  133. // console.log("第二次调用", item);
  134. let _this = this;
  135. _this.itemList = item;
  136. sessionStorage.setItem("persionId", item.id);
  137. let userId = sessionStorage.getItem("b80bb7740288fda1f201890375a60c8f");
  138. //跳转页面到结果页面
  139. let userType = sessionStorage.getItem("f7a42fe7211f98ac7a60a285ac3a9528");
  140. let productId = item.subjectOrCognitiveId;
  141. let resultId = item.id;
  142. if (userType == 1) {
  143. //普通用户
  144. sessionStorage.setItem("persionId", item.id);
  145. console.log("-item.id-------->", item);
  146. if (systemVersion == "public" && item.type != "1") {
  147. _this.$http.get(
  148. `/api/orderInfo/queryOrderByResultIdAndUserId/${productId}/${userId}/${resultId}`,
  149. {},
  150. (res) => {
  151. console.log("查询支付订单", res);
  152. if (res.code == "200") {
  153. if (res.data == null) {
  154. _this.$http.get(
  155. `/api/promotionInfo/queryPromotionBySubjectId/${productId}`,
  156. {},
  157. (res) => {
  158. console.log("获取支付金额", res);
  159. _this.price = res.data.price;
  160. if (this.price != 0) {
  161. let params = {
  162. productId,
  163. userId,
  164. resultId,
  165. description: res.data.name,
  166. total: res.data.price,
  167. };
  168. console.log("二维码参数", params);
  169. // 获取二维码参数
  170. _this.$http.post(
  171. `/api/wx-pay/native`,
  172. params,
  173. (res) => {
  174. console.log(
  175. "======fanghui==8888===============>",
  176. res.data
  177. );
  178. if (res?.data?.codeUrl) {
  179. console.log(
  180. "======fanghui=codeUrl=88880===============>",
  181. res.data.codeUrl
  182. );
  183. _this.wxPayCode = res.data.codeUrl;
  184. _this.testNum = res.data.testNum;
  185. _this.centerDialogVisible = true;
  186. // _this.centerDialogVisible = false; //先关闭,
  187. // _this.$nextTick(function () {
  188. // _this.centerDialogVisible = true; //再打开
  189. // })
  190. console.log(
  191. "====== enterDialogVisible ===============>",
  192. _this.centerDialogVisible
  193. );
  194. _this.timer = setInterval(() => {
  195. _this.$http.get(
  196. `/api/wx-pay/queryOrder/${res?.data?.orderNo}`,
  197. {},
  198. (res) => {
  199. let queryOrderNo = JSON.parse(
  200. res.data.body
  201. );
  202. if (res.code == "200") {
  203. console.log(
  204. "订单支付回调成功订单状态",
  205. queryOrderNo.trade_state
  206. );
  207. console.log("订单支付回调成功", res);
  208. if (
  209. queryOrderNo.trade_state == "SUCCESS"
  210. ) {
  211. _this.JumpJudgment(item.id);
  212. _this.centerDialogVisible = false;
  213. console.log("订单支付回调成功", res);
  214. } else if (
  215. queryOrderNo.trade_state == "CLOSED"
  216. ) {
  217. _this.wxPayCode =
  218. queryOrderNo.trade_state;
  219. _this.trade_state_closed =
  220. queryOrderNo.trade_state;
  221. console.log(
  222. "订单支付回调成功===========CLOSED》",
  223. _this.trade_state_closed
  224. );
  225. } else {
  226. _this.trade_state_closed =
  227. queryOrderNo.trade_state;
  228. // clearInterval(_this.timer);
  229. console.log(
  230. "订单支付回调成功CLOSED===========》",
  231. _this.trade_state_closed
  232. );
  233. }
  234. } else {
  235. _this.centerDialogVisible = false;
  236. _this.$message.error("支付失败");
  237. }
  238. }
  239. );
  240. }, 1000);
  241. } else {
  242. console.log("====== 999999==============>");
  243. }
  244. },
  245. (res) => {
  246. console.log(
  247. "======fanghui=99999================>",
  248. res
  249. );
  250. }
  251. );
  252. } else {
  253. _this.JumpJudgment(item.id);
  254. _this.centerDialogVisible = false;
  255. console.log("=====成功过-------===============>");
  256. }
  257. }
  258. );
  259. } else {
  260. _this.JumpJudgment(item.id);
  261. _this.centerDialogVisible = false;
  262. console.log("=====成功过-------===============>");
  263. }
  264. }
  265. }
  266. );
  267. } else {
  268. _this.JumpJudgment(item.id);
  269. }
  270. // 支付end
  271. //跳转页面到结果页面
  272. // this.JumpJudgment(item.id);
  273. } else {
  274. this.$router.push({
  275. path: "ContainerSys/persionDetail",
  276. query: {
  277. phone: this.userBid,
  278. id: item.id,
  279. },
  280. });
  281. }
  282. },
  283. JumpJudgment(id) {
  284. this.$http.get(`getRecordById?id=${id}`, {}, (res) => {
  285. if (res.code == 2001) {
  286. this.$message.warning(res.msg);
  287. return;
  288. }
  289. if (res && res.code == 200) {
  290. if (res.data?.userRecordEntity.type == '1') {
  291. sessionStorage.setItem("testResult", JSON.stringify(res?.data));
  292. let versionNo = JSON.parse(res.data?.userRecordEntity?.testResult).versionNo;
  293. if (versionNo == '2.0.1' || versionNo == '2.0' ) {
  294. sessionStorage.setItem("backToPageFlag", 'testResultNew')
  295. this.$router.push({
  296. name: "testResultNew",
  297. query: {
  298. id: res.data?.userRecordEntity?.id,
  299. title: res.data?.userRecordEntity?.name,
  300. come: 2, //1-来自认知任务列表,2-测试记录列表
  301. },
  302. });
  303. } else {
  304. sessionStorage.setItem("backToPageFlag", 'PersionDetail')
  305. this.$router.push({
  306. path: "/PersionDetail",
  307. params: {
  308. id: id,
  309. },
  310. query: {
  311. phone: this.userBid,
  312. id: id,
  313. backPage: 1,
  314. },
  315. });
  316. }
  317. } else {
  318. sessionStorage.setItem("backToPageFlag", 'personalCenter')
  319. this.$router.push({
  320. path: "/persionDetailSCl",
  321. params: {
  322. id: id,
  323. },
  324. query: {
  325. // phone: this.userBid,
  326. id: id,
  327. come: 2,
  328. },
  329. });
  330. }
  331. } else {
  332. this.$message({
  333. message: "获取数据失败!服务器异常",
  334. type: "error",
  335. });
  336. }
  337. });
  338. },
  339. goBack() {
  340. let userType = sessionStorage.getItem("f7a42fe7211f98ac7a60a285ac3a9528");
  341. if (userType == 1) {
  342. //普通用户
  343. this.$router.push({
  344. name: "MainTable",
  345. });
  346. } else {
  347. //管理员用户
  348. this.$router.push({
  349. path: "/ContainerSys",
  350. });
  351. }
  352. },
  353. },
  354. };
  355. </script>
  356. <style lang="scss" scoped>
  357. .personal-center-container {
  358. width: 100%;
  359. height: 100%;
  360. display: flex;
  361. flex-direction: column;
  362. justify-content: space-between;
  363. .top-line {
  364. justify-content: space-between;
  365. ::v-deep .el-breadcrumb {
  366. .el-breadcrumb__inner,
  367. .el-breadcrumb__separator,
  368. .el-breadcrumb__inner a {
  369. color: white;
  370. font-size: 0.086rem;
  371. &:hover {
  372. color: white;
  373. }
  374. }
  375. }
  376. .input-with-select {
  377. width: 240px;
  378. }
  379. }
  380. .card-list {
  381. width: 100%;
  382. height: calc(100% - 112px);
  383. ul {
  384. display: flex;
  385. height: 100%;
  386. justify-content: flex-start;
  387. flex-wrap: wrap;
  388. font-family: PingFang SC;
  389. li {
  390. width: 230px;
  391. height: calc(50% - 30px);
  392. background: rgb(255, 255, 255);
  393. box-shadow: 0 3px 6px #d4d4d4;
  394. border-radius: 12px;
  395. margin: 0 28px 30px;
  396. overflow: hidden;
  397. position: relative;
  398. img {
  399. width: 100%;
  400. height: 48%;
  401. margin-bottom: 9px;
  402. }
  403. h2 {
  404. width: calc(100% - 18px);
  405. margin-left: 9px;
  406. font-size: 0.086rem;
  407. font-weight: 500;
  408. line-height: 20px;
  409. color: #333333;
  410. overflow: hidden;
  411. text-overflow: ellipsis;
  412. white-space: nowrap;
  413. }
  414. .content {
  415. font-size: 0.076rem;
  416. font-weight: 400;
  417. line-height: 20px;
  418. color: #999999;
  419. width: calc(100% - 18px);
  420. margin-left: 9px;
  421. margin-top: 8px;
  422. }
  423. .goDetail {
  424. width: calc(100% - 18px);
  425. position: absolute;
  426. left: 9px;
  427. bottom: 12px;
  428. font-size: 0.086rem;
  429. font-weight: 400;
  430. line-height: 20px;
  431. color: #007EFF;
  432. cursor: pointer;
  433. }
  434. }
  435. }
  436. }
  437. }
  438. @media screen and (max-width: 1024px) {
  439. .cardList ul li {
  440. margin: 30px 10px;
  441. }
  442. .wrap {
  443. width: 100%;
  444. margin: 0;
  445. }
  446. }
  447. .pageNationBox {
  448. padding: 20px 10px;
  449. text-align: center;
  450. }
  451. .view-text {
  452. /**
  453. 思路:
  454. 1.设置inline-block属相
  455. 2.强制不换行
  456. 3.固定高度
  457. 4.隐藏超出部分
  458. 5.显示“……”
  459. */
  460. display: inline-block;
  461. word-break: keep-all;
  462. white-space: nowrap;
  463. width: 960px;
  464. overflow: hidden;
  465. text-overflow: ellipsis;
  466. }
  467. .imgSiz {
  468. width: 120px;
  469. height: 75px;
  470. margin-right: 15px;
  471. }
  472. .search_box {
  473. display: flex;
  474. }
  475. .search_box /deep/ .el-input {
  476. width: 300px;
  477. margin: 16px 0 0 35px;
  478. }
  479. </style>