index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view class="pagesCons">
  3. <view class="tab-body">
  4. <view class="uTabs">
  5. <u-tabs-swiper ref="uTabs" bar-width="80" :list="tabList" inactive-color="#9DA8B5" name="dispName" active-color="#4F88F7" :current="current" @change="tabsChange" :is-scroll="false"
  6. swiperWidth="750"></u-tabs-swiper>
  7. </view>
  8. <swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  9. <swiper-item class="swiper-item flex" v-for="(tabs, index) in tabList" :key="index">
  10. <!-- 左侧 -->
  11. <scroll-view scroll-y v-if="index==current" class="nav-left">
  12. <view :class="['nav-left-item', curType == item.code ? 'active' : '']" v-for="(item, index) in typeData" :key="index" @click="selType(item.code)">
  13. {{item.dispName}}
  14. </view>
  15. </scroll-view>
  16. <!-- 右侧 -->
  17. <scroll-view scroll-y class="nav-right flex_1" v-if="index==current" >
  18. <view class="check-order-list"
  19. >
  20. <view v-for="item in list" :key="item.id" class="list-item flex align_center">
  21. <u-image width="36" height="36" :src="item.icon" ></u-image>
  22. <view class="item-cont">
  23. <view>{{item.name}}</view>
  24. <view>{{index==0?item.customerPrice:item.factoryPrice}}元/kg</view>
  25. </view>
  26. </view>
  27. <view v-if="index==current" style="padding: 20upx;">
  28. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  29. </view>
  30. <view class="nodata" v-if="list.length==0 && status!='loading'">
  31. <u-empty src="/static/def_result.png" :text="noDataText" icon-size="260" ></u-empty>
  32. </view>
  33. </view>
  34. </scroll-view>
  35. </swiper-item>
  36. </swiper>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. // import md5 from 'md5'
  42. import { getLookUpDatas } from '@/api/data.js'
  43. import { reservePriceFind } from '@/api/index.js'
  44. export default {
  45. data() {
  46. return {
  47. status: 'loadmore',
  48. noDataText: '暂无数据',
  49. tabList: [
  50. {
  51. dispName: '上门回收价格',
  52. typeId: 1,
  53. queryLabel: ['WAIT_PAY'] // tab参数
  54. },
  55. {
  56. dispName: '工厂回收价格',
  57. typeId: 3,
  58. queryLabel: ['WAIT_SEND'] // tab参数
  59. },
  60. ],
  61. typeData: [], // 左侧类型数据
  62. curType: '', // 当前类型
  63. current: 0,
  64. swiperCurrent: 0,
  65. pageNo: 1,
  66. pageSize: 10,
  67. list: [], // 类型list
  68. }
  69. },
  70. onLoad() {
  71. // this.pageInit()
  72. // 开启分享
  73. uni.showShareMenu({
  74. withShareTicket: true,
  75. menus: ['shareAppMessage', 'shareTimeline']
  76. })
  77. // 获取垃圾类型
  78. this.getRubbishType()
  79. },
  80. onUnload() {
  81. },
  82. onShow() {
  83. },
  84. // 下拉刷新
  85. onPullDownRefresh() {
  86. console.log('refresh')
  87. this.pageNo = 1
  88. this.getRow()
  89. setTimeout(function () {
  90. uni.stopPullDownRefresh()
  91. }, 200)
  92. },
  93. methods: {
  94. pageInit() {
  95. this.sortIndex = 1
  96. this.pageNo = 1
  97. this.getRow()
  98. },
  99. // 获取垃圾类型数据
  100. getRubbishType() {
  101. getLookUpDatas({type:'RESERVE_RUBBISH_TYPE'}).then(res=>{
  102. console.log(res,'------rrrrrr')
  103. if(res.status == 200) {
  104. this.typeData = res.data || []
  105. this.curType = this.typeData.length ? this.typeData[0].code : ''
  106. this.getRow()
  107. } else {
  108. this.typeData = []
  109. }
  110. })
  111. },
  112. handleRefresh() {
  113. this.getRow()
  114. },
  115. // tabs通知swiper切换
  116. tabsChange(index) {
  117. this.swiperCurrent = index;
  118. },
  119. swiperChange(event) {
  120. this.action = 'swiperChange'
  121. this.status = 'loading'
  122. },
  123. // swiper-item左右移动,通知tabs的滑块跟随移动
  124. transition(e) {
  125. let dx = e.detail.dx;
  126. this.$refs.uTabs.setDx(dx);
  127. },
  128. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  129. // swiper滑动结束,分别设置tabs和swiper的状态
  130. animationfinish(e) {
  131. let current = e.detail.current;
  132. let isCurtab = this.current == current
  133. if (this.status != "nomore") {
  134. let loadData = this.action == 'swiperChange' ? !isCurtab : isCurtab;
  135. if (loadData) {
  136. this.$refs.uTabs.setFinishCurrent(current);
  137. this.swiperCurrent = current;
  138. this.current = current;
  139. this.resetPage();
  140. }
  141. }
  142. },
  143. // 单击左侧菜单
  144. selType (v) {
  145. this.typeList = []
  146. this.curType = v
  147. this.getRow()
  148. },
  149. // 查询列表
  150. getRow() {
  151. this.status = "loading"
  152. reservePriceFind({code:this.curType}).then(res => {
  153. if (res.status == 200) {
  154. this.list = res.data
  155. if(this.list && this.list.length) {
  156. // 纸质
  157. if(this.curType == 'PAPER'){
  158. this.list[0].icon = '/static/price/icon_aper_yellow.png'
  159. this.list[1].icon = '/static/price/icon_aper_flower.png'
  160. this.list[2].icon = '/static/price/icon_book.png'
  161. this.list[3].icon = '/static/price/icon_magazine.png'
  162. this.list[4].icon = '/static/price/icon_aper_miscellaneous.png'
  163. this.list[5].icon = '/static/price/icon_newspaper.png'
  164. }
  165. // 衣物
  166. if(this.curType == 'CLOTHES'){
  167. this.list[0].icon = '/static/price/icon_clothes.png'
  168. }
  169. // 金属
  170. if(this.curType == 'METAL'){
  171. this.list[0].icon = '/static/price/icon_iron_thin.png'
  172. this.list[1].icon = '/static/price/icon_iron_thick.png'
  173. this.list[2].icon = '/static/price/icon_steel.png'
  174. }
  175. // 塑料类
  176. if(this.curType == 'PLASTIC'){
  177. this.list[0].icon = '/static/price/icon_frame_white.png'
  178. this.list[1].icon = '/static/price/icon_frame_black.png'
  179. this.list[2].icon = '/static/price/icon_acrylic.png'
  180. this.list[3].icon = '/static/price/icon_bottle.png'
  181. }
  182. }else{
  183. this.noDataText = '暂无数据'
  184. }
  185. } else {
  186. this.list = []
  187. this.total = 0
  188. this.noDataText = res.message
  189. }
  190. this.status = "loadmore"
  191. })
  192. },
  193. resetPage() {
  194. this.status = 'loading';
  195. this.curType = this.typeData[0].code
  196. // 上划分页
  197. if (this.action == 'onreachBottom') {
  198. this.getRow();
  199. }
  200. // 左右切换tab
  201. if (this.action == 'swiperChange') {
  202. this.list = [];
  203. this.getRow();
  204. }
  205. },
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. .pagesCons {
  211. height: 100vh;
  212. width: 100%;
  213. background: #fff;
  214. display: flex;
  215. flex-direction: column;
  216. .text-right {
  217. float: right;
  218. }
  219. .tab-body {
  220. flex: 1;
  221. display: flex;
  222. flex-direction: column;
  223. .uTabs {
  224. border-bottom: 1px solid #EEEEEE;
  225. box-shadow: 1px 1px 3px #eeeeee;
  226. }
  227. .check-list {
  228. flex: 1;
  229. overflow-y: scroll;
  230. .swiper-item {
  231. width: 100%;
  232. height: 100%;
  233. overflow: hidden;
  234. .scroll-view {
  235. width: 100%;
  236. height: 100%;
  237. overflow: auto;
  238. }
  239. .nav-left{
  240. width: 220rpx;
  241. height: 100%;
  242. background-color: #F5F6F7;
  243. .nav-left-item{
  244. color: #303133;
  245. padding: 26upx 32upx;
  246. position: relative;
  247. font-size: 34rpx;
  248. color: #666E75;
  249. }
  250. .nav-left-item.active{
  251. color: #4F88F7;
  252. background: #fff;
  253. }
  254. .nav-left-item.active:after{
  255. content: '';
  256. display: block;
  257. width: 2px;
  258. position: absolute;
  259. top: 0;
  260. bottom: 0;
  261. left: 0;
  262. background: #4F88F7;
  263. }
  264. }
  265. .nav-right{
  266. .check-order-list{
  267. width: 100%;
  268. height: 100%;
  269. padding: 30rpx 10rpx 30rpx 32rpx;
  270. .list-item{
  271. float: left;
  272. margin-right: 20rpx;
  273. margin-bottom: 20rpx;
  274. width: 45%;
  275. height: 120rpx;
  276. border-radius: 12rpx;
  277. background-image: url(../../static/price/bg__book.png);
  278. background-repeat: no-repeat;
  279. padding-left: 20rpx;
  280. color: #fff;
  281. font-size: 24rpx;
  282. .item-cont{
  283. margin-left: 12rpx;
  284. view{
  285. line-height: 32rpx;
  286. }
  287. }
  288. }
  289. .nodata{
  290. padding-top: 120rpx;
  291. }
  292. }
  293. }
  294. }
  295. }
  296. }
  297. }
  298. </style>