recharge.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view class="index" v-if="!loading">
  3. <view class="index-head">
  4. <view class="index-head-top">
  5. <view class="f32">请选择充值金额:</view>
  6. </view>
  7. <view class="index-head-bottom">
  8. <view :class="active==index?'index-head-bottom-item-active':'index-head-bottom-item'" @click="select(index)" v-for="(item,index) in tableData"
  9. :key="index">
  10. <text class="f40">{{item.money}}</text><text class="f22">元</text>
  11. <view class="givemoney" v-if="item.give_money > 0">送{{item.give_money}}元</view>
  12. </view>
  13. </view>
  14. <view class="head-top-botm">注:充值金额只能消费,不能提现;</view>
  15. </view>
  16. <view class="index-body">
  17. <template v-if="settings.is_plan == 1">
  18. <view class="index-head-top">
  19. <view class="f32 p-0-20">可自定义充值金额:</view>
  20. </view>
  21. <view class="index-body-top" @click="select(-1)">
  22. <view class="">其他金额</view>
  23. <input type="text" v-model="user_money" placeholder="请输入您要充值的金额" />
  24. </view>
  25. <view class="gray p-0-30">最低充值金额:{{settings.min_money}}元</view>
  26. </template>
  27. <!--支付方式-->
  28. <view class="buy-checkout">
  29. <view :class="pay_type == 20 ? 'item active' : 'item'" @tap="payTypeFunc(20)">
  30. <view class="d-s-c">
  31. <view class="icon-box d-c-c mr10"><span class="icon iconfont icon-weixin"></span></view>
  32. <text class="key">微信支付:</text>
  33. </view>
  34. <view class="icon-box d-c-c"><span class="icon iconfont icon-xuanze"></span></view>
  35. </view>
  36. <view v-if="showAlipay" :class="pay_type == 30 ? 'item active' : 'item'" @click="payTypeFunc(30)">
  37. <view class="d-s-c">
  38. <view class="icon-box d-c-c mr10"><span class="icon iconfont icon-zhifubao"></span></view>
  39. <text class="key">支付宝支付:</text>
  40. </view>
  41. <view class="icon-box d-c-c"><span class="icon iconfont icon-xuanze"></span></view>
  42. </view>
  43. </view>
  44. <view class="index-body-bottom">
  45. <view class="index-body-bottom-info">
  46. <view class="f32 mb23">充值说明</view>
  47. <text class="gray f26">{{settings.describe}}</text>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="btn">
  52. <button type="default" @click="payFunc">确认支付</button>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import {
  58. pay
  59. } from '@/common/pay.js';
  60. export default {
  61. data() {
  62. return {
  63. tableData: [],
  64. settings: {},
  65. active: -1,
  66. pay_type: 20,
  67. /*套餐id*/
  68. plan_id: 0,
  69. /*自定义金额*/
  70. user_money: '',
  71. loading: true,
  72. /*是否显示支付宝支付,只有在h5,非微信内打开才显示*/
  73. showAlipay: false,
  74. }
  75. },
  76. watch: {
  77. user_money(val) {
  78. if (val != '') {
  79. this.active = -1;
  80. this.plan_id = 0;
  81. }
  82. }
  83. },
  84. mounted() {
  85. /*获取数据*/
  86. this.getData();
  87. },
  88. methods: {
  89. /*获取数据*/
  90. getData() {
  91. let self = this;
  92. self.loading = true;
  93. uni.showLoading({
  94. title: '加载中'
  95. })
  96. self._get(
  97. 'balance.plan/index', {
  98. pay_source: self.getPlatform()
  99. },
  100. function(data) {
  101. self.loading = false;
  102. uni.hideLoading();
  103. self.tableData = data.data.list;
  104. self.settings = data.data.settings;
  105. self.showAlipay = data.data.show_alipay;
  106. }
  107. );
  108. },
  109. //选择套餐
  110. select(index) {
  111. this.active = index;
  112. this.user_money = '';
  113. },
  114. payTypeFunc(e){
  115. this.pay_type = e;
  116. },
  117. payFunc() {
  118. let self = this;
  119. uni.showLoading({
  120. title: '加载中',
  121. mask: true
  122. });
  123. if (self.active != -1) {
  124. self.plan_id = self.tableData[self.active]['plan_id'];
  125. }
  126. if (self.plan_id == 0 && self.user_money == '') {
  127. uni.showToast({
  128. icon: 'none',
  129. title: '请选择充值套餐或输入要充值的金额'
  130. });
  131. return;
  132. }
  133. self._post('balance.plan/submit', {
  134. plan_id: self.plan_id,
  135. user_money: self.user_money,
  136. pay_source: self.getPlatform()
  137. }, function(result) {
  138. uni.hideLoading();
  139. pay(result, self, function() {
  140. uni.showToast({
  141. title: '充值成功'
  142. }, 1000);
  143. setTimeout(function() {
  144. uni.navigateBack();
  145. }, 1000);
  146. }, function() {
  147. uni.showToast({
  148. icon: 'none',
  149. title: '充值失败'
  150. });
  151. });
  152. });
  153. },
  154. }
  155. }
  156. </script>
  157. <style>
  158. page {
  159. background: #FFFFFF;
  160. }
  161. .gray {
  162. color: #808080;
  163. }
  164. .font-28 {
  165. font-size: 28rpx;
  166. }
  167. .font-36 {
  168. font-size: 36rpx;
  169. }
  170. .index {
  171. width: 750rpx;
  172. }
  173. .index-head {
  174. width: 750rpx;
  175. margin: 0 auto;
  176. padding: 30rpx 20rpx;
  177. padding-bottom: 50rpx;
  178. box-sizing: border-box;
  179. background-color: white;
  180. border-top: 16rpx solid #f2f2f2;
  181. }
  182. .index-head-top {
  183. display: flex;
  184. justify-content: space-between;
  185. align-items: baseline;
  186. flex-direction: column;
  187. }
  188. .head-top-botm {
  189. color: #999999;
  190. font-size: 26rpx;
  191. margin-top: 20rpx;
  192. }
  193. .index-head-bottom {
  194. display: flex;
  195. justify-content: space-between;
  196. align-items: center;
  197. flex-wrap: wrap;
  198. }
  199. .index-head-bottom-item {
  200. position: relative;
  201. width: 220rpx;
  202. height: 128rpx;
  203. border: 1rpx solid #999999;
  204. background-color: #FFFFFF;
  205. color: #333333;
  206. text-align: center;
  207. border-radius: 15rpx;
  208. line-height: 128rpx;
  209. margin-top: 20rpx;
  210. font-size: 48rpx;
  211. }
  212. .index-head-bottom-item-active {
  213. position: relative;
  214. width: 220rpx;
  215. height: 128rpx;
  216. color: #323333;
  217. background: #FFE6E3;
  218. border: 1rpx solid #F6220C;
  219. text-align: center;
  220. border-radius: 12rpx;
  221. line-height: 128rpx;
  222. margin-top: 20rpx;
  223. font-size: 48rpx;
  224. }
  225. .givemoney {
  226. position: absolute;
  227. top: 0;
  228. left: 0;
  229. width: 90rpx;
  230. height: 33rpx;
  231. background-color: #F6220C;
  232. color: #FFFFFF;
  233. font-size: 20rpx;
  234. line-height: 33rpx;
  235. text-align: center;
  236. border-top-left-radius: 12rpx;
  237. border-bottom-right-radius: 12rpx;
  238. }
  239. .index-body {
  240. width: 750rpx;
  241. }
  242. .index-body-top {
  243. /* width: 660rpx; */
  244. height: 100rpx;
  245. padding: 0 20rpx;
  246. border: 1rpx solid #f7f7f7;
  247. border-radius: 15rpx;
  248. margin: 0 auto;
  249. display: flex;
  250. justify-content: space-between;
  251. align-items: center;
  252. color: #4b4b4b;
  253. margin-bottom: 15rpx;
  254. }
  255. .active {
  256. background-color: #FDE34880;
  257. color: #323333;
  258. }
  259. .index-body-top view {
  260. width: 20%;
  261. }
  262. .index-body-top input {
  263. width: 80%;
  264. text-align: right;
  265. }
  266. .index-body-bottom {
  267. width: 750rpx;
  268. padding: 30rpx 20rpx;
  269. background-color: white;
  270. border-top: 16rpx solid #f2f2f2;
  271. margin-top: 20rpx;
  272. }
  273. .checkbox {
  274. display: flex;
  275. align-items: center;
  276. }
  277. .index-body-bottom-info {
  278. /* margin-top: 65rpx; */
  279. }
  280. .index-body-bottom-info view {
  281. margin-top: 10rpx;
  282. }
  283. .btn {
  284. margin-top: 50rpx;
  285. }
  286. .btn button {
  287. width: 710rpx;
  288. height: 80rpx;
  289. line-height: 80rpx;
  290. border-radius: 40rpx;
  291. margin: 0 auto;
  292. color: white;
  293. font-size: 32rpx;
  294. background: linear-gradient(90deg, #FF6B6B 4%, #F6220C 100%);
  295. }
  296. .rule text {
  297. margin-left: 15rpx;
  298. color: #88B5D1;
  299. }
  300. </style>