index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="container">
  3. <!-- <view class="list flex_r flex_ac flex_jb mar_t16">
  4. <view class="list_name">充值类型:</view>
  5. <view class="title_select">
  6. <picker @change="bindPickerChange" :value="index" :range="array">
  7. <view class="flex_r flex_ac flex_je" style="width: 300rpx">
  8. <view class="select_name">{{ array[index] }}</view>
  9. <image
  10. style="width: 25rpx; height: 25rpx; margin-left: 15rpx"
  11. src="/static/down.png"
  12. mode=""
  13. >
  14. </image>
  15. </view>
  16. </picker>
  17. </view>
  18. </view> -->
  19. <view class="list flex_r flex_ac flex_jb mar_t16" v-if="index == 0">
  20. <view class="list_name">当前余额:</view>
  21. <view class="list_text flex_r flex_ac"
  22. ><text>¥</text>{{ userinfo.user_money }}</view
  23. >
  24. </view>
  25. <view class="list flex_r flex_ac flex_jb mar_t16" v-if="index == 1">
  26. <view class="list_name">当前拼团金:</view>
  27. <view class="list_text flex_r flex_ac"
  28. ><text>¥</text>{{ detail.qxMoney }}</view
  29. >
  30. </view>
  31. <view class="list flex_r flex_ac flex_jb mar_t16">
  32. <view class="list_name">充值金额:</view>
  33. <view class="list_text flex_r flex_ac">
  34. <input type="text" v-model="price" placeholder="自定义金额" />
  35. </view>
  36. </view>
  37. <view class="option flex_c mar_t16">
  38. <view class="list_name">充值方式</view>
  39. <view class="option_con flex_r flex_ac flex_jb mar_t16">
  40. <view class="way_con flex_r flex_ac">
  41. <image class="way_img" src="/static/weixin_icon.png" mode=""></image>
  42. <view class="way_text">微信支付</view>
  43. </view>
  44. <view
  45. class="way_radio"
  46. :class="isSelect == 1 ? 'select_way' : ''"
  47. ></view>
  48. </view>
  49. </view>
  50. <view class="btn flex_r flex_ac flex_jc" @tap="confimTopUp">立即充值</view>
  51. </view>
  52. </template>
  53. <script>
  54. let app = getApp();
  55. var appEv = app.$vm.$options;
  56. import { ToPayOpre } from "@/utils/reqTools.js";
  57. var toPayOpre = new ToPayOpre();
  58. import { get, post } from "@/request/api.js";
  59. export default {
  60. data() {
  61. return {
  62. price: '',
  63. isSelect: 1,
  64. detail: {},
  65. array: ["余额充值"],
  66. index: 0,
  67. userinfo: undefined, // 获取用户信息
  68. };
  69. },
  70. onLoad: function () {
  71. this.userinfo = uni.getStorageSync("userinfo");
  72. },
  73. methods: {
  74. confimTopUp() {
  75. if (this.price == 0 || this.prioce == '') {
  76. appEv.errTips("充值不能为0");
  77. return;
  78. } else {
  79. // #ifdef H5
  80. let type = "H5";
  81. // #endif
  82. // #ifdef APP
  83. let type = "app";
  84. // #endif
  85. // #ifdef MP-WEIXIN
  86. let type = "jsapi";
  87. // #endif
  88. let data = {
  89. trade_type: type,
  90. amount: this.price,
  91. };
  92. post("/user/recharge", data).then((res) => {
  93. toPayOpre.toPay(res.data.data, (rea) => {
  94. if (!rea) {
  95. // 支付成功
  96. appEv.errTips("支付成功");
  97. this.price = 0;
  98. this.getuserInfo()
  99. } else {
  100. // 支付失败
  101. appEv.errTips("支付已取消");
  102. }
  103. });
  104. });
  105. }
  106. },
  107. getuserInfo() {
  108. post("/user/userinfo").then((res) => {
  109. if (res.code === 0) {
  110. uni.setStorageSync('userinfo', res.data.data);
  111. this.userinfo = res.data.data
  112. }
  113. });
  114. },
  115. bindPickerChange: function (e) {
  116. this.index = e.target.value;
  117. this.loadData();
  118. },
  119. },
  120. };
  121. </script>
  122. <style lang="scss" scoped>
  123. // 页面配置
  124. page {
  125. background: #f4f4f4;
  126. }
  127. // 页面配置-end
  128. // 页面内容
  129. .option_con {
  130. width: 100%;
  131. overflow: hidden;
  132. }
  133. .way_img {
  134. width: 52rpx;
  135. height: 52rpx;
  136. margin-right: 8rpx;
  137. }
  138. .way_text {
  139. font-size: 22rpx;
  140. color: #333333;
  141. font-family: "SourceHanSansCN-Medium";
  142. }
  143. .list_text input {
  144. font-size: 28rpx;
  145. color: #333333;
  146. text-align: right;
  147. margin-left: 20rpx;
  148. }
  149. .list {
  150. width: 100%;
  151. height: 86rpx;
  152. padding: 0 30rpx;
  153. box-sizing: border-box;
  154. background: #fff;
  155. }
  156. .list_text {
  157. font-family: "SourceHanSansCN-Bold";
  158. font-weight: bold;
  159. font-size: 36rpx;
  160. color: #17bb87;
  161. }
  162. .list_name {
  163. color: #333333;
  164. font-size: 28rpx;
  165. font-family: "SourceHanSansCN-Medium";
  166. font-weight: 500;
  167. }
  168. .option {
  169. width: 100%;
  170. overflow: hidden;
  171. padding: 20rpx 30rpx 60rpx;
  172. box-sizing: border-box;
  173. background: #fff;
  174. }
  175. .list_text text {
  176. font-family: "SourceHanSansCN-Medium";
  177. font-size: 22rpx;
  178. font-weight: 500rpx;
  179. color: #17bb87;
  180. }
  181. .way_radio {
  182. width: 39rpx;
  183. height: 35rpx;
  184. background: url("~@/static/weixuanzhong.png");
  185. background-repeat: no-repeat;
  186. background-size: 35rpx 35rpx;
  187. background-position: center center;
  188. }
  189. .btn {
  190. width: 689rpx;
  191. height: 92rpx;
  192. background: #17bb87;
  193. color: #fff;
  194. font-size: 42rpx;
  195. font-family: "SourceHanSansCN-Medium";
  196. font-weight: 500;
  197. margin: 132rpx auto 0;
  198. border-radius: 10rpx;
  199. }
  200. .select_name {
  201. width: 80%;
  202. text-align: end;
  203. font-family: SourceHanSansCN-Medium;
  204. color: #494949;
  205. font-size: 28rpx;
  206. }
  207. .select_way {
  208. background: url("~@/static/xuanzhong_icon.png");
  209. background-repeat: no-repeat;
  210. background-size: 39rpx 35rpx;
  211. background-position: center center;
  212. }
  213. // 页面内容-end
  214. </style>