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.

268 lines
5.7 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 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: $uni-bg-color-app;
  161. // background: rgba(176, 199, 59, .8);
  162. margin: 20rpx auto 30rpx auto;
  163. border: 4rpx solid #D3EA5E;
  164. border: 4rpx solid $uni-bg-color-app;
  165. padding: 60rpx 0rpx;
  166. font-size: 36rpx;
  167. color: $uni-bg-color;
  168. .title,
  169. .money {
  170. display: flex;
  171. justify-content: center;
  172. align-items: center;
  173. height: 60rpx;
  174. .money-unit {
  175. margin-right: 15rpx;
  176. font-size: 28rpx;
  177. font-weight: bold;
  178. }
  179. .money-detail{
  180. font-size: 50rpx;
  181. font-weight: bold;
  182. }
  183. }
  184. }
  185. .recharge-list {
  186. display: flex;
  187. justify-content: space-between;
  188. flex-wrap: wrap;
  189. color: $uni-bg-color-app;
  190. .recharge-item {
  191. box-sizing: border-box;
  192. width: calc(50% - 7rpx);
  193. border: 1px solid #636363;
  194. text-align: center;
  195. margin-bottom: 20rpx;
  196. .money , .unit{
  197. height: 60rpx;
  198. line-height: 60rpx;
  199. }
  200. .money{
  201. font-size: 44rpx;
  202. }
  203. .unit{
  204. font-size: 28rpx;
  205. }
  206. }
  207. .selectRecharge{
  208. color: white;
  209. // border: 1px solid #D3EA5E;
  210. background: $uni-bg-color-app;
  211. // background: rgba(176, 199, 59, .8);
  212. }
  213. }
  214. .input{
  215. margin: 30rpx auto;
  216. input{
  217. border: 1px solid $uni-bg-color-app;
  218. height: 80rpx;
  219. font-size: 34rpx;
  220. color: $uni-bg-color-app;
  221. text-indent: 15rpx;
  222. border-radius: 10rpx;
  223. }
  224. }
  225. .btn{
  226. height: 90rpx;
  227. display: flex;
  228. align-items: center;
  229. justify-content: center;
  230. background: $uni-bg-color-app;
  231. border-radius: 10rpx;
  232. color: $uni-bg-color;
  233. font-size: 40rpx;
  234. font-weight: bold;
  235. }
  236. }
  237. </style>