attach.vue 4.6 KB

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