coreRange.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <view>
  3. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#ffffff">
  4. <view class="flex u-nav-slot" slot="left" @click="toBackCore">
  5. <u-icon name="arrow-left" bold="true" color="#151515" size="18"></u-icon>
  6. <text>兑换大厅</text>
  7. </view>
  8. </u-navbar>
  9. <view class="screen-coin">
  10. <view class="flex screen-coin-select">
  11. <view @click="ascSelect" class="flex">
  12. <view class="title">
  13. <!-- <text v-if="actionInfo.min">{{ actionInfo.min }}</text>
  14. <text v-if="actionInfo.max">-{{ actionInfo.max }}</text> -->
  15. <text>{{ ascListsingle.text}}</text>
  16. </view>
  17. <u-icon name="arrow-up" color="#333" size="18" v-if="ascShow"></u-icon>
  18. <u-icon name="arrow-down" color="#333" size="18" v-else></u-icon>
  19. </view>
  20. <view @click="openSelect" class="flex">
  21. <view class="title">
  22. <text v-if="actionInfo.min">{{ actionInfo.min }}</text>
  23. <text v-if="actionInfo.max">-{{ actionInfo.max }}</text>
  24. <text>{{ actionInfo.desc }}</text>
  25. </view>
  26. <u-icon name="arrow-up" color="#333" size="18" v-if="coinShow"></u-icon>
  27. <u-icon name="arrow-down" color="#333" size="18" v-else></u-icon>
  28. </view>
  29. </view>
  30. <view class="screen-coin-list" v-if="ascShow">
  31. <view class="flex screen-coin-list-item" v-for="(item, index) in ascList" :key="index" @click="selectCoinTwo(item, index)">
  32. <text :class="{ 'action': ascListIndex == index }">{{ item.text }}</text>
  33. </view>
  34. </view>
  35. <view class="screen-coin-list" v-if="coinShow">
  36. <view class="flex screen-coin-list-item" v-for="(item, index) in coinList" :key="index" @click="selectCoin(item, index)">
  37. <text v-if="item.min" :class="{ 'action': actionIndex == index }">{{ item.min }}</text>
  38. <text v-if="item.max" :class="{ 'action': actionIndex == index }">-{{ item.max }}</text>
  39. <text :class="{ 'action': actionIndex == index }">{{ item.desc }}</text>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="core">
  44. <view class="flex core-list">
  45. <navigator :url="`/pages/goods/detail?id=${ item.goodsId }`" class="core-list-item"
  46. hover-class="navigator-hover" v-for="(item, index) in list" :key="index">
  47. <view class="flex iamge-wrap">
  48. <image :src="item.picUrl" mode=""></image>
  49. </view>
  50. <view class="title">{{ item.title }}</view>
  51. <view class="bean">
  52. <image src="../../static/icon/bean.png" mode="aspectFill"></image>
  53. <view>× {{ item.exchangePrice }}</view>
  54. </view>
  55. </navigator>
  56. <view class="core-list-item"></view>
  57. </view>
  58. <view class="flex empty" v-if="!list.length">
  59. <u-empty text="数据为空" mode="order" />
  60. </view>
  61. </view>
  62. <custom-tab-bar :activeValue="'core'" />
  63. <u-overlay :show="coinShow" @click="coinShow = false" zIndex="1"></u-overlay>
  64. <u-overlay :show="ascShow" @click="ascShow = false" zIndex="1"></u-overlay>
  65. </view>
  66. </template>
  67. <script>
  68. import env from '../../config/env.js'
  69. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  70. import $http from '@/utils/request.js'
  71. export default {
  72. components: {
  73. CustomTabBar,
  74. },
  75. data() {
  76. return {
  77. pageNum: 1,
  78. total: 0,
  79. list: [],
  80. coinShow: false,
  81. coinList:[
  82. {
  83. min: null,
  84. max: null,
  85. desc: '全部价格'
  86. },
  87. {
  88. min: 1,
  89. max: 20,
  90. desc: '盲豆'
  91. },
  92. {
  93. min: 21,
  94. max: 40,
  95. desc: '盲豆'
  96. },
  97. {
  98. min: 41,
  99. max: 60,
  100. desc: '盲豆'
  101. },
  102. {
  103. min: 61,
  104. max: 80,
  105. desc: '盲豆'
  106. },
  107. {
  108. min: 81,
  109. max: 100,
  110. desc: '盲豆'
  111. },
  112. {
  113. min: 101,
  114. max: 200,
  115. desc: '盲豆'
  116. },
  117. {
  118. min: 201,
  119. max: 500,
  120. desc: '盲豆'
  121. },
  122. {
  123. min: 501,
  124. max: 1000,
  125. desc: '盲豆'
  126. },
  127. {
  128. min: 1001,
  129. max: 5000,
  130. desc: '盲豆'
  131. },
  132. {
  133. min: 5000,
  134. max: null,
  135. desc: '盲豆以上'
  136. },
  137. ],
  138. actionInfo:{},
  139. actionIndex: 0,
  140. coinNum:{
  141. startPrice: null,
  142. endPrice: null
  143. },
  144. tagIds:'',//标签
  145. categoryId:'',//链接
  146. orderByColumn:'',//默认exchangePrice
  147. isAsc:'',//从低到高asc isAsc:'desc'从高到低
  148. ascShow:false,
  149. ascList:[
  150. {
  151. data:'',
  152. text:'默认排序'
  153. },
  154. {
  155. data:'asc',
  156. text:'价格从低到高'
  157. },
  158. {
  159. data:'desc',
  160. text:'价格从高到低'
  161. },
  162. ],
  163. ascListsingle:{},
  164. ascListIndex:0,
  165. ascListNum:{
  166. }
  167. };
  168. },
  169. // 跳转接参数
  170. onLoad(opthios) {
  171. console.log(opthios)
  172. if(opthios.type = 'link'){
  173. this.categoryId = opthios.data
  174. }else{
  175. this.tagIds = opthios.data
  176. }
  177. // this. = opthios.type
  178. this.pageList()
  179. this.actionInfo = this.coinList[this.actionIndex]
  180. this.ascListsingle = this.ascList[this.ascListIndex]
  181. },
  182. methods: {
  183. toBackCore(){
  184. uni.navigateBack({
  185. })
  186. },
  187. getList() {
  188. uni.showLoading({
  189. title: '加载中'
  190. });
  191. let data = {
  192. categoryId: this.categoryId,
  193. tagIds: this.tagIds,
  194. ...this.coinNum,
  195. noToken: true
  196. }
  197. $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20&orderByColumn=${this.orderByColumn}&isAsc=${this.isAsc}`, data).then(
  198. res => {
  199. uni.hideLoading();
  200. if (res.code == 0) {
  201. res.rows.forEach(item => {
  202. let picUrlArr = item.picUrl.split(',')
  203. item.picUrl = env.filePublic + picUrlArr[0]
  204. })
  205. this.total = res.total
  206. this.list = this.list.concat(res.rows)
  207. }
  208. }).catch(() => {
  209. uni.hideLoading();
  210. })
  211. },
  212. pageList() {
  213. this.pageNum = 1
  214. this.total = 0
  215. this.list = []
  216. this.getList()
  217. },
  218. pageListTwo() {
  219. this.pageNum = 1
  220. this.total = 0
  221. this.list = []
  222. this.getList()
  223. },
  224. openSelect(){
  225. if(this.coinShow == false){
  226. this.coinShow = true
  227. this.ascShow = false
  228. }else{
  229. this.coinShow = false
  230. }
  231. },
  232. //排序切换
  233. ascSelect(){
  234. if(this.ascShow == false){
  235. this.ascShow = true
  236. this.coinShow = false
  237. }else{
  238. this.ascShow = false
  239. }
  240. },
  241. selectCoin(item, index){
  242. this.actionIndex = index
  243. this.actionInfo = this.coinList[this.actionIndex]
  244. this.coinShow = false
  245. this.coinNum.startPrice = item.min
  246. this.coinNum.endPrice = item.max
  247. this.pageList()
  248. },
  249. selectCoinTwo(item, index){
  250. this.ascListIndex = index
  251. this.ascListsingle = this.ascList[this.ascListIndex]
  252. this.ascShow = false
  253. console.log(1111111111,item.data)
  254. if(item.data == ''){
  255. this.orderByColumn = ''
  256. this.isAsc = ''
  257. }else{
  258. this.isAsc = item.data
  259. this.orderByColumn = 'exchangePrice'
  260. }
  261. this.pageListTwo()
  262. },
  263. },
  264. onReachBottom() {
  265. // 判断是否有数据
  266. if (this.total > this.pageNum * 20) {
  267. setTimeout(() => {
  268. ++this.pageNum
  269. this.getList()
  270. }, 500)
  271. } else {
  272. uni.$u.toast('没有更多数据了')
  273. }
  274. },
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. .screen-coin {
  279. position: fixed;
  280. width: 100%;
  281. z-index: 10;
  282. background-color: #FFFFFF;
  283. border-top: 1px solid #F8F8F8;
  284. box-shadow: 0 4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  285. &-select {
  286. height: 86rpx;
  287. line-height: 86rpx;
  288. width: 100%;
  289. justify-content: flex-start;
  290. .title {
  291. padding-left: 40rpx;
  292. margin-right: 10rpx;
  293. }
  294. }
  295. &-list {
  296. width: 100%;
  297. background-color: #FFFFFF;
  298. border-top: 1px solid #F8F8F8;
  299. &-item{
  300. height: 86rpx;
  301. line-height: 86rpx;
  302. background-color: #FFFFFF;
  303. border-bottom: 1px solid #F8F8F8;
  304. }
  305. &-item:last-child{
  306. border: 0;
  307. }
  308. .action{
  309. color: $uni-text-color;
  310. }
  311. }
  312. }
  313. .core {
  314. margin: 20rpx 0;
  315. &-list {
  316. justify-content: space-evenly;
  317. flex-wrap: wrap;
  318. padding-top: 96rpx;
  319. &-item {
  320. box-sizing: border-box;
  321. width: 340rpx;
  322. height: 502rpx;
  323. background-color: #FFFFFF;
  324. border-radius: 10rpx;
  325. margin-bottom: 30rpx;
  326. .iamge-wrap {
  327. image {
  328. border-top-left-radius: 10rpx;
  329. border-top-right-radius: 10rpx;
  330. width: 340rpx;
  331. height: 340rpx;
  332. margin-bottom: 6rpx;
  333. }
  334. }
  335. .title {
  336. padding: 0 14rpx;
  337. font-size: 28rpx;
  338. line-height: 40rpx;
  339. overflow: hidden;
  340. text-overflow: ellipsis;
  341. display: -webkit-box;
  342. -webkit-box-orient: vertical;
  343. -webkit-line-clamp: 2;
  344. }
  345. .bean {
  346. padding: 0 14rpx;
  347. display: flex;
  348. align-items: center;
  349. font-size: 32rpx;
  350. line-height: 44rpx;
  351. color: rgba(235, 112, 9, 100);
  352. margin-top: 12rpx;
  353. image {
  354. width: 42rpx;
  355. height: 42rpx;
  356. margin-right: 16rpx;
  357. }
  358. }
  359. }
  360. &-item:last-child {
  361. padding: 0;
  362. height: 0;
  363. }
  364. }
  365. .empty {
  366. height: 60vh;
  367. }
  368. }
  369. </style>