attach.vue 5.1 KB

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