index.vue 6.2 KB

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