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.

312 lines
6.7 KiB

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