index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索用户姓名">
  5. </view>
  6. <view class="two">
  7. <tabs :tabs="tabs" @tabsChange="tabsChange">
  8. <view class="tabsList">
  9. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  10. <view class="list-scroll-view">
  11. <view class="list" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
  12. <view class="list_1">
  13. <text>
  14. <text class="iconfont icon-yonghu"></text>
  15. {{item.name}}
  16. </text>
  17. <text class="status">{{item.zhStatus}}</text>
  18. </view>
  19. <view class="list_2">
  20. <view class="other">
  21. <text>联系电话:</text>
  22. <text>{{item.tel||'暂无'}}</text>
  23. </view>
  24. <view class="other">
  25. <text>性别:</text>
  26. <text>{{item.zhGender||'暂无'}}</text>
  27. </view>
  28. <view class="other">
  29. <text>角色:</text>
  30. <text>{{item.zhRole||'暂无'}}</text>
  31. </view>
  32. <view class="other">
  33. <text>所属街道:</text>
  34. <text>{{item.zhStreet||'暂无'}}</text>
  35. </view>
  36. <view class="other">
  37. <text>所属社区:</text>
  38. <text>{{item.zhCommunity||'暂无'}}</text>
  39. </view>
  40. </view>
  41. <view class="bottom" v-if="item.status=='0'">
  42. <button size="mini" type="default" @tap.stop="toExam(item,'0')">审核通过</button>
  43. <button size="mini" type="warn" @tap.stop="toExam(item,'1')">审核拒绝</button>
  44. </view>
  45. </view>
  46. <view class="is_bottom" v-if="is_bottom">
  47. <text>{{config.bottom_title}}</text>
  48. </view>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. </tabs>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import tabs from '../../components/tabs/index.vue';
  58. export default {
  59. components: {
  60. tabs
  61. },
  62. data() {
  63. return {
  64. // 系统设置
  65. config: {},
  66. user: {},
  67. status: '',
  68. searchInfo: {},
  69. tabs: {
  70. active: '0',
  71. menu: []
  72. },
  73. list: [],
  74. total: 0,
  75. skip: 0,
  76. limit: 6,
  77. page: 0,
  78. // 数据是否触底
  79. is_bottom: false,
  80. scrollTop: 0,
  81. // 字典表
  82. statusList: [],
  83. genderList: [],
  84. roleList: [],
  85. benlongList: []
  86. }
  87. },
  88. onLoad: function(e) {
  89. const that = this;
  90. that.$set(that, `status`, e.status || '0');
  91. that.$set(that.tabs, `active`, e.status || '0');
  92. that.searchConfig();
  93. },
  94. onShow: async function(e) {
  95. const that = this;
  96. await that.searchOther();
  97. that.searchToken();
  98. },
  99. onPullDownRefresh: async function() {
  100. const that = this;
  101. that.clearPage();
  102. await that.search();
  103. uni.stopPullDownRefresh();
  104. },
  105. methods: {
  106. searchConfig() {
  107. const that = this;
  108. try {
  109. const res = uni.getStorageSync('config');
  110. if (res) that.$set(that, `config`, res);
  111. } catch (e) {
  112. uni.showToast({
  113. title: err.errmsg,
  114. icon: 'error',
  115. duration: 2000
  116. });
  117. }
  118. },
  119. searchToken() {
  120. const that = this;
  121. try {
  122. const res = uni.getStorageSync('token');
  123. if (res) {
  124. that.$set(that, `user`, res);
  125. that.clearPage();
  126. that.search();
  127. }
  128. } catch (e) {
  129. uni.showToast({
  130. title: err.errmsg,
  131. icon: 'error',
  132. duration: 2000
  133. });
  134. }
  135. },
  136. async search() {
  137. const that = this;
  138. let user = that.user;
  139. let status = that.status;
  140. let info = {
  141. skip: that.skip,
  142. limit: that.limit,
  143. street: user.street,
  144. status: status,
  145. }
  146. let res;
  147. res = await that.$api(`/User/queryInfo`, 'GET', {
  148. ...info,
  149. ...that.searchInfo
  150. });
  151. if (res.errcode == '0') {
  152. let list = [...that.list, ...res.data];
  153. for (let val of list) {
  154. val.zhStatus = that.searchDict(val.status, 'status')
  155. val.zhGender = that.searchDict(val.gender, 'gender')
  156. val.zhRole = that.searchDict(val.role, 'role')
  157. val.zhStreet = that.searchDict(val.street, 'street')
  158. val.zhCommunity = that.searchDict(val.community, 'community')
  159. }
  160. that.$set(that, `list`, list);
  161. that.$set(that, `total`, res.total)
  162. } else {
  163. uni.showToast({
  164. title: res.errmsg,
  165. icon: 'none'
  166. })
  167. }
  168. },
  169. // 转换字典表
  170. searchDict(e, model) {
  171. const that = this;
  172. let data;
  173. if (model == 'status') {
  174. data = that.statusList.find((i) => i.value == e);
  175. if (data) return data.label
  176. else return '暂无'
  177. } else if (model == 'gender') {
  178. data = that.genderList.find((i) => i.value == e);
  179. if (data) return data.label
  180. else return '暂无'
  181. } else if (model == 'role') {
  182. data = that.roleList.find((i) => i.code == e);
  183. if (data) return data.name
  184. else return '暂无'
  185. } else if (model == 'street') {
  186. data = that.benlongList.find((i) => i._id == e);
  187. if (data) return data.name
  188. else return '暂无'
  189. } else if (model == 'community') {
  190. data = that.benlongList.find((i) => i._id == e);
  191. if (data) return data.name
  192. else return '暂无'
  193. }
  194. },
  195. // 确认发货
  196. async toExam(item, type) {
  197. const that = this;
  198. let user = that.user;
  199. let obj = {}
  200. if (type == '0') obj.status == '1'
  201. else obj.status == '2'
  202. uni.showModal({
  203. title: '提示',
  204. content: '是否要确认审核?',
  205. success: async function(res) {
  206. if (res.confirm) {
  207. const res = await that.$api(`/User/${item._id}`, 'POST', obj);
  208. if (res.errcode == '0') {
  209. uni.showToast({
  210. title: '维护信息成功',
  211. icon: 'none'
  212. })
  213. that.clearPage()
  214. that.search()
  215. } else {
  216. uni.showToast({
  217. title: res.errmsg,
  218. icon: 'none'
  219. })
  220. }
  221. }
  222. }
  223. });
  224. },
  225. // 查看详情
  226. toInfo(e) {
  227. uni.navigateTo({
  228. url: `/pagesMy/order/detail?id=${e.id||e._id}`
  229. })
  230. },
  231. // 分页
  232. toPage(e) {
  233. const that = this;
  234. let list = that.list;
  235. let limit = that.limit;
  236. if (that.total > list.length) {
  237. uni.showLoading({
  238. title: '加载中',
  239. mask: true
  240. })
  241. let page = that.page + 1;
  242. that.$set(that, `page`, page)
  243. let skip = page * limit;
  244. that.$set(that, `skip`, skip)
  245. that.search();
  246. uni.hideLoading();
  247. } else that.$set(that, `is_bottom`, true)
  248. },
  249. // 触底
  250. toScroll(e) {
  251. const that = this;
  252. let up = that.scrollTop;
  253. that.$set(that, `scrollTop`, e.detail.scrollTop);
  254. let num = Math.sign(up - e.detail.scrollTop);
  255. if (num == 1) that.$set(that, `is_bottom`, false);
  256. },
  257. // 输入框
  258. toInput(e) {
  259. const that = this;
  260. if (that.searchInfo.name) that.$set(that.searchInfo, `name`, e.detail.value)
  261. else that.$set(that, `searchInfo`, {})
  262. that.clearPage();
  263. that.search();
  264. },
  265. // 查询其他信息
  266. async searchOther() {
  267. const that = this;
  268. let res;
  269. // 查询状态
  270. res = await that.$api(`/DictData`, 'GET', {
  271. type: 'status',
  272. is_use: '0'
  273. })
  274. if (res.errcode == '0') {
  275. that.$set(that, `statusList`, res.data);
  276. var menu = res.data.map((item) => {
  277. return {
  278. title: item.label,
  279. active: item.value
  280. }
  281. })
  282. that.$set(that.tabs, `menu`, menu)
  283. }
  284. // 性别
  285. res = await that.$api(`/DictData`, 'GET', {
  286. type: 'gender',
  287. is_use: '0'
  288. })
  289. if (res.errcode == '0') that.$set(that, `genderList`, res.data);
  290. // 角色
  291. res = await that.$api(`/Role`, 'GET', {
  292. is_use: '0'
  293. })
  294. if (res.errcode == '0') that.$set(that, `roleList`, res.data);
  295. // 街道/社区
  296. res = await that.$api(`/Office`, 'GET', {
  297. is_use: '0'
  298. })
  299. if (res.errcode == '0') that.$set(that, `benlongList`, res.data);
  300. },
  301. // 选择选项卡
  302. tabsChange(e) {
  303. const that = this;
  304. that.$set(that.tabs, `active`, e.active)
  305. that.$set(that, `status`, e.active);
  306. that.clearPage();
  307. that.search()
  308. },
  309. // 清空列表
  310. clearPage() {
  311. const that = this;
  312. that.$set(that, `list`, [])
  313. that.$set(that, `skip`, 0)
  314. that.$set(that, `limit`, 6)
  315. that.$set(that, `page`, 0)
  316. }
  317. }
  318. }
  319. </script>
  320. <style lang="scss">
  321. .content {
  322. display: flex;
  323. flex-direction: column;
  324. width: 100vw;
  325. height: 100vh;
  326. .one {
  327. padding: 2vw;
  328. input {
  329. padding: 2vw;
  330. background-color: var(--f1Color);
  331. font-size: var(--font14Size);
  332. border-radius: 5px;
  333. }
  334. }
  335. .two {
  336. position: relative;
  337. flex-grow: 1;
  338. background-color: var(--f9Color);
  339. .tabsList {
  340. position: relative;
  341. width: 100vw;
  342. height: 82vh;
  343. .list {
  344. background-color: #fff;
  345. border: 1px solid var(--f5Color);
  346. padding: 2vw;
  347. margin: 0 2vw 2vw 2vw;
  348. border-radius: 5px;
  349. .list_1 {
  350. display: flex;
  351. justify-content: space-between;
  352. padding: 2vw 0;
  353. font-size: var(--font16Size);
  354. .status {
  355. font-size: var(--font14Size);
  356. color: var(--fF0Color);
  357. }
  358. }
  359. .list_2 {
  360. .other {
  361. font-size: var(--font14Size);
  362. text:last-child {
  363. color: var(--f85Color);
  364. }
  365. }
  366. }
  367. .bottom {
  368. text-align: center;
  369. padding: 1vw 0;
  370. button {
  371. margin: 0 5px 0 0;
  372. }
  373. }
  374. }
  375. }
  376. }
  377. }
  378. .scroll-view {
  379. position: absolute;
  380. top: 0;
  381. left: 0;
  382. right: 0;
  383. bottom: 0;
  384. .list-scroll-view {
  385. display: flex;
  386. flex-direction: column;
  387. }
  388. }
  389. .is_bottom {
  390. text-align: center;
  391. text {
  392. padding: 2vw 0;
  393. display: inline-block;
  394. color: var(--f85Color);
  395. font-size: var(--font14Size);
  396. }
  397. }
  398. </style>