user_spread.vue 9.3 KB

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