index.vue 14 KB

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