attach.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="page" :style="{height:height}">
  3. <view :style="{marginTop:'24rpx'}" class="scroll-Y">
  4. <view class="flex-col outView " :class="{select:item.select}" v-for="(item,index) in roleBindRuleList" @click="selectRule(item,index)">
  5. <view class="flex-row justify-between">
  6. <text class="title">{{item.title}}</text>
  7. <u-icon name="checkbox-mark" color="#666" size="24" v-if="item.select"></u-icon>
  8. </view>
  9. <view class="flex-row justify-between awardView">
  10. <text>直推:</text>
  11. <view>
  12. <view class="flex-row award ">
  13. <text class="awardItem">注册现金:{{item.awardAmount}}元</text>
  14. </view>
  15. <view class="flex-row award ">
  16. <text class="awardItem">消费现金:{{item.consumeAmount}}元</text>
  17. <text class="awardItem">消费比例:{{item.consumeRatio * 100}}%</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="flex-row justify-between awardView">
  22. <text>间推:</text>
  23. <view class="flex-row award ">
  24. <text class="awardItem">间推现金:{{item.indirectAmount}}元</text>
  25. <text class="awardItem">间推比例:{{item.indirectRatio * 100}}%</text>
  26. </view>
  27. </view>
  28. <view class="flex-row justify-between awardView">
  29. <text>优惠券:</text>
  30. <view class="flex-col">
  31. <view class="flex-col discount award" v-for="(item1,index1) in item.strategyList" :key="index1">
  32. <text>{{item1.name}} * {{item1.degree}}张</text>
  33. <text>有效期:{{item1.startTime.substring(0,10)}} 至 {{item1.endTime.substring(0,10)}}</text>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="confirmButton" @click="createQrCode">
  40. <text>生成二维码</text>
  41. </view>
  42. <uni-popup ref="createQrCodePopup" type="center">
  43. <view class="createQrCodePopup">
  44. <view class="flex-row justify-center">
  45. <text class="popupTitle">拓客二维码</text>
  46. </view>
  47. <view class="xoIcon" @click="closePopup">
  48. <u-icon name="close-circle" color="#666" size="24"></u-icon>
  49. </view>
  50. <view class="flex-row justify-center">
  51. <uv-qrcode ref="qrcode" size="540rpx" :value="qrcodeUrl" :options="options"></uv-qrcode>
  52. </view>
  53. </view>
  54. </uni-popup>
  55. </view>
  56. </template>
  57. <script>
  58. export default {
  59. props:{
  60. height: {
  61. type: String,
  62. default () {
  63. return ''
  64. }
  65. },
  66. },
  67. data() {
  68. return {
  69. roleBindRuleList:[],
  70. userInfo:{},
  71. qrcodeUrl:this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}',
  72. options: {
  73. // 指定二维码前景,一般可在中间放logo
  74. foregroundImagePadding:2,
  75. foregroundImageBorderRadius:5,
  76. foregroundImageSrc: '/static/logo.png'
  77. },
  78. }
  79. },
  80. created() {
  81. this.userInfo = uni.getStorageSync('spreadUserInfo')
  82. this.getRuleByRoleId(this.userInfo.roleId)
  83. },
  84. methods: {
  85. selectRule(item,index){
  86. this.roleBindRuleList.forEach(i=>{
  87. i.select=false
  88. })
  89. item.select = true
  90. this.$set(this.roleBindRuleList,index,item)
  91. },
  92. //查询角色已经绑定的规则
  93. getRuleByRoleId(roleId){
  94. this.$api.service.getRuleByRoleId({
  95. roleId:roleId
  96. }).then(res=>{
  97. this.roleBindRuleList = res.data.data
  98. this.roleBindRuleList[0].select = true
  99. })
  100. },
  101. createQrCode(){
  102. let data = {
  103. expandUserId:this.userInfo.id,
  104. ruleId:''
  105. };
  106. this.roleBindRuleList.forEach(item=>{
  107. if (item.select){
  108. data.ruleId= item.id
  109. }
  110. })
  111. if (!data.ruleId){
  112. uni.showToast({
  113. icon: 'error',
  114. duration: 2000,
  115. title: '请选择推广规则'
  116. });
  117. return
  118. }
  119. for (let key in data) {
  120. let regexp = new RegExp("{" + key + "}"); // 构造正则表达式
  121. this.qrcodeUrl = this.qrcodeUrl.replace(regexp, data[key]); // 执行替换操作
  122. }
  123. console.log('++++data+++++',data)
  124. console.log('++++qrcodeUrl+++++',this.qrcodeUrl)
  125. this.$refs.createQrCodePopup.open()
  126. },
  127. closePopup(){
  128. this.qrcodeUrl=this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}',
  129. this.$refs.createQrCodePopup.close()
  130. },
  131. }
  132. }
  133. </script>
  134. <style scoped lang="scss">
  135. @import './index.rpx.css';
  136. </style>