index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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(this.reqOrderParm.rechargeAmount <1 ||this.reqOrderParm.rechargeAmount>100){
  176. console.log(1111111111)
  177. uni.showToast({
  178. icon: 'none',
  179. title: '任意充金额须在1-100之间'
  180. });
  181. return;
  182. }
  183. uni.showModal({
  184. title: '警告!',
  185. content: '您选择任意充不会获得任何优惠,是否确认充值??',
  186. success: function (res) {
  187. if (res.confirm) {
  188. console.log('用户点击确定');
  189. that.handleCommon()
  190. } else if (res.cancel) {
  191. console.log('用户点击取消');
  192. return;
  193. }
  194. }
  195. });
  196. }else {
  197. this.handleCommon()
  198. }
  199. },
  200. //提交充值订单
  201. handleCommon(){
  202. const that = this;
  203. let promotionParam = uni.getStorageSync('promotionParam')
  204. Object.assign(this.reqOrderParm,promotionParam)
  205. // 提交订单
  206. this.$api.commonGeneralOrder(this.reqOrderParm).then((res)=>{
  207. console.log('+++++++++++commonGeneralOrder++++++++++',res)
  208. that.reqPayParm.orderNo = res.data.data.orderNo;
  209. // 调用微信支付
  210. that.wechatPay();
  211. })
  212. },
  213. // 微信支付
  214. wechatPay(){
  215. const that = this;
  216. // 用户信息
  217. that.reqPayParm.requstForm = true;
  218. this.$api.wechatPay(that.reqPayParm).then((res)=>{
  219. var param = res.data.data;
  220. uni.requestPayment({
  221. appId: param.appid,
  222. timeStamp: param.timestamp+"",
  223. nonceStr: param.noncestr,
  224. package: "prepay_id="+param.prepayid,
  225. signType: "RSA",
  226. paySign: param.sign,
  227. success: res => {
  228. uni.showToast({
  229. title: '支付成功!'
  230. });
  231. // 刷新用户信息
  232. that.getUserInfo()
  233. },
  234. fail: res => {
  235. uni.showModal({
  236. content: '支付失败',
  237. showCancel: false
  238. });
  239. }
  240. });
  241. })
  242. },
  243. getUserInfo(){
  244. this.$api.getUserInfo().then(res=>{
  245. console.log('++++++++++++获取用户信息++++++++++++++++++',res)
  246. uni.setStorageSync('userInfo',res.data.data)
  247. this.userInfo = res.data.data
  248. })
  249. },
  250. // 取消上面选择的面值
  251. cancelChooseMoney(){
  252. this.reqOrderParm.strategyId = null;
  253. this.reqOrderParm.rechargeAmount = null;
  254. this.currentTab = '';
  255. },
  256. // 选择充值金额
  257. selectActiveRecharge(item,index){
  258. // 设置充值的金额和策略ID
  259. this.reqOrderParm.strategyId = item.id;
  260. this.reqOrderParm.rechargeAmount = item.reachPrice;
  261. this.currentTab = index;
  262. },
  263. toggleSelection() {
  264. this.isSelected = !this.isSelected;
  265. },
  266. // 交易记录
  267. gotoTransactionRecords(){
  268. uni.navigateTo({
  269. url: '/myPages/transactionRecord/index',
  270. params: {}
  271. })
  272. },
  273. // 充值记录
  274. gotoTransactionOrderRecords(){
  275. uni.navigateTo({
  276. url: '/myPages/rechargeRecord/index',
  277. })
  278. },
  279. // 查看储值协议
  280. gotoTermOfService(type){
  281. uni.navigateTo({
  282. url: '/myPages/TermsOfService/index?name='+'储值协议'+'&type=' + 8,
  283. })
  284. },
  285. },
  286. };
  287. </script>
  288. <style scoped lang="scss">
  289. @import '/common/css/common.css';
  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. background-image: url("/static/recharge/dianka.png");
  321. background-repeat: no-repeat;
  322. background-size: cover;
  323. display: inline-block;
  324. width: 328rpx;
  325. height: 160rpx;
  326. margin-right: 20rpx;
  327. border-radius: 15rpx;
  328. overflow: hidden;
  329. .money{
  330. margin: 34rpx 0 0 40rpx;
  331. color: #333333;
  332. .v{
  333. font-size: 18px;
  334. font-weight: bold;
  335. }
  336. }
  337. .desc{
  338. margin-top: 15rpx;
  339. margin-left: 40rpx;
  340. font-size: 12px;
  341. color: #333333;
  342. line-height: 22px;
  343. }
  344. }
  345. .kiteBackImg{
  346. background-image: url("/static/transaction/u2.png");
  347. background-repeat: no-repeat;
  348. background-size: cover;
  349. }
  350. // 余额
  351. .recharge-me{
  352. .wallet-content{
  353. background-image: linear-gradient(#FFE05C 0, #FFE05C 160px, #F7F7F7 0, #F7F7F7);
  354. padding: 12px;
  355. .h-balance-wrap{
  356. background: #FFFCF1 ;
  357. border-radius: 6px;
  358. text-align: center;
  359. padding-left: 20px;
  360. padding-right: 20px;
  361. .h-balance{
  362. display: flex;
  363. justify-content: space-between;
  364. align-items: center;
  365. height: 118px;
  366. .recharge-balance{
  367. font-family: PingFangSC-Regular, PingFang SC;
  368. .h-nav-img {
  369. image{
  370. height: 18px;
  371. width: 18px;
  372. }
  373. }
  374. .name{
  375. font-size: 14px;
  376. font-weight: 400;
  377. color: #666666;
  378. line-height: 22px;
  379. }
  380. .balance-value{
  381. font-size: 18px;
  382. font-weight: bold;
  383. color: #333333;
  384. line-height: 26px;
  385. }
  386. }
  387. }
  388. .btn{
  389. display: flex;
  390. font-size: 14px;
  391. justify-content: space-between;
  392. height: 60px;
  393. align-items: center;
  394. color: #999999;
  395. .item-btn{
  396. width: 50%;
  397. }
  398. }
  399. }
  400. }
  401. }
  402. // 充值金额选择
  403. .recharge-content-wrap{
  404. width: 100%;
  405. display: flex;
  406. flex-wrap: wrap;
  407. justify-content: space-between;
  408. margin-top: 12px;
  409. position: relative;
  410. .recharge-content{
  411. width: calc(50% - 6px);
  412. margin-bottom: 12px;
  413. position: relative;
  414. .content{
  415. position: absolute;
  416. bottom: 25%;
  417. left:12px;
  418. .money{
  419. color: #333333;
  420. .v{
  421. font-size: 18px;
  422. font-weight: bold;
  423. }
  424. }
  425. .desc{
  426. font-size: 12px;
  427. color: #333333;
  428. line-height: 22px;
  429. }
  430. }
  431. .choose-status{
  432. display: none;
  433. position: absolute;
  434. left: 0px;
  435. top: 0px;
  436. .active{
  437. width: 0;
  438. height: 0;
  439. border-left: 0px solid transparent;
  440. border-right: 30px solid transparent;
  441. border-top: 30px solid green;
  442. }
  443. image{
  444. height: 40px;
  445. width: 40px;
  446. }
  447. }
  448. .active{
  449. display: block;
  450. }
  451. }
  452. }
  453. .h-custom{
  454. background: #FFFCF1;
  455. display: flex;
  456. padding: 12px;
  457. border-radius: 10px;
  458. margin-top: 8px;
  459. .h-money{
  460. margin-left: 6px;
  461. }
  462. }
  463. // 协议
  464. .recharge-agreement{
  465. margin-top: 12px;
  466. margin-bottom: 12px;
  467. margin-left: 12px;
  468. text-align: center;
  469. .radio-group{
  470. .v-text{
  471. // color:green;
  472. }
  473. .h-btn{
  474. color:red;
  475. }
  476. }
  477. }
  478. // 提交按钮
  479. .h-submit-btn{
  480. margin-top: 24rpx;
  481. height: 84rpx;
  482. background: #FFE05C;
  483. border-radius: 54rpx;
  484. text-align: center;
  485. line-height: 84rpx;
  486. }
  487. .bg-img{
  488. height: 160px;
  489. background: #FFE05C;
  490. }
  491. </style>