attach.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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">
  40. <view class="flex-col justify-center">
  41. <text class="roleSelectLabel">选择规则:</text>
  42. </view>
  43. <view class="roleSelect">
  44. <uni-data-select v-model="value" :localdata="ruleList" @change="selectChange" :clear="false"></uni-data-select>
  45. </view>
  46. </view>
  47. <view class="flex-row justify-center">
  48. <view class="qrView" @click="qrCodePopup">
  49. <uv-qrcode ref="qrcode" size="600rpx" :value="qrcodeUrl" :options="options"></uv-qrcode>
  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. qrCreateTime:'',
  78. roleBindRuleList:[],
  79. userInfo:{},
  80. qrcodeUrl:this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}&timestamp={timestamp}&type=1&expand1=1',
  81. options: {
  82. // 指定二维码前景,一般可在中间放logo
  83. foregroundImagePadding:2,
  84. foregroundImageBorderRadius:5,
  85. foregroundImageSrc: '/static/logo.png'
  86. },
  87. }
  88. },
  89. created() {
  90. this.userInfo = uni.getStorageSync('spreadUserInfo')
  91. this.getRuleByRoleId(this.userInfo.roleId)
  92. },
  93. methods: {
  94. formatDate(){
  95. this.qrCreateTime = commonUtils.formatDate(new Date())
  96. },
  97. qrCodePopup(){
  98. this.$refs.createQrCodePopup.open()
  99. },
  100. navigateToPage(url){
  101. uni.navigateTo({
  102. url:url
  103. })
  104. },
  105. selectRule(item,index){
  106. this.roleBindRuleList.forEach(i=>{
  107. i.select=false
  108. })
  109. item.select = true
  110. this.$set(this.roleBindRuleList,index,item)
  111. },
  112. //查询角色已经绑定的规则
  113. getRuleByRoleId(roleId){
  114. this.$api.service.getRuleByRoleId({
  115. roleId:roleId
  116. }).then(res=>{
  117. this.roleBindRuleList = res.data.data
  118. this.roleBindRuleList[0].select = true
  119. })
  120. },
  121. createQrCode(){
  122. let data = {
  123. expandUserId:this.userInfo.id,
  124. ruleId:'',
  125. timestamp:new Date().getTime() + (60 * 1000 * 60 * 24 * 365 * 10)
  126. };
  127. this.roleBindRuleList.forEach(item=>{
  128. if (item.select){
  129. data.ruleId= item.id
  130. }
  131. })
  132. if (!data.ruleId){
  133. uni.showToast({
  134. icon: 'error',
  135. duration: 2000,
  136. title: '请选择推广规则'
  137. });
  138. return
  139. }
  140. for (let key in data) {
  141. let regexp = new RegExp("{" + key + "}"); // 构造正则表达式
  142. this.qrcodeUrl = this.qrcodeUrl.replace(regexp, data[key]); // 执行替换操作
  143. }
  144. console.log('++++data+++++',data)
  145. console.log('++++qrcodeUrl+++++',this.qrcodeUrl)
  146. this.formatDate()
  147. this.$refs.createQrCodePopup.open()
  148. },
  149. createQrCodePopupChange(e){
  150. console.log(e)
  151. if (!e.show){
  152. this.qrcodeUrl=this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}&timestamp={timestamp}&type=1&expand1=1'
  153. }
  154. },
  155. closePopup(){
  156. this.$refs.createQrCodePopup.close()
  157. },
  158. }
  159. }
  160. </script>
  161. <style scoped lang="scss">
  162. @import './index.rpx.css';
  163. </style>