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.

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