coreRange.vue 8.3 KB

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