index.vue 13 KB

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