manager.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <view class="page" :style="{height:height}">
  3. <view class="flex-row justify-between outView" :style="{marginTop:'24rpx'}" v-if="roleList.length>0" @click="selectRole">
  4. <view class="roleName">
  5. <text>角色</text>
  6. </view>
  7. <view class="flex-row" >
  8. <text class="roleName">{{roleList[confirmRoleIndex].name}}</text>
  9. <u-icon name="arrow-right" color="#666" size="18"></u-icon>
  10. </view>
  11. </view>
  12. <view>
  13. <scroll-view scroll-y class="scroll-Y">
  14. <view class="flex-col outView" v-for="(item,index) in roleBindRuleList" :key="index">
  15. <view class="flex-row justify-between">
  16. <text class="title">规则标题</text>
  17. <u-icon name="trash" color="#666" size="24" @click="deleteRule(item)"></u-icon>
  18. </view>
  19. <view class="flex-row justify-between awardView">
  20. <text>直推:</text>
  21. <view>
  22. <view class="flex-row award ">
  23. <text class="awardItem">注册现金:{{item.awardAmount}}元</text>
  24. </view>
  25. <view class="flex-row award ">
  26. <text class="awardItem">消费现金:{{item.consumeAmount}}元</text>
  27. <text class="awardItem">消费比例:{{item.consumeRatio * 100}}%</text>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="flex-row justify-between awardView">
  32. <text>间推:</text>
  33. <view class="flex-row award ">
  34. <text class="awardItem">间推现金:{{item.indirectAmount}}元</text>
  35. <text class="awardItem">间推比例:{{item.indirectRatio * 100}}%</text>
  36. </view>
  37. </view>
  38. <!-- <view class="flex-row justify-between awardView">-->
  39. <!-- <text>优惠券:</text>-->
  40. <!-- <view class="flex-col award ">-->
  41. <!-- <text>满100减250的优惠券</text>-->
  42. <!-- <text>有效期:2024-01-01 至 2024-01-30</text>-->
  43. <!-- </view>-->
  44. <!-- </view>-->
  45. </view>
  46. </scroll-view>
  47. </view>
  48. <view class="addButton" @click="addRule">
  49. <text>+添加规则</text>
  50. </view>
  51. <view class="confirmButton" @click="createQrCode">
  52. <text>生成二维码</text>
  53. </view>
  54. <!--邀请专员二维码-->
  55. <uni-popup ref="createQrCodePopup" type="center">
  56. <view class="createQrCodePopup">
  57. <view class="flex-row justify-center">
  58. <text class="popupTitle">邀请专员二维码</text>
  59. </view>
  60. <view class="xoIcon" @click="closePopup">
  61. <u-icon name="close-circle" color="#666" size="24"></u-icon>
  62. </view>
  63. <view class="flex-row justify-center">
  64. <uv-qrcode ref="qrcode" size="540rpx" :value="qrcodeUrl" :options="options"></uv-qrcode>
  65. </view>
  66. </view>
  67. </uni-popup>
  68. <!--选择规则-->
  69. <uni-popup ref="rulePopup" type="bottom" @change="popupChange">
  70. <view class="rulePopup">
  71. <view class="flex-row justify-between">
  72. <text class="popupTitle">选择规则</text>
  73. <u-icon name="close-circle" color="#666" size="24" @click="closePopup"></u-icon>
  74. </view>
  75. <scroll-view scroll-y class="scroll-Y1">
  76. <view class="flex-col outView " :class="{selectRoleName1: item.select }"
  77. v-for="(item,index) in roleNoBindRuleList" :style="{marginTop: '24rpx'}" @click="selectRule(item,index)" :key="index">
  78. <view class="flex-row justify-between">
  79. <text class="title">{{item.title}}</text>
  80. </view>
  81. <view class="flex-row justify-between awardView">
  82. <text>直推:</text>
  83. <view>
  84. <view class="flex-row award ">
  85. <text class="awardItem">注册现金:{{item.awardAmount}}元</text>
  86. </view>
  87. <view class="flex-row award ">
  88. <text class="awardItem">消费现金:{{item.consumeAmount}}元</text>
  89. <text class="awardItem">消费比例:{{item.consumeRatio * 100}}%</text>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="flex-row justify-between awardView">
  94. <text>间推:</text>
  95. <view class="flex-row award ">
  96. <text class="awardItem">间推现金:{{item.indirectAmount}}元</text>
  97. <text class="awardItem">间推比例:{{item.indirectRatio * 100}}%</text>
  98. </view>
  99. </view>
  100. <!-- <view class="flex-row justify-between awardView">-->
  101. <!-- <text>优惠券:</text>-->
  102. <!-- <view class="flex-col award ">-->
  103. <!-- <text>满100减250的优惠券</text>-->
  104. <!-- <text>有效期:2024-01-01 至 2024-01-30</text>-->
  105. <!-- </view>-->
  106. <!-- </view>-->
  107. </view>
  108. </scroll-view>
  109. <view class="confirmButton" @click="confirmAddRule">
  110. <text>确定</text>
  111. </view>
  112. </view>
  113. </uni-popup>
  114. <!--选择角色-->
  115. <uni-popup ref="rolePopup" type="bottom" @change="popupChange">
  116. <view class="rolePopup">
  117. <view class="flex-row justify-between">
  118. <text class="popupTitle">选择角色</text>
  119. <u-icon name="close-circle" color="#666" size="24" @click="closePopup"></u-icon>
  120. </view>
  121. <scroll-view scroll-y class="scroll-Y2">
  122. <view class="roleName1" :class="{selectRoleName1: selectRoleIndex === index }" v-for="(item,index) in roleList" :key="index" @click="selectRoleIndex = index">
  123. <text>{{item.name}}</text>
  124. </view>
  125. </scroll-view>
  126. <view class="confirmButton" @click="confirmRole">
  127. <text>确定</text>
  128. </view>
  129. </view>
  130. </uni-popup>
  131. </view>
  132. </template>
  133. <script>
  134. export default {
  135. props:{
  136. height: {
  137. type: String,
  138. default () {
  139. return ''
  140. }
  141. },
  142. },
  143. data() {
  144. return {
  145. selectRoleIndex:0, //正在选择的角色下标
  146. confirmRoleIndex:0, //当前选中的角色下标
  147. roleList:[],
  148. roleBindRuleList:[], //角色已经绑定的规则
  149. roleNoBindRuleList:[], //角色没有绑定的规则
  150. roleBindRuleParam:{},
  151. value: 1,
  152. qrcodeUrl:this.$tkUrl+'?roleId={roleId}&parentId={parentId}',
  153. options: {
  154. // 指定二维码前景,一般可在中间放logo
  155. foregroundImagePadding:2,
  156. foregroundImageBorderRadius:5,
  157. foregroundImageSrc: '/static/logo.png'
  158. },
  159. range: [
  160. { value: 0, text: "篮球篮球篮球篮球篮球篮" },
  161. { value: 1, text: "足球" },
  162. { value: 2, text: "游泳" },
  163. ],
  164. }
  165. },
  166. created() {
  167. this.userInfo = uni.getStorageSync('spreadUserInfo')
  168. this.getRoleList()
  169. },
  170. methods: {
  171. deleteRule(item){
  172. this.$api.service.cancelRoleBindRule({
  173. roleId:this.roleList[this.confirmRoleIndex].id,
  174. ruleIds:[item.id]
  175. }).then(res=>{
  176. this.getRuleByRoleId(this.roleList[this.confirmRoleIndex].id)
  177. this.getNewRules(this.roleList[this.confirmRoleIndex].id)
  178. })
  179. },
  180. selectRule(item,index){
  181. console.log(item)
  182. item.select = !item.select
  183. this.$set(this.roleNoBindRuleList,index,item)
  184. },
  185. confirmAddRule(){
  186. let ruleIds =[]
  187. for (const rule of this.roleNoBindRuleList) {
  188. if (rule.select){
  189. ruleIds.push(rule.id)
  190. }
  191. }
  192. this.$api.service.roleBindRule({
  193. roleId:this.roleList[this.confirmRoleIndex].id,
  194. ruleIds:ruleIds
  195. }).then(res=>{
  196. this.getRuleByRoleId(this.roleList[this.confirmRoleIndex].id)
  197. this.getNewRules(this.roleList[this.confirmRoleIndex].id)
  198. })
  199. this.closePopup()
  200. },
  201. confirmRole(){
  202. this.confirmRoleIndex = this.selectRoleIndex
  203. this.getRuleByRoleId(this.roleList[this.confirmRoleIndex].id)
  204. this.getNewRules(this.roleList[this.confirmRoleIndex].id)
  205. this.closePopup()
  206. },
  207. popupChange(e){
  208. if (e.show){
  209. uni.hideTabBar()
  210. }
  211. if (!e.show){
  212. uni.showTabBar()
  213. }
  214. },
  215. closePopup(){
  216. this.$refs.rolePopup.close()
  217. this.$refs.createQrCodePopup.close()
  218. this.$refs.rulePopup.close()
  219. },
  220. selectRole(){
  221. this.$refs.rolePopup.open()
  222. },
  223. createQrCode(){
  224. let data = {
  225. roleId:this.roleList[this.confirmRoleIndex].id,
  226. parentId:this.userInfo.id
  227. };
  228. for (let key in data) {
  229. let regexp = new RegExp("{" + key + "}"); // 构造正则表达式
  230. this.qrcodeUrl = this.qrcodeUrl.replace(regexp, data[key]); // 执行替换操作
  231. }
  232. console.log('++++qrcodeUrl+++++',this.qrcodeUrl)
  233. this.$refs.createQrCodePopup.open()
  234. },
  235. addRule(){
  236. this.$refs.rulePopup.open()
  237. },
  238. change(e) {
  239. console.log("e:", e);
  240. },
  241. //查询规则
  242. getRuleList(){
  243. this.$api.service.getRuleList().then(res=>{
  244. console.log(res)
  245. this.ruleList = res.data.data
  246. })
  247. },
  248. //查询角色
  249. getRoleList(){
  250. this.$api.service.getRoleList().then(res=>{
  251. console.log(res)
  252. this.roleList = res.data.data
  253. this.getRuleByRoleId(this.roleList[this.confirmRoleIndex].id)
  254. this.getNewRules(this.roleList[this.confirmRoleIndex].id)
  255. })
  256. },
  257. //查询角色已经绑定的规则
  258. getRuleByRoleId(roleId){
  259. this.$api.service.getRuleByRoleId({
  260. roleId:roleId
  261. }).then(res=>{
  262. this.roleBindRuleList = res.data.data
  263. })
  264. },
  265. //查询角色没有绑定的规则
  266. getNewRules(roleId){
  267. this.$api.service.getNewRules({
  268. roleId:roleId
  269. }).then(res=>{
  270. this.roleNoBindRuleList = res.data.data
  271. })
  272. },
  273. }
  274. }
  275. </script>
  276. <style scoped lang="scss">
  277. @import './index.rpx.css';
  278. </style>