robot.nvue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="page-news">
  3. <view class="listview">
  4. <view class="robot">
  5. <robot-list :dataList="dataList"></robot-list>
  6. </view>
  7. <view>
  8. <view class="loading-more">
  9. <view class="creatView" v-if="isNoData">
  10. <image class="imsa" src="../../../static/nodata.png" mode=""></image>
  11. <text class="c-te">暂无消息</text>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import uniList from '@/components/uni-list.vue';
  20. import uniCell from '@/components/uni-cell.vue';
  21. import uniRefresh from '@/components/uni-refresh.vue';
  22. import uniLoadMore from '@/components/uni-load-more.vue';
  23. import robotList from '@/components/dl-product-class/index.nvue'
  24. import {
  25. getRobotList,
  26. } from '@/common/api.js'
  27. export default {
  28. components: {
  29. uniList,
  30. uniCell,
  31. uniRefresh,
  32. robotList,
  33. uniLoadMore,
  34. },
  35. props: {
  36. nid: {
  37. type: [Number, String],
  38. default: ''
  39. },
  40. },
  41. data() {
  42. return {
  43. searchContent: "",
  44. dataList: [],
  45. navigateFlag: false,
  46. pulling: false,
  47. refreshing: false,
  48. refreshFlag: false,
  49. refreshText: "",
  50. isLoading: false,
  51. isNoData: false,
  52. pulling: false,
  53. angle: 0,
  54. loadingMoreText: {
  55. contentdown: '',
  56. contentrefresh: '',
  57. contentnomore: ''
  58. },
  59. requestParams: {},
  60. refreshIcon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAB5QTFRFcHBw3Nzct7e39vb2ycnJioqK7e3tpqam29vb////D8oK7wAAAAp0Uk5T////////////ALLMLM8AAABxSURBVHja7JVBDoAgDASrjqj//7CJBi90iyYeOHTPMwmFZrHjYyyFYYUy1bwUZqtJIYVxhf1a6u0R7iUvWsCcrEtwJHp8MwMdvh2amHduiZD3rpWId9+BgPd7Cc2LIkPyqvlQvKxKBJ//Qwq/CacAAwDUv0a0YuKhzgAAAABJRU5ErkJggg=="
  61. }
  62. },
  63. created() {
  64. this.pullTimer = null;
  65. this.loadData()
  66. },
  67. methods: {
  68. loadData(refresh) {
  69. if (this.isLoading) {
  70. return;
  71. }
  72. this.isLoading = true;
  73. this.isNoData = false;
  74. getRobotList({
  75. }, (e) => {
  76. this.isLoading = false;
  77. if (refresh) {
  78. this.refreshing = false;
  79. this.refreshFlag = false;
  80. this.refreshText = "已刷新";
  81. if (this.pullTimer) {
  82. clearTimeout(this.pullTimer);
  83. }
  84. this.pullTimer = setTimeout(() => {
  85. this.pulling = false;
  86. }, 1000);
  87. }
  88. }).then(result => {
  89. let data_list = result;
  90. let namelist = []
  91. let arr = []
  92. try{
  93. data_list.map((item,index) =>{
  94. if(!namelist.includes(item.usePlace)){
  95. namelist.push(item.usePlace)
  96. arr[index] = {
  97. name:item.usePlace,
  98. list:[
  99. {
  100. ...item
  101. }
  102. ]
  103. }
  104. }
  105. else{
  106. let ind = namelist.indexOf(item.usePlace)
  107. arr[ind].list.push(item)
  108. }
  109. })
  110. }catch(e){
  111. console.log(e)
  112. }
  113. this.dataList = arr;
  114. if (this.dataList.length == 0) {
  115. this.isNoData = true
  116. }
  117. this.isLoading = false;
  118. }).catch(e => {
  119. })
  120. },
  121. clear() {
  122. this.dataList = [];
  123. },
  124. refreshData() {
  125. if (this.isLoading) {
  126. return;
  127. }
  128. this.pulling = true;
  129. this.refreshing = true;
  130. this.refreshText = "正在刷新...";
  131. this.clear()
  132. this.loadData(true);
  133. },
  134. onrefresh(e) {
  135. console.log(e)
  136. this.isNoData = false
  137. this.refreshData();
  138. },
  139. onpullingdown(e) {
  140. if (this.refreshing) {
  141. return;
  142. }
  143. this.pulling = false;
  144. if (Math.abs(e.pullingDistance) > Math.abs(e.viewHeight)) {
  145. this.refreshFlag = true;
  146. this.refreshText = "释放立即刷新";
  147. } else {
  148. this.refreshFlag = false;
  149. this.refreshText = "下拉可以刷新";
  150. }
  151. },
  152. }
  153. }
  154. </script>
  155. <style scoped >
  156. .creatView {
  157. display: flex;
  158. justify-content: center;
  159. align-items: center;
  160. flex-direction: column;
  161. }
  162. .c-te{
  163. color: #0581FD;
  164. padding:30rpx;
  165. font-size: 30rpx;
  166. }
  167. .imsa {
  168. margin-top:260rpx;
  169. width: 387rpx;
  170. height: 200rpx;
  171. }
  172. .no-data {
  173. flex: 1;
  174. position: absolute;
  175. left: 0;
  176. top: 0;
  177. right: 0;
  178. bottom: 0;
  179. z-index: 10;
  180. }
  181. .page-news {
  182. flex: 1;
  183. flex-direction: column;
  184. position: absolute;
  185. left: 0;
  186. top: 0;
  187. right: 0;
  188. bottom: 0;
  189. }
  190. .listview {
  191. position: absolute;
  192. left: 0;
  193. background-color: #F9F9F9;
  194. top: 0;
  195. right: 0;
  196. bottom: 0;
  197. /* #ifndef APP-NVUE */
  198. display: flex;
  199. flex-direction: column;
  200. /* #endif */
  201. /* #ifndef MP-ALIPAY */
  202. flex-direction: column;
  203. /* #endif */
  204. }
  205. .robot{
  206. position: absolute;
  207. left: 0;
  208. background-color: #F9F9F9;
  209. top: 0rpx;
  210. right: 0;
  211. bottom: 0;
  212. }
  213. .refresh {
  214. justify-content: center;
  215. }
  216. .refresh-view {
  217. /* #ifndef APP-NVUE */
  218. display: flex;
  219. /* #endif */
  220. width: 750rpx;
  221. height: 64px;
  222. flex-direction: row;
  223. flex-wrap: nowrap;
  224. align-items: center;
  225. justify-content: center;
  226. }
  227. .refresh-icon {
  228. width: 32px;
  229. height: 32px;
  230. transition-duration: .5s;
  231. transition-property: transform;
  232. transform: rotate(0deg);
  233. transform-origin: 15px 15px;
  234. }
  235. .refresh-icon-active {
  236. transform: rotate(180deg);
  237. }
  238. .loading-icon {
  239. width: 28px;
  240. height: 28px;
  241. margin-right: 5px;
  242. color: gray;
  243. }
  244. .loading-text {
  245. margin-left: 2px;
  246. font-size: 16px;
  247. color: #999999;
  248. }
  249. .loading-more {
  250. align-items: center;
  251. justify-content: center;
  252. padding-top: 14px;
  253. padding-bottom: 14px;
  254. text-align: center;
  255. }
  256. .loading-more-text {
  257. font-size: 28upx;
  258. color: #999;
  259. }
  260. </style>