You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

264 lines
5.5 KiB

8 months ago
  1. <!-- 充值界面 -->
  2. <template>
  3. <view class="purse bx">
  4. <navbar :leftClick="leftClick" :title="$t('page.purse.recharge')"></navbar>
  5. <!-- 用户余额信息 -->
  6. <view class="user-money content">
  7. <view class="title">{{ $t('page.purse.account') }}</view>
  8. <view class="money">
  9. <view class="money-unit">{{ $t('page.purse.unit') }}</view>
  10. <view class="money-detail">{{ money }}</view>
  11. </view>
  12. </view>
  13. <!-- 充值方案列表 -->
  14. <view class="recharge-list content">
  15. <view @click="selectRecharge(index)" v-for="(item,index) in rechargeList" :key="item.id" class="recharge-item" :class="{ selectRecharge : index === active}">
  16. <view class="money">{{ item.price }}</view>
  17. <view class="unit">{{ $t('page.purse.unit') }}</view>
  18. </view>
  19. </view>
  20. <!-- 输入框 -->
  21. <view class="input content">
  22. <input @input="moneyChange" v-model="form.money" class="input content" type="number" :placeholder="$t('page.purse.deposit-now')" />
  23. </view>
  24. <view class="input content">
  25. <input v-model="form.payPass" class="input content" type="text" :placeholder="$t('page.purse.security-pin')" />
  26. </view>
  27. <!-- 按钮 -->
  28. <view @click="recharge" class="btn content">{{ $t('page.purse.deposit-now') }}</view>
  29. <!-- 客服列表 -->
  30. <serviceList :show="showService" :serverList="serverList" @close="closeServiceList"></serviceList>
  31. </view>
  32. </template>
  33. <script>
  34. import navbar from '@/components/base/m-navbar.vue'
  35. import serviceList from '@/components/serviceList/serviceList.vue';
  36. export default {
  37. components: {
  38. navbar,
  39. serviceList
  40. },
  41. data() {
  42. return {
  43. rechargeList : [],
  44. active : 0,
  45. money : '',
  46. form : {
  47. money : '',
  48. payPass : '',
  49. id : ''
  50. },
  51. serverList : [],
  52. showService : false
  53. }
  54. },
  55. onShow() {
  56. this.getUserInfo()
  57. this.getTopUpScheme()
  58. this.forgetPass()
  59. },
  60. methods: {
  61. leftClick() {
  62. uni.navigateTo({
  63. url: '/pages/home/home'
  64. })
  65. },
  66. //选择充值方案
  67. selectRecharge(index){
  68. this.$play()
  69. this.active = index
  70. this.form.money = this.rechargeList[index].price
  71. this.form.id = this.rechargeList[index].id
  72. },
  73. //获取用户信息
  74. getUserInfo(){
  75. this.request('userInfo').then(res => {
  76. if(res.code == 200){
  77. this.money = res.result.userInfo.money
  78. }
  79. })
  80. },
  81. //获取充值方案
  82. getTopUpScheme(){
  83. this.request('shopNo').then(res => {
  84. if(res.code == 200){
  85. this.rechargeList = res.result
  86. this.form.money = res.result[0].price; //默认选中第一个
  87. }
  88. })
  89. },
  90. //充值
  91. recharge(){
  92. this.$play()
  93. let { money , payPass } = this.form
  94. if(!money){
  95. return uni.$u.toast(this.$t('page.purse.moneyEmpty'))
  96. }
  97. if(money <= 0){
  98. return uni.$u.toast(this.$t('page.purse.AmountThan0'))
  99. }
  100. if(payPass.trim() == ''){
  101. return uni.$u.toast(this.$t('page.purse.payPassEmpty'))
  102. }
  103. this.request('recharge',{},this.form).then(res => {
  104. if(res.code == 200){
  105. uni.$u.toast(this.$t('page.purse.success'))
  106. this.cleanForm()
  107. this.revealServiceList()
  108. this.getUserInfo() //刷新用户信息(更新用户余额)
  109. }
  110. })
  111. },
  112. //用户手动填写充值金额
  113. moneyChange(e){
  114. this.active = ''
  115. let inputValue= e.detail.value;
  116. this.rechargeList.forEach((recharge,index) => {
  117. if(parseInt(recharge.price) == inputValue){
  118. this.active = index
  119. }
  120. })
  121. },
  122. //显示客服列表
  123. revealServiceList(){
  124. this.$play()
  125. this.showService = true;
  126. },
  127. //关闭客服列表
  128. closeServiceList(){
  129. this.showService = false;
  130. },
  131. //忘记密码(获取客服列表)
  132. forgetPass(){
  133. this.request('forgetPass').then(res => {
  134. if(res.code == 200){
  135. this.serverList = res.result
  136. }
  137. })
  138. },
  139. //清空表单数据
  140. cleanForm(){
  141. this.form = {}
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. .purse {
  148. width: 750rpx;
  149. min-height: 100vh;
  150. background-color: black;
  151. margin: 0 auto;
  152. background-image: url('@/static/pruse/bg.png');
  153. background-size: 100%;
  154. background-repeat: no-repeat;
  155. .content {
  156. width: 96%;
  157. margin: 0 auto;
  158. }
  159. .user-money {
  160. background: rgba(176, 199, 59, .8);
  161. margin: 20rpx auto 30rpx auto;
  162. border: 4rpx solid #D3EA5E;
  163. padding: 60rpx 0rpx;
  164. font-size: 36rpx;
  165. .title,
  166. .money {
  167. display: flex;
  168. justify-content: center;
  169. align-items: center;
  170. height: 60rpx;
  171. .money-unit {
  172. margin-right: 15rpx;
  173. font-size: 28rpx;
  174. font-weight: bold;
  175. }
  176. .money-detail{
  177. font-size: 50rpx;
  178. font-weight: bold;
  179. }
  180. }
  181. }
  182. .recharge-list {
  183. display: flex;
  184. justify-content: space-between;
  185. flex-wrap: wrap;
  186. color: #B0C73B;
  187. .recharge-item {
  188. box-sizing: border-box;
  189. width: calc(50% - 7rpx);
  190. border: 1px solid #636363;
  191. text-align: center;
  192. margin-bottom: 20rpx;
  193. .money , .unit{
  194. height: 60rpx;
  195. line-height: 60rpx;
  196. }
  197. .money{
  198. font-size: 44rpx;
  199. }
  200. .unit{
  201. font-size: 28rpx;
  202. }
  203. }
  204. .selectRecharge{
  205. color: white;
  206. border: 1px solid #D3EA5E;
  207. background: rgba(176, 199, 59, .8);
  208. }
  209. }
  210. .input{
  211. margin: 30rpx auto;
  212. input{
  213. border: 1px solid #B0C73B;
  214. height: 80rpx;
  215. font-size: 34rpx;
  216. color: #B0C73B;
  217. text-indent: 15rpx;
  218. border-radius: 10rpx;
  219. }
  220. }
  221. .btn{
  222. height: 90rpx;
  223. display: flex;
  224. align-items: center;
  225. justify-content: center;
  226. background: #B0C73B;
  227. border-radius: 10rpx;
  228. font-size: 40rpx;
  229. font-weight: bold;
  230. }
  231. }
  232. </style>