index.vue 13 KB

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