user_spread.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <template>
  2. <view>
  3. <form @submit="submitSub" :style="colorStyle">
  4. <view class="payment-top acea-row row-column row-center-wrapper">
  5. <span class="name">我的佣金</span>
  6. <view class="pic">
  7. ¥<span class="pic-font">{{userinfo.commissionCount || 0.00}}</span>
  8. </view>
  9. </view>
  10. <view class="payment">
  11. <view class="nav acea-row row-around row-middle">
  12. <view class="item" :class="active==index?'on':''" v-if="showBroker[item.key]"
  13. v-for="(item,index) in navRecharge" :key="index" @click="navRecharges(index)">{{item.title}}
  14. </view>
  15. </view>
  16. <!-- <view class='tip picList' v-if='!active'>
  17. <view class='input'>
  18. <text>¥</text>
  19. <input @input='inputNum' :maxlength="moneyMaxLeng" placeholder="0.00" type='digit'
  20. placeholder-class='placeholder' :value="number" name="number"></input>
  21. </view>
  22. </view> -->
  23. <!-- <view class="tip picList" v-else> -->
  24. <view class="tip picList">
  25. <view class='input'>
  26. <text>¥</text>
  27. <input @input='inputNum' :maxlength="moneyMaxLeng" placeholder="0.00" type='digit'
  28. placeholder-class='placeholder' :value="number" name="number"></input>
  29. </view>
  30. <view class='to_uid acea-row row-between' v-if="active==2">
  31. <view class="title">用户UID</view>
  32. <input class="uidbox" placeholder-class='placeholderUid' placeholder="请输入转入的用户uid" type='number' :value="uid" name="uid"></input>
  33. </view>
  34. </view>
  35. <view class="tips-title">
  36. <view style="font-weight: bold; font-size: 26rpx;">提示:</view>
  37. <view style="margin-top: 10rpx;">当前可转佣金为 <text
  38. class='font-color'>¥{{userinfo.commissionCount || 0}}</text>,冻结佣金为<text
  39. class='font-color'>¥{{userinfo.broken_commission}}</text></view>
  40. </view>
  41. <button class='but bg-color' formType="submit"> 立即转换</button>
  42. </view>
  43. </form>
  44. <home v-if="navigation"></home>
  45. <view v-show="false" v-html="formContent"></view>
  46. <!-- #ifdef MP -->
  47. <!-- <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize> -->
  48. <!-- #endif -->
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. getUserInfo,
  54. rechargeRoutine,
  55. rechargeWechat,
  56. energyImport,
  57. extractBank,
  58. brokerageTrade
  59. } from '@/api/user.js';
  60. import {
  61. toLogin
  62. } from '@/libs/login.js';
  63. import {
  64. orderOfflinePayType
  65. } from '@/api/order.js';
  66. import {
  67. mapGetters
  68. } from "vuex";
  69. import home from '@/components/home';
  70. import colors from "@/mixins/color";
  71. import {
  72. openPaySubscribe
  73. } from '@/utils/SubscribeMessage.js';
  74. export default {
  75. components: {
  76. home,
  77. },
  78. mixins: [colors],
  79. data() {
  80. let that = this;
  81. return {
  82. now_money: 0,
  83. navRecharge: [{
  84. title: '佣金转能量',
  85. key: "brokerage_to_energy_switch",
  86. bool: true,
  87. }, {
  88. title: '佣金转余额',
  89. key: "brokerage_to_money_switch",
  90. bool: true,
  91. }, {
  92. title: '佣金互转',
  93. key: "brokerage_trade_switch",
  94. bool: true,
  95. }],
  96. active: 0,
  97. number: '',
  98. uid: '', //转入用户UID
  99. userinfo: {},
  100. placeholder: "0.00",
  101. from: '',
  102. isAuto: false, //没有授权的不会自动授权
  103. isShowAuth: false, //是否隐藏授权
  104. picList: [],
  105. activePic: 0,
  106. money: "",
  107. numberPic: '',
  108. rechar_id: 0,
  109. password: '',
  110. goodsList: [],
  111. pay_order_id: '',
  112. payMode: [{
  113. name: '微信支付',
  114. icon: 'icon-weixinzhifu',
  115. value: 'weixin',
  116. title: '微信快捷支付',
  117. payStatus: true
  118. }
  119. // #ifdef H5 ||APP-PLUS
  120. ,
  121. {
  122. name: '支付宝支付',
  123. icon: 'icon-zhifubao',
  124. value: 'alipay',
  125. title: '支付宝支付',
  126. payStatus: true
  127. }
  128. // #endif
  129. ],
  130. pay_close: false,
  131. payType: 'alipay',
  132. totalPrice: '0',
  133. formContent: '',
  134. // #ifdef H5
  135. isWeixin: this.$wechat.isWeixin(),
  136. // #endif
  137. type: '',
  138. rechargeAttention: [],
  139. moneyMaxLeng: 8,
  140. showBroker: {
  141. brokerage_to_energy_switch: false,
  142. brokerage_to_money_switch: false,
  143. brokerage_trade_switch: false,
  144. }
  145. };
  146. },
  147. computed: mapGetters(['isLogin']),
  148. watch: {
  149. isLogin: {
  150. handler: function(newV, oldV) {
  151. if (newV) {
  152. this.getUserInfo();
  153. }
  154. },
  155. deep: true
  156. }
  157. },
  158. onLoad(options) {
  159. // #ifdef H5
  160. this.from = this.$wechat.isWeixin() ? "weixinh5" : "alipay"
  161. // #endif
  162. if (this.isLogin) {
  163. this.getUserInfo();
  164. } else {
  165. toLogin();
  166. }
  167. },
  168. onShow() {
  169. uni.removeStorageSync('form_type_cart');
  170. },
  171. methods: {
  172. onLunch() {
  173. this.getUserInfo();
  174. },
  175. inputNum: function(e) {
  176. let val = e.detail.value;
  177. let dot = val.indexOf('.');
  178. if (dot > -1) {
  179. this.moneyMaxLeng = dot + 3;
  180. } else {
  181. this.moneyMaxLeng = 8
  182. }
  183. },
  184. /**
  185. * 选择金额
  186. */
  187. picCharge(idx, item) {
  188. this.activePic = idx;
  189. if (item === undefined) {
  190. this.rechar_id = 0;
  191. this.numberPic = "";
  192. } else {
  193. this.money = "";
  194. this.rechar_id = item.id;
  195. this.numberPic = item.price;
  196. }
  197. },
  198. onLoadFun: function() {
  199. this.getUserInfo();
  200. this.isShowAuth = false;
  201. },
  202. // 授权关闭
  203. authColse: function(e) {
  204. this.isShowAuth = e
  205. },
  206. navRecharges: function(index) {
  207. this.active = index;
  208. },
  209. /**
  210. * 获取用户信息
  211. */
  212. getUserInfo: function() {
  213. let that = this;
  214. getUserInfo().then(res => {
  215. that.$set(that, 'userinfo', res.data);
  216. })
  217. extractBank().then(({
  218. data
  219. }) => {
  220. that.showBroker.brokerage_to_energy_switch = !!(+data.brokerage_to_energy_switch);
  221. that.showBroker.brokerage_to_money_switch = !!(+data.brokerage_to_money_switch);
  222. that.showBroker.brokerage_trade_switch = !!(+data.brokerage_trade_switch);
  223. })
  224. },
  225. submitSub: function(e) {
  226. let that = this
  227. let value = e.detail.value.number;
  228. if (parseFloat(value) < 0 || parseFloat(value) == NaN || value == undefined || value == "") {
  229. return that.$util.Tips({
  230. title: '请输入转换金额'
  231. });
  232. }
  233. const type = that.navRecharge[that.active].key;
  234. // 转入余额
  235. if (type == "brokerage_to_money_switch") {
  236. uni.showModal({
  237. title: '转入余额',
  238. content: '转入余额后无法再次转出,确认是否转入余额',
  239. success(res) {
  240. if (res.confirm) {
  241. // #ifdef MP || APP-PLUS
  242. rechargeRoutine({
  243. price: parseFloat(value),
  244. type: 1
  245. })
  246. // #endif
  247. // #ifdef H5
  248. rechargeWechat({
  249. price: parseFloat(value),
  250. from: that.from,
  251. type: 1
  252. })
  253. // #endif
  254. .then(res => {
  255. // that.$set(that, 'userinfo.now_money', that.$util.$h.Add(value, that.userinfo.now_money))
  256. return that.$util.Tips({
  257. title: '转入成功',
  258. icon: 'success'
  259. }, {
  260. tab: 5,
  261. url: '/pages/users/user_money/index'
  262. });
  263. }).catch(err => {
  264. return that.$util.Tips({
  265. title: err
  266. })
  267. });
  268. } else if (res.cancel) {
  269. return that.$util.Tips({
  270. title: '已取消'
  271. });
  272. }
  273. },
  274. })
  275. } else if (type == "brokerage_to_energy_switch") {
  276. uni.showModal({
  277. title: '转入能量',
  278. content: '转入能量后无法再次转出,确认是否转入能量',
  279. success(res) {
  280. if (res.confirm) {
  281. energyImport({
  282. price: parseFloat(value),
  283. }).then(res => {
  284. // that.$set(that, 'userinfo.now_money', that.$util.$h.Add(value, that.userinfo.now_money))
  285. return that.$util.Tips({
  286. title: '转入成功',
  287. icon: 'success'
  288. }, {
  289. tab: 3,
  290. url: '/pages/user/index'
  291. });
  292. }).catch(err => {
  293. return that.$util.Tips({
  294. title: err
  295. })
  296. });
  297. } else if (res.cancel) {
  298. return that.$util.Tips({
  299. title: '已取消'
  300. });
  301. }
  302. },
  303. })
  304. } else if (type == "brokerage_trade_switch") {
  305. uni.showModal({
  306. title: '佣金互转',
  307. content: '佣金转出后无法撤回,确认是否转出佣金',
  308. success(res) {
  309. if (res.confirm) {
  310. brokerageTrade({
  311. to_uid: '',
  312. num: parseFloat(value),
  313. }).then(res => {
  314. // that.$set(that, 'userinfo.now_money', that.$util.$h.Add(value, that.userinfo.now_money))
  315. return that.$util.Tips({
  316. title: '转入成功',
  317. icon: 'success'
  318. }, {
  319. tab: 3,
  320. url: '/pages/user/index'
  321. });
  322. }).catch(err => {
  323. return that.$util.Tips({
  324. title: err
  325. })
  326. });
  327. } else if (res.cancel) {
  328. return that.$util.Tips({
  329. title: '已取消'
  330. });
  331. }
  332. },
  333. })
  334. }
  335. }
  336. }
  337. }
  338. </script>
  339. <style lang="scss">
  340. page {
  341. width: 100%;
  342. height: 100%;
  343. background-color: #fff;
  344. }
  345. .bgcolor {
  346. background-color: var(--view-theme)
  347. }
  348. .payment {
  349. position: relative;
  350. width: 100%;
  351. background-color: #fff;
  352. border-radius: 10rpx;
  353. padding-top: 25rpx;
  354. border-top-right-radius: 39rpx;
  355. border-top-left-radius: 39rpx;
  356. }
  357. .payment .nav {
  358. height: 75rpx;
  359. line-height: 75rpx;
  360. padding: 0 100rpx;
  361. }
  362. .payment .nav .item {
  363. font-size: 30rpx;
  364. color: #333;
  365. }
  366. .payment .nav .item.on {
  367. font-weight: bold;
  368. border-bottom: 4rpx solid var(--view-theme);
  369. }
  370. .payment .input {
  371. display: flex;
  372. align-items: center;
  373. justify-content: center;
  374. border-bottom: 1px dashed #dddddd;
  375. margin: 60rpx auto 0 auto;
  376. padding-bottom: 20rpx;
  377. font-size: 56rpx;
  378. color: #333333;
  379. flex-wrap: nowrap;
  380. }
  381. .payment .input text {
  382. padding-left: 106rpx;
  383. }
  384. .payment .input input {
  385. padding-right: 106rpx;
  386. width: 300rpx;
  387. height: 94rpx;
  388. text-align: center;
  389. font-size: 70rpx;
  390. }
  391. .payment .placeholder {
  392. color: #d0d0d0;
  393. height: 100%;
  394. line-height: 94rpx;
  395. }
  396. .payment .tip {
  397. font-size: 26rpx;
  398. color: #888888;
  399. padding: 0 30rpx;
  400. margin-top: 25rpx;
  401. }
  402. .payment .but {
  403. color: #fff;
  404. font-size: 30rpx;
  405. width: 700rpx;
  406. height: 86rpx;
  407. border-radius: 50rpx;
  408. margin: 46rpx auto 0 auto;
  409. line-height: 86rpx;
  410. }
  411. .payment-top {
  412. width: 100%;
  413. height: 350rpx;
  414. background-color: var(--view-theme);
  415. .name {
  416. font-size: 26rpx;
  417. color: rgba(255, 255, 255, 0.8);
  418. margin-top: -38rpx;
  419. margin-bottom: 30rpx;
  420. }
  421. .pic {
  422. font-size: 32rpx;
  423. color: #fff;
  424. }
  425. .pic-font {
  426. font-size: 78rpx;
  427. color: #fff;
  428. }
  429. }
  430. .picList {
  431. margin: 30rpx 0;
  432. }
  433. .tips-box {
  434. .tips {
  435. font-size: 28rpx;
  436. color: #333333;
  437. font-weight: 800;
  438. margin-bottom: 14rpx;
  439. margin-top: 20rpx;
  440. }
  441. .tips-samll {
  442. font-size: 24rpx;
  443. color: #333333;
  444. margin-bottom: 14rpx;
  445. }
  446. .tip-box {
  447. margin-top: 30rpx;
  448. }
  449. }
  450. .tips-title {
  451. padding-left: 30rpx;
  452. margin-top: 20rpx;
  453. font-size: 24rpx;
  454. color: #333;
  455. }
  456. .to_uid {
  457. padding: 20rpx;
  458. width: 100%;
  459. line-height: 1;
  460. font-size: 28rpx;
  461. align-items: center;
  462. border-bottom:1px solid #dddddd;
  463. .title {
  464. font-weight: bold;
  465. }
  466. .uidbox{
  467. flex-grow: 1;
  468. text-align: right;
  469. }
  470. .placeholderUid{
  471. text-align: right;
  472. }
  473. }
  474. </style>