index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. <template>
  2. <view class="page">
  3. <!-- 钱包 -->
  4. <view class="recharge-me">
  5. <view class="bg-img">
  6. <!-- <image src="../../static/recharge/u1709.jpg" mode=""></image> -->
  7. </view>
  8. <view class="wallet-content">
  9. <view class="h-balance-wrap">
  10. <view class="h-balance">
  11. <view class="recharge-balance">
  12. <view class="h-nav-img">
  13. <image src="../../static/transaction/u1.png" mode=""></image>
  14. </view>
  15. <view class="name">储值余额</view>
  16. <view class="balance-value">¥
  17. <text v-if="userInfo.rechargeBalance">{{userInfo.rechargeBalance}}</text>
  18. <text v-else>0</text>
  19. </view>
  20. </view>
  21. <view class="recharge-balance">
  22. <view class="h-nav-img">
  23. <image src="../../static/transaction/u3.png" mode=""></image>
  24. </view>
  25. <view class="name">赠送余额</view>
  26. <view class="balance-value">¥
  27. <text v-if="userInfo.rewardBalance" class="">{{userInfo.rewardBalance}}</text>
  28. <text v-else>0</text>
  29. </view>
  30. </view>
  31. <view class="recharge-balance">
  32. <view class="h-nav-img">
  33. <image src="../../static/transaction/u4.png" mode=""></image>
  34. </view>
  35. <view class="name">赠送优惠券</view>
  36. <view class="balance-value">
  37. <text v-if="userInfo.coupon" >{{userInfo.coupon}}</text>
  38. <text v-else>0</text>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="horizontal-dashed-line"></view>
  43. <view class="btn">
  44. <view @click="gotoTransactionRecords()" class="item-btn">
  45. <text>交易记录</text>>
  46. </view>
  47. <view class="dashed-line" ></view>
  48. <view @click="gotoTransactionOrderRecords()" class="item-btn">
  49. <text>储值订单</text>>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="skill-sequence-panel-content-wrapper">
  54. <!--左边虚化-->
  55. <!-- <view class="hide-content-box hide-content-box-left"></view> -->
  56. <!--右边虚化-->
  57. <!-- <view class="hide-content-box hide-content-box-right"></view> -->
  58. <scroll-view scroll-x="true" class="kite-classify-scroll">
  59. <view @click="selectActiveRecharge(item,index)" class="kite-classify-cell shadow" v-for="(item, index) in rechargeList" :key="index">
  60. <view v-if="currentTab === index" class="h-bg-img">
  61. <image src="../../static/transaction/u2.png" mode=""></image>
  62. </view>
  63. <view v-else class="h-bg-img">
  64. <image src="../../static/recharge/dianka.png" mode=""></image>
  65. </view>
  66. <view class="content">
  67. <view class="money">
  68. ¥<text class="v">{{item.reachPrice}}</text>
  69. </view>
  70. <view class="desc">
  71. <text>{{item.name}} </text>
  72. <!-- <text>充¥{{item.reachPrice}}赚送¥{{item.discountsPrice}}</text> -->
  73. </view>
  74. </view>
  75. </view>
  76. </scroll-view>
  77. </view>
  78. <!-- 选择充值金额 -->
  79. <!-- <view class="recharge-content-wrap">
  80. <view v-for="(item,index) in rechargeList"
  81. @click="selectActiveRecharge(item,index)" class="recharge-content">
  82. <view v-if="currentTab === index" class="h-bg-img">
  83. <image src="../../static/transaction/u2.png" mode=""></image>
  84. </view>
  85. <view v-else class="h-bg-img">
  86. <image src="../../static/recharge/dianka.png" mode=""></image>
  87. </view>
  88. <view class="content">
  89. <view class="money">
  90. ¥<text class="v">{{item.reachPrice}}</text>
  91. </view>
  92. <view class="desc">
  93. <text>{{item.name}} </text>
  94. <text>充¥{{item.reachPrice}}赚送¥{{item.discountsPrice}}</text>
  95. </view>
  96. </view>
  97. </view>
  98. </view> -->
  99. <!-- 自定义充值金额 -->
  100. <!-- <view class="h-custom">
  101. <view class="h-icon">
  102. <u-icon name="rmb" color="#333" size="22"></u-icon>
  103. </view>
  104. <view class="h-money">
  105. <input v-model="reqOrderParm.rechargeAmount" @click="cancelChooseMoney" placeholder="请输入金额" type="number">
  106. </view>
  107. </view> -->
  108. <!-- 充值按钮 -->
  109. <view v-if="rechargeList.length > 0" @click="submitOrder()" class="h-submit-btn">
  110. <text>立即充值</text>
  111. </view>
  112. <!-- 用户充值协议 -->
  113. <view class="recharge-agreement">
  114. <view class="radio-group">
  115. <radio @click="toggleSelection" class="v-text" :checked="isSelected" >我已阅读并同意</radio>
  116. <text @click="gotoTermOfService(8)" class="h-btn">《储值协议》</text>
  117. </view>
  118. </view>
  119. <!-- 使用说明 -->
  120. <view class="h-desc">
  121. <view class="title">
  122. <text>使用说明</text>
  123. </view>
  124. <view class="h-content">
  125. <view class="h-v-text">
  126. <text>1、 这上面的夜的天空,奇怪而高,我生平。</text>
  127. </view>
  128. <view class="h-v-text">
  129. <text>2、 这上面的夜的天空,奇怪而高,我生平。</text>
  130. </view>
  131. <view class="h-v-text">
  132. <text>3、 这上面的夜的天空,奇怪而高,我生平。</text>
  133. </view>
  134. <view class="h-v-text">
  135. <text>4、 这上面的夜的天空,奇怪而高,我生平。</text>
  136. </view>
  137. <view class="h-v-text">
  138. <text>5、 这上面的夜的天空,奇怪而高,我生平。</text>
  139. </view>
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. </template>
  146. <script>
  147. export default {
  148. data() {
  149. return {
  150. show: false,
  151. currentTab: '', // 当前选中的 Tab
  152. isSelected: true,
  153. userInfo: {},
  154. reqOrderParm: {
  155. auth: true,
  156. orderType: 3, // 订单类型;1-服务订单 2-产品订单 3-充值订单
  157. rechargeAmount: null, // 充值金额
  158. strategyId: null, // 优惠策略的ID 测试id 1694514233806888962
  159. remark: null
  160. },
  161. reqPayParm: {
  162. auth: true,
  163. orderNo: null,
  164. openid: null,
  165. requstForm: true
  166. },
  167. rechargeList: [],
  168. };
  169. },
  170. onLoad() {
  171. },
  172. onShow() {
  173. // 获取充值面额
  174. this.getRechargeList();
  175. // 用户信息
  176. this.userInfo = uni.getStorageSync('userInfo');
  177. },
  178. methods: {
  179. // 获取充值面额
  180. getRechargeList(){
  181. console.log('+++++++++666666666666666666+++++++++++++++++++')
  182. this.$api.getRechargeList(this.reqOrderParm).then((res)=>{
  183. console.log('++++++++++++++getRechargeList+++++++++++++++++',res)
  184. this.rechargeList = res.data.data;
  185. }).catch(() =>{
  186. uni.showToast({
  187. title: "操作失败"
  188. })
  189. });
  190. },
  191. // 提交订单
  192. submitOrder(){
  193. const that = this;
  194. if(!this.isSelected){ // 是否确定协议
  195. uni.showToast({
  196. title: '请选择充值协议!'
  197. });
  198. return;
  199. }
  200. if(this.reqOrderParm.strategyId == null){
  201. uni.showToast({
  202. title: '请选择充值项目!'
  203. });
  204. return;
  205. }
  206. // 提交订单
  207. this.$api.commonGeneralOrder(this.reqOrderParm).then((res)=>{
  208. console.log('+++++++++++commonGeneralOrder++++++++++',res)
  209. that.reqPayParm.orderNo = res.data.data.orderNo;
  210. // 调用微信支付
  211. that.wechatPay();
  212. }).catch(() =>{
  213. uni.showToast({
  214. title: "操作失败"
  215. })
  216. });
  217. },
  218. // 微信支付
  219. wechatPay(){
  220. const that = this;
  221. // 用户信息
  222. that.reqPayParm.requstForm = true;
  223. this.$api.wechatPay(that.reqPayParm).then((res)=>{
  224. var param = res.data.data;
  225. uni.requestPayment({
  226. appId: param.appid,
  227. timeStamp: param.timestamp+"",
  228. nonceStr: param.noncestr,
  229. package: "prepay_id="+param.prepayid,
  230. signType: "RSA",
  231. paySign: param.sign,
  232. success: res => {
  233. uni.showToast({
  234. title: '支付成功!'
  235. });
  236. // 刷新用户信息
  237. that.getUserInfo()
  238. },
  239. fail: res => {
  240. uni.showModal({
  241. content: '支付失败',
  242. showCancel: false
  243. });
  244. }
  245. });
  246. }).catch(() =>{
  247. uni.showToast({
  248. title: "操作失败"
  249. })
  250. });
  251. },
  252. getUserInfo(){
  253. this.$api.getUserInfo().then(res=>{
  254. console.log('++++++++++++获取用户信息++++++++++++++++++',res)
  255. uni.setStorageSync('userInfo',res.data.data)
  256. this.userInfo = res.data.data
  257. })
  258. },
  259. // 取消上面选择的面值
  260. cancelChooseMoney(){
  261. this.reqOrderParm.strategyId = null;
  262. this.reqOrderParm.rechargeAmount = null;
  263. this.currentTab = '';
  264. },
  265. // 选择充值金额
  266. selectActiveRecharge(item,index){
  267. // 设置充值的金额和策略ID
  268. this.reqOrderParm.strategyId = item.id;
  269. this.reqOrderParm.rechargeAmount = item.reachPrice;
  270. this.currentTab = index;
  271. },
  272. toggleSelection() {
  273. this.isSelected = !this.isSelected;
  274. },
  275. // 交易记录
  276. gotoTransactionRecords(){
  277. uni.navigateTo({
  278. url: '/myPages/transactionRecord/index',
  279. params: {}
  280. })
  281. },
  282. // 充值记录
  283. gotoTransactionOrderRecords(){
  284. uni.navigateTo({
  285. url: '/myPages/rechargeRecord/index',
  286. })
  287. },
  288. // 查看储值协议
  289. gotoTermOfService(type){
  290. uni.$u.route({
  291. url: '/pages/me/term-of-service-detatil',
  292. params: {
  293. data: type
  294. }
  295. })
  296. },
  297. },
  298. };
  299. </script>
  300. <style scoped lang="scss">
  301. .page{
  302. background: red;
  303. }
  304. /*scroll-view外层*/
  305. .skill-sequence-panel-content-wrapper {
  306. position: relative;
  307. white-space: nowrap;
  308. // padding: 10rpx 0 10rpx 10rpx;
  309. margin-top: 10px;
  310. }
  311. /*左右渐变遮罩*/
  312. .hide-content-box {
  313. position: absolute;
  314. top: 0;
  315. height: 100%;
  316. width: 10px;
  317. z-index: 2;
  318. }
  319. .hide-content-box-left {
  320. left: 0;
  321. background-image: linear-gradient(to left, rgba(255, 255, 255, 0), #f3f3f3 60%);
  322. }
  323. .hide-content-box-right {
  324. right: 0;
  325. background-image: linear-gradient(to right, rgba(255, 255, 255, 0), #f3f3f3 60%);
  326. }
  327. .kite-classify-scroll {
  328. width: 100%;
  329. // height: 380rpx;
  330. overflow: hidden;
  331. white-space: nowrap;
  332. }
  333. .kite-classify-cell {
  334. display: inline-block;
  335. width: 266rpx;
  336. // height: 370rpx;
  337. margin-right: 20rpx;
  338. background-color: #ffffff;
  339. border-radius: 10rpx;
  340. overflow: hidden;
  341. box-shadow: 2px 2px 3px rgba(26, 26, 26, 0.2);
  342. position: relative;
  343. .h-bg-img{
  344. image{
  345. height: 80px;
  346. }
  347. }
  348. .content{
  349. position: absolute;
  350. bottom: 20%;
  351. left:12px;
  352. .money{
  353. color: #333333;
  354. .v{
  355. font-size: 18px;
  356. font-weight: bold;
  357. }
  358. }
  359. .desc{
  360. margin-top: 6px;
  361. font-size: 12px;
  362. color: #333333;
  363. line-height: 22px;
  364. }
  365. }
  366. .active{
  367. display: block;
  368. }
  369. }
  370. // 余额
  371. .recharge-me{
  372. position: relative;
  373. .bg-img{
  374. height: 160px;
  375. background: #FFE05C;
  376. }
  377. .wallet-content{
  378. position: absolute;
  379. top: 0;
  380. left: 0;
  381. right: 0;
  382. padding: 12px;
  383. .h-balance-wrap{
  384. background: #FFFCF1 ;
  385. border-radius: 6px;
  386. text-align: center;
  387. padding-left: 20px;
  388. padding-right: 20px;
  389. .h-balance{
  390. display: flex;
  391. justify-content: space-between;
  392. align-items: center;
  393. height: 118px;
  394. .recharge-balance{
  395. font-family: PingFangSC-Regular, PingFang SC;
  396. .h-nav-img {
  397. image{
  398. height: 18px;
  399. width: 18px;
  400. }
  401. }
  402. .name{
  403. font-size: 14px;
  404. font-weight: 400;
  405. color: #666666;
  406. line-height: 22px;
  407. }
  408. .balance-value{
  409. font-size: 18px;
  410. font-weight: bold;
  411. color: #333333;
  412. line-height: 26px;
  413. }
  414. }
  415. }
  416. .btn{
  417. display: flex;
  418. font-size: 14px;
  419. justify-content: space-between;
  420. height: 60px;
  421. align-items: center;
  422. color: #999999;
  423. .item-btn{
  424. width: 50%;
  425. }
  426. }
  427. }
  428. }
  429. }
  430. // 充值金额选择
  431. .recharge-content-wrap{
  432. width: 100%;
  433. display: flex;
  434. flex-wrap: wrap;
  435. justify-content: space-between;
  436. margin-top: 12px;
  437. position: relative;
  438. .recharge-content{
  439. width: calc(50% - 6px);
  440. margin-bottom: 12px;
  441. position: relative;
  442. .h-bg-img{
  443. image{
  444. height: 80px;
  445. }
  446. }
  447. .content{
  448. position: absolute;
  449. bottom: 25%;
  450. left:12px;
  451. .money{
  452. color: #333333;
  453. .v{
  454. font-size: 18px;
  455. font-weight: bold;
  456. }
  457. }
  458. .desc{
  459. font-size: 12px;
  460. color: #333333;
  461. line-height: 22px;
  462. }
  463. }
  464. .choose-status{
  465. display: none;
  466. position: absolute;
  467. left: 0px;
  468. top: 0px;
  469. .active{
  470. width: 0;
  471. height: 0;
  472. border-left: 0px solid transparent;
  473. border-right: 30px solid transparent;
  474. border-top: 30px solid green;
  475. }
  476. image{
  477. height: 40px;
  478. width: 40px;
  479. }
  480. }
  481. .active{
  482. display: block;
  483. }
  484. }
  485. }
  486. .h-custom{
  487. background: #FFFCF1;
  488. display: flex;
  489. padding: 12px;
  490. border-radius: 10px;
  491. margin-top: 8px;
  492. .h-money{
  493. margin-left: 6px;
  494. }
  495. }
  496. // 协议
  497. .recharge-agreement{
  498. margin-top: 12px;
  499. margin-bottom: 12px;
  500. margin-left: 12px;
  501. text-align: center;
  502. .radio-group{
  503. .v-text{
  504. // color:green;
  505. }
  506. .h-btn{
  507. color:green;
  508. }
  509. }
  510. }
  511. // 提交按钮
  512. .h-submit-btn{
  513. margin-top: 12px;
  514. width: 343px;
  515. height: 42px;
  516. background: #FFE05C;
  517. border-radius: 27px;
  518. text-align: center;
  519. line-height: 42px;
  520. }
  521. // 使用说明
  522. .h-desc{
  523. font-family: PingFangSC-Regular, PingFang SC;
  524. .title{
  525. height: 24px;
  526. font-size: 14px;
  527. font-family: PingFangSC-Regular, PingFang SC;
  528. font-weight: 400;
  529. color: #333333;
  530. line-height: 24px;
  531. }
  532. .h-content{
  533. height: 40px;
  534. font-size: 12px;
  535. font-weight: 400;
  536. color: #999999;
  537. line-height: 20px;
  538. }
  539. }
  540. </style>