attach.vue 5.7 KB

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