manager.vue 10 KB

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