index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. getList() {
  134. uni.showLoading({
  135. title: '加载中'
  136. });
  137. let data = {
  138. categoryId: '',
  139. ...this.coinNum,
  140. noToken: true
  141. }
  142. $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20`, data).then(
  143. res => {
  144. uni.hideLoading();
  145. if (res.code == 0) {
  146. res.rows.forEach(item => {
  147. let picUrlArr = item.picUrl.split(',')
  148. item.picUrl = env.filePublic + picUrlArr[0]
  149. })
  150. this.total = res.total
  151. this.list = this.list.concat(res.rows)
  152. }
  153. }).catch(() => {
  154. uni.hideLoading();
  155. })
  156. },
  157. pageList() {
  158. this.pageNum = 1
  159. this.total = 0
  160. this.list = []
  161. this.getList()
  162. },
  163. openSelect(){
  164. this.coinShow = !this.coinShow
  165. },
  166. selectCoin(item, index){
  167. this.actionIndex = index
  168. this.actionInfo = this.coinList[this.actionIndex]
  169. this.coinShow = false
  170. this.coinNum.startPrice = item.min
  171. this.coinNum.endPrice = item.max
  172. this.pageList()
  173. },
  174. },
  175. onReachBottom() {
  176. // 判断是否有数据
  177. if (this.total > this.pageNum * 20) {
  178. setTimeout(() => {
  179. ++this.pageNum
  180. this.getList()
  181. }, 500)
  182. } else {
  183. uni.$u.toast('没有更多数据了')
  184. }
  185. },
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. </style>
  190. <style lang="scss" scoped>
  191. .screen-coin {
  192. position: fixed;
  193. width: 100%;
  194. z-index: 10;
  195. background-color: #FFFFFF;
  196. border-top: 1px solid #F8F8F8;
  197. box-shadow: 0 4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  198. &-select {
  199. height: 86rpx;
  200. line-height: 86rpx;
  201. width: 100%;
  202. justify-content: flex-start;
  203. .title {
  204. padding-left: 40rpx;
  205. margin-right: 10rpx;
  206. }
  207. }
  208. &-list {
  209. width: 100%;
  210. background-color: #FFFFFF;
  211. border-top: 1px solid #F8F8F8;
  212. &-item{
  213. height: 86rpx;
  214. line-height: 86rpx;
  215. background-color: #FFFFFF;
  216. border-bottom: 1px solid #F8F8F8;
  217. }
  218. &-item:last-child{
  219. border: 0;
  220. }
  221. .action{
  222. color: $uni-text-color;
  223. }
  224. }
  225. }
  226. .core {
  227. margin: 20rpx 0;
  228. &-list {
  229. justify-content: space-evenly;
  230. flex-wrap: wrap;
  231. padding-top: 96rpx;
  232. &-item {
  233. box-sizing: border-box;
  234. width: 340rpx;
  235. height: 502rpx;
  236. background-color: #FFFFFF;
  237. border-radius: 10rpx;
  238. margin-bottom: 30rpx;
  239. .iamge-wrap {
  240. image {
  241. border-top-left-radius: 10rpx;
  242. border-top-right-radius: 10rpx;
  243. width: 340rpx;
  244. height: 340rpx;
  245. margin-bottom: 6rpx;
  246. }
  247. }
  248. .title {
  249. padding: 0 14rpx;
  250. font-size: 28rpx;
  251. line-height: 40rpx;
  252. overflow: hidden;
  253. text-overflow: ellipsis;
  254. display: -webkit-box;
  255. -webkit-box-orient: vertical;
  256. -webkit-line-clamp: 2;
  257. }
  258. .bean {
  259. padding: 0 14rpx;
  260. display: flex;
  261. align-items: center;
  262. font-size: 32rpx;
  263. line-height: 44rpx;
  264. color: rgba(235, 112, 9, 100);
  265. margin-top: 12rpx;
  266. image {
  267. width: 42rpx;
  268. height: 42rpx;
  269. margin-right: 16rpx;
  270. }
  271. }
  272. }
  273. &-item:last-child {
  274. padding: 0;
  275. height: 0;
  276. }
  277. }
  278. .empty {
  279. height: 60vh;
  280. }
  281. }
  282. </style>