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.

364 lines
7.8 KiB

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