attach.vue 4.6 KB

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