Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

recharge.vue 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  1. <template>
  2. <view class="wrapper">
  3. <view class="account">
  4. <image :src="`${$imgUrl}common/bg-recharge.png`" class="head-bg" mode="aspectFill"></image>
  5. <view class="account-text">
  6. <view class="balance">
  7. <text class="balance-tit">账户余额</text>
  8. <text class="balance-val">0元</text>
  9. </view>
  10. <view class="right-box">
  11. <view class="no">账户编号:000100</view>
  12. <view class="btn btn-record" @click="goRecord()">账户充值记录</view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="input-box">
  17. <input v-model="state.money" placeholder="请输入金额" class="input" />
  18. <view class="tips">最低充值金额不小于10元</view>
  19. </view>
  20. <view class="tabs">
  21. <view class="tab-tit as-gravity-center-start">充值方式
  22. <radio-group @change="radioChange" style="flex: 1;display:flex;margin-right: 30rpx;">
  23. <radio class="as-weight as-gravity-center" value="blu" :checked="state.transWay === 'blu'">蓝牙
  24. </radio>
  25. <radio class="as-weight" value="nfc" :checked="state.transWay === 'nfc'">NFC</radio>
  26. </radio-group>
  27. </view>
  28. <view class="tab-tit">在线充值</view>
  29. <view class="tab">
  30. <view v-for="(item,index) in state.moneryArray" @click="tableIndexAction(index)" :key="index"
  31. :class="{'item':state.moneryArray,'active':state.tableIndex===index}">{{item.name}}</view>
  32. </view>
  33. </view>
  34. <view class="btn btn-primary" @click="rechargeAction">立即充值</view>
  35. </view>
  36. <!-- <bluetooth :routeType="2" :cardId="state.cardId" v-if="state.isShowBlue" @submit="getParams"></bluetooth> -->
  37. </template>
  38. <script setup lang="ts">
  39. import {
  40. stringToJson
  41. } from "@/utils/network/encryption";
  42. import {
  43. onLoad,
  44. onShow
  45. } from "@dcloudio/uni-app";
  46. import {
  47. quanCheck,
  48. quanApply,
  49. quanXf,
  50. cardCzPayResultCheck,
  51. cardCzApply,
  52. cardCzPay,
  53. cardCzPayResult,
  54. cardCzXFCheck,
  55. quanConfirm,
  56. wechatAppID,
  57. wechatPayConfigId,
  58. wechatSecret,
  59. } from "@/utils/network/api.js";
  60. import {
  61. request
  62. } from "@/utils/network/request.js";
  63. import {
  64. reactive
  65. } from "vue";
  66. import {
  67. navTo
  68. } from "@/utils/utils"
  69. import {
  70. msg
  71. } from "@/utils/utils";
  72. import {
  73. getItem,
  74. StorageKeys,
  75. setItem
  76. } from "@/utils/storage";
  77. // const bluetooth=require("../../components/bluetooth/bluetooth")
  78. const datas = require("../../static/etcUtil/datas.js");
  79. const bluetoothUtil = require("../../static/etcUtil/index.js");
  80. const cmd = require("../../static/etcUtil/cmdConfig.js");
  81. const tools = require("../../static/etcUtil/tools.js");
  82. const NFCAPI = require('../../static/nfc/NFCAPI.js');
  83. const state = reactive({
  84. isShowBlue: false,
  85. moneryArray: [{
  86. name: '50元',
  87. value: 50
  88. }, {
  89. name: '100元',
  90. value: 100
  91. }, {
  92. name: '200元',
  93. value: 200
  94. }, {
  95. name: '300元',
  96. value: 300
  97. }, {
  98. name: '500元',
  99. value: 500
  100. }, {
  101. name: '1000元',
  102. value: 1000
  103. }],
  104. tableIndex: 0,
  105. openid: "",
  106. connectSuccess: undefined,
  107. fee: 5000,
  108. money: 50,
  109. orderNum: "",
  110. transWay: "blu", //“blu”为蓝牙充值方式、“nfc”为NFC充值方式
  111. cardId: "", //卡号 需要传参
  112. mockpreBalance: 2000, //fix:模拟余额 目前没有检测状态接口,第一次会模拟圈层检测来检测状态
  113. show: false,
  114. items: [{
  115. value: '0',
  116. name: '微信',
  117. checked: 'true'
  118. },
  119. {
  120. value: '1',
  121. name: '对公账户'
  122. }
  123. ],
  124. current: 0
  125. });
  126. //读卡信息
  127. const card : any = reactive({
  128. cardId: "",
  129. netId: "",
  130. cardType: "",
  131. startTime: "",
  132. endTime: "",
  133. userName: "",
  134. idNum: "",
  135. vehiclePlate: "",
  136. vehiclePlateColor: "",
  137. color: "",
  138. version: "",
  139. type: "",
  140. favourable: "",
  141. money: undefined,
  142. v_userType: "",
  143. });
  144. // const getParams = (val: any) => {
  145. // console.log("val蓝牙完毕传过来的参数", val)
  146. // state.cardId = val.cardId;
  147. // state.connectSuccess = val.connectSuccess;
  148. // }
  149. onLoad((option) => {
  150. /*获取openId 用途:(用户支付)*/
  151. getOpenID();
  152. /*传参*/
  153. state.cardId = option.cardId;
  154. state.connectSuccess = option.connectSuccess;
  155. state.orderNum = getItem("orderNum");
  156. // 金额回填,本来是好的,但是他跳转了,跳转过来就得刷新页面,所以就是默认的5000
  157. if (option.fee) {
  158. state.fee = option.fee
  159. state.money = option.fee / 100
  160. } else {
  161. state.fee = state.money * 100; //元换成分
  162. }
  163. console.log("state.fee", option)
  164. //跳转过来走圈存流程
  165. if (state.connectSuccess === "1") {
  166. /*读卡*/
  167. getCardId();
  168. } else {
  169. quanCheckAction().then((val : any) => {
  170. console.log("圈层检测val", val)
  171. //如果 圈层检测正常
  172. if (val.chargeStatus === 1) {
  173. console.log(`进行充值检测`);
  174. czCheckAction().then((checkResult : any) => {
  175. //判断订单逻辑如果有订单充值 则直接拿到订单去链接蓝牙
  176. if (checkResult.orders && checkResult.orders.length > 0) {
  177. //拿到订单,存起来
  178. state.orderNum = checkResult.orders[0].orderNum;
  179. setItem("orderNum", state.orderNum);
  180. // 检测用户是否存在有半条流水
  181. go()
  182. } else {
  183. console.log('没有可修复的流水')
  184. }
  185. });
  186. } else {
  187. // 检测用户是否存在有半条流水
  188. go()
  189. }
  190. });
  191. }
  192. });
  193. function radioChange(evt) {
  194. console.log('输出内容', evt)
  195. state.transWay = evt.detail.value; //“blu”为蓝牙充值方式、“nfc”为NFC充值方式
  196. }
  197. function go() {
  198. uni.showModal({
  199. title: '提示',
  200. content: '检测到你有一笔未充值的订单,请先进行充值!',
  201. success: () => {
  202. //走蓝牙进行修复
  203. uni.redirectTo({
  204. url: `/pages/bluetooth/bluetooth?routeType=2&&cardId=${state.cardId}&&fee=${state.fee}`,
  205. });
  206. // state.isShowBlue=true;
  207. console.log("state.isShowBlue", state.isShowBlue)
  208. },
  209. fail: () => { }
  210. })
  211. }
  212. const tableIndexAction = (val : any) => {
  213. state.tableIndex = val
  214. state.money = state.moneryArray[val].value
  215. }
  216. /*点击充值按钮*/
  217. const rechargeAction = () => {
  218. state.fee = state.money * 100; //元换成分
  219. wx.showModal({
  220. title: '圈存确认',
  221. content: '您确定要充值圈存吗',
  222. success: function (res) {
  223. if (res.confirm) {
  224. /*进行圈层检测,此处检测仅为校验圈层状态来决定去哪里*/
  225. console.log("进行圈层检测");
  226. quanCheckAction().then((val : any) => {
  227. //如果 圈层检测正常
  228. if (val.chargeStatus === 1) {
  229. console.log(`进行充值检测`);
  230. czCheckAction().then((checkResult : any) => {
  231. //判断订单逻辑如果有订单充值 则直接拿到订单去链接蓝牙
  232. if (checkResult.orders && checkResult.orders.length > 0) {
  233. //拿到订单,存起来
  234. state.orderNum = checkResult.orders[0].orderNum;
  235. setItem("orderNum", state.orderNum);
  236. //链接蓝牙
  237. go()
  238. } else {
  239. cardCzApplyAction().then((applyResult : any) => {
  240. //拿到订单 存起来
  241. state.orderNum = applyResult.orderNum;
  242. setItem("orderNum", state.orderNum);
  243. //如果订单没有支付 走支付
  244. if (applyResult.orderStatus === "ORDER_NOT_PAY") {
  245. //走支付
  246. console.log("走支付");
  247. wxPayment();
  248. }
  249. });
  250. }
  251. });
  252. } else {
  253. //走蓝牙进行修复
  254. go()
  255. }
  256. });
  257. }
  258. }
  259. });
  260. };
  261. /*读卡*/
  262. const getCardId = () => {
  263. console.log("======获取卡信息======");
  264. let cmdArr = [
  265. cmd.HOME_DIRECTORY,
  266. //选择主目
  267. cmd.APPLICATION_DIRECTORY,
  268. //选择文件1001--DF01联网收费应用目录
  269. cmd.CMD_READBINARY,
  270. //15文件--卡片发行基本数据文件
  271. cmd.CMD_GETBALANCE,
  272. //钱包
  273. ];
  274. tools.showLoadingAlert("正在执行指令");
  275. transCmd(cmdArr, function (res : any) {
  276. getCardIdReturn(res);
  277. })
  278. };
  279. function getCardIdReturn(res : any) {
  280. tools.hideLoadingAlert();
  281. //10:写卡 20:写OBU
  282. let str = res[2].substring(res[2].length - 4, res[2].length);
  283. let str3 = res[3].substring(res[3].length - 4, res[3].length);
  284. if (str == "9000" || str3 == "9000") {
  285. if (res[2].length > 86 || res[3] >= 12) {
  286. card.cardId = res[2].substring(20, 40); //卡号
  287. card.startTime = res[2].substring(40, 48);
  288. card.endTime = res[2].substring(48, 56);
  289. card.version = res[2].substring(18, 19) >= 4 ? "4x" : "2x";
  290. card.netId = res[2].substring(20, 24);
  291. card.cardType = res[2].substring(28, 29) == 23 ? 1 : 2;
  292. card.vehiclePlateColor = parseInt(res[2].substring(82, 84), 16);
  293. (card.money = parseInt(parseInt(res[3].substring(0, 8), 16), 10)),
  294. console.log("======卡信息======", card);
  295. if (card.cardId !== state.cardId) {
  296. msg("设备卡信息与当前充值卡号不匹配,请核对卡号");
  297. return;
  298. }
  299. quanCheckActionTrue().then((val) => {
  300. checkQuanCengEvent(val);
  301. });
  302. } else {
  303. console.error("CMD_READBINARY指令长度不符" + res[2]);
  304. tools.hideLoadingAlert();
  305. }
  306. }
  307. console.error("CMD_READBINARY指令长度不符" + res[2]);
  308. tools.hideLoadingAlert();
  309. }
  310. const checkQuanCengEvent = (val : any) => {
  311. if (val.chargeStatus === 1) {
  312. let cmdArr = val.command.split(",");
  313. uni.showLoading({
  314. title: "写入中",
  315. });
  316. transCmd(cmdArr, function (res : any) {
  317. let response = res.toString();
  318. var dic = {
  319. command: val.command,
  320. cosResponse: response,
  321. };
  322. uni.hideLoading();
  323. cardCzXFCheckAction().then((xfRes) => {
  324. quanApplyAction(dic).then((value : any) => {
  325. console.log("圈层申请完后的结果");
  326. console.log(value.commandType, value);
  327. //圈存初始化验证通过 , 进行圈存
  328. if (value.commandType === 2) {
  329. uanConfirmAction(value);
  330. } else {
  331. quanApplyAction(value).then((values) => {
  332. console.log("圈层申请完后的结果");
  333. uanConfirmAction(values);
  334. });
  335. // msg("圈存初始化指令验证失败, 重新初始化");
  336. }
  337. });
  338. });
  339. });
  340. } else {
  341. let cmdArr = val.command.split(",");
  342. uni.showLoading({
  343. title: "写入中",
  344. });
  345. transCmd(cmdArr, function (res : any) {
  346. var status = res[1].substring(res[1].length - 4, res[1].length);
  347. console.log("打印状态");
  348. console.log(status);
  349. if (status === "9000") {
  350. console.log("修复指令入参");
  351. let response = res.toString();
  352. var dic = {
  353. command: val.command,
  354. cosResponse: response,
  355. rechargeId: val.rechargeId,
  356. };
  357. quanFixAction(dic).then((value : any) => {
  358. console.log(value);
  359. console.log("修复结果返回");
  360. var fixStatus = value.fixStatus;
  361. //圈存修复COS指令Response信息不足,重新进行修复初始化
  362. if (fixStatus === 3) {
  363. let xfcmdArr = value.command.split(",");
  364. bluetoothUtil.transCmd(xfcmdArr, "10", function (resValueData) {
  365. var status = resValueData[1].substring(
  366. resValueData[1].length - 4,
  367. resValueData[1].length
  368. );
  369. console.log("打印状态");
  370. console.log(status);
  371. if (status === "9000") {
  372. console.log(resValueData);
  373. var valueResponse = resValueData.toString();
  374. console.log(response);
  375. var applyDic = {
  376. command: value.command,
  377. cosResponse: valueResponse,
  378. rechargeId: value.rechargeId,
  379. };
  380. console.log("消费成功");
  381. quanApplyAction(applyDic).then((applyValue) => {
  382. uanConfirmAction(applyValue);
  383. });
  384. }
  385. });
  386. } else if (fixStatus === 2) {
  387. uanConfirmSucessAction(value).then((confirmResult) => {
  388. console.log("充值成功")
  389. msg("充值成功");
  390. navTo(`/pages/recharge/result`)
  391. });
  392. } else if (fixStatus === 1) {
  393. quanCheckActionTrue().then((val) => {
  394. checkQuanCengEvent(val);
  395. });
  396. }
  397. });
  398. uni.hideLoading();
  399. }
  400. });
  401. }
  402. };
  403. /*透传*/
  404. const transCmd = (cmd : any, click : any) => {
  405. if (state.transWay == 'blu') {
  406. bluetoothUtil.transCmd(cmd, "10", function (res : any) {
  407. click(res);
  408. });
  409. } else {
  410. //nfc透传
  411. NFCAPI.transCmd(cmd, function (res : any) {
  412. tools.hideLoadingAlert();
  413. if (res.code == 0) {
  414. click(res.data);
  415. } else {
  416. //透传失败返回
  417. tools.alertF(res.msg);
  418. }
  419. });
  420. }
  421. };
  422. /*圈层检测 -假数据校验*/
  423. const quanCheckAction = () => {
  424. var data = {
  425. cardId: state.cardId, //卡号
  426. fee: state.fee,
  427. preBalance: state.mockpreBalance, //假余额
  428. tradeType: 14,
  429. };
  430. const options = {
  431. type: 2,
  432. data: data,
  433. method: "POST",
  434. showLoading: true,
  435. };
  436. return new Promise(async (resolve, reject) => {
  437. const res = await request(quanCheck, options);
  438. const data = stringToJson(res.bizContent);
  439. resolve(data);
  440. }).catch((error) => {
  441. reject(error);
  442. });
  443. };
  444. const quanCheckActionTrue = () => {
  445. console.log("进行真实圈层检测");
  446. var data = {
  447. cardId: card.cardId,
  448. fee: state.fee,
  449. preBalance: card.money,
  450. tradeType: 14,
  451. };
  452. const options = {
  453. type: 2,
  454. data: data,
  455. method: "POST",
  456. showLoading: true,
  457. };
  458. return new Promise(async (resolve, reject) => {
  459. const res = await request(quanCheck, options);
  460. const data = stringToJson(res.bizContent);
  461. resolve(data);
  462. }).catch((error) => {
  463. reject(error);
  464. });
  465. };
  466. /*充值消费*/
  467. const cardCzXFCheckAction = () => {
  468. var data = {
  469. cardId: card.cardId, //修复初始化的指令
  470. openId: getItem(StorageKeys.OpenId), //修复初始化结果
  471. orderNum: state.orderNum, //充值流水号
  472. };
  473. const options = {
  474. type: 2,
  475. data: data,
  476. method: "POST",
  477. showLoading: true,
  478. };
  479. return new Promise(async (resolve, reject) => {
  480. const res = await request(cardCzXFCheck, options);
  481. const data = stringToJson(res.bizContent);
  482. resolve(data);
  483. }).catch((error) => {
  484. reject(error);
  485. });
  486. };
  487. /*圈存修复*/
  488. const quanFixAction = (val) => {
  489. var data = {
  490. command: val.command, //修复初始化的指令
  491. cosResponse: val.cosResponse, //修复初始化结果
  492. rechargeId: val.rechargeId, //充值流水号
  493. };
  494. const options = {
  495. type: 2,
  496. data: data,
  497. method: "POST",
  498. showLoading: true,
  499. };
  500. return new Promise(async (resolve, reject) => {
  501. const res = await request(quanXf, options);
  502. const data = stringToJson(res.bizContent);
  503. resolve(data);
  504. }).catch((error) => {
  505. reject(error);
  506. });
  507. };
  508. /*圈层申请*/
  509. const quanApplyAction = (data) => {
  510. var form = {
  511. cardId: card.cardId,
  512. fee: state.fee,
  513. preBalance: card.money,
  514. tradeType: 14,
  515. command: data.command,
  516. cosResponse: data.cosResponse,
  517. orderId: state.orderNum,
  518. rechargeId: data.rechargeId,
  519. };
  520. const options = {
  521. type: 2,
  522. data: form,
  523. method: "POST",
  524. showLoading: true,
  525. };
  526. return new Promise(async (resolve, reject) => {
  527. const res = await request(quanApply, options);
  528. const data = stringToJson(res.bizContent);
  529. resolve(data);
  530. console.log("quanApplyAction", data)
  531. }).catch((error) => {
  532. reject(error);
  533. });
  534. };
  535. /*圈层确认*/
  536. const uanConfirmAction = (data : any) => {
  537. console.log("圈层确认进入");
  538. let cmdArr = data.command.split(",");
  539. console.log(cmdArr);
  540. transCmd(cmdArr, function (res : any) {
  541. console.log("圈层透传");
  542. console.log(res);
  543. var arraylenth = res.length;
  544. var status = res[arraylenth - 1].substring(
  545. res[arraylenth - 1].length - 4,
  546. res[arraylenth - 1].length
  547. );
  548. console.log("打印圈层确认指令状态");
  549. if (status === "9000") {
  550. var form = {
  551. command: data.command,
  552. cosResponse: res.toString(),
  553. rechargeId: data.rechargeId,
  554. paidAmount: state.fee,
  555. giftAmount: 0,
  556. };
  557. const options = {
  558. type: 2,
  559. data: form,
  560. method: "POST",
  561. showLoading: true,
  562. };
  563. return new Promise(async () => {
  564. const res = await request(quanConfirm, options);
  565. const data = stringToJson(res.bizContent);
  566. // resolve(data);
  567. console.log("data", data);
  568. msg("充值成功");
  569. navTo(`/pages/recharge/result`)
  570. }).catch((error) => {
  571. console.log('输出内容', error)
  572. });
  573. }
  574. });
  575. };
  576. const uanConfirmSucessAction = (data) => {
  577. var form = {
  578. command: data.command,
  579. cosResponse: "9000",
  580. rechargeId: data.rechargeId,
  581. paidAmount: state.fee,
  582. giftAmount: 0,
  583. };
  584. const options = {
  585. type: 2,
  586. data: form,
  587. method: "POST",
  588. showLoading: true,
  589. };
  590. return new Promise(async (resolve, reject) => {
  591. const res = await request(quanConfirm, options);
  592. const data = stringToJson(res.bizContent);
  593. resolve(data);
  594. console.log("uanConfirmSucessAction", data)
  595. }).catch((error) => {
  596. reject(error);
  597. });
  598. };
  599. /*充值检测*/
  600. const czCheckAction = () => {
  601. var form = {
  602. cardId: state.cardId,
  603. openId: getItem(StorageKeys.OpenId),
  604. };
  605. const options = {
  606. type: 2,
  607. data: form,
  608. method: "POST",
  609. showLoading: true,
  610. };
  611. return new Promise(async (resolve, reject) => {
  612. const res = await request(cardCzPayResultCheck, options);
  613. const data = stringToJson(res.bizContent);
  614. console.log("充值检测", data)
  615. resolve(data);
  616. }).catch((error) => {
  617. reject(error);
  618. });
  619. };
  620. /*充值申请*/
  621. const cardCzApplyAction = () => {
  622. var data = {
  623. cardId: state.cardId,
  624. openId: getItem(StorageKeys.OpenId),
  625. rechargeMoney: state.fee,
  626. };
  627. const options = {
  628. type: 2,
  629. data: data,
  630. method: "POST",
  631. showLoading: true,
  632. };
  633. return new Promise(async (resolve, reject) => {
  634. const res = await request(cardCzApply, options);
  635. const data = stringToJson(res.bizContent);
  636. resolve(data);
  637. }).catch((error) => {
  638. reject(error);
  639. });
  640. };
  641. //获取微信小程序openid
  642. const getOpenID = () => {
  643. uni.login({
  644. provider: "weixin",
  645. success: function (e) {
  646. wx.request({
  647. url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  648. success: (res : any) => {
  649. state.openid = res.data.openid;
  650. },
  651. });
  652. },
  653. fail: function () {
  654. msg("获取不到oppenId,请检查AppID和Secret是否争取");
  655. },
  656. });
  657. };
  658. //掉起微信支付
  659. const wxPayment = () => {
  660. // #ifdef MP-WEIXIN
  661. const options = {
  662. type: 2,
  663. data: {
  664. openId: getItem(StorageKeys.OpenId),
  665. wxOpenId: state.openid,
  666. cardId: state.cardId,
  667. orderNum: state.orderNum,
  668. payConfigId: wechatPayConfigId,
  669. body: "储值卡充值",
  670. },
  671. method: "POST",
  672. showLoading: true,
  673. };
  674. request(cardCzPay, options).then((res) => {
  675. const data = stringToJson(res.bizContent);
  676. uni.requestPayment({
  677. provider: "wxpay",
  678. orderInfo: "",
  679. timeStamp: data.timestamp,
  680. nonceStr: data.noncestr,
  681. package: data.wxPackage ? data.wxPackage : "",
  682. signType: data.signType,
  683. paySign: data.sign,
  684. success: function () {
  685. //回调订单状态
  686. console.log("回调订单状态");
  687. checkOrder();
  688. },
  689. fail: function (err) {
  690. confirm(err, () => { }, "支付失败", false);
  691. },
  692. });
  693. });
  694. // #endif
  695. };
  696. //支付成功改变订单状态
  697. const checkOrder = () => {
  698. const options = {
  699. type: 2,
  700. data: {
  701. cardId: state.cardId,
  702. openId: getItem(StorageKeys.OpenId),
  703. orderNum: state.orderNum,
  704. },
  705. method: "POST",
  706. showLoading: true,
  707. };
  708. request(cardCzPayResult, options).then((res) => {
  709. const data = stringToJson(res.bizContent);
  710. if (data.tradeState === "SUCCESS") {
  711. if (state.transWay == 'blu') {
  712. uni.redirectTo({
  713. url: `/pages/bluetooth/bluetooth?routeType=2&&cardId=${state.cardId}&&fee=${state.fee}`,
  714. });
  715. } else {
  716. uni.redirectTo({
  717. url: `/pages/nfc/nfc?routeType=2&&cardId=${state.cardId}&&fee=${state.fee}`,
  718. });
  719. }
  720. }
  721. // state.isShowBlue=true;
  722. console.log(data);
  723. });
  724. };
  725. const goRecord = () => {
  726. uni.navigateTo({
  727. url: `/subpackage/personal-center/consumption-record?cardId=${state.cardId}`
  728. })
  729. }
  730. </script>
  731. <style>
  732. .account {
  733. height: 224rpx;
  734. width: 690rpx;
  735. margin: 30rpx;
  736. position: relative;
  737. }
  738. .account .account-text {
  739. display: flex;
  740. justify-content: space-between;
  741. padding: 20rpx 50rpx;
  742. height: 100%;
  743. }
  744. .account .balance {
  745. display: flex;
  746. flex-direction: column;
  747. justify-content: center;
  748. align-items: flex-start;
  749. color: #ffffff;
  750. }
  751. .account .balance-tit {
  752. font-size: 26rpx;
  753. margin-bottom: 10rpx;
  754. }
  755. .account .balance-val {
  756. font-size: 56rpx;
  757. }
  758. .account .right-box {
  759. display: flex;
  760. flex-direction: column;
  761. justify-content: flex-start;
  762. align-items: flex-end;
  763. }
  764. .account .right-box .no {
  765. font-size: 26rpx;
  766. color: #ffffff;
  767. }
  768. .account .right-box .btn {
  769. font-size: 26rpx;
  770. padding: 0 20rpx;
  771. box-sizing: border-box;
  772. height: 42rpx;
  773. line-height: 42rpx;
  774. color: #28d20f;
  775. background: #ffffff;
  776. border-radius: 21rpx;
  777. display: inline-block;
  778. margin-top: 18rpx;
  779. }
  780. .account .head-bg {
  781. width: 690rpx;
  782. height: 224rpx;
  783. position: absolute;
  784. left: 0;
  785. top: 0;
  786. z-index: -99;
  787. }
  788. .input-box {
  789. display: flex;
  790. flex-direction: column;
  791. justify-content: center;
  792. align-items: center;
  793. padding: 20rpx 0;
  794. }
  795. .input-box .input {
  796. width: 430rpx;
  797. height: 98rpx;
  798. line-height: 98rpx;
  799. background: #f8f8f8;
  800. border: 1px solid #999999;
  801. border-radius: 6rpx;
  802. font-size: 30rpx;
  803. text-align: center;
  804. }
  805. .input-box .tips {
  806. color: #666666;
  807. font-size: 26rpx;
  808. margin-top: 18rpx;
  809. }
  810. .tabs {}
  811. .tabs .tab-tit {
  812. font-size: 30rpx;
  813. color: #333;
  814. padding: 45rpx 0 22rpx 30rpx;
  815. }
  816. .tabs .tab {
  817. display: flex;
  818. flex-wrap: wrap;
  819. justify-content: space-evenly;
  820. }
  821. .tabs .tab .item {
  822. width: 210rpx;
  823. height: 100rpx;
  824. background: #f6fff7;
  825. border: 1px solid #dcdde1;
  826. box-sizing: border-box;
  827. line-height: 100rpx;
  828. border-radius: 6rpx;
  829. text-align: center;
  830. margin-bottom: 24rpx;
  831. color: #333333;
  832. font-size: 32rpx;
  833. }
  834. .tabs .tab .item.active {
  835. border: 1px solid #24cc49;
  836. color: #24cc49;
  837. }
  838. .btn-primary {
  839. width: 670rpx;
  840. height: 80rpx;
  841. line-height: 80rpx;
  842. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  843. border-radius: 40rpx;
  844. font-size: 32rpx;
  845. color: #ffffff;
  846. margin: 200rpx 40rpx 0;
  847. text-align: center;
  848. }
  849. .uni-list {
  850. padding: 120rpx 10rpx 0 10rpx;
  851. font-size: 34rpx;
  852. }
  853. label {
  854. display: flex;
  855. justify-content: space-between;
  856. margin-top: 30rpx;
  857. }
  858. </style>