index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view class="share-index">
  3. <view class="head-box">
  4. <view class="user-info dir-left-nowrap">
  5. <view class="head-img">
  6. <image :src="userInfo.avatar" alt="" />
  7. </view>
  8. <view class="base-info dir-top-wrap main-center">
  9. <view class="nickname">{{ userInfo.nickname }}</view>
  10. <view class="parent">推荐人: {{ parent.nickname || '-' }}</view>
  11. </view>
  12. </view>
  13. <view class="withdraw-box main-between cross-center">
  14. <view class="withdraw-item dir-top-wrap main-center" @click="$u.route('/pages/share/withdraw')">
  15. <view class="static-txt main-left cross-center">
  16. 可提现佣金
  17. <view class="badge">提现</view>
  18. </view>
  19. <view class="price main-left cross-center">
  20. {{ userInfo.income }}
  21. <view class="unit">元</view>
  22. </view>
  23. </view>
  24. <view class="withdraw-item dir-top-wrap main-center">
  25. <view class="static-txt">
  26. 已提现佣金
  27. </view>
  28. <view class="price main-left cross-center">
  29. {{ parseFloat(userInfo.total_income - userInfo.income).toFixed(2) }}
  30. <view class="unit">元</view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <!--菜单-->
  36. <view class="menu-group">
  37. <button
  38. v-for="(menu,index) in menus"
  39. :key="index"
  40. class="menu-item main-between cross-center"
  41. :open-type="menu.type ? menu.type : ''"
  42. @bindcontact="handleMenu"
  43. @click="handleMenu(menu)"
  44. >
  45. <view class="left-box dir-left-nowrap cross-center">
  46. <view class="icon">
  47. <image :src="menu.icon" />
  48. </view>
  49. <text>{{ menu.name }}</text>
  50. </view>
  51. <u-icon name="arrow-right" :color="$colors.infoColor" bold />
  52. </button>
  53. </view>
  54. <!-- QRCODE 弹窗 -->
  55. <qrcode :show.sync="qrcodeModal.show" />
  56. </view>
  57. </template>
  58. <script>
  59. import { mapState } from 'vuex'
  60. import Qrcode from './components/Qrcode'
  61. import { parent } from '../../api/user'
  62. export default {
  63. components: { Qrcode },
  64. data() {
  65. return {
  66. menus: [
  67. { icon: '/static/image/my-page/share.png', name: '分享好友', type: 'share' },
  68. { icon: '/static/image/share/income.png', name: '分享佣金', href: '/pages/share/income' },
  69. { icon: '/static/image/share/order.png', name: '分享订单', href: '/pages/share/order' },
  70. { icon: '/static/image/share/detail.png', name: '提现明细', href: '/pages/share/withdrawDetail' },
  71. { icon: '/static/image/share/team.png', name: '我的团队', href: '/pages/share/team' },
  72. // #ifdef MP-TOUTIAO | MP-WEIXIN
  73. { icon: '/static/image/share/qrcode.png', name: '分享二维码', type: 'share_qrcode' }
  74. // #endif
  75. ],
  76. qrcodeModal: {
  77. show: false
  78. },
  79. parent: {}
  80. }
  81. },
  82. computed: {
  83. ...mapState({
  84. userInfo: seate => seate.user.info
  85. })
  86. },
  87. methods: {
  88. handleMenu(menu) {
  89. // #ifdef MP-KUAISHOU
  90. if (menu.type === 'contact') {
  91. ks.makePhoneCall({
  92. phoneNumber: this.config.contact,
  93. success(res) {
  94. console.log('-->success', res)
  95. },
  96. fail(err) {
  97. console.log('-->error', err)
  98. }
  99. })
  100. }
  101. // #endif
  102. if (menu.type === 'share_qrcode') {
  103. this.handleGenerateQrcode()
  104. }
  105. if (menu.href) {
  106. this.$u.route(menu.href)
  107. }
  108. },
  109. handleGenerateQrcode() {
  110. if (this.userInfo.share_qrcode) {
  111. this.qrcodeModal.show = true
  112. return
  113. }
  114. this.$loading()
  115. this.$api.share.generateQrcode().then(res => {
  116. this.$hideLoading()
  117. // 获取用户信息
  118. this.$api.user.info().then(res => {
  119. this.$store.dispatch('user/info', res.data)
  120. this.qrcodeModal.show = true
  121. })
  122. }).catch(() => {
  123. this.$hideLoading()
  124. })
  125. },
  126. getParentInfo() {
  127. this.$api.user.parent().then(res => {
  128. this.parent = res.data
  129. })
  130. }
  131. },
  132. onShareAppMessage() {
  133. return this.$util.shareMessage(this.userInfo)
  134. },
  135. onShow() {
  136. this.getParentInfo()
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .share-index {
  142. color: #6eebe8;
  143. font-size: 32rpx;
  144. padding: 40rpx 30rpx 80rpx;
  145. .head-box{
  146. background: $bg-op-color;
  147. border-radius: 20rpx;
  148. padding: 40rpx 0;
  149. margin-bottom: 50rpx;
  150. .user-info{
  151. padding: 0 30rpx 40rpx;
  152. border-bottom: 1rpx $border-op-color solid;
  153. .head-img{
  154. width: 120rpx;
  155. height: 120rpx;
  156. border-radius: 50%;
  157. overflow: hidden;
  158. image{
  159. width: 100%;
  160. height: 100%;
  161. }
  162. }
  163. .base-info{
  164. margin-left: 30rpx;
  165. .parent{
  166. font-size: 26rpx;
  167. }
  168. }
  169. }
  170. .withdraw-box{
  171. padding: 40rpx 0 0;
  172. .withdraw-item{
  173. flex: 1;
  174. position: relative;
  175. padding: 0 40rpx;
  176. &:first-child{
  177. &:after{
  178. content: "";
  179. position: absolute;
  180. background: $border-op-color;
  181. right: 0;
  182. top: 50%;
  183. height: 60%;
  184. width: 1rpx;
  185. transform: translateY(-50%);
  186. }
  187. }
  188. .static-txt{
  189. font-size: 26rpx;
  190. .badge{
  191. font-size: 18rpx;
  192. border: 1rpx solid #6eebe8;
  193. border-radius: 30rpx;
  194. padding: 2rpx 20rpx;
  195. margin-left: 30rpx;
  196. }
  197. }
  198. .price{
  199. margin-top: 10rpx;
  200. font-size: 48rpx;
  201. .unit{
  202. font-size: 34rpx;
  203. margin-left: 4rpx;
  204. }
  205. }
  206. }
  207. }
  208. }
  209. .menu-group{
  210. .menu-item{
  211. padding: 20rpx 0;
  212. background: transparent;
  213. border: none;
  214. text-align: unset;
  215. width: 100%;
  216. line-height: initial;
  217. font-size: initial;
  218. justify-content: space-between;
  219. border-bottom: 1rpx solid $border-op-color;
  220. border-radius: 0;
  221. &:after{
  222. content: unset;
  223. }
  224. .left-box{
  225. flex: 1;
  226. .icon{
  227. transform: translateY(4rpx);
  228. image{
  229. width: 55rpx;
  230. height: 55rpx;
  231. }
  232. }
  233. text{
  234. color: #fff;
  235. margin-left: 10rpx;
  236. }
  237. }
  238. }
  239. }
  240. }
  241. </style>