attach.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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="roleBindRuleList" @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. value:0,
  88. }
  89. },
  90. created() {
  91. this.userInfo = uni.getStorageSync('spreadUserInfo')
  92. this.getRuleByRoleId(this.userInfo.roleId)
  93. },
  94. methods: {
  95. formatDate(){
  96. this.qrCreateTime = commonUtils.formatDate(new Date())
  97. },
  98. qrCodePopup(){
  99. this.$refs.createQrCodePopup.open()
  100. },
  101. navigateToPage(url){
  102. uni.navigateTo({
  103. url:url
  104. })
  105. },
  106. selectRule(item,index){
  107. this.roleBindRuleList.forEach(i=>{
  108. i.select=false
  109. })
  110. item.select = true
  111. this.$set(this.roleBindRuleList,index,item)
  112. },
  113. //查询角色已经绑定的规则
  114. getRuleByRoleId(roleId){
  115. this.$api.service.getRuleByRoleId({
  116. roleId:roleId
  117. }).then(res=>{
  118. this.roleBindRuleList = res.data.data
  119. // for (let i = 0;i<this.roleList.length;i++){
  120. // this.roleBindRuleList[i].value = i;
  121. // this.roleBindRuleList[i].text = this.roleList[i].name
  122. // }
  123. })
  124. },
  125. createQrCode(){
  126. let data = {
  127. expandUserId:this.userInfo.id,
  128. ruleId:'',
  129. timestamp:new Date().getTime() + (60 * 1000 * 60 * 24 * 365 * 10)
  130. };
  131. this.roleBindRuleList.forEach(item=>{
  132. if (item.select){
  133. data.ruleId= item.id
  134. }
  135. })
  136. if (!data.ruleId){
  137. uni.showToast({
  138. icon: 'error',
  139. duration: 2000,
  140. title: '请选择推广规则'
  141. });
  142. return
  143. }
  144. for (let key in data) {
  145. let regexp = new RegExp("{" + key + "}"); // 构造正则表达式
  146. this.qrcodeUrl = this.qrcodeUrl.replace(regexp, data[key]); // 执行替换操作
  147. }
  148. console.log('++++data+++++',data)
  149. console.log('++++qrcodeUrl+++++',this.qrcodeUrl)
  150. this.formatDate()
  151. this.$refs.createQrCodePopup.open()
  152. },
  153. createQrCodePopupChange(e){
  154. console.log(e)
  155. if (!e.show){
  156. this.qrcodeUrl=this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}&timestamp={timestamp}&type=1&expand1=1'
  157. }
  158. },
  159. closePopup(){
  160. this.$refs.createQrCodePopup.close()
  161. },
  162. }
  163. }
  164. </script>
  165. <style scoped lang="scss">
  166. @import './index.rpx.css';
  167. </style>