Invite.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div class="invite-bg">
  3. <div class="invite-top" v-if="info.wx_user">
  4. <img :src="info.wx_user.head" class="top-head" alt="">
  5. <div class="top-name" v-if="info.wx_user.nickname">{{info.wx_user.nickname}}</div>
  6. <div class="top-name" v-if="!info.wx_user.nickname">微信用户</div>
  7. <div class="clear"></div>
  8. </div>
  9. <div class="invite-center">
  10. <div class="center-top">
  11. <div class="top-title">我的收益</div>
  12. <img src="@/assets/img/icon.png" @click="toincome" alt="" class="top-icon">
  13. <div class="top-detail" @click="toincome">查看明细</div>
  14. <div class="clear"></div>
  15. </div>
  16. <div class="center-income">
  17. <div class="income-left">
  18. <div class="income-title">当前收益</div>
  19. <div class="income-count">{{balance.available | getAcounting('¥',false)}}</div>
  20. </div>
  21. <div class="income-right">
  22. <div class="income-title">历史总收益</div>
  23. <div class="income-count">{{balance.total | getAcounting('¥',false)}}</div>
  24. </div>
  25. <div class="clear"></div>
  26. </div>
  27. </div>
  28. <div class="invite-bottom">
  29. <div class="bottom-top">
  30. <div class="top-title">我的邀请</div>
  31. <img src="@/assets/img/icon.png" @click="torecode" alt="" class="top-icon">
  32. <div class="top-detail" @click="torecode">查看记录</div>
  33. <div class="clear"></div>
  34. </div>
  35. <div class="bottom-center">{{countnumber}}</div>
  36. <div class="bottom-btn" :data-clipboard-text="countnumber" @click="copy">点击按钮邀请</div>
  37. <!-- <div class="bottom-center">邀请人数</div>
  38. <div class="bottom-count">8</div> -->
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. import Clipboard from 'clipboard'
  44. import { Toast } from 'vant'
  45. import { mapGetters } from 'vuex'
  46. import Weixin from '@/common/wx'
  47. export default {
  48. name: '',
  49. props: [''],
  50. data () {
  51. return {
  52. balance: {},
  53. info: {},
  54. countnumber: '',
  55. id: 0
  56. };
  57. },
  58. created() {
  59. this.$store.dispatch('userInfo')
  60. this.getbalanceinfo()
  61. // this.getinvitelist()
  62. },
  63. components: {},
  64. computed: {
  65. ...mapGetters(['userInfo'])
  66. },
  67. beforeMount() {},
  68. mounted() {},
  69. methods: {
  70. toincome () {
  71. this.$router.push({ path: '/income' })
  72. },
  73. torecode () {
  74. this.$router.push({ path: '/recode', query: { id: this.id } })
  75. },
  76. copy () {
  77. var clipboard = new Clipboard('.bottom-btn')
  78. clipboard.on('success', e => {
  79. console.log(e)
  80. Toast({
  81. message: '链接复制成功,快去邀请吧~',
  82. duration: 2000
  83. })
  84. clipboard.destroy()
  85. })
  86. clipboard.on('error', e => {
  87. console.log(e)
  88. Toast({
  89. message: '该浏览器不支持自动复制',
  90. duration: 2000
  91. })
  92. clipboard.destroy()
  93. })
  94. },
  95. getbalanceinfo () {
  96. this.$get({
  97. url: 'v1/user/cash/balance/info',
  98. data: {}
  99. }).then((res) => {
  100. console.log(res)
  101. this.balance = res
  102. })
  103. },
  104. getinvitelist () {
  105. this.$get({
  106. url: `v1/invite/1/list`,
  107. data: {}
  108. }).then((res) => {
  109. console.log(res)
  110. // this.balance = res
  111. })
  112. }
  113. },
  114. watch: {
  115. 'userInfo': function (val) {
  116. console.log(val)
  117. this.countnumber = window.location.origin + '/product?invite_id=' + val.wx_user.id
  118. this.info = val
  119. this.id = val.wx_user.id
  120. const wx = new Weixin({
  121. title: '天下一家',
  122. desc: '醇酱香酒之一',
  123. imgUrl: 'http://world-wine.oss-cn-shenzhen.aliyuncs.com/shareImg/wine_share.jpg',
  124. link: window.location.origin + '/product?invite_id=' + val.wx_user.id
  125. })
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang='less' scoped>
  131. .invite-bg {
  132. background: #eeeeed;
  133. min-height: 100%;
  134. width: 100%;
  135. overflow: hidden;
  136. .invite-top {
  137. width: 7.1rem;
  138. background: #fff;
  139. border-radius: 0.1rem;
  140. padding: 0.2rem;
  141. box-sizing: border-box;
  142. margin: 0.3rem auto 0.3rem;
  143. .top-head {
  144. height: 0.62rem;
  145. width: 0.62rem;
  146. background: #ccc;
  147. float: left;
  148. border-radius: 50%;
  149. margin-right: 0.2rem;
  150. }
  151. .top-name {
  152. font-size: 0.28rem;
  153. color: #4c4c4c;
  154. float: left;
  155. margin-top: 0.1rem;
  156. }
  157. }
  158. .invite-center {
  159. width: 7.1rem;
  160. background: #fff;
  161. border-radius: 0.1rem;
  162. padding: 0.2rem;
  163. padding-top: 0.3rem;
  164. box-sizing: border-box;
  165. margin: 0 auto 0.3rem;
  166. .center-top {
  167. margin-bottom: 0.3rem;
  168. .top-title {
  169. color: #acbac3;
  170. float: left;
  171. font-weight: 600;
  172. font-size: 0.3rem;
  173. }
  174. .top-detail {
  175. float: right;
  176. color: #acbac3;
  177. font-size: 0.28rem;
  178. }
  179. .top-icon {
  180. float: right;
  181. width: 0.12rem;
  182. height: 0.2rem;
  183. margin-top: 0.08rem;
  184. margin-left: 0.2rem;
  185. }
  186. }
  187. .center-income {
  188. padding-bottom: 0.2rem;
  189. .income-left {
  190. float: left;
  191. width: 50%;
  192. .income-title {
  193. color: #999999;
  194. font-size: 0.28rem;
  195. margin-bottom: 0.1rem;
  196. }
  197. .income-count {
  198. font-size: 0.4rem;
  199. font-weight: 600;
  200. color: #ff696b;
  201. }
  202. }
  203. .income-right {
  204. float: left;
  205. width: 50%;
  206. .income-title {
  207. color: #999999;
  208. font-size: 0.28rem;
  209. margin-bottom: 0.1rem;
  210. }
  211. .income-count {
  212. font-size: 0.4rem;
  213. font-weight: 600;
  214. color: #4c4c4c;
  215. }
  216. }
  217. }
  218. }
  219. .invite-bottom {
  220. width: 7.1rem;
  221. background: #fff;
  222. border-radius: 0.1rem;
  223. padding: 0.3rem 0.2rem;
  224. box-sizing: border-box;
  225. margin: 0 auto 0.3rem;
  226. .bottom-top {
  227. margin-bottom: 0.2rem;
  228. .top-title {
  229. color: #acbac3;
  230. float: left;
  231. font-weight: 600;
  232. font-size: 0.3rem;
  233. }
  234. .top-detail {
  235. float: right;
  236. color: #acbac3;
  237. font-size: 0.28rem;
  238. }
  239. .top-icon {
  240. float: right;
  241. width: 0.12rem;
  242. height: 0.2rem;
  243. margin-top: 0.08rem;
  244. margin-left: 0.2rem;
  245. }
  246. }
  247. .bottom-center {
  248. background: #ebf3f7;
  249. // height:0.8rem;
  250. width: 100%;
  251. text-align: center;
  252. line-height: 0.3rem;
  253. font-size: 0.24rem;
  254. color: #708fa3;
  255. box-sizing: border-box;
  256. word-wrap: break-word;
  257. word-break: normal;
  258. padding: 0.2rem;
  259. margin-top: 0.3rem;
  260. margin-bottom: 0.2rem;
  261. border-radius: 0.05rem;
  262. }
  263. .bottom-btn {
  264. width: 100%;
  265. height: 0.8rem;
  266. background: #28cd5e;
  267. color: #fff;
  268. text-align: center;
  269. line-height: 0.8rem;
  270. border-radius: 0.05rem;
  271. font-size: 0.3rem;
  272. }
  273. // .bottom-count {
  274. // text-align: center;
  275. // font-size: 0.3rem;
  276. // color: #ff696b;
  277. // font-weight: 600;
  278. // }
  279. }
  280. }
  281. </style>