authManage.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view class="site-wrapper">
  3. <!-- 筛选框start -->
  4. <view style="height:90rpx"></view>
  5. <view class="ding">
  6. <view class="cu-bar search bg-gray filter-section">
  7. <view class="search-form round bg-white">
  8. <text class="cuIcon-search"></text>
  9. <input class="" @focus="InputFocus" @blur="InputBlur" :adjust-position="false" type="text"
  10. v-model="phoneNumber"></input>
  11. </view>
  12. <view class="action">
  13. <button class="cu-btn bg-blue round" @click="searchAuthList">查询</button>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 筛选框end -->
  18. <!-- 权限管理start -->
  19. <view class="site-items" style="margin-top:0;height: calc(100vh - 286rpx);">
  20. <view class="cu-list menu-avatar">
  21. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in authList" :key="index"
  22. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  23. <view class="cu-avatar round lg" style="background-image: url(../../static/auth-icon.jpg);"></view>
  24. <view class="content">
  25. <view class="text-grey site-tit">{{item.phone}}</view>
  26. </view>
  27. <view class="move">
  28. <view class="bg-grey" @click.stop="EditItem(item)">编辑</view>
  29. <view class="bg-red" @click.stop="deleteItem(item)">删除</view>
  30. </view>
  31. </view>
  32. </view>
  33. <view v-if="!authList.length&&authListRes==1" class="text-center margin-top"> 暂无数据</view>
  34. <view v-show="isLoadMore&&this.currentPage>1">
  35. <uni-load-more :status="loadStatus"></uni-load-more>
  36. </view>
  37. </view>
  38. <!-- 权限管理end-->
  39. <!-- 新增按钮start -->
  40. <view style="width: 100%;
  41. position: fixed;
  42. bottom: 0px;
  43. right: 0px;
  44. height: 64px;
  45. background: #fff;">
  46. <view class="plus">
  47. <image src="../../static/plus.png" style="width:100rpx;height:100rpx" @tap="goAddPage(type)"></image>
  48. </view>
  49. </view>
  50. <!-- 新增按钮end -->
  51. </view>
  52. </template>
  53. <script>
  54. import json from '../../data/json.js';
  55. export default {
  56. data() {
  57. return {
  58. phoneNumber: '',
  59. authListRes: 0,
  60. authList: [],
  61. type: '0',
  62. siteListData: json.siteListData,
  63. modalName: null,
  64. listTouchStart: 0,
  65. listTouchDirection: null,
  66. CustomBar: this.CustomBar,
  67. csListArrl: [],
  68. //左滑默认宽度
  69. delBtnWidth: 160,
  70. flag: false,
  71. currentPage: 1,
  72. size: 10,
  73. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  74. isLoadMore: false, //是否加载中
  75. };
  76. },
  77. onReachBottom() { //上拉触底函数
  78. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  79. this.isLoadMore = true
  80. this.currentPage += 1;
  81. this.loadData()
  82. }
  83. },
  84. onLoad: function(option) {
  85. this.loadData()
  86. },
  87. methods: {
  88. searchAuthList() {
  89. this.currentPage = 1;
  90. this.loadData()
  91. },
  92. loadData(){
  93. this.getAuthData({
  94. "phone": this.phoneNumber,
  95. currentPage: this.currentPage,
  96. size: this.size,
  97. })
  98. },
  99. EditItem(item){
  100. uni.navigateTo({
  101. url: '/pages/authAdd/authAdd?phone='+item.phone+'',
  102. });
  103. },
  104. deleteItem(item) {
  105. let deleteT=0;
  106. uni.showModal({
  107. title: '确认删除吗?',
  108. content: '',
  109. success: function (result) {
  110. if (result.confirm) {
  111. this.deleteAuth({
  112. "phone": item.phone
  113. });
  114. } else if (result.cancel) {
  115. console.log('用户点击取消');
  116. }
  117. }.bind(this)
  118. });
  119. },
  120. // 删除请求接口
  121. async deleteAuth(ming = {}) {
  122. let res = await this.$myRequest({
  123. url: 'AuthorityManagement/setDelAuthority',
  124. data: ming
  125. })
  126. if (!res.data.flag) {
  127. alert('删除失败');
  128. return;
  129. }
  130. this.loadData()
  131. return res;
  132. },
  133. async getAuthData(ming = {}) {
  134. const res = await this.$myRequest({
  135. url: 'AuthorityManagement/getAuthorityList',
  136. showLoading: true,
  137. data: ming
  138. })
  139. this.authListRes = 1;
  140. if (res.data.total) {
  141. this.authList = this.authList.concat(res.data.data)
  142. if (res.data.data.length < this.size) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
  143. this.isLoadMore = true
  144. this.loadStatus = 'nomore'
  145. } else {
  146. this.isLoadMore = false
  147. }
  148. } else {
  149. this.isLoadMore = true
  150. this.loadStatus = 'nomore'
  151. }
  152. // this.authList = res.data.data
  153. // console.log(res.data.data);
  154. },
  155. // 页面跳转
  156. goAddPage(type) {
  157. uni.navigateTo({
  158. url: '/pages/authAdd/authAdd',
  159. success: res => {},
  160. fail: () => {},
  161. complete: () => {}
  162. });
  163. },
  164. InputFocus(e) {
  165. this.InputBottom = e.detail.height
  166. },
  167. InputBlur(e) {
  168. this.InputBottom = 0
  169. },
  170. // ListTouch触摸开始
  171. ListTouchStart(e) {
  172. this.listTouchStart = e.touches[0].pageX
  173. },
  174. // ListTouch计算方向
  175. ListTouchMove(e) {
  176. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -60 ? 'left' : 'right'
  177. },
  178. // ListTouch计算滚动
  179. ListTouchEnd(e) {
  180. if (this.listTouchDirection == 'left') {
  181. this.modalName = e.currentTarget.dataset.target
  182. } else {
  183. this.modalName = null
  184. }
  185. this.listTouchDirection = null
  186. }
  187. }
  188. }
  189. </script>