ktadmin.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <view class="content padding-t-30">
  3. <!-- 空白页 -->
  4. <!-- #ifdef H5 -->
  5. <empty src="../../../static/error/emptyOrder.png"
  6. v-if="searchData.loaded === true && searchData.list.length === 0"></empty>
  7. <!-- #endif -->
  8. <!-- #ifndef H5 -->
  9. <empty src="../../static/error/emptyOrder.png"
  10. v-if="searchData.loaded === true && searchData.list.length === 0"></empty>
  11. <!-- #endif -->
  12. <view class="user-item" v-for="(item,index) in searchData.list">
  13. <view class="flex">
  14. <image :src="item.user.avatar" mode="scaleToFill" class="item-logo"></image>
  15. <view class="item-info">
  16. <view class="info-name clamp padding-b-10">
  17. {{item.address.real_name}} {{item.address.phone}}
  18. </view>
  19. <view class="info padding-b-10">
  20. {{item.address.locate_address}}
  21. </view>
  22. <view class="info padding-b-10">
  23. 空桶型号:{{item.product.keyword}}
  24. </view>
  25. </view>
  26. </view>
  27. <view class="info-info flex">
  28. <view>
  29. 持桶:<text class="font-color-red">{{item.hold_num}}</text>
  30. </view>
  31. <view>
  32. 押桶:<text class="font-color-red">{{item.pledge_num}}</text>
  33. </view>
  34. <view>
  35. 借桶:<text class="font-color-red">{{item.borrow_num}}</text>
  36. </view>
  37. <view class="btn" @click="out(item)">
  38. 回收桶
  39. </view>
  40. </view>
  41. </view>
  42. <uni-load-more :status="searchData.loadingType"></uni-load-more>
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. pledge_recovery,
  48. admin_certificate,
  49. } from '@/api/water.js';
  50. export default {
  51. data() {
  52. return {
  53. keyword: '', //搜索关键字
  54. searchData: {
  55. page: 1,
  56. limit: 10,
  57. list: [],
  58. loadingType: 'more',
  59. loaded: false,
  60. }
  61. };
  62. },
  63. onLoad(opt) {
  64. this.getlist()
  65. },
  66. onShow() {
  67. },
  68. // #ifndef MP
  69. //点击导航栏 buttons 时触发
  70. onNavigationBarButtonTap(e) {
  71. const index = e.index;
  72. if (index === 0) {
  73. this.reLoadSearch();
  74. }
  75. },
  76. // 点击键盘搜索事件
  77. onNavigationBarSearchInputConfirmed(e) {
  78. this.reLoadSearch();
  79. },
  80. // 搜索栏内容变化事件
  81. onNavigationBarSearchInputChanged(e) {
  82. this.keyword = e.text;
  83. },
  84. // #endif
  85. onReady(res) {
  86. var that = this;
  87. },
  88. onReachBottom() {
  89. this.getlist();
  90. },
  91. methods: {
  92. // 空桶回收
  93. out(item) {
  94. const that = this;
  95. uni.showModal({
  96. title: '桶回收',
  97. placeholderText: '请输入回收数量',
  98. editable: true,
  99. cancelText: '关闭',
  100. confirmText: '回收',
  101. success: res => {
  102. if (res.confirm) {
  103. if (res.content.search(/^\d*$/) < 0) {
  104. uni.showModal({
  105. title: '错误',
  106. content: '请输入数字',
  107. showCancel: false,
  108. });
  109. return
  110. }
  111. pledge_recovery({
  112. id:item.id,
  113. num: res.content,
  114. }).then(() => {
  115. uni.showToast({
  116. title: '回收成功'
  117. })
  118. that.reLoadSearch();
  119. }).catch(e => {
  120. console.log(e);
  121. });
  122. }
  123. },
  124. });
  125. },
  126. // 搜索
  127. reLoadSearch() {
  128. this.searchData = {
  129. page: 1,
  130. limit: 10,
  131. list: [],
  132. loadingType: 'more',
  133. loaded: false
  134. };
  135. this.getlist()
  136. },
  137. // 载入数据
  138. getlist() {
  139. //这里是将订单挂载到tab列表下
  140. let navItem = this.searchData;
  141. if (navItem.loadingType === 'loading') {
  142. //防止重复加载
  143. return;
  144. }
  145. if (navItem.loadingType === 'noMore') {
  146. //防止重复加载
  147. return;
  148. }
  149. // 修改当前对象状态为加载中
  150. navItem.loadingType = 'loading';
  151. admin_certificate({
  152. page: navItem.page,
  153. limit: navItem.limit,
  154. key: this.keyword
  155. })
  156. .then(({
  157. data
  158. }) => {
  159. let arr = data.data.map(e => {
  160. return e;
  161. });
  162. navItem.list = navItem.list.concat(arr);
  163. // console.log(navItem.orderList);
  164. navItem.page++;
  165. if (navItem.limit == data.length) {
  166. //判断是否还有数据, 有改为 more, 没有改为noMore
  167. navItem.loadingType = 'more';
  168. return;
  169. } else {
  170. //判断是否还有数据, 有改为 more, 没有改为noMore
  171. navItem.loadingType = 'noMore';
  172. }
  173. uni.hideLoading();
  174. navItem.loaded = true;
  175. })
  176. .catch(e => {
  177. console.log(e);
  178. });
  179. }
  180. }
  181. };
  182. </script>
  183. <style lang="scss" scoped>
  184. .user-item {
  185. padding: 30rpx;
  186. background-color: #fff;
  187. margin: 0 30rpx;
  188. margin-bottom: 15rpx;
  189. border-radius: 30rpx;
  190. .info-info {
  191. width: 100%;
  192. font-size: $font-base;
  193. font-weight: bold;
  194. line-height: 1;
  195. .btn {
  196. background: $bg-gradual;
  197. color: #fff;
  198. padding: 10rpx 20rpx;
  199. border-radius: 10rpx;
  200. }
  201. }
  202. .item-logo {
  203. align-self: flex-start;
  204. width: 115rpx;
  205. height: 115rpx;
  206. border-radius: 50%;
  207. background-color: #eee;
  208. flex-shrink: 0;
  209. margin-right: 24rpx;
  210. }
  211. .item-info {
  212. flex-grow: 1;
  213. height: 100%;
  214. flex-direction: column;
  215. align-items: flex-start;
  216. justify-content: space-between;
  217. color: $font-color-base;
  218. .info-name {
  219. font-size: $font-lg;
  220. font-weight: bold;
  221. }
  222. .info {
  223. font-size: $font-base;
  224. font-weight: 500;
  225. color: $font-color-light;
  226. }
  227. }
  228. }
  229. </style>