attach.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="attach">
  3. <view class="flex-row justify-center">
  4. <view class="grid">
  5. <view class="flex-col gridItem">
  6. <view class="title flex-row justify-center">
  7. <text>累计邀约</text>
  8. </view>
  9. <view class="number flex-row justify-center">
  10. <text>2008</text>
  11. </view>
  12. </view>
  13. <view class="flex-col gridItem leftBorder">
  14. <view class="title flex-row justify-center">
  15. <text>用券情况</text>
  16. </view>
  17. <view class="number flex-row justify-center">
  18. <text>20/80</text>
  19. </view>
  20. </view>
  21. <view class="flex-col gridItem leftBorder">
  22. <view class="title flex-row justify-center">
  23. <text>关联邀请</text>
  24. </view>
  25. <view class="number flex-row justify-center">
  26. <text>2800</text>
  27. </view>
  28. </view>
  29. <view class="flex-col gridItem" @click="navigateToPage('/pages/earningsList/earningsList')">
  30. <view class="title flex-row justify-center">
  31. <text>业绩推广</text>
  32. </view>
  33. <view class="number flex-row justify-center">
  34. <text>2008</text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="flex-row justify-center">
  40. <view class="qrView" @click="qrCodePopup">
  41. <uv-qrcode ref="qrcode" size="600rpx" :value="qrcodeUrl" :options="options"></uv-qrcode>
  42. </view>
  43. </view>
  44. <uni-popup ref="createQrCodePopup" type="center">
  45. <view class="createQrCodePopup flex-col justify-center">
  46. <view class="flex-row justify-center">
  47. <uv-qrcode ref="qrcode" size="600rpx" :value="qrcodeUrl" :options="options"></uv-qrcode>
  48. </view>
  49. <view class="xoIcon" @click="closePopup">
  50. <u-icon name="close-circle" color="#666" size="35"></u-icon>
  51. </view>
  52. </view>
  53. </uni-popup>
  54. </view>
  55. </template>
  56. <script>
  57. import commonUtils from '../../../common/js/utils/commonUtils'
  58. export default {
  59. props:{
  60. height: {
  61. type: String,
  62. default () {
  63. return ''
  64. }
  65. },
  66. },
  67. data() {
  68. return {
  69. qrCreateTime:'',
  70. roleBindRuleList:[],
  71. userInfo:{},
  72. qrcodeUrl:this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}&timestamp={timestamp}&type=1&expand1=1',
  73. options: {
  74. // 指定二维码前景,一般可在中间放logo
  75. foregroundImagePadding:2,
  76. foregroundImageBorderRadius:5,
  77. foregroundImageSrc: '/static/logo.png'
  78. },
  79. }
  80. },
  81. created() {
  82. this.userInfo = uni.getStorageSync('spreadUserInfo')
  83. this.getRuleByRoleId(this.userInfo.roleId)
  84. },
  85. methods: {
  86. formatDate(){
  87. this.qrCreateTime = commonUtils.formatDate(new Date())
  88. },
  89. qrCodePopup(){
  90. this.$refs.createQrCodePopup.open()
  91. },
  92. navigateToPage(url){
  93. uni.navigateTo({
  94. url:url
  95. })
  96. },
  97. selectRule(item,index){
  98. this.roleBindRuleList.forEach(i=>{
  99. i.select=false
  100. })
  101. item.select = true
  102. this.$set(this.roleBindRuleList,index,item)
  103. },
  104. //查询角色已经绑定的规则
  105. getRuleByRoleId(roleId){
  106. this.$api.service.getRuleByRoleId({
  107. roleId:roleId
  108. }).then(res=>{
  109. this.roleBindRuleList = res.data.data
  110. this.roleBindRuleList[0].select = true
  111. })
  112. },
  113. createQrCode(){
  114. let data = {
  115. expandUserId:this.userInfo.id,
  116. ruleId:'',
  117. timestamp:new Date().getTime() + (60 * 1000 * 60 * 24 * 365 * 10)
  118. };
  119. this.roleBindRuleList.forEach(item=>{
  120. if (item.select){
  121. data.ruleId= item.id
  122. }
  123. })
  124. if (!data.ruleId){
  125. uni.showToast({
  126. icon: 'error',
  127. duration: 2000,
  128. title: '请选择推广规则'
  129. });
  130. return
  131. }
  132. for (let key in data) {
  133. let regexp = new RegExp("{" + key + "}"); // 构造正则表达式
  134. this.qrcodeUrl = this.qrcodeUrl.replace(regexp, data[key]); // 执行替换操作
  135. }
  136. console.log('++++data+++++',data)
  137. console.log('++++qrcodeUrl+++++',this.qrcodeUrl)
  138. this.formatDate()
  139. this.$refs.createQrCodePopup.open()
  140. },
  141. createQrCodePopupChange(e){
  142. console.log(e)
  143. if (!e.show){
  144. this.qrcodeUrl=this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}&timestamp={timestamp}&type=1&expand1=1'
  145. }
  146. },
  147. closePopup(){
  148. this.$refs.createQrCodePopup.close()
  149. },
  150. }
  151. }
  152. </script>
  153. <style scoped lang="scss">
  154. @import './index.rpx.css';
  155. </style>