index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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: err => {
  243. console.log(err)
  244. if (err.errMsg === "requestPayment:fail cancel"){
  245. uni.showModal({
  246. content: '支付取消',
  247. showCancel: false
  248. });
  249. }else {
  250. uni.showModal({
  251. content: '支付失败',
  252. showCancel: false
  253. });
  254. }
  255. }
  256. });
  257. })
  258. },
  259. getUserInfo(){
  260. this.$api.getUserInfo().then(res=>{
  261. console.log('++++++++++++获取用户信息++++++++++++++++++',res)
  262. uni.setStorageSync('userInfo',res.data.data)
  263. this.userInfo = res.data.data
  264. })
  265. },
  266. // 取消上面选择的面值
  267. cancelChooseMoney(){
  268. this.reqOrderParm.strategyId = null;
  269. this.reqOrderParm.rechargeAmount = null;
  270. this.currentTab = '';
  271. },
  272. // 选择充值金额
  273. selectActiveRecharge(item,index){
  274. // 设置充值的金额和策略ID
  275. this.reqOrderParm.strategyId = item.id;
  276. this.reqOrderParm.rechargeAmount = item.reachPrice;
  277. this.currentTab = index;
  278. },
  279. toggleSelection() {
  280. this.isSelected = !this.isSelected;
  281. },
  282. // 交易记录
  283. gotoTransactionRecords(){
  284. uni.navigateTo({
  285. url: '/myPages/transactionRecord/index',
  286. params: {}
  287. })
  288. },
  289. // 充值记录
  290. gotoTransactionOrderRecords(){
  291. uni.navigateTo({
  292. url: '/myPages/rechargeRecord/index',
  293. })
  294. },
  295. // 查看储值协议
  296. gotoTermOfService(type){
  297. uni.navigateTo({
  298. url: '/myPages/TermsOfService/index?name='+'储值协议'+'&type=' + 8,
  299. })
  300. },
  301. },
  302. };
  303. </script>
  304. <style scoped lang="scss">
  305. @import '/common/css/common.css';
  306. /*scroll-view外层*/
  307. .skill-sequence-panel-content-wrapper {
  308. position: relative;
  309. white-space: nowrap;
  310. // padding: 10rpx 0 10rpx 10rpx;
  311. margin-top: 10px;
  312. }
  313. /*左右渐变遮罩*/
  314. .hide-content-box {
  315. position: absolute;
  316. top: 0;
  317. height: 100%;
  318. width: 10px;
  319. z-index: 2;
  320. }
  321. .hide-content-box-left {
  322. left: 0;
  323. background-image: linear-gradient(to left, rgba(255, 255, 255, 0), #f3f3f3 60%);
  324. }
  325. .hide-content-box-right {
  326. right: 0;
  327. background-image: linear-gradient(to right, rgba(255, 255, 255, 0), #f3f3f3 60%);
  328. }
  329. .kite-classify-scroll {
  330. width: 100%;
  331. // height: 380rpx;
  332. overflow: hidden;
  333. white-space: nowrap;
  334. }
  335. .kite-classify-cell {
  336. background-image: url("/static/recharge/dianka.png");
  337. background-repeat: no-repeat;
  338. background-size: cover;
  339. display: inline-block;
  340. width: 328rpx;
  341. height: 160rpx;
  342. margin-right: 20rpx;
  343. border-radius: 15rpx;
  344. overflow: hidden;
  345. .money{
  346. margin: 34rpx 0 0 40rpx;
  347. color: #333333;
  348. .v{
  349. font-size: 18px;
  350. font-weight: bold;
  351. }
  352. }
  353. .desc{
  354. margin-top: 15rpx;
  355. margin-left: 40rpx;
  356. font-size: 12px;
  357. color: #333333;
  358. line-height: 22px;
  359. }
  360. }
  361. .kiteBackImg{
  362. background-image: url("/static/transaction/u2.png");
  363. background-repeat: no-repeat;
  364. background-size: cover;
  365. }
  366. // 余额
  367. .recharge-me{
  368. .wallet-content{
  369. background-image: linear-gradient(#FFE05C 0, #FFE05C 160px, #F7F7F7 0, #F7F7F7);
  370. padding: 12px;
  371. .h-balance-wrap{
  372. background: #FFFCF1 ;
  373. border-radius: 6px;
  374. text-align: center;
  375. padding-left: 20px;
  376. padding-right: 20px;
  377. .h-balance{
  378. display: flex;
  379. justify-content: space-between;
  380. align-items: center;
  381. height: 118px;
  382. .recharge-balance{
  383. font-family: PingFangSC-Regular, PingFang SC;
  384. .h-nav-img {
  385. image{
  386. height: 18px;
  387. width: 18px;
  388. }
  389. }
  390. .name{
  391. font-size: 14px;
  392. font-weight: 400;
  393. color: #666666;
  394. line-height: 22px;
  395. }
  396. .balance-value{
  397. font-size: 18px;
  398. font-weight: bold;
  399. color: #333333;
  400. line-height: 26px;
  401. }
  402. }
  403. }
  404. .btn{
  405. display: flex;
  406. font-size: 14px;
  407. justify-content: space-between;
  408. height: 60px;
  409. align-items: center;
  410. color: #999999;
  411. .item-btn{
  412. width: 50%;
  413. }
  414. }
  415. }
  416. }
  417. }
  418. // 充值金额选择
  419. .recharge-content-wrap{
  420. width: 100%;
  421. display: flex;
  422. flex-wrap: wrap;
  423. justify-content: space-between;
  424. margin-top: 12px;
  425. position: relative;
  426. .recharge-content{
  427. width: calc(50% - 6px);
  428. margin-bottom: 12px;
  429. position: relative;
  430. .content{
  431. position: absolute;
  432. bottom: 25%;
  433. left:12px;
  434. .money{
  435. color: #333333;
  436. .v{
  437. font-size: 18px;
  438. font-weight: bold;
  439. }
  440. }
  441. .desc{
  442. font-size: 12px;
  443. color: #333333;
  444. line-height: 22px;
  445. }
  446. }
  447. .choose-status{
  448. display: none;
  449. position: absolute;
  450. left: 0px;
  451. top: 0px;
  452. .active{
  453. width: 0;
  454. height: 0;
  455. border-left: 0px solid transparent;
  456. border-right: 30px solid transparent;
  457. border-top: 30px solid green;
  458. }
  459. image{
  460. height: 40px;
  461. width: 40px;
  462. }
  463. }
  464. .active{
  465. display: block;
  466. }
  467. }
  468. }
  469. .h-custom{
  470. background: #FFFCF1;
  471. display: flex;
  472. padding: 12px;
  473. border-radius: 10px;
  474. margin-top: 8px;
  475. .h-money{
  476. margin-left: 6px;
  477. }
  478. }
  479. // 协议
  480. .recharge-agreement{
  481. margin-top: 12px;
  482. margin-bottom: 12px;
  483. margin-left: 12px;
  484. text-align: center;
  485. .radio-group{
  486. .v-text{
  487. // color:green;
  488. }
  489. .h-btn{
  490. color:red;
  491. }
  492. }
  493. }
  494. // 提交按钮
  495. .h-submit-btn{
  496. margin-top: 24rpx;
  497. height: 84rpx;
  498. background: #FFE05C;
  499. border-radius: 54rpx;
  500. text-align: center;
  501. line-height: 84rpx;
  502. }
  503. .bg-img{
  504. height: 160px;
  505. background: #FFE05C;
  506. }
  507. </style>