recharge.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="main">
  3. <view class="pr" style="z-index:2">
  4. <view class="plr15">
  5. <view class="bdr4 bg-white" style="margin-top: 38rpx;box-shadow: 0 0 50rpx 0 rgba(0, 0, 0, 0.1);">
  6. <view class="" style="height: 350rpx;">
  7. <view class="text-df text-bold" style="padding-top: 32rpx; margin-left: 28rpx;">
  8. 兑换金币
  9. </view>
  10. <view class="flex flex-wrap align-center justify-around" style="margin-top: 15rpx;margin-left: 28rpx;margin-right: 28rpx">
  11. <view @click="replaceMoney(item)" :class="num==item.index?'text-lg flex align-center justify-center margin-top moneyActivate':'text-lg flex align-center justify-center margin-top money'"
  12. v-for="(item,index) in moneyList" :data-index="index" :key="index" style="width: 174rpx;height: 78rpx;border-radius: 16rpx;">
  13. {{item.price}}元
  14. </view>
  15. <input type="number" placeholder="输入金额" :class="num==5?'margin-top padding-lr-sm moneyActivate':'margin-top padding-lr-sm money'"
  16. style="width: 174rpx;height: 78rpx;border-radius: 16rpx;" value="" @focus="focusstyle" v-model="inputmoney" />
  17. </view>
  18. </view>
  19. <view class="pr" style="padding: 40rpx 40rpx;background-color: #fff;border-radius: 16rpx; border-top: 2rpx solid #efefef; ">
  20. <view class="tl f14 flex justify-between align-center">
  21. <view class="m-gray-letter mt5 f12">支付金额</view>
  22. <view class="m-gray-big f15 fb pr10">¥{{paymentMoney}}</view>
  23. </view>
  24. <view class="tl f14 flex justify-between align-center margin-top-sm">
  25. <view class="m-gray-letter mt5 f12">到账金额</view>
  26. <view class="m-gray-big f15 fb pr10">¥{{accountMoney}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="margin-lr margin-top">
  33. <view class="text-df" style="color: #999999;font-weight: 400;">
  34. 温馨提示
  35. </view>
  36. <view class="text-sm" style="color: #999999;font-weight: 400;margin-top: 15rpx;">
  37. 温馨提示信息后台编辑温馨提示信息后台编辑温馨提示信息后台编辑温馨提示信息后台编辑温馨提示信息后台编辑温馨提示信息后台编辑温馨提示信息后。
  38. </view>
  39. </view>
  40. <view class="margin-lr" style="margin-top: 210rpx;">
  41. <view class="text-sm margin-bottom" style="color: #999999;text-align: center;">
  42. 点击充值按钮即表示已阅读并同意 <text style="color: #0B73B9;">《充值规则》</text>
  43. </view>
  44. <u-button size="default" :ripple="true" @click="recharge" :custom-style="customStyle">充值</u-button>
  45. </view>
  46. <view class="cu-tabbar-height"></view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. onLoad() {
  52. this.paymentMoney = this.moneyList[0].price
  53. this.accountMoney = this.moneyList[0].price
  54. },
  55. data() {
  56. return {
  57. paymentMoney: "",
  58. accountMoney: "",
  59. inputmoney: '',
  60. num: 0,
  61. moneyList: [{
  62. index: 0,
  63. price: 0.01
  64. },
  65. {
  66. index: 1,
  67. price: 100
  68. },
  69. {
  70. index: 2,
  71. price: 200
  72. },
  73. {
  74. index: 3,
  75. price: 500
  76. },
  77. {
  78. index: 4,
  79. price: 1000
  80. },
  81. ],
  82. customStyle: {
  83. backgroundColor: '#0B73B9',
  84. color: '#FFFFFF'
  85. },
  86. };
  87. },
  88. watch: {
  89. inputmoney: function(newtext, jiu) {
  90. if (typeof newtext === 'string') {
  91. if (newtext.trim().length !== 0) {
  92. this.debounce(this.changeStr, 500);
  93. } else {}
  94. }
  95. }
  96. },
  97. methods: {
  98. replaceMoney(item) {
  99. this.paymentMoney = item.price
  100. this.accountMoney = item.price
  101. this.num = item.index
  102. this.inputmoney = ""
  103. },
  104. debounce(fn, wait) {
  105. if (this.fun !== null) {
  106. clearTimeout(this.fun)
  107. }
  108. this.fun = setTimeout(fn, wait)
  109. },
  110. changeStr() {
  111. this.paymentMoney = this.inputmoney
  112. this.accountMoney = this.inputmoney
  113. if (this.inputmoney == "") {
  114. this.paymentMoney = 0
  115. this.accountMoney = 0
  116. }
  117. },
  118. focusstyle() {
  119. this.paymentMoney = 0
  120. this.accountMoney = 0
  121. this.num = 5
  122. },
  123. recharge: async function() {
  124. let res = await this.$request.post("/api/v1/order/topup", {
  125. amount: this.paymentMoney * 100
  126. })
  127. if (res.status == 0) {
  128. uni.requestPayment({
  129. timeStamp: res.data.timeStamp,
  130. nonceStr: res.data.nonceStr,
  131. package: res.data.package,
  132. signType: res.data.signType,
  133. paySign: res.data.paySign,
  134. success: (res) => {
  135. if (res.errMsg == "requestPayment:ok") {
  136. uni.showToast({
  137. title: "充值成功",
  138. duration: 1500
  139. })
  140. setTimeout(() => {
  141. uni.navigateBack({
  142. delta: 1
  143. })
  144. }, 1500)
  145. }
  146. },
  147. fail: (err) => {
  148. console.log(err)
  149. },
  150. complete: (res) => {
  151. console.log(res)
  152. }
  153. })
  154. }
  155. }
  156. },
  157. onShow() {
  158. }
  159. };
  160. </script>
  161. <style lang="scss">
  162. @import url("../index/mine.css");
  163. button {
  164. border-radius: 15rpx;
  165. }
  166. .money {
  167. border: 2rpx solid #C0C0C0;
  168. }
  169. .moneyActivate {
  170. border: 2rpx solid #0B73B9;
  171. color: #0B73B9;
  172. background-color: rgba(11, 115, 185, .1);
  173. }
  174. .header-content {
  175. position: absolute;
  176. top: 0;
  177. right: 0;
  178. bottom: 0;
  179. left: 0;
  180. width: 100%;
  181. z-index: -1;
  182. overflow: hidden;
  183. box-sizing: border-box;
  184. }
  185. .header-box {
  186. box-shadow: 0px 8rpx 34rpx -6rpx rgba(248, 151, 164, 0.13);
  187. }
  188. .header-img {
  189. width: 36rpx;
  190. height: 36rpx;
  191. }
  192. .tip {
  193. position: absolute;
  194. top: 0;
  195. right: 20%;
  196. bottom: 0;
  197. background-color: red;
  198. width: 12rpx;
  199. height: 12rpx;
  200. border-radius: 50%;
  201. }
  202. .msg {
  203. top: -3rpx;
  204. right: -9rpx;
  205. }
  206. swiper {
  207. height: 320rpx;
  208. }
  209. .swiper-wrapper {
  210. padding: 0 10rpx;
  211. box-sizing: border-box;
  212. }
  213. .swiper-item {
  214. width: 100%;
  215. height: 300rpx;
  216. box-shadow: 0 26rpx 40rpx 0 rgba(255, 255, 255, 0.31);
  217. background: url("http://file.supermm.me/miniProgram/images/personal/bg_doc.png") no-repeat bottom center;
  218. }
  219. .dots {
  220. position: absolute;
  221. left: 0;
  222. right: 0;
  223. bottom: -40rpx;
  224. display: flex;
  225. justify-content: center;
  226. }
  227. .dots .dot {
  228. margin: 0 8rpx;
  229. width: 14rpx;
  230. height: 14rpx;
  231. background: #E4E4E4;
  232. border-radius: 8rpx;
  233. transition: all .6s;
  234. }
  235. .dots .dot.active {
  236. width: 24rpx;
  237. background: rgb(153, 153, 153);
  238. }
  239. .game-wrap {
  240. position: relative;
  241. width: 100%;
  242. height: 100%;
  243. overflow: hidden;
  244. box-sizing: border-box;
  245. }
  246. .game-item {
  247. height: 100%;
  248. background: url("https://file.supermm.me/h5/wechat-h5/integral/personeBg001.jpg") no-repeat;
  249. background-size: 100% 100%;
  250. background-position: center center;
  251. border-radius: 100rpx;
  252. }
  253. </style>