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 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <view class="wrapper">
  3. <view class="account">
  4. <image :src="`${$imgUrl}common/bg-recharge.png`" class="head-bg"></image>
  5. <view class="account-text">
  6. <view class="balance">
  7. <text class="balance-tit">账户余额</text>
  8. <text class="balance-val">20.00元</text>
  9. </view>
  10. <view class="right-box">
  11. <view class="no">账户编号:000100</view>
  12. <view class="btn btn-record">账户充值记录</view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="input-box">
  17. <input placeholder="请输入金额" class="input" />
  18. <view class="tips">最低充值金额不小于10元</view>
  19. </view>
  20. <view class="tabs">
  21. <view class="tab-tit">在线充值</view>
  22. <view class="tab">
  23. <view class="item">50元</view>
  24. <view class="item active">100元</view>
  25. <view class="item">200元</view>
  26. <view class="item">300元</view>
  27. <view class="item">500元</view>
  28. <view class="item">1000元</view>
  29. </view>
  30. </view>
  31. <view class="btn btn-primary" @click="recharge">立即充值</view>
  32. </view>
  33. </template>
  34. <script setup lang="ts">
  35. import {
  36. stringToJson
  37. } from "@/utils/network/encryption";
  38. import navBar from "../components/nav-bar/nav-bar2.vue";
  39. import {
  40. onLoad,
  41. onShow
  42. } from "@dcloudio/uni-app";
  43. import {
  44. quanCheck,
  45. quanApply,
  46. quanXf,
  47. cardCzPayResultCheck,
  48. cardCzApply
  49. } from "@/utils/network/api.js";
  50. import {
  51. request
  52. } from "@/utils/network/request.js";
  53. import {
  54. reactive
  55. } from "vue";
  56. import {
  57. msg
  58. } from "@/utils/utils";
  59. import {
  60. getItem,
  61. StorageKeys
  62. } from "@/utils/storage";
  63. const datas = require("../../static/etcUtil/datas.js");
  64. const bluetoothUtil = require("../../static/etcUtil/index.js");
  65. const recharge = () => {
  66. uni.navigateTo({
  67. url: "/pages/recharge/result"
  68. })
  69. }
  70. onLoad((option) => {
  71. /*1.圈层检测*/
  72. quanCheckAction().then(val => {
  73. //圈层检测正常
  74. if (val.chargeStatus === 1) {
  75. czCheckAction()
  76. } else {
  77. if (option.connectSuccess !== '1') {
  78. uni.navigateTo({
  79. url: `/pages/bluetooth/device-active-step3?routeType=2`,
  80. });
  81. } else {
  82. let cmdArr = val.command.split(",");
  83. uni.showLoading({
  84. title: "写入中"
  85. })
  86. bluetoothUtil.transCmd(cmdArr, "10", function(res) {
  87. let response = res.toString();
  88. var dic = {
  89. command: val.command,
  90. cosResponse: response,
  91. rechargeId: val.rechargeId
  92. }
  93. quanFixAction(dic).then(value => {
  94. var fixStatus = value.fixStatus;
  95. //圈存修复COS指令Response信息不足,重新进行修复初始化
  96. if (fixStatus === 1) {
  97. } else if (fixStatus === 2) {
  98. quanApplyAction()
  99. //圈存确认
  100. } else if (fixStatus === 3) {
  101. //圈存确认
  102. }
  103. console.log('修复成功')
  104. })
  105. uni.hideLoading()
  106. });
  107. }
  108. }
  109. })
  110. });
  111. /*圈层检测*/
  112. const quanCheckAction = () => {
  113. var data = {
  114. cardId: '52011328220201979745',
  115. fee: 199,
  116. preBalance: 19588,
  117. tradeType: 14,
  118. agentId: "52010106004",
  119. channelId: "5201010200601130001",
  120. channelType: "1",
  121. staffId: "opId",
  122. terminalId: "999999999999"
  123. };
  124. const options = {
  125. type: 2,
  126. data: data,
  127. method: "POST",
  128. showLoading: true,
  129. };
  130. return new Promise(async (resolve, reject) => {
  131. const res = await request(quanCheck, options);
  132. const data = stringToJson(res.bizContent);
  133. resolve(data);
  134. }).catch((error) => {
  135. reject(error);
  136. });
  137. }
  138. /*圈存修复*/
  139. const quanFixAction = (val) => {
  140. var data = {
  141. command: val.command, //修复初始化的指令
  142. cosResponse: val.cosResponse, //修复初始化结果
  143. rechargeId: val.rechargeId, //充值流水号
  144. agentId: "52010106004",
  145. channelId: "5201010200601130001",
  146. channelType: "1",
  147. staffId: "opId",
  148. terminalId: "999999999999"
  149. };
  150. console.log('111111111')
  151. const options = {
  152. type: 2,
  153. data: data,
  154. method: "POST",
  155. showLoading: true,
  156. };
  157. return new Promise(async (resolve, reject) => {
  158. const res = await request(quanXf, options);
  159. const data = stringToJson(res.bizContent);
  160. resolve(data);
  161. }).catch((error) => {
  162. reject(error);
  163. });
  164. }
  165. /*圈层申请*/
  166. const quanApplyAction = (data) => {
  167. var form = {
  168. cardId: '52011328220201979745',
  169. fee: 50,
  170. preBalance: 100,
  171. tradeType: 14,
  172. command: data.command,
  173. cosResponse: '',
  174. agentId: "52010106004",
  175. channelId: "5201010200601130001",
  176. channelType: "1",
  177. staffId: "opId",
  178. terminalId: "999999999999"
  179. };
  180. const options = {
  181. type: 2,
  182. data: form,
  183. method: "POST",
  184. showLoading: true,
  185. };
  186. request(quanApply, options).then((res) => {
  187. const data = stringToJson(res.bizContent);
  188. quanApplyAction(data)
  189. });
  190. }
  191. /*充值检测*/
  192. const czCheckAction = (data) => {
  193. var form = {
  194. cardId: '52011328220201979745',
  195. openId: getItem(StorageKeys.OpenId),
  196. agentId: "52010106004",
  197. channelId: "5201010200601130001",
  198. channelType: "1",
  199. staffId: "opId",
  200. terminalId: "999999999999"
  201. };
  202. const options = {
  203. type: 2,
  204. data: form,
  205. method: "POST",
  206. showLoading: true,
  207. };
  208. request(cardCzPayResultCheck, options).then((res) => {
  209. const data = stringToJson(res.bizContent);
  210. cardCzApplyAction().then(val => {
  211. console.log(val)
  212. })
  213. });
  214. }
  215. const cardCzApplyAction = () => {
  216. var data = {
  217. cardId: '52011328220201979745',
  218. openId: getItem(StorageKeys.OpenId),
  219. rechargeMoney: 100,
  220. agentId: "52010106004",
  221. channelId: "5201010200601130001",
  222. channelType: "1",
  223. staffId: "opId",
  224. terminalId: "999999999999"
  225. };
  226. const options = {
  227. type: 2,
  228. data: data,
  229. method: "POST",
  230. showLoading: true,
  231. };
  232. return new Promise(async (resolve, reject) => {
  233. const res = await request(cardCzApply, options);
  234. const data = stringToJson(res.bizContent);
  235. resolve(data);
  236. }).catch((error) => {
  237. reject(error);
  238. });
  239. }
  240. </script>
  241. <style>
  242. .account {
  243. height: 224rpx;
  244. width: 690rpx;
  245. margin: 30rpx;
  246. position: relative;
  247. }
  248. .account .account-text {
  249. display: flex;
  250. justify-content: space-between;
  251. padding: 20rpx 50rpx;
  252. height: 100%;
  253. }
  254. .account .balance {
  255. display: flex;
  256. flex-direction: column;
  257. justify-content: center;
  258. align-items: flex-start;
  259. color: #ffffff;
  260. }
  261. .account .balance-tit {
  262. font-size: 26rpx;
  263. margin-bottom: 10rpx;
  264. }
  265. .account .balance-val {
  266. font-size: 56rpx;
  267. }
  268. .account .right-box {
  269. display: flex;
  270. flex-direction: column;
  271. justify-content: flex-start;
  272. align-items: flex-end;
  273. }
  274. .account .right-box .no {
  275. font-size: 26rpx;
  276. color: #ffffff;
  277. }
  278. .account .right-box .btn {
  279. font-size: 26rpx;
  280. padding: 0 20rpx;
  281. box-sizing: border-box;
  282. height: 42rpx;
  283. line-height: 42rpx;
  284. color: #28d20f;
  285. background: #ffffff;
  286. border-radius: 21rpx;
  287. display: inline-block;
  288. margin-top: 18rpx;
  289. }
  290. .account .head-bg {
  291. width: 690rpx;
  292. height: 224rpx;
  293. position: absolute;
  294. left: 0;
  295. top: 0;
  296. z-index: -99;
  297. }
  298. .input-box {
  299. display: flex;
  300. flex-direction: column;
  301. justify-content: center;
  302. align-items: center;
  303. padding: 20rpx 0;
  304. }
  305. .input-box .input {
  306. width: 430rpx;
  307. height: 98rpx;
  308. line-height: 98rpx;
  309. background: #f8f8f8;
  310. border: 1px solid #999999;
  311. border-radius: 6rpx;
  312. font-size: 30rpx;
  313. text-align: center;
  314. }
  315. .input-box .tips {
  316. color: #666666;
  317. font-size: 26rpx;
  318. margin-top: 18rpx;
  319. }
  320. .tabs {}
  321. .tabs .tab-tit {
  322. font-size: 30rpx;
  323. color: #333;
  324. padding: 45rpx 0 22rpx 30rpx;
  325. }
  326. .tabs .tab {
  327. display: flex;
  328. flex-wrap: wrap;
  329. justify-content: space-evenly;
  330. }
  331. .tabs .tab .item {
  332. width: 210rpx;
  333. height: 100rpx;
  334. background: #F6FFF7;
  335. border: 1px solid #DCDDE1;
  336. box-sizing: border-box;
  337. line-height: 100rpx;
  338. border-radius: 6rpx;
  339. text-align: center;
  340. margin-bottom: 24rpx;
  341. color: #333333;
  342. font-size: 32rpx;
  343. }
  344. .tabs .tab .item.active {
  345. border: 1px solid #24cc49;
  346. color: #24cc49;
  347. }
  348. .btn-primary {
  349. width: 670rpx;
  350. height: 80rpx;
  351. line-height: 80rpx;
  352. background: linear-gradient(-90deg, #43A1E0 0%, #13E7C1 100%);
  353. border-radius: 40rpx;
  354. font-size: 32rpx;
  355. color: #ffffff;
  356. margin: 200rpx 40rpx 0;
  357. text-align: center;
  358. }
  359. </style>