parentPay.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view class="container">
  3. <view class="content1" v-if="content1">
  4. <view class="mark" v-show="showSearch" @click="close1"></view>
  5. <view class="messageBg1"></view>
  6. <view class="messageBg2"></view>
  7. <view class="messageCard">
  8. <image src="../../static/images/null.png" mode="scaleToFill" />
  9. <text>暂无缴费信息</text>
  10. <button hover-class="button-hover" @click="toSearch">帮人代缴</button>
  11. <button hover-class="button-hover" @click="toOrder">查询订单</button>
  12. </view>
  13. <view class="pop-up" v-show="showSearch">
  14. <view class="top">
  15. <text>代缴人信息</text>
  16. <view class="close" @click="close1">
  17. <view class="image"></view>
  18. </view>
  19. </view>
  20. <view class="name">
  21. <text>姓 名</text>
  22. <input
  23. v-model="SeaStudentName"
  24. type="text"
  25. placeholder="请输入姓名"
  26. placeholder-style="color:rgba(0, 0, 0, 0.29);"
  27. />
  28. </view>
  29. <view class="studentNo">
  30. <text>学 号</text>
  31. <input
  32. v-model="SeaStudentNo"
  33. type="text"
  34. placeholder="请输入学号"
  35. placeholder-style="color:rgba(0, 0, 0, 0.29);"
  36. />
  37. </view>
  38. <view class="remark">
  39. 备注:新生输入身份证号码代替学号,老生输入学号
  40. </view>
  41. <view class="confirm">
  42. <button hover-class="button-hover" @click="close1">取消</button>
  43. <button hover-class="button-hover" @click="searchDetailMess">
  44. 确认
  45. </button>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="content2" v-if="showMess">
  50. <view class="mark" v-show="showSearch"></view>
  51. <view class="messageBg1"></view>
  52. <view class="messageBg2"></view>
  53. <view class="messageCard">
  54. <view class="item-form">
  55. <view class="item">
  56. <text class="ite">收费单位 </text>
  57. <text class="content">南昌交通学院</text>
  58. </view>
  59. <view class="item">
  60. <text class="ite">姓名 </text>
  61. <text class="content">{{ studentName }}</text>
  62. </view>
  63. <view class="item">
  64. <text class="ite">学号 </text>
  65. <text class="content">{{ studentNo }}</text>
  66. </view>
  67. <view class="item">
  68. <text class="ite">专业 </text>
  69. <text class="content">{{ majorName }}</text>
  70. </view>
  71. <view class="item">
  72. <text class="ite">班级 </text>
  73. <text class="content">{{ className }}</text>
  74. </view>
  75. <view class="item">
  76. <text class="ite">缴费学年 </text>
  77. <text class="content">{{ years }}</text>
  78. </view>
  79. <!-- <template v-if="(itemArr.length = 0)"> -->
  80. <view class="item-pay" v-for="item in Arr">
  81. <text class="ite">{{ item.id }} </text>
  82. <text class="content">¥{{ item.money }}</text>
  83. </view>
  84. <!-- </template> -->
  85. <view class="item">
  86. <text class="ite">总金额 </text>
  87. <text class="content">¥{{ realPayAmount }}</text>
  88. </view>
  89. </view>
  90. <button @click="getPay()" hover-class="button-hover" v-if="payStatu1">
  91. 支付
  92. </button>
  93. <text class="okPay" v-if="payStatu2">已支付</text>
  94. <view class="bottom-a"></view>
  95. </view>
  96. </view>
  97. </view>
  98. </template>
  99. <script>
  100. export default {
  101. data() {
  102. return {
  103. content1: true,
  104. showMess: false,
  105. showSearch: false,
  106. studentName: "",
  107. studentNo: "",
  108. SeaStudentName: "",
  109. SeaStudentNo: "",
  110. majorName: "",
  111. className: "",
  112. years: "",
  113. realPayAmount: "",
  114. Arr: [],
  115. payStatu1: true,
  116. payStatu2: false,
  117. homeUrl: "https://jtishfw.ncjti.edu.cn/jiaofei/backendApi",
  118. notifyUrl:
  119. "https://jtishfw.ncjti.edu.cn/jiaofei/backendApi/pay/jxnxs/notify/",
  120. openId: "",
  121. cardNumber: "",
  122. orderNo: "", //订单号
  123. //微信支付参数
  124. appId: "",
  125. timeStamp: "",
  126. nonceStr: "",
  127. package: "",
  128. signType: "",
  129. paySign: "",
  130. };
  131. },
  132. onLoad(options) {
  133. this.getOpenId();
  134. },
  135. methods: {
  136. toSearch() {
  137. this.showSearch = !this.showSearch;
  138. },
  139. close1() {
  140. this.showSearch = !this.showSearch;
  141. },
  142. toShowMess() {
  143. this.showMess = !this.showMess;
  144. this.content1 = false;
  145. },
  146. //获取openId
  147. getOpenId() {
  148. let openId = localStorage.getItem("openId");
  149. if (!openId) {
  150. let openId = this.getQueryString("openId");
  151. let error = this.getQueryString("error");
  152. let errorMsg = this.getQueryString("errorMsg");
  153. let homeWeb = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd87cbe1db0437303&redirect_uri=${this.homeUrl}/wechat/pub/auth&response_type=code&scope=snsapi_base&state=pages/parentPay/parentPay#wechat_redire`;
  154. if (error) {
  155. uni.showToast({
  156. title: errorMsg,
  157. icon: "error",
  158. mask: true,
  159. duration: 1000,
  160. });
  161. } else if (!openId) {
  162. window.location.href = homeWeb;
  163. } else {
  164. localStorage.setItem("openId", openId);
  165. }
  166. }
  167. },
  168. //代缴费
  169. searchDetailMess() {
  170. if (!this.SeaStudentNo || !this.SeaStudentName) {
  171. uni.showToast({
  172. title: "学号或姓名不能为空",
  173. icon: "error",
  174. mask: true,
  175. duration: 1000,
  176. });
  177. } else {
  178. let that = this;
  179. let cardNumber = sessionStorage.getItem("cardNumber");
  180. let url =
  181. that.homeUrl +
  182. `/tuitionpayment/payableinfo/payableInfo/${that.SeaStudentNo}/${that.SeaStudentName}`;
  183. uni.request({
  184. url: url,
  185. header: {
  186. card_number: cardNumber,
  187. Accept: "application/json",
  188. "Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
  189. "X-Requested-With": "XMLHttpRequest",
  190. },
  191. method: "GET",
  192. sslVerify: true,
  193. success: ({ data, statusCode, header }) => {
  194. if (!data.success) {
  195. uni.showToast({
  196. title: data.message,
  197. icon: "error",
  198. mask: true,
  199. duration: 1000,
  200. });
  201. } else {
  202. uni.showToast({
  203. title: "信息查询中",
  204. icon: "loading",
  205. mask: true,
  206. duration: 500,
  207. });
  208. that.showSearch = !that.showSearch;
  209. that.toShowMess();
  210. let res = data.data;
  211. that.studentName = res.studentName;
  212. that.studentNo = res.studentNo;
  213. that.years = res.years;
  214. that.majorName = res.majorName;
  215. that.className = res.className;
  216. that.realPayAmount = res.realPayAmount;
  217. that.getPayDetail(res.payItemDetail);
  218. if (res.pay) {
  219. that.payStatu1 = false;
  220. that.payStatu2 = true;
  221. } else {
  222. that.payStatu1 = true;
  223. that.payStatu2 = false;
  224. }
  225. }
  226. },
  227. fail: (error) => {},
  228. });
  229. }
  230. },
  231. //获取学费明细
  232. getPayDetail(len) {
  233. //获取明细款项名称数组
  234. var arr = len.match(/[^\\u4e00-\\u9fa5]+/g);
  235. var itemIdArr = arr.filter(function (value) {
  236. return value !== ".";
  237. });
  238. //获取明细金额数组
  239. var itemMoneyArr = len.match(/([0-9]+\.[0-9]+)+/g);
  240. //拼接成对象数组
  241. var item = [];
  242. for (var i in (itemIdArr, itemMoneyArr)) {
  243. var c = {
  244. id: itemIdArr[i],
  245. money: itemMoneyArr[i],
  246. };
  247. item.push(c);
  248. }
  249. this.Arr = item;
  250. },
  251. //支付
  252. getPay() {
  253. uni.showToast({
  254. title: "支付中,请稍等",
  255. icon: "loading",
  256. mask: true,
  257. duration: 1500,
  258. });
  259. this.getOrderNo(); //获取订单号
  260. },
  261. //获取订单号
  262. getOrderNo() {
  263. let that = this;
  264. let cardNumber = sessionStorage.getItem("cardNumber");
  265. let url =
  266. that.homeUrl + `/tuitionpayment/payorder/${that.studentNo}/create`;
  267. uni.request({
  268. url: url,
  269. data: {},
  270. header: {
  271. card_number: cardNumber,
  272. Accept: "application/json",
  273. "Content-Type": "application/json",
  274. "X-Requested-With": "XMLHttpRequest",
  275. },
  276. method: "POST",
  277. sslVerify: true,
  278. success: ({ data, statusCode, header }) => {
  279. let res = data.data;
  280. that.orderNo = res.orderNo;
  281. if (!data.success) {
  282. uni.showToast({
  283. title: data.message,
  284. icon: "error",
  285. mask: true,
  286. duration: 2000,
  287. });
  288. } else {
  289. that.getPayMethod();
  290. }
  291. },
  292. fail: (error) => {},
  293. });
  294. },
  295. //获取支付方式
  296. getPayMethod() {
  297. let url = this.homeUrl + "/payMethodSetting/currentPay";
  298. uni.request({
  299. url: url,
  300. data: {},
  301. header: {
  302. Accept: "application/json",
  303. "Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
  304. "X-Requested-With": "XMLHttpRequest",
  305. },
  306. method: "GET",
  307. sslVerify: true,
  308. success: ({ data, statusCode, header }) => {
  309. let res = data.data;
  310. if (data.success) {
  311. if (res.currentPayMethod === "1") {
  312. this.getwxParam();
  313. } else {
  314. this.nsPay();
  315. }
  316. } else {
  317. uni.showToast({
  318. title: data.message,
  319. icon: "error",
  320. mask: true,
  321. duration: 1000,
  322. });
  323. }
  324. },
  325. fail: (error) => {},
  326. });
  327. },
  328. //拉起农商行支付
  329. nsPay() {
  330. let O = "5494ec3310685daa218382619dd20e27";
  331. let out_no = this.orderNo;
  332. let amount = this.realPayAmount;
  333. let appoint_notify = this.notifyUrl;
  334. let mainUrl = `https://q.jxnxs.com/newpay?O=${O}&out_no=${out_no}&amount=${amount}&appoint_notify=${appoint_notify}`;
  335. window.location.href = mainUrl;
  336. },
  337. //获取微信支付参数
  338. getwxParam() {
  339. let that = this;
  340. let cardNumber = sessionStorage.getItem("cardNumber");
  341. let openId = localStorage.getItem("openId");
  342. let url = that.homeUrl + "/pay/ccb/getJsApiParam";
  343. uni.request({
  344. url: url,
  345. data: {
  346. orderNo: that.orderNo,
  347. openId: openId,
  348. },
  349. header: {
  350. card_number: cardNumber,
  351. Accept: "application/json",
  352. "Content-Type": "application/json",
  353. "X-Requested-With": "XMLHttpRequest",
  354. },
  355. method: "GET",
  356. sslVerify: true,
  357. success: ({ data, statusCode, header }) => {
  358. if (!data.success) {
  359. uni.showToast({
  360. title: data.message,
  361. icon: "error",
  362. mask: true,
  363. duration: 2000,
  364. });
  365. } else {
  366. let res = data.data;
  367. that.appId = res.appId;
  368. that.timeStamp = res.timeStamp;
  369. that.nonceStr = res.nonceStr;
  370. that.package = res.package;
  371. that.signType = res.signType;
  372. that.paySign = res.paySign;
  373. that.wxPay();
  374. }
  375. },
  376. fail: (error) => {},
  377. });
  378. },
  379. //吊起微信支付
  380. wxPay() {
  381. let that = this;
  382. function onBridgeReady() {
  383. WeixinJSBridge.invoke(
  384. "getBrandWCPayRequest",
  385. {
  386. appId: that.appId, //公众号ID,由商户传入
  387. timeStamp: that.timeStamp, //时间戳,自1970年以来的秒数
  388. nonceStr: that.nonceStr, //随机串
  389. package: that.package,
  390. signType: that.signType, //微信签名方式:
  391. paySign: that.paySign, //微信签名
  392. },
  393. function (res) {
  394. if (res.err_msg == "get_brand_wcpay_request:ok") {
  395. // 使用以上方式判断前端返回,微信团队郑重提示:
  396. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  397. }
  398. }
  399. );
  400. }
  401. if (typeof WeixinJSBridge == "undefined") {
  402. if (document.addEventListener) {
  403. document.addEventListener(
  404. "WeixinJSBridgeReady",
  405. onBridgeReady,
  406. false
  407. );
  408. } else if (document.attachEvent) {
  409. document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
  410. document.attachEvent("onWeixinJSBridgeReady", onBridgeReady);
  411. }
  412. } else {
  413. onBridgeReady();
  414. }
  415. },
  416. //获取当前URL指定参数
  417. getQueryString(name) {
  418. let url = window.location.href; // 获取URL
  419. let pattern = new RegExp("[\?\&]" + name + "=([^\&]+)", "i"); // 正则匹配URL
  420. let matcher = pattern.exec(url);
  421. if (matcher == null || matcher.length < 1) {
  422. return false;
  423. }
  424. return decodeURIComponent(matcher[1]); // 输出指定的参数值 中文也可以
  425. },
  426. //跳转订单页面
  427. toOrder() {
  428. uni.redirectTo({ url: "/pages/order/order" });
  429. },
  430. },
  431. };
  432. </script>
  433. <style lang="scss" scoped>
  434. @import url("./css/parentPay.min.css");
  435. </style>