discernRecord.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <view>
  3. <!-- tab切换 -->
  4. <view class="inv-h-w">
  5. <view :class="['inv-h',Inv==0?'inv-h-se':'']" @click="Inv=0">虫害</view>
  6. <view :class="['inv-h',Inv==1?'inv-h-se':'']" @click="Inv=1">病害</view>
  7. </view>
  8. <view v-if="isShow">
  9. <!-- 虫害 -->
  10. <view class="plant_ul" v-show="Inv == 0">
  11. <view class="plant_li" v-for="(item, index) in insectArr" :key="index">
  12. <u-image width="320rpx" height="200rpx" class="plant_li_img" :src="$imageURL_58003+'/bigservers/' + item.img"></u-image>
  13. <view class="plant_liBox">
  14. <view class="plant_liBox_top">{{ item.name == '' ? '识别失败' : item.name }}</view>
  15. <view class="plant_liBox_center">识别日期:{{ item.time }}</view>
  16. <view class="plant_liBox_bottom">
  17. <u-button @click="details(item.id)" v-if='item.name !== ""' size="mini" shape="circle" :ripple="true" ripple-bg-color="#909399" type="success">详情</u-button>
  18. <u-button @click="delData(item.id, index)" size="mini" shape="circle" :ripple="true" ripple-bg-color="#909399"
  19. type="error">删除</u-button>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <!-- 病害 -->
  25. <view class="plant_ul" v-show="Inv == 1">
  26. <view class="plant_li" v-for="(item, index) in plantArr" :key="index">
  27. <u-image width="320rpx" height="200rpx" class="plant_li_img" :src="$imageURL_58003+'/bigservers/' + item.img"></u-image>
  28. <view class="plant_liBox">
  29. <view class="plant_liBox_top">{{ item.name == '' ? '识别失败' : item.name }}</view>
  30. <view class="plant_liBox_center">识别日期:{{ item.time }}</view>
  31. <view class="plant_liBox_bottom">
  32. <u-button @click="details(item.id)" v-if='item.name !== ""' size="mini" shape="circle" :ripple="true"
  33. ripple-bg-color="#909399" type="success">详情</u-button>
  34. <u-button size="mini" shape="circle" @click="delData(item.id, index)" :ripple="true" ripple-bg-color="#909399"
  35. type="error">删除</u-button>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- 暂无 -->
  42. <view class="notDataBox" v-else>
  43. <image :src="$imageURL_58003+'/bigservers/' + 'images/detail_11.png'" class="notDataBox_img" mode=""></image>
  44. </view>
  45. <!-- 返回顶部 -->
  46. <u-back-top :scroll-top="scrollTop" top="600"></u-back-top>
  47. <!-- 删除框 -->
  48. <u-modal :show-cancel-button="true" @confirm="confirm" @cancel="cancel" v-model="show" :content="content"></u-modal>
  49. <!-- 提示框 -->
  50. <u-top-tips ref="uTips"></u-top-tips>
  51. <view class="isOver" v-if="flag">
  52. ---- 我是有底线的 ----
  53. </view>
  54. <!--loading-->
  55. <ourLoading v-show="loadingShow" isFullScreen active text="加载中..." />
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. Inv: 0,
  63. scrollTop: 0, //返回顶部
  64. isShow: true, //暂无
  65. insectArr: [], //害虫
  66. plantArr: [], //病害
  67. dataNum: null, //列表总条数
  68. pageIndex: 1, //当前页数
  69. pagination: null, //总页码
  70. numData: 10, //固定每页显示多少条
  71. content: '是否确定删除该条数据?',
  72. show: false,
  73. idData: null, //数据id
  74. indexData: null, //数据下标
  75. flag: false,
  76. listLangth: null, //每次请求数据条数
  77. loadingShow: true, //加载
  78. }
  79. },
  80. watch: {
  81. Inv(val) {
  82. this.dataNum = null //清空
  83. // console.log(this.pageIndex)
  84. this.pageIndex = 1 //清空
  85. this.pagination = null //清空
  86. this.listLength = null
  87. this.flag = false
  88. if (val == 0) {
  89. //虫害
  90. this.listData('2')
  91. this.insectArr = []
  92. } else if (val == 1) {
  93. //病害
  94. this.listData('1')
  95. this.plantArr = []
  96. }
  97. },
  98. insectArr(val) {
  99. if (val.length == 0) {
  100. this.isShow = false
  101. }
  102. },
  103. plantArr(val) {
  104. if (val.length == 0) {
  105. this.isShow = false
  106. }
  107. },
  108. },
  109. methods: {
  110. changeTab(Inv) {
  111. that.navIdx = Inv;
  112. },
  113. // 列表数据
  114. listData(types) {
  115. var that = this
  116. uni.request({
  117. url: 'check_record',
  118. method: 'POST',
  119. data: {
  120. page: this.pageIndex,
  121. types,
  122. },
  123. header: {
  124. "Content-Type": "application/x-www-form-urlencoded"
  125. },
  126. dataType: 'json',
  127. success(res) {
  128. if (res.data.num !== 0) {
  129. that.dataNum = res.data.num
  130. if (types == '1') {
  131. that.plantArr = [...that.plantArr, ...res.data.dat]
  132. } else {
  133. that.insectArr = [...that.insectArr, ...res.data.dat]
  134. }
  135. that.isShow = true
  136. } else {
  137. that.isShow = false
  138. }
  139. console.log(that.plantArr)
  140. that.listLength = res.data.dat.length
  141. that.loadingShow = false
  142. },
  143. fail(err) {
  144. console.log(err)
  145. },
  146. })
  147. },
  148. // 删除
  149. delData(id, index) {
  150. this.idData = id
  151. this.indexData = index
  152. this.show = true;
  153. },
  154. // 删除确定
  155. confirm() {
  156. var that = this
  157. var index = that.indexData
  158. uni.request({
  159. url: 'del_record',
  160. method: 'POST',
  161. data: {
  162. id: that.idData,
  163. },
  164. header: {
  165. "Content-Type": "application/x-www-form-urlencoded"
  166. },
  167. dataType: 'json',
  168. success(res) {
  169. if (res.data == 0) {
  170. that.$refs.uTips.show({
  171. title: '删除成功',
  172. type: 'success',
  173. duration: '2000'
  174. })
  175. if (that.Inv == 0) {
  176. // 虫害
  177. that.insectArr.splice(index, 1)
  178. } else {
  179. //病害
  180. that.plantArr.splice(index, 1)
  181. }
  182. } else {
  183. that.$refs.uTips.show({
  184. title: '删除失败',
  185. type: 'error',
  186. duration: '2000'
  187. })
  188. }
  189. },
  190. fail(err) {
  191. that.$refs.uTips.show({
  192. title: '删除失败',
  193. type: 'error',
  194. duration: '2000'
  195. })
  196. },
  197. })
  198. },
  199. // 删除取消
  200. cancel() {
  201. this.show = false
  202. this.id = null
  203. },
  204. // 详情
  205. details(id) {
  206. uni.navigateTo({
  207. url: '/pages/detailsB/detailsB?id=' + id
  208. })
  209. // uni.navigateTo({
  210. // url: '/pages/detailsB/detailsB'
  211. // })
  212. },
  213. },
  214. onLoad() {
  215. this.listData('2')
  216. },
  217. // 滚动到底翻页
  218. onReachBottom() {
  219. if (this.dataNum !== 0 || this.dataNum !== null) {
  220. if (this.pagination == null) {
  221. var a = this.dataNum
  222. var b = this.numData
  223. var c = a / b
  224. console.log(a)
  225. console.log(b)
  226. this.pagination = Math.ceil(c)
  227. }
  228. this.pagination--
  229. // if (this.pagination !== 0) {
  230. // if (this.listLength == 10) {
  231. // if (this.pagination >= 1) {
  232. // this.pageIndex++
  233. // if (this.Inv == 0) {
  234. // this.listData('2')
  235. // } else if (this.Inv == 1) {
  236. // this.listData('1')
  237. // }
  238. // } else {
  239. // this.flag = true
  240. // }
  241. // } else if (this.listLength < 10) {
  242. // this.flag = true
  243. // }
  244. if (this.listLength == 10) {
  245. console.log(this.listLength + '_______每次获取到数据的长度-true______')
  246. if (this.pagination >= 1) {
  247. console.log(this.pagination + '_______总页码-true______')
  248. this.pageIndex++
  249. if (this.Inv == 0) {
  250. console.log('_______虫害-true______')
  251. this.listData('2')
  252. } else if (this.Inv == 1) {
  253. console.log('_______病害-false______')
  254. this.listData('1')
  255. }
  256. } else {
  257. console.log(this.pagination + '_______总页码-false______')
  258. this.flag = true
  259. }
  260. } else if (this.listLength < 10) {
  261. console.log(this.listLength + '_______每次获取到数据的长度-false______')
  262. this.flag = true
  263. }
  264. } else {
  265. this.flag = true
  266. }
  267. },
  268. // 监听下拉动作
  269. onPullDownRefresh() {
  270. setTimeout(() => {
  271. this.insectArr = []
  272. this.plantArr = []
  273. if (this.Inv == 0) {
  274. this.listData('2')
  275. } else if (this.Inv == 1) {
  276. this.listData('1')
  277. }
  278. uni.stopPullDownRefresh()
  279. },2000)
  280. },
  281. // 监听获取滚动条位置
  282. onPageScroll(e) {
  283. this.scrollTop = e.scrollTop;
  284. },
  285. }
  286. </script>
  287. <style lang="scss">
  288. // tab切换
  289. page {
  290. background-color: #f7f8fc;
  291. }
  292. .inv-h-w {
  293. background-color: #FFFFFF;
  294. height: 100upx;
  295. display: flex;
  296. }
  297. .inv-h {
  298. font-size: 30upx;
  299. flex: 1;
  300. text-align: center;
  301. color: #C9C9C9;
  302. height: 100upx;
  303. line-height: 100upx;
  304. }
  305. .inv-h-se {
  306. color: #20c7a1;
  307. border-bottom: 4upx solid #20c7a1;
  308. }
  309. // 内容列表
  310. .plant_ul {
  311. .plant_li {
  312. border-radius: 6px;
  313. background: #fff;
  314. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  315. display: flex;
  316. justify-content: space-between;
  317. width: 720rpx;
  318. margin: 15rpx auto;
  319. padding: 15rpx 20rpx 15rpx 20rpx;
  320. .plant_li_img {
  321. width: 320rpx;
  322. height: 200rpx;
  323. border-radius: 5px;
  324. }
  325. .plant_liBox {
  326. // border: 1px solid #007AFF;
  327. padding: 25rpx 0 15rpx 0;
  328. .plant_liBox_top {
  329. font-weight: 550;
  330. font-size: 17px;
  331. margin-bottom: 10rpx;
  332. }
  333. .plant_liBox_center {
  334. color: #9d9d9d;
  335. font-size: 12px;
  336. margin-bottom: 20rpx;
  337. }
  338. .plant_liBox_bottom {
  339. button {
  340. margin: 0 15rpx 0 0;
  341. }
  342. }
  343. }
  344. }
  345. }
  346. // 暂无数据
  347. .notDataBox {
  348. .notDataBox_img {
  349. display: block;
  350. margin: 300rpx auto;
  351. width: 300rpx;
  352. height: 300rpx;
  353. }
  354. }
  355. .isOver {
  356. width: 100%;
  357. height: 50px;
  358. line-height: 50px;
  359. text-align: center;
  360. // background: #fff;
  361. font-size: 28rpx;
  362. }
  363. </style>