attach.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="page">
  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" @change="createQrCodePopupChange">
  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 class="flex-row justify-center qrCreateTime">
  63. <text>生成时间:{{qrCreateTime}}</text>
  64. </view>
  65. </view>
  66. </uni-popup>
  67. </view>
  68. </template>
  69. <script>
  70. import commonUtils from '../../../common/js/utils/commonUtils'
  71. export default {
  72. props:{
  73. height: {
  74. type: String,
  75. default () {
  76. return ''
  77. }
  78. },
  79. },
  80. data() {
  81. return {
  82. qrCreateTime:'',
  83. roleBindRuleList:[],
  84. userInfo:{},
  85. qrcodeUrl:this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}&timestamp={timestamp}&type=1',
  86. options: {
  87. // 指定二维码前景,一般可在中间放logo
  88. foregroundImagePadding:2,
  89. foregroundImageBorderRadius:5,
  90. foregroundImageSrc: '/static/logo.png'
  91. },
  92. }
  93. },
  94. created() {
  95. this.userInfo = uni.getStorageSync('spreadUserInfo')
  96. this.getRuleByRoleId(this.userInfo.roleId)
  97. },
  98. methods: {
  99. formatDate(){
  100. this.qrCreateTime = commonUtils.formatDate(new Date())
  101. },
  102. selectRule(item,index){
  103. this.roleBindRuleList.forEach(i=>{
  104. i.select=false
  105. })
  106. item.select = true
  107. this.$set(this.roleBindRuleList,index,item)
  108. },
  109. //查询角色已经绑定的规则
  110. getRuleByRoleId(roleId){
  111. this.$api.service.getRuleByRoleId({
  112. roleId:roleId
  113. }).then(res=>{
  114. this.roleBindRuleList = res.data.data
  115. this.roleBindRuleList[0].select = true
  116. })
  117. },
  118. createQrCode(){
  119. let data = {
  120. expandUserId:this.userInfo.id,
  121. ruleId:'',
  122. timestamp:new Date().getTime() + (60 * 1000 * 60 * 24 * 365 * 10)
  123. };
  124. this.roleBindRuleList.forEach(item=>{
  125. if (item.select){
  126. data.ruleId= item.id
  127. }
  128. })
  129. if (!data.ruleId){
  130. uni.showToast({
  131. icon: 'error',
  132. duration: 2000,
  133. title: '请选择推广规则'
  134. });
  135. return
  136. }
  137. for (let key in data) {
  138. let regexp = new RegExp("{" + key + "}"); // 构造正则表达式
  139. this.qrcodeUrl = this.qrcodeUrl.replace(regexp, data[key]); // 执行替换操作
  140. }
  141. console.log('++++data+++++',data)
  142. console.log('++++qrcodeUrl+++++',this.qrcodeUrl)
  143. this.formatDate()
  144. this.$refs.createQrCodePopup.open()
  145. },
  146. createQrCodePopupChange(e){
  147. console.log(e)
  148. if (!e.show){
  149. this.qrcodeUrl=this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}&timestamp={timestamp}&type=1'
  150. }
  151. },
  152. closePopup(){
  153. this.$refs.createQrCodePopup.close()
  154. },
  155. }
  156. }
  157. </script>
  158. <style scoped lang="scss">
  159. @import './index.rpx.css';
  160. </style>