index.vue 12 KB

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