recharge.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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="margin-top padding-lr-sm" style="width: 174rpx;height: 78rpx;border-radius: 16rpx;border: 2rpx solid #C0C0C0;"
  16. value="" 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, 1500);
  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. },
  103. debounce(fn, wait) {
  104. if (this.fun !== null) {
  105. clearTimeout(this.fun)
  106. }
  107. this.fun = setTimeout(fn, wait)
  108. },
  109. changeStr() {
  110. this.paymentMoney = this.inputmoney
  111. this.accountMoney = this.inputmoney
  112. if (this.inputmoney == "") {
  113. this.paymentMoney = 0
  114. this.accountMoney = 0
  115. }
  116. },
  117. recharge: async function() {
  118. let res = await this.$request.post("/api/v1/order/topup", {
  119. amount: this.paymentMoney * 100
  120. })
  121. if (res.status == 0) {
  122. uni.requestPayment({
  123. timeStamp: res.data.timeStamp,
  124. nonceStr: res.data.nonceStr,
  125. package: res.data.package,
  126. signType: res.data.signType,
  127. paySign: res.data.paySign,
  128. success: (res) => {
  129. if (res.errMsg == "requestPayment:ok") {
  130. uni.showToast({
  131. title: "充值成功",
  132. duration: 1500
  133. })
  134. setTimeout(() => {
  135. uni.navigateBack({
  136. delta: 1
  137. })
  138. }, 1500)
  139. }
  140. },
  141. fail: (err) => {
  142. console.log(err)
  143. },
  144. complete: (res) => {
  145. console.log(res)
  146. }
  147. })
  148. }
  149. }
  150. },
  151. onShow() {
  152. }
  153. };
  154. </script>
  155. <style lang="scss">
  156. @import url("../index/mine.css");
  157. button {
  158. border-radius: 15rpx;
  159. }
  160. .money {
  161. border: 2rpx solid #C0C0C0;
  162. }
  163. .moneyActivate {
  164. border: 2rpx solid #0B73B9;
  165. color: #0B73B9;
  166. background-color: rgba(11, 115, 185, .1);
  167. }
  168. .header-content {
  169. position: absolute;
  170. top: 0;
  171. right: 0;
  172. bottom: 0;
  173. left: 0;
  174. width: 100%;
  175. z-index: -1;
  176. overflow: hidden;
  177. box-sizing: border-box;
  178. }
  179. .header-box {
  180. box-shadow: 0px 8rpx 34rpx -6rpx rgba(248, 151, 164, 0.13);
  181. }
  182. .header-img {
  183. width: 36rpx;
  184. height: 36rpx;
  185. }
  186. .tip {
  187. position: absolute;
  188. top: 0;
  189. right: 20%;
  190. bottom: 0;
  191. background-color: red;
  192. width: 12rpx;
  193. height: 12rpx;
  194. border-radius: 50%;
  195. }
  196. .msg {
  197. top: -3rpx;
  198. right: -9rpx;
  199. }
  200. swiper {
  201. height: 320rpx;
  202. }
  203. .swiper-wrapper {
  204. padding: 0 10rpx;
  205. box-sizing: border-box;
  206. }
  207. .swiper-item {
  208. width: 100%;
  209. height: 300rpx;
  210. box-shadow: 0 26rpx 40rpx 0 rgba(255, 255, 255, 0.31);
  211. background: url("http://file.supermm.me/miniProgram/images/personal/bg_doc.png") no-repeat bottom center;
  212. }
  213. .dots {
  214. position: absolute;
  215. left: 0;
  216. right: 0;
  217. bottom: -40rpx;
  218. display: flex;
  219. justify-content: center;
  220. }
  221. .dots .dot {
  222. margin: 0 8rpx;
  223. width: 14rpx;
  224. height: 14rpx;
  225. background: #E4E4E4;
  226. border-radius: 8rpx;
  227. transition: all .6s;
  228. }
  229. .dots .dot.active {
  230. width: 24rpx;
  231. background: rgb(153, 153, 153);
  232. }
  233. .game-wrap {
  234. position: relative;
  235. width: 100%;
  236. height: 100%;
  237. overflow: hidden;
  238. box-sizing: border-box;
  239. }
  240. .game-item {
  241. height: 100%;
  242. background: url("https://file.supermm.me/h5/wechat-h5/integral/personeBg001.jpg") no-repeat;
  243. background-size: 100% 100%;
  244. background-position: center center;
  245. border-radius: 100rpx;
  246. }
  247. </style>