order.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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 @click="getPay()" hover-class="button-hover">支付</button>
  106. <button @click="closePay()" hover-class="button-hover">取消</button>
  107. </view>
  108. <!-- 查看详情 -->
  109. <view class="detail" v-show="showDetail">
  110. <view class="top">
  111. <text>订单详情</text>
  112. <view class="close" @click="closeDetail()">
  113. <view class="image"></view>
  114. </view>
  115. </view>
  116. <view class="content">
  117. <view class="mess-itm">
  118. <text>收费单位:</text>
  119. <text>南昌交通学院</text>
  120. </view>
  121. <view class="mess-itm">
  122. <text>姓名:</text>
  123. <text>{{ studentName }}</text>
  124. </view>
  125. <view class="mess-itm">
  126. <text>学号:</text>
  127. <text>{{ studentNo }}</text>
  128. </view>
  129. <view class="mess-itm">
  130. <text>专业:</text>
  131. <text>{{ majorName }}</text>
  132. </view>
  133. <view class="mess-itm">
  134. <text>班级:</text>
  135. <text>{{ className }}</text>
  136. </view>
  137. <view class="mess-itm">
  138. <text>缴费学年:</text>
  139. <text>{{ years }}</text>
  140. </view>
  141. <view class="mess-itm-pay" v-for="item in Arr">
  142. <text>{{ item.id }}:</text>
  143. <text>¥{{ item.money }}</text>
  144. </view>
  145. <view class="mess-itm">
  146. <text>总金额:</text>
  147. <text>¥{{ orderAmount }}</text>
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. </template>
  153. <script>
  154. export default {
  155. data() {
  156. return {
  157. showPay: false, //继续支付弹窗
  158. showHint: true, //无订单提示页
  159. showDetail: false, //订单详情弹窗
  160. orderList: [],
  161. studentName: "",
  162. studentNo: "",
  163. majorName: "",
  164. className: "",
  165. years: "",
  166. Arr: [],
  167. orderAmount: "",
  168. homeUrl: "https://jtishfw.ncjti.edu.cn/jiaofei/backendApi",
  169. notifyUrl:
  170. "https://jtishfw.ncjti.edu.cn/jiaofei/backendApi/pay/jxnxs/notify/",
  171. orderNo: "",
  172. //微信支付参数
  173. appId: "",
  174. timeStamp: "",
  175. nonceStr: "",
  176. package: "",
  177. signType: "",
  178. paySign: "",
  179. };
  180. },
  181. onLoad(options) {
  182. let cardNumber = sessionStorage.getItem("cardNumber");
  183. if (cardNumber == null) {
  184. uni.showToast({
  185. title: "cardNumber为空",
  186. icon: "error",
  187. mask: true,
  188. duration: 2000,
  189. });
  190. } else {
  191. this.getOrderList(); //获取订单列表
  192. }
  193. },
  194. methods: {
  195. markClose() {
  196. this.showPay = false;
  197. this.showDetail = false;
  198. },
  199. closeDetail() {
  200. this.showDetail = false;
  201. },
  202. closePay() {
  203. this.showPay = false;
  204. },
  205. //获取订单列表
  206. getOrderList() {
  207. let cardNumber = sessionStorage.getItem("cardNumber");
  208. let url = this.homeUrl + "/tuitionpayment/payorder/currentUserList";
  209. uni.request({
  210. url: url,
  211. data: {},
  212. header: {
  213. card_number: cardNumber,
  214. Accept: "application/json",
  215. "Content-Type": " application/x-www-form-urlencoded;charset=utf-8",
  216. "X-Requested-With": "XMLHttpRequest",
  217. },
  218. method: "GET",
  219. sslVerify: true,
  220. success: ({ data, statusCode, header }) => {
  221. if (data.success) {
  222. if (data.data.list.length !== 0) {
  223. this.showHint = false;
  224. this.orderList = data.data.list;
  225. }
  226. } else {
  227. uni.showToast({
  228. title: data.message,
  229. icon: "error",
  230. mask: true,
  231. duration: 2000,
  232. });
  233. }
  234. },
  235. fail: (error) => {},
  236. });
  237. },
  238. //查看详情
  239. detailMess(payForIdentify, studentName) {
  240. this.showDetail = !this.showDetail;
  241. let cardNumber = sessionStorage.getItem("cardNumber");
  242. let url =
  243. this.homeUrl +
  244. `/tuitionpayment/payableinfo/payableInfo/${payForIdentify}/${studentName}`;
  245. uni.request({
  246. url: url,
  247. header: {
  248. card_number: cardNumber,
  249. Accept: "application/json",
  250. "Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
  251. "X-Requested-With": "XMLHttpRequest",
  252. },
  253. method: "GET",
  254. sslVerify: true,
  255. success: ({ data, statusCode, header }) => {
  256. let res = data.data;
  257. this.studentName = res.studentName;
  258. this.studentNo = res.studentNo;
  259. this.years = res.years;
  260. this.majorName = res.majorName;
  261. this.className = res.className;
  262. this.getPayDetail(res.payItemDetail);
  263. this.orderAmount = res.realPayAmount;
  264. },
  265. fail: (error) => {},
  266. });
  267. },
  268. //继续支付
  269. toPay(payForIdentify, studentName) {
  270. this.showPay = !this.showPay;
  271. let cardNumber = sessionStorage.getItem("cardNumber");
  272. let url =
  273. this.homeUrl +
  274. `/tuitionpayment/payableinfo/payableInfo/${payForIdentify}/${studentName}`;
  275. uni.request({
  276. url: url,
  277. header: {
  278. card_number: cardNumber,
  279. Accept: "application/json",
  280. "Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
  281. "X-Requested-With": "XMLHttpRequest",
  282. },
  283. method: "GET",
  284. sslVerify: true,
  285. success: ({ data, statusCode, header }) => {
  286. let res = data.data;
  287. this.studentName = res.studentName;
  288. this.studentNo = res.studentNo;
  289. this.years = res.years;
  290. this.majorName = res.majorName;
  291. this.className = res.className;
  292. this.getPayDetail(res.payItemDetail);
  293. this.orderAmount = res.realPayAmount;
  294. },
  295. fail: (error) => {},
  296. });
  297. },
  298. //获取学费明细
  299. getPayDetail(len) {
  300. //获取明细款项名称数组
  301. var arr = len.match(/[^\\u4e00-\\u9fa5]+/g);
  302. //过滤
  303. var itemIdArr = arr.filter(function (value) {
  304. return value !== ".";
  305. });
  306. //获取明细金额数组
  307. var itemMoneyArr = len.match(/([0-9]+\.[0-9]+)+/g);
  308. //拼接成对象数组
  309. var item = [];
  310. for (var i in (itemIdArr, itemMoneyArr)) {
  311. var c = {
  312. id: itemIdArr[i],
  313. money: itemMoneyArr[i],
  314. };
  315. item.push(c);
  316. }
  317. this.Arr = item;
  318. },
  319. //订单反馈
  320. feedBack(orderNo) {
  321. let cardNumber = sessionStorage.getItem("cardNumber");
  322. let url = this.homeUrl + `/tuitionpayment/payorder/${orderNo}/orderStatu`;
  323. uni.request({
  324. url: url,
  325. data: {},
  326. header: {
  327. card_number: cardNumber,
  328. Accept: "application/json",
  329. "Content-Type": "application/json",
  330. "X-Requested-With": "XMLHttpRequest",
  331. },
  332. method: "GET",
  333. sslVerify: true,
  334. success: ({ data, statusCode, header }) => {
  335. if (data.data.status == 1) {
  336. uni.showToast({
  337. title: "支付失败",
  338. icon: "error",
  339. mask: true,
  340. });
  341. }
  342. },
  343. fail: (error) => {},
  344. });
  345. },
  346. //支付
  347. getPay() {
  348. uni.showToast({
  349. title: "支付中,请稍等",
  350. icon: "loading",
  351. mask: true,
  352. duration: 1500,
  353. });
  354. this.getOrderNo(); //获取订单号
  355. },
  356. //获取订单号
  357. getOrderNo() {
  358. let that = this;
  359. let cardNumber = sessionStorage.getItem("cardNumber");
  360. let url =
  361. that.homeUrl + `/tuitionpayment/payorder/${that.studentNo}/create`;
  362. uni.request({
  363. url: url,
  364. data: {},
  365. header: {
  366. card_number: cardNumber,
  367. Accept: "application/json",
  368. "Content-Type": "application/json",
  369. "X-Requested-With": "XMLHttpRequest",
  370. },
  371. method: "POST",
  372. sslVerify: true,
  373. success: ({ data, statusCode, header }) => {
  374. let res = data.data;
  375. that.orderNo = res.orderNo;
  376. if (!data.success) {
  377. uni.showToast({
  378. title: data.message,
  379. icon: "error",
  380. mask: true,
  381. duration: 2000,
  382. });
  383. } else {
  384. that.getPayMethod();
  385. }
  386. },
  387. fail: (error) => {},
  388. });
  389. },
  390. //获取支付方式
  391. getPayMethod() {
  392. let url = this.homeUrl + "/payMethodSetting/currentPay";
  393. uni.request({
  394. url: url,
  395. data: {},
  396. header: {
  397. Accept: "application/json",
  398. "Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
  399. "X-Requested-With": "XMLHttpRequest",
  400. },
  401. method: "GET",
  402. sslVerify: true,
  403. success: ({ data, statusCode, header }) => {
  404. let res = data.data;
  405. if (data.success) {
  406. if (res.currentPayMethod === "1") {
  407. this.getwxParam();
  408. } else {
  409. this.nsPay();
  410. }
  411. } else {
  412. uni.showToast({
  413. title: data.message,
  414. icon: "error",
  415. mask: true,
  416. duration: 1000,
  417. });
  418. }
  419. },
  420. fail: (error) => {},
  421. });
  422. },
  423. //拉起农商行支付
  424. nsPay() {
  425. let O = "5494ec3310685daa218382619dd20e27";
  426. let out_no = this.orderNo;
  427. let amount = this.orderAmount;
  428. let appoint_notify = this.notifyUrl;
  429. let mainUrl = `https://q.jxnxs.com/newpay?O=${O}&out_no=${out_no}&amount=${amount}&appoint_notify=${appoint_notify}`;
  430. window.location.href = mainUrl;
  431. },
  432. //获取微信支付参数
  433. getwxParam() {
  434. let that = this;
  435. let cardNumber = sessionStorage.getItem("cardNumber");
  436. let openId = localStorage.getItem("openId");
  437. let url = that.homeUrl + "/pay/ccb/getJsApiParam";
  438. uni.request({
  439. url: url,
  440. data: {
  441. orderNo: that.orderNo,
  442. openId: openId,
  443. },
  444. header: {
  445. card_number: cardNumber,
  446. Accept: "application/json",
  447. "Content-Type": "application/json",
  448. "X-Requested-With": "XMLHttpRequest",
  449. },
  450. method: "GET",
  451. sslVerify: true,
  452. success: ({ data, statusCode, header }) => {
  453. if (!data.success) {
  454. uni.showToast({
  455. title: data.message,
  456. icon: "error",
  457. mask: true,
  458. duration: 2000,
  459. });
  460. } else {
  461. let res = data.data;
  462. that.appId = res.appId;
  463. that.timeStamp = res.timeStamp;
  464. that.nonceStr = res.nonceStr;
  465. that.package = res.package;
  466. that.signType = res.signType;
  467. that.paySign = res.paySign;
  468. that.wxPay();
  469. }
  470. },
  471. fail: (error) => {},
  472. });
  473. },
  474. //吊起微信支付
  475. wxPay() {
  476. let that = this;
  477. function onBridgeReady() {
  478. WeixinJSBridge.invoke(
  479. "getBrandWCPayRequest",
  480. {
  481. appId: that.appId, //公众号ID,由商户传入
  482. timeStamp: that.timeStamp, //时间戳,自1970年以来的秒数
  483. nonceStr: that.nonceStr, //随机串
  484. package: that.package,
  485. signType: that.signType, //微信签名方式:
  486. paySign: that.paySign, //微信签名
  487. },
  488. function (res) {
  489. if (res.err_msg == "get_brand_wcpay_request:ok") {
  490. // 使用以上方式判断前端返回,微信团队郑重提示:
  491. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  492. }
  493. }
  494. );
  495. }
  496. if (typeof WeixinJSBridge == "undefined") {
  497. if (document.addEventListener) {
  498. document.addEventListener(
  499. "WeixinJSBridgeReady",
  500. onBridgeReady,
  501. false
  502. );
  503. } else if (document.attachEvent) {
  504. document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
  505. document.attachEvent("onWeixinJSBridgeReady", onBridgeReady);
  506. }
  507. } else {
  508. onBridgeReady();
  509. }
  510. },
  511. },
  512. };
  513. </script>
  514. <style lang="less">
  515. @import url("./css/order.min.css");
  516. </style>