coreRange.vue 8.4 KB

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