order.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <template>
  2. <view class="container">
  3. <!-- 空列表提示 -->
  4. <view class="hint" v-if="showHint">暂无订单记录</view>
  5. <!-- 遮罩层 -->
  6. <view
  7. class="mark"
  8. v-show="showDetail || showPay"
  9. @click="markClose()"
  10. ></view>
  11. <!-- 订单列表 -->
  12. <view class="list">
  13. <template v-if="orderList.length !== 0">
  14. <view class="messCard" v-for="item in orderList">
  15. <view class="field">
  16. <view class="header">
  17. <text>订单号:{{ item.orderNo }}</text>
  18. <text v-if="item.status == 2">缴费成功</text>
  19. <text v-if="item.status == 1" style="color: #ff8b02"
  20. >缴费失败</text
  21. >
  22. </view>
  23. <view class="content">
  24. <view class="mess-itm">
  25. <text>姓名:</text>
  26. <text>{{ item.studentName }}</text>
  27. </view>
  28. <view class="mess-itm">
  29. <text>学号:</text>
  30. <text>{{ item.payForIdentify }}</text>
  31. </view>
  32. <view class="mess-itm">
  33. <text>班级:</text>
  34. <text>{{ item.className }}</text>
  35. </view>
  36. <view class="mess-itm">
  37. <text class="time">{{ item.createTime }}</text>
  38. <text class="amount">实付款¥{{ item.orderAmount }}</text>
  39. </view>
  40. </view>
  41. <view class="footer">
  42. <view class="bt-item">
  43. <view
  44. class="button"
  45. @click="feedBack(item.orderNo)"
  46. v-if="item.status == 1"
  47. >
  48. 订单反馈
  49. </view>
  50. <view
  51. class="button"
  52. @click="toPay(item.payForIdentify, item.studentName)"
  53. v-if="item.status == 1"
  54. >
  55. 继续支付
  56. </view>
  57. <view
  58. class="button"
  59. @click="detailMess(item.payForIdentify, item.studentName)"
  60. >查看详情</view
  61. >
  62. </view>
  63. </view>
  64. </view>
  65. <view class="fieldBg"></view>
  66. </view>
  67. </template>
  68. </view>
  69. <!-- 继续支付弹窗 -->
  70. <view class="messageCard" v-show="showPay">
  71. <view class="item-form">
  72. <view class="item">
  73. <text class="ite">收费单位 </text>
  74. <text class="content">南昌交通学院</text>
  75. </view>
  76. <view class="item">
  77. <text class="ite">姓名 </text>
  78. <text class="content">{{ studentName }}</text>
  79. </view>
  80. <view class="item">
  81. <text class="ite">学号 </text>
  82. <text class="content">{{ studentNo }}</text>
  83. </view>
  84. <view class="item">
  85. <text class="ite">专业 </text>
  86. <text class="content">{{ majorName }}</text>
  87. </view>
  88. <view class="item">
  89. <text class="ite">班级 </text>
  90. <text class="content">{{ className }}</text>
  91. </view>
  92. <view class="item">
  93. <text class="ite">缴费学年 </text>
  94. <text class="content">{{ years }}</text>
  95. </view>
  96. <view class="item-pay" v-for="item in Arr">
  97. <text class="ite">{{ item.id }} </text>
  98. <text class="content">¥{{ item.money }}</text>
  99. </view>
  100. <view class="item">
  101. <text class="ite">总金额 </text>
  102. <text class="content">¥{{ orderAmount }}</text>
  103. </view>
  104. </view>
  105. <button
  106. @click="getPay()"
  107. :disabled="btDisabled"
  108. :style="bgColor"
  109. hover-class="button-hover"
  110. >
  111. 支付
  112. </button>
  113. <button @click="closePay()" hover-class="button-hover">取消</button>
  114. </view>
  115. <!-- 查看详情弹窗 -->
  116. <view class="detail" v-show="showDetail">
  117. <view class="top">
  118. <text>订单详情</text>
  119. <view class="close" @click="closeDetail()">
  120. <view class="image"></view>
  121. </view>
  122. </view>
  123. <view class="content">
  124. <view class="mess-itm">
  125. <text>收费单位:</text>
  126. <text>南昌交通学院</text>
  127. </view>
  128. <view class="mess-itm">
  129. <text>姓名:</text>
  130. <text>{{ studentName }}</text>
  131. </view>
  132. <view class="mess-itm">
  133. <text>学号:</text>
  134. <text>{{ studentNo }}</text>
  135. </view>
  136. <view class="mess-itm">
  137. <text>专业:</text>
  138. <text>{{ majorName }}</text>
  139. </view>
  140. <view class="mess-itm">
  141. <text>班级:</text>
  142. <text>{{ className }}</text>
  143. </view>
  144. <view class="mess-itm">
  145. <text>缴费学年:</text>
  146. <text>{{ years }}</text>
  147. </view>
  148. <view class="mess-itm-pay" v-for="item in Arr">
  149. <text>{{ item.id }}:</text>
  150. <text>¥{{ item.money }}</text>
  151. </view>
  152. <view class="mess-itm">
  153. <text>总金额:</text>
  154. <text>¥{{ orderAmount }}</text>
  155. </view>
  156. </view>
  157. </view>
  158. </view>
  159. </template>
  160. <script>
  161. export default {
  162. data() {
  163. return {
  164. showPay: false, //继续支付弹窗
  165. showHint: true, //无订单列表提示
  166. showDetail: false, //查看详情弹窗
  167. orderList: [], //接口获取的订单列表数组
  168. studentName: "", //学生姓名
  169. studentNo: "", //学生学号
  170. majorName: "", //专业
  171. className: "", //班级
  172. years: "", //缴费学年
  173. Arr: [], //缴费明细数组
  174. orderAmount: "", //总金额
  175. btDisabled: false,
  176. bgColor: "background: #298def;",
  177. homeUrl: "https://jtishfw.ncjti.edu.cn/jiaofei/backendApi", //线上域名地址
  178. notifyUrl:
  179. "https://jtishfw.ncjti.edu.cn/jiaofei/backendApi/pay/jxnxs/notify/", //农商行回跳地址
  180. orderNo: "", //订单号
  181. //以下为微信支付参数
  182. appId: "",
  183. timeStamp: "",
  184. nonceStr: "",
  185. package: "",
  186. signType: "",
  187. paySign: "",
  188. };
  189. },
  190. onLoad(options) {
  191. let cardNumber = localStorage.getItem("cardNumber");
  192. if (cardNumber === null) {
  193. uni.showToast({
  194. title: "cardNumber为空,请重新授权",
  195. icon: "error",
  196. mask: true,
  197. duration: 2000,
  198. });
  199. } else {
  200. this.getOrderList(); //获取订单列表
  201. }
  202. },
  203. methods: {
  204. //点击遮罩层
  205. markClose() {
  206. this.showPay = false;
  207. this.showDetail = false;
  208. },
  209. //关闭查看详情弹窗
  210. closeDetail() {
  211. this.showDetail = false;
  212. },
  213. //关闭继续支付弹窗
  214. closePay() {
  215. this.showPay = false;
  216. },
  217. //获取订单列表
  218. getOrderList() {
  219. let cardNumber = localStorage.getItem("cardNumber");
  220. let url = this.homeUrl + "/tuitionpayment/payorder/currentUserList";
  221. uni.request({
  222. url: url,
  223. data: {},
  224. header: {
  225. card_number: cardNumber,
  226. Accept: "application/json",
  227. "Content-Type": " application/x-www-form-urlencoded;charset=utf-8",
  228. "X-Requested-With": "XMLHttpRequest",
  229. },
  230. method: "GET",
  231. sslVerify: true,
  232. success: ({ data, statusCode, header }) => {
  233. if (data.success) {
  234. if (data.data.list.length !== 0) {
  235. this.showHint = false; //关闭“暂无订单列表”提示
  236. this.orderList = data.data.list; //获取订单列表
  237. }
  238. } else {
  239. //接口error提示框
  240. uni.showToast({
  241. title: data.message,
  242. icon: "error",
  243. mask: true,
  244. duration: 2000,
  245. });
  246. }
  247. },
  248. fail: (error) => {},
  249. });
  250. },
  251. //查看详情
  252. detailMess(payForIdentify, studentName) {
  253. this.showDetail = !this.showDetail; //打开查看详情弹窗
  254. let cardNumber = localStorage.getItem("cardNumber");
  255. let url =
  256. this.homeUrl +
  257. `/tuitionpayment/payableinfo/payableInfo/${payForIdentify}/${studentName}`;
  258. uni.request({
  259. url: url,
  260. header: {
  261. card_number: cardNumber,
  262. Accept: "application/json",
  263. "Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
  264. "X-Requested-With": "XMLHttpRequest",
  265. },
  266. method: "GET",
  267. sslVerify: true,
  268. success: ({ data, statusCode, header }) => {
  269. let res = data.data;
  270. this.studentName = res.studentName;
  271. this.studentNo = res.studentNo;
  272. this.years = res.years;
  273. this.majorName = res.majorName;
  274. this.className = res.className;
  275. this.getPayDetail(res.payItemDetail); //分割缴费明细数组
  276. this.orderAmount = res.realPayAmount;
  277. },
  278. fail: (error) => {},
  279. });
  280. },
  281. //继续支付
  282. toPay(payForIdentify, studentName) {
  283. this.showPay = !this.showPay; //打开继续支付弹窗
  284. let cardNumber = localStorage.getItem("cardNumber");
  285. let url =
  286. this.homeUrl +
  287. `/tuitionpayment/payableinfo/payableInfo/${payForIdentify}/${studentName}`;
  288. uni.request({
  289. url: url,
  290. header: {
  291. card_number: cardNumber,
  292. Accept: "application/json",
  293. "Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
  294. "X-Requested-With": "XMLHttpRequest",
  295. },
  296. method: "GET",
  297. sslVerify: true,
  298. success: ({ data, statusCode, header }) => {
  299. let res = data.data;
  300. this.studentName = res.studentName;
  301. this.studentNo = res.studentNo;
  302. this.years = res.years;
  303. this.majorName = res.majorName;
  304. this.className = res.className;
  305. this.getPayDetail(res.payItemDetail); //分割缴费明细数组
  306. this.orderAmount = res.realPayAmount;
  307. },
  308. fail: (error) => {},
  309. });
  310. },
  311. //获取学费明细
  312. getPayDetail(len) {
  313. //获取明细款项名称数组
  314. var arr = len.match(/[^\\u4e00-\\u9fa5]+/g);
  315. //过滤
  316. var itemIdArr = arr.filter(function (value) {
  317. return value !== ".";
  318. });
  319. //获取明细金额数组
  320. var itemMoneyArr = len.match(/([0-9]+\.[0-9]+)+/g);
  321. //拼接成对象数组
  322. var item = [];
  323. for (var i in (itemIdArr, itemMoneyArr)) {
  324. var c = {
  325. id: itemIdArr[i],
  326. money: itemMoneyArr[i],
  327. };
  328. item.push(c);
  329. }
  330. this.Arr = item;
  331. },
  332. //订单反馈
  333. feedBack(orderNo) {
  334. let cardNumber = localStorage.getItem("cardNumber");
  335. let url = this.homeUrl + `/tuitionpayment/payorder/${orderNo}/orderStatu`;
  336. uni.request({
  337. url: url,
  338. data: {},
  339. header: {
  340. card_number: cardNumber,
  341. Accept: "application/json",
  342. "Content-Type": "application/json",
  343. "X-Requested-With": "XMLHttpRequest",
  344. },
  345. method: "GET",
  346. sslVerify: true,
  347. success: ({ data, statusCode, header }) => {
  348. if (data.data.status == 1) {
  349. //反馈支付失败
  350. uni.showToast({
  351. title: "支付失败",
  352. icon: "error",
  353. mask: true,
  354. });
  355. }
  356. },
  357. fail: (error) => {},
  358. });
  359. },
  360. //支付
  361. getPay() {
  362. this.btDisabled = !this.btDisabled;
  363. this.bgColor = " background: #b3b3b3;";
  364. setTimeout(() => {
  365. this.btDisabled = !this.btDisabled;
  366. this.bgColor = " background: #298def;";
  367. }, 4000);
  368. uni.showToast({
  369. title: "支付中,请稍等",
  370. icon: "loading",
  371. mask: true,
  372. duration: 2000,
  373. });
  374. this.getOrderNo(); //获取订单号
  375. },
  376. //获取订单号
  377. getOrderNo() {
  378. let that = this;
  379. let cardNumber = localStorage.getItem("cardNumber");
  380. if (cardNumber == null) {
  381. uni.showToast({
  382. title: "cardNumber为空,请重新授权",
  383. icon: "error",
  384. mask: true,
  385. duration: 1500,
  386. });
  387. setTimeout(() => this.toBlank, 2000);
  388. }
  389. let url =
  390. that.homeUrl + `/tuitionpayment/payorder/${that.studentNo}/create`;
  391. uni.request({
  392. url: url,
  393. data: {},
  394. header: {
  395. card_number: cardNumber,
  396. Accept: "application/json",
  397. "Content-Type": "application/json",
  398. "X-Requested-With": "XMLHttpRequest",
  399. },
  400. method: "POST",
  401. sslVerify: true,
  402. success: ({ data, statusCode, header }) => {
  403. let res = data.data;
  404. that.orderNo = res.orderNo;
  405. if (data.success) {
  406. that.getPayMethod(); //获取后端支付方式
  407. } else {
  408. uni.showToast({
  409. title: data.message,
  410. icon: "error",
  411. mask: true,
  412. duration: 2000,
  413. });
  414. }
  415. },
  416. fail: (error) => {},
  417. });
  418. },
  419. //获取支付方式
  420. getPayMethod() {
  421. let url = this.homeUrl + "/payMethodSetting/currentPay";
  422. uni.request({
  423. url: url,
  424. data: {},
  425. header: {
  426. Accept: "application/json",
  427. "Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
  428. "X-Requested-With": "XMLHttpRequest",
  429. },
  430. method: "GET",
  431. sslVerify: true,
  432. success: ({ data, statusCode, header }) => {
  433. let res = data.data;
  434. if (data.success) {
  435. if (res.currentPayMethod === "1") {
  436. this.getwxParam(); //建行支付
  437. } else {
  438. this.nsPay(); //农商行支付
  439. }
  440. } else {
  441. //接口错误提示框
  442. uni.showToast({
  443. title: data.message,
  444. icon: "error",
  445. mask: true,
  446. duration: 1000,
  447. });
  448. }
  449. },
  450. fail: (error) => {},
  451. });
  452. },
  453. //拉起农商行支付
  454. nsPay() {
  455. let O = "5494ec3310685daa218382619dd20e27";
  456. let out_no = this.orderNo;
  457. let amount = this.orderAmount;
  458. let appoint_notify = this.notifyUrl;
  459. let mainUrl = `https://q.jxnxs.com/newpay?O=${O}&out_no=${out_no}&amount=${amount}&appoint_notify=${appoint_notify}`;
  460. window.location.href = mainUrl;
  461. },
  462. //获取微信支付参数
  463. getwxParam() {
  464. let that = this;
  465. let cardNumber = localStorage.getItem("cardNumber");
  466. let openId = localStorage.getItem("openId");
  467. let url = that.homeUrl + "/pay/ccb/getJsApiParam";
  468. uni.request({
  469. url: url,
  470. data: {
  471. orderNo: that.orderNo,
  472. openId: openId,
  473. },
  474. header: {
  475. card_number: cardNumber,
  476. Accept: "application/json",
  477. "Content-Type": "application/json",
  478. "X-Requested-With": "XMLHttpRequest",
  479. },
  480. method: "GET",
  481. sslVerify: true,
  482. success: ({ data, statusCode, header }) => {
  483. if (!data.success) {
  484. uni.showToast({
  485. title: data.message,
  486. icon: "error",
  487. mask: true,
  488. duration: 2000,
  489. });
  490. } else {
  491. let res = data.data;
  492. that.appId = res.appId;
  493. that.timeStamp = res.timeStamp;
  494. that.nonceStr = res.nonceStr;
  495. that.package = res.package;
  496. that.signType = res.signType;
  497. that.paySign = res.paySign;
  498. that.wxPay(); //吊起微信支付
  499. }
  500. },
  501. fail: (error) => {},
  502. });
  503. },
  504. //吊起微信支付
  505. wxPay() {
  506. let that = this;
  507. function onBridgeReady() {
  508. WeixinJSBridge.invoke(
  509. "getBrandWCPayRequest",
  510. {
  511. appId: that.appId, //公众号ID,由商户传入
  512. timeStamp: that.timeStamp, //时间戳,自1970年以来的秒数
  513. nonceStr: that.nonceStr, //随机串
  514. package: that.package,
  515. signType: that.signType, //微信签名方式:
  516. paySign: that.paySign, //微信签名
  517. },
  518. function (res) {
  519. if (res.err_msg == "get_brand_wcpay_request:ok") {
  520. // 使用以上方式判断前端返回,微信团队郑重提示:
  521. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  522. }
  523. }
  524. );
  525. }
  526. if (typeof WeixinJSBridge == "undefined") {
  527. if (document.addEventListener) {
  528. document.addEventListener(
  529. "WeixinJSBridgeReady",
  530. onBridgeReady,
  531. false
  532. );
  533. } else if (document.attachEvent) {
  534. document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
  535. document.attachEvent("onWeixinJSBridgeReady", onBridgeReady);
  536. }
  537. } else {
  538. onBridgeReady();
  539. }
  540. },
  541. //跳转空白页面重新授权拿cardNumber
  542. toBlank() {
  543. uni.navigateTo({ url: "/pages/blankIndex/blankIndex" });
  544. },
  545. },
  546. };
  547. </script>
  548. <style lang="less">
  549. @import url("./css/order.min.css");
  550. </style>