yjzz.vue 7.3 KB

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