inspection.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <view :class="[AppTheme]" class="all_box">
  3. <!-- #ifdef APP-PLUS || MP-WEIXIN -->
  4. <u-sticky offset-top="0" style="z-index: 10;">
  5. <!-- #endif -->
  6. <!-- #ifdef H5 -->
  7. <u-sticky offset-top="-44" style="z-index: 10;">
  8. <!-- #endif -->
  9. <view class="navbar">
  10. <u-tabs ref="uTabs" @click="tabsChange" :list="titlelist" :scrollable="false" lineWidth="30"
  11. :lineColor="primary" :current="current" :activeStyle="{
  12. color: primary,
  13. transform: 'scale(1.05)'
  14. }" :inactiveStyle="{
  15. color: '#606266',
  16. transform: 'scale(1)'
  17. }">
  18. </u-tabs>
  19. </view>
  20. </u-sticky>
  21. <swiper class="swiper_item" :current="swiperCurrent" @transition="transition"
  22. @animationfinish="animationfinish">
  23. <swiper-item v-for="(item, index) in swimglist" :key="index" @touchmove="stopTouchMove">
  24. <scroll-view class="scroll_bar" scroll-y @scrolltolower="handle"
  25. :refresher-enabled="true" :refresher-triggered="triggered"
  26. @refresherrefresh="refresh">
  27. <view class="merchant_box" v-for="(item,index2) in storelist" :key="index2">
  28. <view class="text_area">
  29. <view class="shop_name">
  30. <!-- <image :src="item.farm_logo" :lazy-load="true" class="shop_thumbnail"></image> -->
  31. <view class="right_shop_mess">
  32. <view class="shop_line">
  33. <view class="shop_line_p1">{{item.ntime}}
  34. </view>
  35. <view class="shop_line_p2">
  36. {{item.soil_name}} {{item.name}}
  37. </view>
  38. <view v-if="item.status==0" class="shop_line_p3">
  39. {{item.statustitle}}
  40. </view>
  41. </view>
  42. <view v-if="item.status==0" class="shop_line_fl bg-primary" @click="gostoredetail(item)">
  43. <view >立即巡检</view>
  44. </view>
  45. <view v-if="item.status==1" class="shop_line_f2">
  46. <view>{{item.statustitle}}</view>
  47. </view>
  48. </view>
  49. <view v-if="item.status==1" class="shop_line_p4">
  50. <view>完成时间</view>
  51. <view>{{item.etime}}</view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="">
  56. <u-album singleSize="50" :urls="item.detail_img" maxCount="4" :showMore='true'
  57. rowCount="4"></u-album>
  58. </view>
  59. </view>
  60. <view v-if="storelist.length>0">
  61. <u-loadmore style="margin-top: 30rpx;" :status="loadingType" />
  62. </view>
  63. <u-empty v-if="storelist.length<=0" text="无数据" color="#c0c4cc" icon-color="#c0c4cc" margin-top="70" mode="list">
  64. </u-empty>
  65. <!-- <view style="height: 40rpx;"></view> -->
  66. <!-- <u-loadmore :line="true" :status="loadmore" /> -->
  67. </scroll-view>
  68. </swiper-item>
  69. </swiper>
  70. </view>
  71. </template>
  72. <script>
  73. import mineApi from "@/api/mine/index.js"
  74. export default {
  75. data() {
  76. return {
  77. _freshing: false,
  78. triggered: true,
  79. page: 1,
  80. pagesize: 5,
  81. primary: this.$theme.primary,
  82. loadingType: 'more',
  83. settingFile: getApp().globalData.siteinfo,
  84. loadmore: '',
  85. titlelist: [{
  86. name: '待巡检'
  87. },
  88. {
  89. name: '已完成'
  90. }
  91. ],
  92. // 因为内部的滑动机制限制,请将tabs组件和swiper组件的current用不同变量赋值
  93. couponlist: [],
  94. // tabs组件的current值,表示当前活动的tab选项
  95. current: 0,
  96. // swiper组件的current值,表示当前那个swiper-item是活动的
  97. swiperCurrent: 0,
  98. //轮播图数组
  99. swimglist: [1, 2, 3, 4],
  100. swierheight: 0,
  101. storelist: [], //店铺列表
  102. longitude: '',
  103. latitude: '',
  104. position: false,
  105. shipping_address: '', //收货地址
  106. listtype: 0 //店铺列表分页的排序类型
  107. }
  108. },
  109. onLoad() {
  110. if (this.$config && this.$config.app.position == 1) {
  111. this.position = true;
  112. }
  113. this.vueinit()
  114. this.inspection()
  115. },
  116. onPullDownRefresh() {
  117. this.vueinit()
  118. this.getlist(function() {
  119. uni.stopPullDownRefresh()
  120. })
  121. },
  122. onReachBottom() {
  123. console.log("上拉加载了")
  124. },
  125. methods: {
  126. refresh() { //自定义下拉刷新
  127. console.log('下拉刷新了')
  128. if (this._freshing) return;
  129. this._freshing = true;
  130. //调用获取数据的函数
  131. // this.getData();
  132. if (!this.triggered)
  133. //界面下拉触发,triggered可能不是true,要设为true
  134. this.triggered = true;
  135. setTimeout(() => {
  136. this.triggered = false;
  137. this._freshing = false;
  138. uni.stopPullDownRefresh()
  139. }, 2000);
  140. },
  141. preview(url, idx) { //预览图片
  142. uni.previewImage({
  143. current: idx,
  144. urls: url,
  145. success: function(res) {
  146. console.log(res, '预览')
  147. }
  148. })
  149. },
  150. getlocation() { //获取当前位置
  151. let that = this
  152. // #ifdef MP-WEIXIN || APP-PLUS
  153. that.$until.chooseLocation(function(res) {
  154. that.shipping_address = res.address
  155. that.longitude = res.longitude
  156. that.latitude = res.latitude
  157. that.storelist = []
  158. that.inspection()
  159. });
  160. // #endif
  161. },
  162. gostoredetail(farmid) { //
  163. uni.redirectTo({
  164. url: "/pagesD/pages/inspection/index?item=" + JSON.stringify(farmid)
  165. })
  166. },
  167. inspection(fun) { //店铺列表
  168. let that=this
  169. let data = {
  170. type: that.listtype,
  171. p: that.page,
  172. longitude: that.longitude,
  173. latitude: that.latitude
  174. }
  175. that.loadmore = 'loading'
  176. mineApi.inspection(data)
  177. .then(res => {
  178. if (res.status == 1) {
  179. if (res.data.length >= that.pagesize) {
  180. that.loadingType = 'more';
  181. that.page++;
  182. } else {
  183. that.page++;
  184. that.loadingType = 'nomore';
  185. }
  186. that.storelist = that.storelist.concat(res.data);
  187. // this.storelist = res.data;
  188. }else{
  189. this.loadingType = 'more';
  190. }
  191. })
  192. },
  193. //初始化方法
  194. vueinit() {
  195. let that = this
  196. uni.getSystemInfo({
  197. success: function(res) {
  198. that.swierheight = res.windowWidth * 0.9 * 0.65 * 2
  199. }
  200. })
  201. },
  202. // tabs通知swiper切换并更改数据
  203. tabsChange(e) {
  204. this.storelist = []
  205. this.pages = 1
  206. this.swiperCurrent = e.index
  207. this.listtype = e.index
  208. this.inspection()
  209. },
  210. // swiper-item左右移动,通知tabs的滑块跟随移动
  211. transition(e) {
  212. let dx = e.detail.dx
  213. // this.$refs.uTabs.setDx(dx)
  214. },
  215. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  216. // swiper滑动结束,分别设置tabs和swiper的状态
  217. animationfinish(e) {
  218. let current = e.detail.current
  219. // this.$refs.uTabs.setFinishCurrent(current)
  220. this.swiperCurrent = current
  221. this.current = current
  222. },
  223. // //展开底部,可以查看全部信息
  224. expandbottom() {
  225. this.pages++
  226. this.inspection()
  227. },
  228. // //阻止用户手动滑动
  229. stopTouchMove() {
  230. return true
  231. },
  232. handle() {
  233. console.log('上拉加载了')
  234. this.loadingType = 'loading';
  235. // this.p++;
  236. this.inspection(this.swiperCurrent);
  237. },
  238. },
  239. // onReachBottom() {
  240. // console.log('到底了');
  241. // },
  242. // onPullDownRefresh() {
  243. // this.page = 1;
  244. // this.inspection();
  245. // setTimeout(() => {
  246. // uni.stopPullDownRefresh();
  247. // }, 600);
  248. // }
  249. }
  250. </script>
  251. <style scoped lang="scss">
  252. page{
  253. height: 101%;
  254. }
  255. .all_box {
  256. width: auto;
  257. background-color: #fcfcfc;
  258. height: 100%;
  259. .navbar {
  260. background-color: #fff;
  261. width: 100%;
  262. z-index: 99;
  263. }
  264. .swiper_item {
  265. height: calc(100vh - 44px);
  266. .chooseaddress {
  267. box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.08);
  268. background-color: #ffffff;
  269. padding: 20rpx 10rpx;
  270. display: flex;
  271. justify-content: space-between;
  272. align-items: center;
  273. margin: 15rpx 20rpx;
  274. margin-top: 20rpx;
  275. border-radius: 10rpx;
  276. .chooseaddress_p1 {
  277. display: flex;
  278. align-items: center;
  279. .chdress_p1txt {
  280. color: #999;
  281. font-size: 24rpx;
  282. }
  283. }
  284. }
  285. .merchant_box {
  286. padding: 20rpx;
  287. margin: 25rpx 20rpx;
  288. border-radius: 10rpx;
  289. box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.08);
  290. background-color: #ffffff;
  291. .text_area {
  292. .shop_thumbnail {
  293. width: 135rpx;
  294. height: 120rpx;
  295. border-radius: 50%;
  296. }
  297. .right_shop_mess {
  298. // width: calc(100% - 120rpx);
  299. display: flex;
  300. justify-content: space-between;
  301. align-items: center;
  302. .shop_line {
  303. width: 70%;
  304. display: flex;
  305. flex-direction: column;
  306. padding: 10rpx;
  307. .shop_line_p1 {
  308. font-size: 28rpx;
  309. }
  310. .shop_line_p2 {
  311. font-size: 32rpx;
  312. font-weight: 600;
  313. margin-top: 2vh;
  314. -webkit-line-clamp: 1;
  315. display: -webkit-box;
  316. -webkit-box-orient: vertical;
  317. overflow: hidden;
  318. text-overflow: ellipsis;
  319. }
  320. .shop_line_p3 {
  321. font-size: 28rpx;
  322. margin-top: 2vh;
  323. color: red;
  324. }
  325. }
  326. .shop_line_fl {
  327. line-height: 65rpx;
  328. width: 180rpx;
  329. text-align: center;
  330. border-radius: 40rpx;
  331. font-size: 30rpx;
  332. color: #fff;
  333. float: right;
  334. }
  335. .shop_line_f2 {
  336. font-size: 30rpx;
  337. color: #999;
  338. }
  339. }
  340. .shop_line_p4 {
  341. margin-top: 1vh;
  342. display: flex;
  343. justify-content: space-between;
  344. font-size: 28rpx;
  345. padding: 10rpx;
  346. }
  347. }
  348. .display_diagram {
  349. width: 100%;
  350. white-space: nowrap;
  351. margin: 10rpx 0;
  352. .display_diagram_item {
  353. width: 200rpx;
  354. height: 200rpx;
  355. margin: 0 15rpx 0 0;
  356. border-radius: 7.5%;
  357. }
  358. }
  359. }
  360. .scroll_bar {
  361. height: 100%;
  362. }
  363. }
  364. }
  365. </style>