index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. this.list = []
  153. reservePriceFind({code:this.curType}).then(res => {
  154. if (res.status == 200) {
  155. let data = res.data
  156. if(data && data.length) {
  157. // 纸质
  158. if(this.curType == 'PAPER'){
  159. data[0].icon = '/static/price/icon_aper_yellow.png'
  160. data[1].icon = '/static/price/icon_aper_flower.png'
  161. data[2].icon = '/static/price/icon_book.png'
  162. data[3].icon = '/static/price/icon_magazine.png'
  163. data[4].icon = '/static/price/icon_aper_miscellaneous.png'
  164. data[5].icon = '/static/price/icon_newspaper.png'
  165. }
  166. // 衣物
  167. if(this.curType == 'CLOTHES'){
  168. data[0].icon = '/static/price/icon_clothes.png'
  169. }
  170. // 金属
  171. if(this.curType == 'METAL'){
  172. data[0].icon = '/static/price/icon_iron_thin.png'
  173. data[1].icon = '/static/price/icon_iron_thick.png'
  174. data[2].icon = '/static/price/icon_steel.png'
  175. }
  176. // 塑料类
  177. if(this.curType == 'PLASTIC'){
  178. data[0].icon = '/static/price/icon_frame_white.png'
  179. data[1].icon = '/static/price/icon_frame_black.png'
  180. data[2].icon = '/static/price/icon_acrylic.png'
  181. data[3].icon = '/static/price/icon_bottle.png'
  182. }
  183. if(this.current==0) {
  184. data.map(item=>{
  185. if(item.customerPrice){
  186. this.list.push(item)
  187. }
  188. })
  189. }
  190. if(this.current==1) {
  191. data.map(item=>{
  192. if(item.factoryPrice){
  193. this.list.push(item)
  194. }
  195. })
  196. }
  197. }
  198. this.noDataText = '暂无数据'
  199. } else {
  200. this.list = []
  201. this.total = 0
  202. this.noDataText = res.message
  203. }
  204. this.status = "loadmore"
  205. })
  206. },
  207. resetPage() {
  208. this.status = 'loading';
  209. this.curType = this.typeData[0].code
  210. // 上划分页
  211. if (this.action == 'onreachBottom') {
  212. this.getRow();
  213. }
  214. // 左右切换tab
  215. if (this.action == 'swiperChange') {
  216. this.list = [];
  217. this.getRow();
  218. }
  219. },
  220. }
  221. }
  222. </script>
  223. <style lang="scss">
  224. .pagesCons {
  225. height: 100vh;
  226. width: 100%;
  227. background: #fff;
  228. display: flex;
  229. flex-direction: column;
  230. .text-right {
  231. float: right;
  232. }
  233. .tab-body {
  234. flex: 1;
  235. display: flex;
  236. flex-direction: column;
  237. .uTabs {
  238. border-bottom: 1px solid #EEEEEE;
  239. box-shadow: 1px 1px 3px #eeeeee;
  240. }
  241. .check-list {
  242. flex: 1;
  243. overflow-y: scroll;
  244. .swiper-item {
  245. width: 100%;
  246. height: 100%;
  247. overflow: hidden;
  248. .scroll-view {
  249. width: 100%;
  250. height: 100%;
  251. overflow: auto;
  252. }
  253. .nav-left{
  254. width: 220rpx;
  255. height: 100%;
  256. background-color: #F5F6F7;
  257. .nav-left-item{
  258. color: #303133;
  259. padding: 26upx 32upx;
  260. position: relative;
  261. font-size: 34rpx;
  262. color: #666E75;
  263. }
  264. .nav-left-item.active{
  265. color: #4F88F7;
  266. background: #fff;
  267. }
  268. .nav-left-item.active:after{
  269. content: '';
  270. display: block;
  271. width: 2px;
  272. position: absolute;
  273. top: 0;
  274. bottom: 0;
  275. left: 0;
  276. background: #4F88F7;
  277. }
  278. }
  279. .nav-right{
  280. .check-order-list{
  281. width: 100%;
  282. height: 100%;
  283. padding: 30rpx 10rpx 30rpx 32rpx;
  284. .list-item{
  285. float: left;
  286. margin-right: 20rpx;
  287. margin-bottom: 20rpx;
  288. width: 45%;
  289. height: 120rpx;
  290. border-radius: 12rpx;
  291. background-image: url(../../static/price/bg__book.png);
  292. background-repeat: no-repeat;
  293. padding-left: 20rpx;
  294. color: #fff;
  295. font-size: 24rpx;
  296. .item-cont{
  297. margin-left: 12rpx;
  298. view{
  299. line-height: 32rpx;
  300. }
  301. }
  302. }
  303. .nodata{
  304. padding-top: 120rpx;
  305. }
  306. }
  307. }
  308. }
  309. }
  310. }
  311. }
  312. </style>