recharge.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view class="recharge">
  3. <view class="header">
  4. <text>{{ integral || '0.00' }}</text><br>
  5. <text>我的当前积分</text>
  6. </view>
  7. <view class="footer">
  8. <view class="item" v-for="l in list" @click="confirm(l)">
  9. <image :src="l.img" class="border"></image>
  10. <image :src="l.icon" class="i"></image>
  11. <view class="rechargetext">{{l.recharge}}<text>积分</text></view>
  12. <view class="pay">充{{l.pay}}</view>
  13. <view class="song" :style="{color: l.color}">送</view>
  14. <view class="button">充值{{l.pay}}元</view>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. // #ifdef H5
  21. import { rechargeWechat } from '@/api/wallet.js';
  22. // #endif
  23. // #ifdef MP
  24. import { rechargeRoutine } from '@/api/wallet.js';
  25. // #endif
  26. export default {
  27. data() {
  28. return {
  29. type: 'weixin',
  30. list:
  31. [{
  32. pay: 1000,
  33. recharge: 100,
  34. img: require('@/static/img/i1.png'),
  35. icon: require('@/static/img/ic1.png'),
  36. color: "#FF6000",
  37. },
  38. {
  39. pay: 500,
  40. recharge: 50,
  41. img: require('@/static/img/i2.png'),
  42. icon: require('@/static/img/ic2.png'),
  43. color: "#FF3115",
  44. },
  45. {
  46. pay: 200,
  47. recharge: 20,
  48. img: require('@/static/img/i3.png'),
  49. icon: require('@/static/img/ic3.png'),
  50. color: "#FF2C4F",
  51. },
  52. {
  53. pay: 100,
  54. recharge: 10,
  55. img: require('@/static/img/i4.png'),
  56. icon: require('@/static/img/ic3.png'),
  57. color: "#9525FE ",
  58. }]
  59. }
  60. },
  61. methods: {
  62. //充值
  63. confirm(item) {
  64. let obj = this
  65. uni.showModal({
  66. // title: "是否确认充值",
  67. content: "确认充值?",
  68. success:function(res){
  69. if(res.confirm) {
  70. obj.submit(item.pay)
  71. }else {
  72. console.log("xu")
  73. }
  74. }
  75. })
  76. },
  77. // 提交
  78. submit(money) {
  79. let obj = this;
  80. // obj.payLoding = true;
  81. // #ifdef H5
  82. rechargeWechat({ price: money, from: this.type })
  83. .then(e => {
  84. let da = e.data.data;
  85. obj.weichatObj.chooseWXPay({
  86. timestamp: da.timestamp,
  87. nonceStr: da.nonceStr,
  88. package: da.package,
  89. signType: da.signType,
  90. paySign: da.paySign,
  91. success: function(res) {
  92. uni.showToast({
  93. title: '充值成功',
  94. duration: 2000,
  95. position: 'top'
  96. });
  97. }
  98. });
  99. obj.payLoding = false;
  100. })
  101. .catch(e => {
  102. obj.payLoding = false;
  103. console.log(e);
  104. });
  105. // #endif
  106. // #ifdef MP
  107. rechargeRoutine({ price: money})
  108. .then(e => {
  109. let da = e.data;
  110. wx.requestPayment({
  111. timeStamp: da.timestamp,
  112. nonceStr: da.nonceStr,
  113. package: da.package,
  114. signType: da.signType,
  115. paySign: da.paySign,
  116. success: function(res) {
  117. uni.redirectTo({
  118. url: '/pages/money/paySuccess'
  119. });
  120. },
  121. })
  122. obj.payLoding = false;
  123. })
  124. .catch(e => {
  125. obj.payLoding = false;
  126. console.log(e);
  127. });
  128. // #endif
  129. }
  130. },
  131. computed: {
  132. //积分
  133. integral() {
  134. return this.$store.state.user.userInfo.integral
  135. }
  136. },
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. page {
  141. height: 100%;
  142. background-color: #fff;
  143. }
  144. .recharge {
  145. background-color: #EBF3FF;
  146. }
  147. .header {
  148. padding: 80rpx;
  149. padding-top: 100rpx;
  150. color: #438BED;
  151. text-align: center;
  152. text:nth-child(1) {
  153. font-size: 80rpx;
  154. }
  155. }
  156. .footer {
  157. border-radius: 50rpx 50rpx 0 0;
  158. height: 70%;
  159. display: flex;
  160. flex-wrap: wrap;
  161. justify-content: space-between;
  162. background-color: #fff;
  163. width: 100%;
  164. padding: 30rpx;
  165. .item {
  166. margin: 10rpx;
  167. width: 320rpx;
  168. height: 180rpx;
  169. margin-bottom: 30rpx;
  170. .border {
  171. position: absolute;
  172. width: 320rpx;
  173. height: 190rpx;
  174. }
  175. .i {
  176. width: 100rpx;
  177. height: 100rpx;
  178. position: relative;
  179. left: 30rpx;
  180. top: 20rpx;
  181. }
  182. view {
  183. position: relative;
  184. }
  185. .rechargetext {
  186. font-weight: bold;
  187. color: #fff;
  188. position: relative;
  189. left: calc(10% + 120rpx);
  190. font-size: 50rpx;
  191. bottom: 55rpx;
  192. text {
  193. font-weight: 500;
  194. margin-left: 5rpx;
  195. font-size: 28rpx;
  196. }
  197. }
  198. .pay {
  199. text-align: center;
  200. width: 150rpx;
  201. bottom: 162rpx;
  202. left: calc(50% - 75rpx);
  203. color: #fff;
  204. font-size: 28rpx;
  205. }
  206. .song {
  207. height: 20rpx;
  208. bottom: 156.8rpx;
  209. left: 64rpx;
  210. font-weight: bold;
  211. color: #FF6000;
  212. font-size: 36rpx;
  213. }
  214. .button {
  215. background-color: #FFF583;
  216. width: 200rpx;
  217. height: 50rpx;
  218. bottom: 95rpx;
  219. line-height: 50rpx;
  220. text-align: center;
  221. border-radius: 10rpx;
  222. color: #722E18;
  223. left: calc(50% - 100rpx);
  224. font-size: 26rpx;
  225. box-shadow: 0px 3px 8px #aaa,
  226. }
  227. }
  228. }
  229. </style>