authorizeForm.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="container">
  3. <view class="authorize-head">
  4. <cover-image class="authorize-image" :src="userInfo.merchantImg"></cover-image>
  5. <view class="authorize-info">
  6. <view class="authorize-name">{{userInfo.merchantNickname}}</view>
  7. <view class="authorize-phone">{{userInfo.merchantPhone}}</view>
  8. </view>
  9. </view>
  10. <view class="authorize-box">
  11. <u-checkbox-group wrap>
  12. <u-checkbox v-model="item.checked" v-for="(item, index) in checkList" :key="index" :name="item.name" shape="circle"
  13. active-color="#52A63A">{{item.name}}</u-checkbox>
  14. </u-checkbox-group>
  15. </view>
  16. <view class="form-handle">
  17. <u-button type="success" shape="circle" :ripple="true" @click="creatAuthorize" class="handle-custom">确认授权</u-button>
  18. <u-button type="error" shape="circle" :ripple="true" @click="modalShow1 = true" class="handle-custom2">删除该授权用户</u-button>
  19. </view>
  20. <u-modal v-model="modalShow1" content="是否确认授予该授权用户对应权限" @confirm="setAuthorize" :async-close="true" :show-cancel-button="true"></u-modal>
  21. <u-modal v-model="modalShow2" content="是否删除该授权用户" @confirm="deleteAuthorize" :async-close="true" :show-cancel-button="true"></u-modal>
  22. <u-top-tips ref="uTips"></u-top-tips>
  23. </view>
  24. </template>
  25. <script>
  26. const NET = require('@/utils/request')
  27. const API = require('@/config/api')
  28. export default {
  29. data() {
  30. return {
  31. modalShow1: false,
  32. modalShow2: false,
  33. userInfo: {
  34. userId: '',
  35. merchantImg: 'xx',
  36. merchantNickname: 'xx',
  37. merchantPhone: 'xx',
  38. },
  39. checkList: [{
  40. name: '商品管理1',
  41. checked: false,
  42. disabled: false
  43. }, {
  44. name: '商品管理1',
  45. checked: false,
  46. disabled: false
  47. }, {
  48. name: '商品管理1',
  49. checked: false,
  50. disabled: false
  51. }, {
  52. name: '商品管理1',
  53. checked: false,
  54. disabled: false
  55. }, {
  56. name: '商品管理1',
  57. checked: false,
  58. disabled: false
  59. }, {
  60. name: '商品管理1',
  61. checked: false,
  62. disabled: false
  63. }, {
  64. name: '商品管理1',
  65. checked: false,
  66. disabled: false
  67. }, {
  68. name: '商品管理1',
  69. checked: false,
  70. disabled: false
  71. }, {
  72. name: '商品管理1',
  73. checked: false,
  74. disabled: false
  75. },
  76. {
  77. name: '商品管理2',
  78. checked: false,
  79. disabled: false
  80. },
  81. {
  82. name: '商品管理3',
  83. checked: false,
  84. disabled: false
  85. }
  86. ],
  87. }
  88. },
  89. onShow() {},
  90. methods: {
  91. // 设置授权用户权限
  92. setAuthorize() {
  93. NET.request(API.setAuthorize + this.userInfo.userId, {
  94. roleInfos: ''
  95. }, 'POST').then(res => {
  96. this.modalShow1 = false
  97. this.$refs.uTips.show({
  98. title: '授权户成功',
  99. type: 'success',
  100. })
  101. setTimeout(() => {
  102. uni.navigateBack()
  103. }, 1000)
  104. }).catch(error => {
  105. this.modalShow1 = false
  106. this.$refs.uTips.show({
  107. title: error.data.msg,
  108. type: 'warning',
  109. })
  110. })
  111. },
  112. // 删除授权用户
  113. deleteAuthorize() {
  114. NET.request(API.deleteAuthorizeUser + this.userInfo.userId, {}, 'DELETE').then(res => {
  115. this.modalShow2 = false
  116. this.$refs.uTips.show({
  117. title: '删除授权用户成功',
  118. type: 'success',
  119. })
  120. setTimeout(() => {
  121. uni.navigateBack()
  122. }, 1000)
  123. }).catch(error => {
  124. this.modalShow2 = false
  125. this.$refs.uTips.show({
  126. title: error.data.msg,
  127. type: 'warning',
  128. })
  129. })
  130. },
  131. },
  132. }
  133. </script>
  134. <style lang="less" scoped>
  135. page {
  136. width: 100%;
  137. height: 100%;
  138. }
  139. .container {
  140. width: 100%;
  141. height: 100%;
  142. float: left;
  143. .authorize-head {
  144. width: 100%;
  145. height: 120px;
  146. float: left;
  147. background: #52A63A;
  148. box-sizing: border-box;
  149. padding: 15px;
  150. .authorize-image {
  151. width: 66px;
  152. height: 66px;
  153. float: left;
  154. border-radius: 50%;
  155. overflow: hidden;
  156. }
  157. .authorize-info {
  158. width: calc(100% - 82px);
  159. height: 66px;
  160. float: left;
  161. margin-left: 15px;
  162. .authorize-name {
  163. width: 100%;
  164. height: 42px;
  165. float: left;
  166. font-size: 18px;
  167. font-family: PingFang SC;
  168. color: #333333;
  169. line-height: 42px;
  170. }
  171. .authorize-phone {
  172. width: 100%;
  173. height: 24px;
  174. float: left;
  175. font-size: 15px;
  176. font-family: PingFang SC;
  177. color: #666666;
  178. line-height: 24px;
  179. }
  180. }
  181. }
  182. .authorize-box {
  183. width: 100%;
  184. height: calc(100% - 220px);
  185. float: left;
  186. box-sizing: border-box;
  187. padding: 15px;
  188. margin-top: -25px;
  189. background: #FFFFFF;
  190. border-radius: 10px 10px 0px 0px;
  191. overflow-y: auto;
  192. /deep/.u-checkbox-group {
  193. float: left;
  194. }
  195. /deep/.u-checkbox {
  196. padding: 8px 0;
  197. }
  198. /deep/.u-checkbox__label {
  199. margin-left: 10px;
  200. }
  201. }
  202. .form-handle {
  203. width: 100%;
  204. height: 120px;
  205. box-sizing: border-box;
  206. padding: 10px 15px;
  207. float: left;
  208. .handle-custom {
  209. background-color: #51A539;
  210. margin-bottom: 15px;
  211. }
  212. }
  213. }
  214. </style>