recharge.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. <rich-text :nodes="recharge_notice"></rich-text>
  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;" @click.stop="gotoxieyi">《充值规则》</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. this.$util.getAgreement().then(res => {
  55. this.recharge_protocol = res.data.recharge_protocol
  56. this.recharge_notice = res.data.recharge_notice
  57. }).catch(err => {
  58. })
  59. },
  60. data() {
  61. return {
  62. paymentMoney: "",
  63. accountMoney: "",
  64. inputmoney: '',
  65. num: 0,
  66. moneyList: [{
  67. index: 0,
  68. price: 0.01
  69. },
  70. {
  71. index: 1,
  72. price: 100
  73. },
  74. {
  75. index: 2,
  76. price: 200
  77. },
  78. {
  79. index: 3,
  80. price: 500
  81. },
  82. {
  83. index: 4,
  84. price: 1000
  85. },
  86. ],
  87. customStyle: {
  88. backgroundColor: '#0B73B9',
  89. color: '#FFFFFF'
  90. },
  91. recharge_protocol: "",
  92. recharge_notice: ""
  93. };
  94. },
  95. watch: {
  96. inputmoney: function(newtext, jiu) {
  97. if (typeof newtext === 'string') {
  98. if (newtext.trim().length !== 0) {
  99. this.debounce(this.changeStr, 500);
  100. } else {}
  101. }
  102. }
  103. },
  104. methods: {
  105. gotoxieyi() {
  106. uni.navigateTo({
  107. url: "../index/agreement?data=" + encodeURIComponent(this.recharge_protocol)
  108. })
  109. },
  110. replaceMoney(item) {
  111. this.paymentMoney = item.price
  112. this.accountMoney = item.price
  113. this.num = item.index
  114. this.inputmoney = ""
  115. },
  116. debounce(fn, wait) {
  117. if (this.fun !== null) {
  118. clearTimeout(this.fun)
  119. }
  120. this.fun = setTimeout(fn, wait)
  121. },
  122. changeStr() {
  123. this.paymentMoney = this.inputmoney
  124. this.accountMoney = this.inputmoney
  125. if (this.inputmoney == "") {
  126. this.paymentMoney = 0
  127. this.accountMoney = 0
  128. }
  129. },
  130. focusstyle() {
  131. this.paymentMoney = 0
  132. this.accountMoney = 0
  133. this.num = 5
  134. },
  135. recharge: async function() {
  136. let res = await this.$request.post("/api/v1/order/topup", {
  137. amount: this.paymentMoney * 100
  138. })
  139. if (res.status == 0) {
  140. uni.requestPayment({
  141. timeStamp: res.data.timeStamp,
  142. nonceStr: res.data.nonceStr,
  143. package: res.data.package,
  144. signType: res.data.signType,
  145. paySign: res.data.paySign,
  146. success: (res) => {
  147. if (res.errMsg == "requestPayment:ok") {
  148. uni.showToast({
  149. title: "充值成功",
  150. duration: 1500
  151. })
  152. setTimeout(() => {
  153. uni.navigateBack({
  154. delta: 1
  155. })
  156. }, 1500)
  157. }
  158. },
  159. fail: (err) => {
  160. console.log(err)
  161. },
  162. complete: (res) => {
  163. console.log(res)
  164. }
  165. })
  166. }
  167. }
  168. },
  169. onShow() {
  170. }
  171. };
  172. </script>
  173. <style lang="scss">
  174. @import url("../index/mine.css");
  175. button {
  176. border-radius: 15rpx;
  177. }
  178. .money {
  179. border: 2rpx solid #C0C0C0;
  180. }
  181. .moneyActivate {
  182. border: 2rpx solid #0B73B9;
  183. color: #0B73B9;
  184. background-color: rgba(11, 115, 185, .1);
  185. }
  186. .header-content {
  187. position: absolute;
  188. top: 0;
  189. right: 0;
  190. bottom: 0;
  191. left: 0;
  192. width: 100%;
  193. z-index: -1;
  194. overflow: hidden;
  195. box-sizing: border-box;
  196. }
  197. .header-box {
  198. box-shadow: 0px 8rpx 34rpx -6rpx rgba(248, 151, 164, 0.13);
  199. }
  200. .header-img {
  201. width: 36rpx;
  202. height: 36rpx;
  203. }
  204. .tip {
  205. position: absolute;
  206. top: 0;
  207. right: 20%;
  208. bottom: 0;
  209. background-color: red;
  210. width: 12rpx;
  211. height: 12rpx;
  212. border-radius: 50%;
  213. }
  214. .msg {
  215. top: -3rpx;
  216. right: -9rpx;
  217. }
  218. swiper {
  219. height: 320rpx;
  220. }
  221. .swiper-wrapper {
  222. padding: 0 10rpx;
  223. box-sizing: border-box;
  224. }
  225. .swiper-item {
  226. width: 100%;
  227. height: 300rpx;
  228. box-shadow: 0 26rpx 40rpx 0 rgba(255, 255, 255, 0.31);
  229. background: url("http://file.supermm.me/miniProgram/images/personal/bg_doc.png") no-repeat bottom center;
  230. }
  231. .dots {
  232. position: absolute;
  233. left: 0;
  234. right: 0;
  235. bottom: -40rpx;
  236. display: flex;
  237. justify-content: center;
  238. }
  239. .dots .dot {
  240. margin: 0 8rpx;
  241. width: 14rpx;
  242. height: 14rpx;
  243. background: #E4E4E4;
  244. border-radius: 8rpx;
  245. transition: all .6s;
  246. }
  247. .dots .dot.active {
  248. width: 24rpx;
  249. background: rgb(153, 153, 153);
  250. }
  251. .game-wrap {
  252. position: relative;
  253. width: 100%;
  254. height: 100%;
  255. overflow: hidden;
  256. box-sizing: border-box;
  257. }
  258. .game-item {
  259. height: 100%;
  260. background: url("https://file.supermm.me/h5/wechat-h5/integral/personeBg001.jpg") no-repeat;
  261. background-size: 100% 100%;
  262. background-position: center center;
  263. border-radius: 100rpx;
  264. }
  265. </style>