authorizeList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. <image class="authorize-image" :src="item.merchantImg"></image>
  7. <view class="authorize-info">
  8. <view class="authorize-name">{{item.merchantNickname}}</view>
  9. <view class="authorize-phone">{{item.merchantPhone ? 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 ? '#ffffff' : '#51A539'"
  16. :border-color="isOver ? '#ffffff' : '#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. onPullDownRefresh() {
  49. this.pageIndex = 1
  50. this.isOver = false
  51. this.loadingData = false
  52. this.authorizeList = []
  53. this.getList('refresh')
  54. },
  55. methods: {
  56. // 生成授权码
  57. creatAuthorize() {
  58. NET.request(API.createAuthorizeCode, {}, 'GET').then(res => {
  59. this.modalContent = '您当前生成的授权码为:' + res.data
  60. this.modalShow = true
  61. }).catch(error => {
  62. this.$refs.uTips.show({
  63. title: error.data.msg,
  64. type: 'warning',
  65. })
  66. })
  67. },
  68. // 权限操作
  69. handleAuthorize(item) {
  70. uni.navigateTo({
  71. url: '/pagesMain/authorizeForm?id=' + item.id
  72. });
  73. },
  74. // 懒加载
  75. handleLoadMore() {
  76. if (!this.isOver) {
  77. this.pageIndex++
  78. this.getList()
  79. }
  80. },
  81. // 获取列表数据
  82. getList(type) {
  83. this.loadingData = true
  84. NET.request(API.getAuthorizeList + this.pageIndex + '/10', {}, 'GET').then(res => {
  85. if (type == 'refresh') {
  86. uni.stopPullDownRefresh();
  87. }
  88. this.loadingData = false
  89. this.isOver = res.data.list.length != 10
  90. this.authorizeList = this.authorizeList.concat(res.data.list)
  91. }).catch(error => {
  92. this.loadingData = false
  93. this.$refs.uTips.show({
  94. title: error.data.msg,
  95. type: 'warning',
  96. })
  97. })
  98. },
  99. },
  100. }
  101. </script>
  102. <style lang="less" scoped>
  103. page {
  104. width: 100%;
  105. height: 100%;
  106. }
  107. .container {
  108. width: 100%;
  109. height: 100%;
  110. float: left;
  111. box-sizing: border-box;
  112. padding-bottom: 60px;
  113. background-color: #f7f7f7;
  114. position: relative;
  115. .authorize-head {
  116. width: 100%;
  117. height: 115px;
  118. float: left;
  119. background: #52A63A;
  120. border-radius: 0px 0px 20px 20px;
  121. box-sizing: border-box;
  122. padding: 18px 15px;
  123. font-size: 15px;
  124. font-family: PingFang SC;
  125. color: #FFFFFF;
  126. line-height: 16px;
  127. }
  128. .authorize-box {
  129. width: 100%;
  130. height: calc(100% - 52px);
  131. float: left;
  132. overflow-y: auto;
  133. box-sizing: border-box;
  134. padding: 0 15px;
  135. margin-top: -63px;
  136. .authorize-card {
  137. width: 100%;
  138. height: 96px;
  139. float: left;
  140. background: #FFFFFF;
  141. border-radius: 10px;
  142. box-sizing: border-box;
  143. padding: 15px;
  144. margin-bottom: 10px;
  145. .authorize-image {
  146. width: 66px;
  147. height: 66px;
  148. float: left;
  149. border-radius: 50%;
  150. overflow: hidden;
  151. }
  152. .authorize-info {
  153. width: calc(100% - 94px);
  154. height: 66px;
  155. float: left;
  156. margin-left: 15px;
  157. .authorize-name {
  158. width: 100%;
  159. height: 42px;
  160. float: left;
  161. font-size: 18px;
  162. font-family: PingFang SC;
  163. color: #333333;
  164. line-height: 42px;
  165. }
  166. .authorize-phone {
  167. width: 100%;
  168. height: 24px;
  169. float: left;
  170. font-size: 15px;
  171. font-family: PingFang SC;
  172. color: #666666;
  173. line-height: 24px;
  174. }
  175. }
  176. .authorize-arrow {
  177. width: 12px;
  178. height: 66px;
  179. float: left;
  180. line-height: 66px;
  181. text-align: center;
  182. .iconfont {
  183. font-size: 16px;
  184. color: #999999;
  185. }
  186. }
  187. }
  188. /deep/.u-divider {
  189. background-color: transparent !important;
  190. }
  191. }
  192. .form-handle {
  193. width: 100%;
  194. height: 60px;
  195. position: absolute;
  196. z-index: 10;
  197. padding: 10px 15px 20px 15px;
  198. box-sizing: border-box;
  199. bottom: 0;
  200. background-color: #FFFFFF;
  201. border-top: 1px solid #EEEEEE;
  202. .handle-custom {
  203. background-color: #51A539;
  204. /deep/button {
  205. background-color: #56a83a;
  206. }
  207. /deep/.u-btn--success--disabled {
  208. background-color: #74bd60 !important;
  209. }
  210. }
  211. }
  212. }
  213. </style>