You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

438 lines
10 KiB

6 months ago
  1. <template>
  2. <view>
  3. <view class="block">
  4. <!-- <view class="title">
  5. 我的账户
  6. </view> -->
  7. <view class="content">
  8. <view class="my">
  9. 我的账户余额{{yue}}
  10. <text v-if="userinfo.djmoney" style="font-size: 25upx;color: red;">--冻结:{{userinfo.djmoney}}</text>
  11. <view class="tx" @click="totx()">提现</view>
  12. </view>
  13. <view v-if="userinfo.djmoney" style="font-size: 24upx;color: red;margin-top: 30upx;">温馨提示申请提现待到账金额为冻结金额</view>
  14. </view>
  15. </view>
  16. <view class="block">
  17. <view class="title">
  18. 充值金额
  19. </view>
  20. <view class="content">
  21. <view class="amount">
  22. <view class="list">
  23. <view v-if="!giftamountList.length" class="box" v-for="(amount,index) in amountList" :key="index" @tap="select(amount,index)" :class="{'on':amount == inputAmount}">
  24. {{amount}}
  25. </view>
  26. <view v-if="giftamountList.length" class="box" v-for="(amount,index) in amountList" :key="index" @tap="select(amount,index)" :class="{'on':amount == inputAmount}">
  27. {{amount}}元送{{giftamountList[index]}}
  28. </view>
  29. </view>
  30. <view class="num">
  31. <view class="text">
  32. 自定义充值金额
  33. </view>
  34. <view class="input">
  35. <input v-model="inputAmount" :placeholder="lessdesc" @input='inputamountchange'/>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="block">
  42. <view class="title">
  43. 选择支付方式
  44. </view>
  45. <view class="content">
  46. <view class="pay-list">
  47. <view class="row" @tap="paytype='wxpay'">
  48. <view class="left">
  49. <image src="/static/img/wxpay.png"></image>
  50. </view>
  51. <view class="center">
  52. 微信支付
  53. </view>
  54. <view class="right">
  55. <radio :checked="paytype=='wxpay'" color="#f06c7a" />
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <uni-popup ref="popup" type="center" :maskClick="maskclose" :custom="custom">
  62. <view class="order">
  63. <view class="colseorder" @click="doclose">
  64. <image src="/static/img/close.png"></image>
  65. </view>
  66. <view class="ordercontent">
  67. <view class="title">订单信息</view>
  68. <view class="info">
  69. <view class="infolist">
  70. <view class="addnumtitle">类型:</view>
  71. <view class="addnumtitle">余额充值</view>
  72. </view>
  73. <view class="infolist">
  74. <view class="addnumtitle">支付金额:</view>
  75. <view class="addnum">{{inputAmount}}</view>
  76. </view>
  77. <view class="infolist">
  78. <view class="addnumtitle">优惠金额:</view>
  79. <view class="addnum">{{gitmoney}}</view>
  80. </view>
  81. <view class="infolist">
  82. <view class="addnumtitle">到账金额:</view>
  83. <view class="addnum">{{(Number(inputAmount)+Number(gitmoney))}}</view>
  84. </view>
  85. </view>
  86. <view class="addbt" @click="doaddmoney">确认充值</view>
  87. </view>
  88. </view>
  89. </uni-popup>
  90. <view class="pay">
  91. <view class="btn" @tap="doDeposit">立即充值</view>
  92. <!-- <view class="tis">
  93. 点击立即充值即代表您同意
  94. <view class="terms">
  95. <navigator url="../../../pages/xieyi/xieyi?type=1">
  96. 条款协议
  97. </navigator>
  98. </view>
  99. </view> -->
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. import uniPopup from "@/components/uni-popup/uni-popup.vue"
  105. export default {
  106. components: {uniPopup},
  107. data() {
  108. return {
  109. maskclose:false,
  110. custom:true,
  111. inputAmount:'',//金额
  112. amountList:[10,50,100],//预设3个可选快捷金额
  113. giftamountList:[],//送金额
  114. paytype:'wxpay',//支付类型,
  115. yue:0.00,
  116. seleteindex:-1,//选中赠送列表下标
  117. gitmoney:'0',
  118. timerId: null,
  119. lessmoney:1,
  120. lessdesc:'不低于1元',
  121. userinfo:[]
  122. }
  123. },
  124. onLoad(e){
  125. },
  126. onShow(){
  127. let getuserinfo=uni.getStorageSync('userinfo');
  128. this.getbaseinfo('defaultmoney');
  129. this.getbaseinfo('lessczje');;
  130. this.getuserinfo(getuserinfo.uid,getuserinfo.aid);
  131. },
  132. methods: {
  133. async getuserinfo(uid,aid) {
  134. let reinfo=await this.$api.userinfo({action:'userinfo',uid:uid,aid:aid});
  135. this.yue=reinfo.data.yue;
  136. this.userinfo=reinfo.data;
  137. },
  138. //获取充值活动数据
  139. async getbaseinfo(key){
  140. let getdata= await this.$api.baseinfo({action:'baseinfo',key:key});
  141. if(getdata.data.info!=''){
  142. if(key=='defaultmoney'){
  143. this.amountList=getdata.data.info;
  144. }else if(key=='lessczje'){
  145. this.lessdesc="不低于"+getdata.data.info+"元";
  146. this.lessmoney=parseFloat(getdata.data.info);
  147. }
  148. //this.giftamountList=info.data.giftamountList;
  149. }
  150. },
  151. async wxpay(money,openid,uid) {
  152. let userinfo = uni.getStorageSync('userinfo');
  153. let reinfo=await this.$api.czwxpay({action:'czwxpay',openid:openid,addmoney:money,uid:uid,aid:userinfo.aid});
  154. console.log(reinfo,'返回');
  155. let t=this;
  156. uni.requestPayment({
  157. provider: 'wxpay',
  158. timeStamp: reinfo.data.timeStamp,
  159. nonceStr: reinfo.data.nonceStr,
  160. package: reinfo.data.package,
  161. signType: 'MD5',
  162. paySign: reinfo.data.paySign,
  163. success: function (res) {
  164. //console.log('success:' + JSON.stringify(res));
  165. uni.showToast({
  166. title:'充值成功'
  167. })
  168. setTimeout(function(e){
  169. uni.reLaunch({
  170. url:'/pages/user/user'
  171. })
  172. },1000)
  173. },
  174. fail: function (err) {
  175. uni.showToast({
  176. title:'支付失败'+reinfo.msg,icon:'fail'
  177. })
  178. }
  179. });
  180. },
  181. select(amount,index){
  182. this.inputAmount = amount;
  183. this.seleteindex=index;
  184. },
  185. inputamountchange(val){
  186. console.log(val.target.value,'输入')
  187. },
  188. doDeposit(){
  189. let getuserinfo=uni.getStorageSync('userinfo');
  190. if(getuserinfo.openid==''||getuserinfo.openid==null){
  191. uni.navigateTo({
  192. url:'/pages/user/login'
  193. })
  194. }else{
  195. console.log(this.lessmoney,'最低金额')
  196. if(this.inputAmount<this.lessmoney){
  197. uni.showToast({title:'充值金额不低于'+this.lessmoney+'元',icon:'none'});
  198. return ;
  199. }
  200. if (parseFloat(this.inputAmount).toString() == "NaN") {
  201. uni.showToast({title:'请输入正确金额',icon:'none'});
  202. return ;
  203. }
  204. // if(this.inputAmount%10!=0){
  205. // uni.showToast({title:'请输入10的整数金额',icon:'none'});
  206. // return ;
  207. // }
  208. if(parseFloat(this.inputAmount).toFixed(2)!=parseFloat(this.inputAmount)){
  209. uni.showToast({title:'最多只能输入两位小数哦~',icon:'none'});
  210. return ;
  211. }
  212. this.$refs.popup.open();
  213. }
  214. },
  215. doclose(){
  216. this.btstatus=false;
  217. this.$refs.popup.close()
  218. },
  219. doaddmoney(){
  220. var getmoney=this.inputAmount;
  221. var getgifmoney=this.gitmoney;
  222. let getuserinfo=uni.getStorageSync('userinfo');
  223. this.wxpay(getmoney,getuserinfo.openid,getuserinfo.uid)
  224. console.log(getgifmoney+'--'+this.inputAmount,'金额');
  225. },
  226. totx(){
  227. uni.navigateTo({url:'/pages/user/tixian'})
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="scss">
  233. .block{
  234. width: 100%;
  235. padding: 20upx 3%;
  236. .title{
  237. width: 100%;
  238. font-size: 34upx;
  239. }
  240. .content{
  241. .my{
  242. width: 100%;
  243. height: 120upx;
  244. display: flex;
  245. align-items: center;
  246. font-size: 30upx;
  247. border-bottom: solid 1upx #eee;
  248. }
  249. .tx{
  250. padding: 15rpx 35rpx;
  251. background-color: #00B7B8;
  252. color: #FFFFFF;
  253. float: right;
  254. position: absolute;
  255. right: 20rpx;
  256. top: 45rpx;
  257. border-radius: 10upx;
  258. }
  259. .amount{
  260. width: 100%;
  261. .list{
  262. display: flex;
  263. flex-flow:row wrap;
  264. justify-content: space-between;
  265. padding: 20upx 0;
  266. .box{
  267. width: 31%;
  268. height: 120upx;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. border-radius: 10upx;
  273. box-shadow: 0upx 5upx 20upx rgba(0,0,0,0.05);
  274. font-size: 36upx;
  275. background-color: #52B4F5;
  276. color: #FFFFFF;
  277. margin-top:15upx;
  278. &.on{
  279. background-color: #f06c7a;
  280. color: #fff;
  281. }
  282. }
  283. }
  284. .num{
  285. margin-top: 10upx;
  286. display: flex;
  287. justify-content: flex-end;
  288. align-items: center;
  289. .text{
  290. padding-right: 10upx;
  291. font-size: 30upx;
  292. }
  293. .input{
  294. width: 30.2vw;
  295. border-bottom: solid 2upx #999;
  296. justify-content: flex-end;
  297. align-items: center;
  298. input{
  299. margin: 0 20upx;
  300. height: 60upx;
  301. font-size: 30upx;
  302. color: #f06c7a;
  303. justify-content: flex-end;
  304. align-items: center;
  305. }
  306. }
  307. }
  308. }
  309. .pay-list{
  310. width: 100%;
  311. border-bottom: solid 1upx #eee;
  312. .row{
  313. width: 100%;
  314. height: 120upx;
  315. display: flex;
  316. align-items: center;
  317. .left{
  318. width: 100upx;
  319. flex-shrink: 0;
  320. display: flex;
  321. align-items: center;
  322. image{
  323. width: 60upx;
  324. height: 60upx;
  325. }
  326. }
  327. .center{
  328. width: 100%;
  329. font-size: 30upx;
  330. }
  331. .right{
  332. width: 100upx;
  333. flex-shrink: 0;
  334. display: flex;
  335. justify-content: flex-end;
  336. }
  337. }
  338. }
  339. }
  340. }
  341. .pay{
  342. margin-top: 20upx;
  343. width: 100%;
  344. display: flex;
  345. justify-content: center;
  346. flex-wrap: wrap;
  347. .btn{
  348. width: 70%;
  349. height: 80upx;
  350. border-radius: 80upx;
  351. display: flex;
  352. justify-content: center;
  353. align-items: center;
  354. color: #fff;
  355. background-color: #f06c7a;
  356. box-shadow: 0upx 5upx 10upx rgba(0,0,0,0.2);
  357. }
  358. .tis{
  359. margin-top: 20upx;
  360. width: 100%;
  361. font-size: 24upx;
  362. display: flex;
  363. justify-content: center;
  364. align-items: baseline;
  365. color: #999;
  366. .terms{
  367. color: #5a9ef7;
  368. }
  369. }
  370. }
  371. .order{
  372. width: 550rpx;
  373. height: 580rpx;
  374. background-color: #FFFFFF;
  375. border-radius: 25rpx;
  376. }
  377. .colseorder{
  378. position: absolute;
  379. right: -8px;
  380. top: -8px;
  381. image{
  382. width: 60rpx;
  383. height: 60rpx;
  384. }
  385. }
  386. .ordercontent{
  387. padding: 20rpx;
  388. }
  389. .title{
  390. color:#444f62;
  391. border-bottom: 1rpx #e7e8ea solid;
  392. }
  393. .infolist{
  394. padding: 20rpx 5rpx;
  395. display: flex;
  396. justify-content: space-around;
  397. border-bottom: 1rpx #e7e8ea solid;
  398. align-items: center;
  399. }
  400. .addnum{
  401. color: #ff1f3a;
  402. font-weight: bold;
  403. margin-left: 50rpx;
  404. font-size: 30rpx;
  405. }
  406. .addnumtitle{
  407. margin-left: -50rpx;
  408. color:#444f62;
  409. }
  410. .addnumtitle{
  411. margin-left: -50rpx;
  412. color: #49586d;
  413. font-size: 30rpx;
  414. }
  415. .addbt{
  416. color: #FFFFFF;
  417. font-size: 35rpx;
  418. background-color: #00bca2;
  419. padding: 10rpx 30rpx;
  420. display: flex;
  421. justify-content: center;
  422. margin-top: 30rpx;
  423. border-radius: 15rpx;
  424. }
  425. </style>