index.vue 8.2 KB

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