yjzz.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="flex">
  5. <view class="buttom">
  6. <view class="icon" v-if="type == 0">{{ userInfo.brokerage_price || 0}}</view>
  7. <view class="icon" v-if="type == 1">{{ userInfo.now_money || 0}}</view>
  8. <view class="icon" v-if="type == 3">{{ pUser.points || 0}}</view>
  9. <text class="text">可转账余额</text>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="row-box">
  14. <view class="title">收款人UID</view>
  15. <view class="row"><input class="input" type="number" v-model="phone" placeholder="请输入收款人UID"
  16. placeholder-class="placeholder" /></view>
  17. </view>
  18. <view class="row-box">
  19. <view class="title">转账金额</view>
  20. <view class="row">
  21. <input class="input" type="number" v-model="withdrawal" placeholder="转入金额"
  22. placeholder-class="placeholder" />
  23. <view class="buttom" @click="getAll" >全部转账</view>
  24. </view>
  25. </view>
  26. <button class="add-btn up" @click="!loding ? confirm('zz') : ''">转账</button>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. getUserInfo,
  32. jfzz
  33. } from '@/api/user.js';
  34. import { passUser,createGs } from '@/api/zero.js'
  35. import {
  36. mapMutations,
  37. mapState
  38. } from 'vuex';
  39. export default {
  40. data() {
  41. return {
  42. phone: '',
  43. money: '0.00', //可提现金额
  44. withdrawal: '', //提现金额
  45. password: '', //支付密码
  46. card: '', //转账卡号
  47. name: '',
  48. // #ifdef H5
  49. weichatBsrowser: false,
  50. // #endif
  51. loding: true,
  52. type: 0,
  53. pUser: {}
  54. };
  55. },
  56. onLoad(options) {
  57. // #ifdef H5
  58. this.weichatBsrowser = uni.getStorageSync('weichatBrowser');
  59. // #endif
  60. this.dataUp();
  61. if (options.type) {
  62. this.type = options.type;
  63. if(this.type == 1) {
  64. uni.setNavigationBarTitle({
  65. title:'余额转账'
  66. })
  67. }else if(this.type == 3) {
  68. uni.setNavigationBarTitle({
  69. title:'阅读积分转账'
  70. })
  71. }
  72. }
  73. },
  74. computed: {
  75. ...mapState('user', ['userInfo'])
  76. },
  77. methods: {
  78. ...mapMutations('user', ['setUserInfo']),
  79. passUser() {
  80. passUser().then(res => {
  81. // console.log(res);
  82. this.pUser = res.data
  83. })
  84. },
  85. getAll() {
  86. if(this.type == 0) {
  87. this.withdrawal = this.userInfo.brokerage_price
  88. }else if(this.type == 2){
  89. this.withdrawal = this.userInfo.now_money
  90. }else if(this.type == 3) {
  91. this.withdrawal = this.pUser.points
  92. }
  93. },
  94. // 更新数据
  95. dataUp() {
  96. let obj = this;
  97. getUserInfo({})
  98. .then(e => {
  99. obj.loding = false;
  100. // 保存返回用户数据
  101. obj.setUserInfo(e.data);
  102. // this.passUser()
  103. })
  104. .catch(e => {
  105. console.log(e);
  106. });
  107. },
  108. // 切换选中对象
  109. tabRadio(e) {
  110. this.type = e.detail.value;
  111. },
  112. // 提交
  113. confirm(tit) {
  114. let obj = this;
  115. obj.loding = true;
  116. if(obj.phone == '') {
  117. return obj.$api.msg('请输入用户UID/手机号');
  118. }
  119. if ( !obj.withdrawal || obj.withdrawal<=0 ) {
  120. obj.loding = false;
  121. obj.$api.msg('转账金额须大于0');
  122. return;
  123. }
  124. let data = {
  125. to_uid: obj.phone, //编号
  126. num: obj.withdrawal ,//金额
  127. type: obj.type
  128. };
  129. if(obj.type == 3) {
  130. createGs({
  131. amount: obj.withdrawal,
  132. to_uid: obj.phone,
  133. type: tit == 'jy'? 1: 2
  134. }).then(res => {
  135. uni.showToast({
  136. title: tit == 'jy'? '交易成功': '转账成功',
  137. duration:2000
  138. });
  139. obj.dataUp();
  140. obj.loding = false;
  141. }).catch(err => {
  142. obj.dataUp();
  143. obj.loding = false;
  144. })
  145. }else {
  146. jfzz(data)
  147. .then(e => {
  148. // 初始化提现金额
  149. obj.withdrawal = '';
  150. uni.showToast({
  151. title: '转账成功',
  152. duration: 2000,
  153. position: 'top'
  154. });
  155. obj.dataUp();
  156. })
  157. .catch(e => {
  158. obj.$api.msg(e.msg);
  159. obj.loding = false;
  160. console.log();
  161. });
  162. }
  163. },
  164. boblack() {
  165. uni.navigateBack({
  166. fail() {
  167. uni.switchTab({
  168. url: '/pages/index/index'
  169. })
  170. }
  171. })
  172. },
  173. }
  174. };
  175. </script>
  176. <style lang="scss">
  177. page {
  178. height: 100%;
  179. }
  180. .content-money {
  181. padding: 30rpx 0;
  182. background: #ffffff;
  183. }
  184. .item {
  185. padding: 0 $page-row-spacing;
  186. background-color: #ffffff;
  187. }
  188. .flex {
  189. background-color: #ffffff;
  190. text-align: center;
  191. margin: 0 30rpx;
  192. border-radius: $border-radius-sm;
  193. justify-content: center;
  194. .buttom {
  195. font-size: $font-lg;
  196. width: 50%;
  197. }
  198. .interval {
  199. width: 2px;
  200. height: 60rpx;
  201. background-color: #eeeeee;
  202. }
  203. .icon {
  204. background-size: 100%;
  205. font-size: 42rpx;
  206. color: $font-color-dark;
  207. font-weight: bold;
  208. background-repeat: no-repeat;
  209. background-position: center;
  210. }
  211. .text {
  212. color: $font-color-light;
  213. }
  214. }
  215. .row-box {
  216. margin-top: 30rpx;
  217. padding: 20rpx 30rpx;
  218. background: #fff;
  219. .title {
  220. font-size: $font-base + 2rpx;
  221. color: $font-color-dark;
  222. }
  223. .row {
  224. display: flex;
  225. align-items: center;
  226. position: relative;
  227. height: 80rpx;
  228. .tit {
  229. flex-shrink: 0;
  230. width: 40rpx;
  231. font-size: 30rpx;
  232. color: $font-color-dark;
  233. }
  234. .input {
  235. flex: 1;
  236. font-size: 30rpx;
  237. color: $font-color-dark;
  238. }
  239. .iconlocation {
  240. font-size: 36rpx;
  241. color: $font-color-light;
  242. }
  243. .buttom {
  244. color: $base-color;
  245. font-size: $font-base;
  246. }
  247. }
  248. }
  249. .add-btn {
  250. width: 520rpx;
  251. height: 80rpx;
  252. border-radius: 20rpx;
  253. margin: 140rpx auto 0;
  254. font-size: 36rpx;
  255. font-weight: bold;
  256. color: #fff;
  257. background-color:$base-color;
  258. }
  259. .back-btn {
  260. width: 520rpx;
  261. height: 80rpx;
  262. border-radius: 20rpx;
  263. margin: 40rpx auto;
  264. font-size: 36rpx;
  265. font-weight: bold;
  266. color: #303030;
  267. background-color: #F8DABA;
  268. }
  269. .name {
  270. background: #fff;
  271. padding: 30rpx;
  272. }
  273. .list {
  274. padding-left: 30rpx;
  275. margin-top: 30rpx;
  276. background-color: #ffffff;
  277. .box {
  278. display: flex;
  279. align-items: center;
  280. width: 100%;
  281. height: 120rpx;
  282. border-bottom: 1px solid $border-color-light;
  283. .icon {
  284. font-size: 48rpx;
  285. padding-right: 20rpx;
  286. .icon-img {
  287. height: 50rpx;
  288. width: 50rpx;
  289. }
  290. }
  291. .iconweixin1 {
  292. color: #18bf16;
  293. }
  294. .iconzhifubao {
  295. color: #08aaec;
  296. }
  297. .title-box {
  298. flex-grow: 1;
  299. text-align: left;
  300. .title {
  301. font-size: $font-base + 2rpx;
  302. color: $font-color-base;
  303. }
  304. .node {
  305. font-size: $font-sm;
  306. color: $font-color-light;
  307. }
  308. }
  309. }
  310. }
  311. .tip {
  312. padding: 20rpx;
  313. color: #ff0000;
  314. }
  315. /deep/ .uni-radio-input {
  316. width: 45rpx;
  317. height: 45rpx;
  318. }
  319. .psw-wrapper {
  320. width: 548rpx;
  321. height: 344rpx;
  322. background-color: #FFFFFF;
  323. border-radius: 15rpx 15rpx;
  324. .psw-title {
  325. width: 100%;
  326. font-size: 35rpx;
  327. padding: 43rpx 0 49rpx;
  328. text-align: center;
  329. font-weight: 800;
  330. }
  331. .psw-ipt {
  332. display: block;
  333. background-color: #dce3ed;
  334. height: 90rpx;
  335. width: 464rpx;
  336. padding-left: 30rpx;
  337. margin: 0 auto;
  338. font-size: 80rpx;
  339. }
  340. .psw-btn text {
  341. display: inline-block;
  342. text-align: center;
  343. width: 50%;
  344. padding-top: 29rpx;
  345. font-size: 35rpx;
  346. }
  347. .psw-qd {
  348. color: #5771DF;
  349. }
  350. }
  351. .jy {
  352. background-color: $base-color;
  353. color: #fff;
  354. margin-top: 30rpx;
  355. }
  356. </style>