index.vue 13 KB

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