authorizeList.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view class="container">
  3. <view class="authorize-head">授权用户</view>
  4. <view class="authorize-box">
  5. <view class="authorize-card" v-for="(item, index) in authorizeList" :key="index" @click="handleAuthorize(item)">
  6. <cover-image class="authorize-image" :src="item.merchantImg"></cover-image>
  7. <view class="authorize-info">
  8. <view class="authorize-name">{{item.merchantNickname}}</view>
  9. <view class="authorize-phone">{{item.merchantPhone}}</view>
  10. </view>
  11. <view class="authorize-arrow">
  12. <text class="iconfont iconfangxiang"></text>
  13. </view>
  14. </view>
  15. <u-divider :style="{marginTop : authorizeList.length ? '' : '80px'}" :color="isOver ? '#909399' : '#51A539'"
  16. :border-color="isOver ? '#909399' : '#51A539'" @click="handleLoadMore()">
  17. <u-loading mode="circle" v-if="loadingData"></u-loading>{{loadingData ? '加载中' : (isOver ? '没有更多了' : '点击加载更多')}}
  18. </u-divider>
  19. </view>
  20. <view class="form-handle">
  21. <u-button type="success" shape="circle" :ripple="true" @click="creatAuthorize" class="handle-custom">生成授权码</u-button>
  22. </view>
  23. <u-modal v-model="modalShow" :content="modalContent"></u-modal>
  24. <u-top-tips ref="uTips"></u-top-tips>
  25. </view>
  26. </template>
  27. <script>
  28. const NET = require('@/utils/request')
  29. const API = require('@/config/api')
  30. export default {
  31. data() {
  32. return {
  33. pageIndex: 1,
  34. isOver: false,
  35. loadingData: false,
  36. authorizeList: [],
  37. modalShow: false,
  38. modalContent: '',
  39. }
  40. },
  41. onShow() {
  42. this.pageIndex = 1
  43. this.isOver = false
  44. this.loadingData = false
  45. this.authorizeList = []
  46. this.getList()
  47. },
  48. methods: {
  49. // 生成授权码
  50. creatAuthorize() {
  51. NET.request(API.createAuthorizeCode, {}, 'GET').then(res => {
  52. this.modalContent = '您当前生成的授权码为:' + res.data
  53. this.modalShow = true
  54. }).catch(error => {
  55. this.$refs.uTips.show({
  56. title: error.data.msg,
  57. type: 'warning',
  58. })
  59. })
  60. },
  61. // 权限操作
  62. handleAuthorize(item) {
  63. uni.navigateTo({
  64. url: '/pagesMain/authorizeForm?id=' + item.id
  65. });
  66. },
  67. // 懒加载
  68. handleLoadMore() {
  69. if (!this.isOver) {
  70. this.pageIndex++
  71. this.getList()
  72. }
  73. },
  74. // 获取列表数据
  75. getList() {
  76. this.loadingData = true
  77. NET.request(API.getAuthorizeList + this.pageIndex + '/10', {}, 'GET').then(res => {
  78. this.loadingData = false
  79. this.isOver = res.data.list.length != 10
  80. this.authorizeList = this.authorizeList.concat(res.data.list)
  81. }).catch(error => {
  82. this.loadingData = false
  83. this.$refs.uTips.show({
  84. title: error.data.msg,
  85. type: 'warning',
  86. })
  87. })
  88. },
  89. },
  90. }
  91. </script>
  92. <style lang="less" scoped>
  93. page {
  94. width: 100%;
  95. height: 100%;
  96. }
  97. .container {
  98. width: 100%;
  99. height: 100%;
  100. float: left;
  101. box-sizing: border-box;
  102. padding-bottom: 60px;
  103. background-color: #f7f7f7;
  104. position: relative;
  105. .authorize-head {
  106. width: 100%;
  107. height: 115px;
  108. float: left;
  109. background: #52A63A;
  110. border-radius: 0px 0px 20px 20px;
  111. box-sizing: border-box;
  112. padding: 18px 15px;
  113. font-size: 15px;
  114. font-family: PingFang SC;
  115. color: #FFFFFF;
  116. line-height: 16px;
  117. }
  118. .authorize-box {
  119. width: 100%;
  120. height: calc(100% - 52px);
  121. float: left;
  122. overflow-y: auto;
  123. box-sizing: border-box;
  124. padding: 0 15px;
  125. margin-top: -63px;
  126. .authorize-card {
  127. width: 100%;
  128. height: 96px;
  129. float: left;
  130. background: #FFFFFF;
  131. border-radius: 10px;
  132. box-sizing: border-box;
  133. padding: 15px;
  134. margin-bottom: 10px;
  135. .authorize-image {
  136. width: 66px;
  137. height: 66px;
  138. float: left;
  139. border-radius: 50%;
  140. overflow: hidden;
  141. }
  142. .authorize-info {
  143. width: calc(100% - 94px);
  144. height: 66px;
  145. float: left;
  146. margin-left: 15px;
  147. .authorize-name {
  148. width: 100%;
  149. height: 42px;
  150. float: left;
  151. font-size: 18px;
  152. font-family: PingFang SC;
  153. color: #333333;
  154. line-height: 42px;
  155. }
  156. .authorize-phone {
  157. width: 100%;
  158. height: 24px;
  159. float: left;
  160. font-size: 15px;
  161. font-family: PingFang SC;
  162. color: #666666;
  163. line-height: 24px;
  164. }
  165. }
  166. .authorize-arrow {
  167. width: 12px;
  168. height: 66px;
  169. float: left;
  170. line-height: 66px;
  171. text-align: center;
  172. .iconfont {
  173. font-size: 16px;
  174. color: #999999;
  175. }
  176. }
  177. }
  178. /deep/.u-divider {
  179. background-color: transparent !important;
  180. }
  181. }
  182. .form-handle {
  183. width: 100%;
  184. height: 60px;
  185. position: absolute;
  186. z-index: 10;
  187. padding: 10px 15px 20px 15px;
  188. box-sizing: border-box;
  189. bottom: 0;
  190. background-color: #FFFFFF;
  191. border-top: 1px solid #EEEEEE;
  192. .handle-custom {
  193. background-color: #51A539;
  194. }
  195. }
  196. }
  197. </style>