list.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view class="phone-list-page phone-zzh-page">
  3. <view class="phone-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">子账号管理</text>
  6. <uni-icons class="nav-bar-right-icon" type="search" size="22" color="#666" @click="searchBtn"></uni-icons>
  7. </view>
  8. <view class="zzh-new-btn-box">
  9. <button type="default" class="phone-green-btn" @click="handleAddZizhanghao">新增</button>
  10. </view>
  11. <!-- 课程列表 -->
  12. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  13. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh" @scrolltolower="onScrolltolower"
  14. class="zzh-saixuan-view">
  15. <uni-list>
  16. <uni-list-item v-for="item in data.list" class="zzh-list-item-box">
  17. <template v-slot:body>
  18. <view class="zzh-item-card">
  19. <view class="zzh-name-row">
  20. <view class="row-item"><icon class="user-icon"></icon>姓名:{{item.realName}}</view>
  21. <view class="row-item"><icon class="tel-icon"></icon>手机:{{item.userName}}</view>
  22. </view>
  23. <view class="zzh-btn-row">
  24. <button class="zzh-btn phone-green-btn" type="default" @click="handleEditor(item)">编辑</button>
  25. <button class="zzh-btn phone-green-btn" type="default" @click="handleReset(item)">重置密码</button>
  26. <button class="zzh-btn phone-white-btn" type="default" @click="handleDelete(item)">删除</button>
  27. </view>
  28. </view>
  29. </template>
  30. </uni-list-item>
  31. <uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
  32. </uni-list>
  33. </scroll-view>
  34. <!-- 页面底端 -->
  35. <customTabbarClientVue></customTabbarClientVue>
  36. <!-- 搜索 -->
  37. <search-dialog ref="searchDialogRef" @search-btn="dialogSearchBtn"
  38. @reset-search="dialogSearchReset"></search-dialog>
  39. <!-- 删除子账号 -->
  40. <common-dialog ref="commonDialogRef" :title="deleteTitle" :content="deleteConcent"
  41. @confirm-btn="deleteQuerenBtn"></common-dialog>
  42. <!-- 新增子账号 -->
  43. <addUserDlVue ref="addUserRef" title="新增" @confirm-btn="onAddSuccess"></addUserDlVue>
  44. <!-- 更新子账号 -->
  45. <editorUserDlVue ref="editorUserRef" title="编辑" @confirm-btn="onUpdateSuccess"></editorUserDlVue>
  46. <!-- 更新密码 -->
  47. <resetPasswordVue ref="resetPasswordRef"></resetPasswordVue>
  48. </view>
  49. </template>
  50. <script setup>
  51. import searchDialog from "@/pages/admin/banzheng/search.vue";
  52. import commonDialog from '@/components/dialog/commonDialog.vue';
  53. import customTabbarClientVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  54. import addUserDlVue from "./components/addUserDl.vue";
  55. import editorUserDlVue from "./components/editorUserDl.vue";
  56. import resetPasswordVue from "./components/resetPassword.vue";
  57. import {
  58. reactive,
  59. ref
  60. } from "vue";
  61. import {
  62. onLoad
  63. } from "@dcloudio/uni-app"
  64. import {
  65. getUserGuanliList,
  66. getUserGuanliDelete
  67. } from "@/api/zizhanghao.js"
  68. const data = reactive({
  69. list: [], // 办证列表
  70. loading: false,
  71. page: 0,
  72. size: 10,
  73. state: 'more',
  74. contentText: {
  75. contentdown: '查看更多',
  76. contentrefresh: '加载中',
  77. contentnomore: '没有更多'
  78. },
  79. userName: '', // 手机号
  80. realName: '', // 姓名
  81. })
  82. const deleteTitle = ref('删除')
  83. const deleteConcent = ref('你确定要执行这个操作吗')
  84. const deletUserId = ref(null)
  85. const addUserRef = ref(null)
  86. const editorUserRef = ref(null)
  87. const commonDialogRef = ref(null)
  88. const resetPasswordRef = ref(null)
  89. const searchDialogRef = ref(null)
  90. function goUpPage() {
  91. uni.redirectTo({
  92. url: '/pages/admin/ShouYe/shouye'
  93. })
  94. }
  95. function onScrolltolower() {
  96. getMore()
  97. }
  98. function handleEditor(item) {
  99. editorUserRef.value.handleShow(item.userId);
  100. }
  101. function handleDelete(item) {
  102. deletUserId.value = item.userId;
  103. commonDialogRef.value.handleShow();
  104. }
  105. function handleReset(item) {
  106. resetPasswordRef.value.handleShow(item.userId)
  107. }
  108. function onAddSuccess() {
  109. data.page = 0;
  110. refreshData();
  111. }
  112. function onUpdateSuccess() {
  113. data.page = 0;
  114. refreshData();
  115. }
  116. function handleAddZizhanghao() {
  117. addUserRef.value.handleShow()
  118. }
  119. function searchBtn() {
  120. searchDialogRef.value.handleShow();
  121. }
  122. function refreshData() {
  123. const opt = {
  124. realName: data.realName, // 姓名
  125. userName: data.userName, // 手机号
  126. page: 1,
  127. size: 10, // 固定查询10条
  128. }
  129. data.list = [];
  130. // 数学
  131. data.state = 'loading';
  132. data.page++;
  133. opt.page = data.page;
  134. getUserGuanliList(opt).then(res => {
  135. data.list = data.list.concat(res.data.data);
  136. data.loading = false;
  137. if (res.data.total > data.list.length) {
  138. data.state = 'more';
  139. data.loading = false;
  140. } else {
  141. data.state = 'no-more';
  142. data.loading = false;
  143. }
  144. }).catch(err => {
  145. data.state = 'more';
  146. data.loading = false;
  147. })
  148. }
  149. function getMore() {
  150. const opt = {
  151. realName: data.realName, // 姓名
  152. userName: data.userName, // 手机号
  153. page: 1,
  154. size: 10, // 固定查询10条
  155. }
  156. if (data.state == 'no-more') return;
  157. data.state = 'loading';
  158. data.page++;
  159. opt.page = data.page;
  160. getUserGuanliList(opt).then(res => {
  161. data.list = data.list.concat(res.data.data);
  162. data.loading = false;
  163. if (res.data.total > data.list.length) {
  164. data.state = 'more';
  165. data.loading = false;
  166. } else {
  167. data.state = 'no-more';
  168. data.loading = false;
  169. }
  170. }).catch(err => {
  171. data.state = 'more';
  172. data.loading = false;
  173. })
  174. }
  175. function onRefresh() {
  176. data.page = 0;
  177. data.list = [];
  178. data.loading = true;
  179. refreshData();
  180. }
  181. function dialogSearchBtn(name, searchData) {
  182. switch (name) {
  183. case '姓名':
  184. dialogSearchReset();
  185. data.realName = searchData.value;
  186. break;
  187. case '手机号':
  188. data.userName = searchData.value;
  189. break;
  190. }
  191. data.page = 0;
  192. refreshData();
  193. }
  194. function dialogSearchReset() {
  195. data.userName = '';
  196. data.realName = '';
  197. }
  198. function deleteQuerenBtn() {
  199. getUserGuanliDelete({
  200. userId: deletUserId.value
  201. }).then(res => {
  202. if (res.code == 0) {
  203. uni.showToast({
  204. title: '成功'
  205. })
  206. data.page = 0;
  207. refreshData();
  208. } else {
  209. uni.showToast({
  210. title: '失败'
  211. })
  212. }
  213. })
  214. }
  215. onLoad(() => {
  216. getMore()
  217. })
  218. </script>
  219. <style>
  220. </style>