You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

recharge.vue 23KB

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