金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

340 lines
7.7 KiB

  1. <template>
  2. <view>
  3. <lf-nav title="积分商城" titleColor="#fff" bgColor="transparent" :showIcon="true" :spreadOut="false"></lf-nav>
  4. <view class="head">
  5. <view class="bg-view"></view>
  6. </view>
  7. <view class="menu">
  8. <view class="left">
  9. <view>
  10. <text class="lf-iconfont icon-jifen"></text>
  11. <text class="point-num">{{ point.point }}</text>
  12. <text class="lf-iconfont icon-xiangyou lf-font-24"></text>
  13. </view>
  14. <view class="lf-font-24">当前积分</view>
  15. </view>
  16. <view class="lf-flex">
  17. <view class="item" @click="$url('/pages/point/exchangeRecord/exchangeRecord')">
  18. <text class="lf-iconfont icon-jilu2 lf-font-50"></text>
  19. <text>兑换记录</text>
  20. </view>
  21. <view class="item" @click="$url('/pages/store/cart/cart')">
  22. <text class="lf-iconfont icon-gouwulan lf-font-50"></text>
  23. <text>购物车</text>
  24. <view class="angle-mark">99+</view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="lf-m-t-30" v-if="tab_list.length">
  29. <u-tabs :list="tab_list"
  30. active-color="#15716E"
  31. inactive-color='#777777'
  32. :is-scroll="true"
  33. :current="tab_current"
  34. @change="tabChange">
  35. </u-tabs>
  36. </view>
  37. <view class="page-item" v-for="(tab_item, tab_index) in tab_list"
  38. :key="tab_index" v-if="tab_current == tab_index">
  39. <view class="filter">
  40. <view :class="{'filter-item': true, 'filter-active': index == filter_current}"
  41. v-for="(item, index) in filter_list" :key="index"
  42. @click="activeFilter(index)">{{ item.name }}
  43. </view>
  44. </view>
  45. <view class="goods" v-if="$isRight(tab_list)">
  46. <lf-waterfall :list="tab_list[tab_current].list"></lf-waterfall>
  47. <lf-nocontent src="/static/images/empty.png" v-if="tab_list[tab_current].list.length <= 0"></lf-nocontent>
  48. </view>
  49. </view>
  50. <u-back-top :scrollTop="pageScrollTop"></u-back-top>
  51. </view>
  52. </template>
  53. <script>
  54. import lfWaterfall from '@/components/lf-waterfall-pointgoods/lf-waterfall.vue';
  55. export default {
  56. components: {
  57. lfWaterfall
  58. },
  59. data(){
  60. return {
  61. tab_current: 0,
  62. tab_list: [],
  63. filter_list: [{
  64. name: '1~100',
  65. point_start: '1',
  66. point_end: '100'
  67. },{
  68. name: '100~1万',
  69. point_start: '100',
  70. point_end: '10000'
  71. },{
  72. name: '1万~2万',
  73. point_start: '10000',
  74. point_end: '20000'
  75. },{
  76. name: '2万~5万',
  77. point_start: '20000',
  78. point_end: '50000'
  79. },{
  80. name: '>5万',
  81. point_start: '50000',
  82. point_end: ''
  83. }],
  84. filter_current: null,
  85. token: '',
  86. point: {point: 0}
  87. }
  88. },
  89. onLoad(){
  90. this.token = this.$cookieStorage.get('user_token');
  91. this.getTotalPoint();
  92. this.getCategoryList();
  93. },
  94. methods: {
  95. getTotalPoint(){
  96. this.$http.get({
  97. api: 'api/users/point',
  98. header: {
  99. Authorization: this.token
  100. }
  101. }).then(res => {
  102. console.log("getTotalPoint", res)
  103. this.point = res.data.data;
  104. });
  105. },
  106. getCategoryList(){
  107. uni.showLoading({
  108. title: '正在获取分类'
  109. })
  110. this.$http.get({
  111. api: 'api/category/list',
  112. header: {
  113. Authorization: this.token
  114. }
  115. }).then(res => {
  116. let list = res.data.data.map(item => {
  117. return {
  118. c_id: item.id,
  119. name: item.name,
  120. list: [],
  121. page: 1,
  122. isPage: true,
  123. loadingClass: true,
  124. loadingText: '正在加载中'
  125. }
  126. })
  127. this.tab_list = list;
  128. uni.hideLoading();
  129. this.getPointList();
  130. }).catch(err => uni.hideLoading())
  131. },
  132. getPointList(){
  133. uni.showLoading({
  134. title: '正在获取商品'
  135. })
  136. let tabItem = this.tab_list[this.tab_current];
  137. let par = {
  138. is_largess: 1,
  139. page: tabItem.page,
  140. c_id: tabItem.c_id
  141. };
  142. if(this.filter_current != null){
  143. let f_item = this.filter_list[this.filter_current];
  144. par.point_start = f_item.point_start;
  145. par.point_end = f_item.point_end;
  146. }
  147. this.$http.get({
  148. api: 'api/store/list',
  149. data: par,
  150. header: {
  151. Authorization: this.token
  152. }
  153. }).then(res => {
  154. let list = res.data.data.map(item => {
  155. return {
  156. id: item.id,
  157. sale: item.sale_count,
  158. picture: item.img,
  159. title: item.name,
  160. store_nums: item.store_nums
  161. }
  162. })
  163. let pagination = res.data.meta.pagination;
  164. tabItem.isPage = pagination.current_page < pagination.total_pages;
  165. if(tabItem.page == 1){
  166. tabItem.list = list;
  167. }else{
  168. tabItem.list.push(...list);
  169. }
  170. uni.hideLoading();
  171. }).catch(err => uni.hideLoading())
  172. },
  173. activeFilter(index){
  174. if(this.filter_current == index){
  175. this.filter_current = null;
  176. }else{
  177. this.filter_current = index;
  178. }
  179. let tabItem = this.tab_list[this.tab_current];
  180. tabItem.page = 1;
  181. tabItem.isPage = true;
  182. tabItem.loadingClass = true;
  183. tabItem.loadingText = '正在加载中';
  184. this.getPointList();
  185. },
  186. tabChange(event){
  187. this.tab_current = event;
  188. if(this.tab_list[event].list.length <= 0){
  189. this.getPointList();
  190. }
  191. }
  192. },
  193. onReachBottom(){
  194. let tabItem = this.tab_list[this.tab_current];
  195. if(tabItem.isPage){
  196. tabItem.page = tabItem.page+1;
  197. this.getPointList();
  198. }else{
  199. this.$msg('没有更多啦~')
  200. }
  201. }
  202. }
  203. </script>
  204. <style>
  205. page{
  206. overflow-x: hidden;
  207. }
  208. </style>
  209. <style lang="scss" scoped="scoped">
  210. .head{
  211. width: 750rpx;
  212. height: 283rpx;
  213. background: linear-gradient(90deg, #22A2A0 0%, #187B7A 100%);
  214. position: relative;
  215. overflow: hidden;
  216. .bg-view{
  217. position: absolute;
  218. right: -100rpx;
  219. top: -200rpx;
  220. width: 400rpx;
  221. height: 400rpx;
  222. border-radius: 50%;
  223. background-color: rgba(255,255,255,0.04);
  224. }
  225. }
  226. .menu{
  227. width: 686rpx;
  228. height: 170rpx;
  229. background: #FFFFFF;
  230. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  231. border-radius: 20rpx;
  232. box-sizing: border-box;
  233. padding: 30rpx;
  234. display: flex;
  235. justify-content: space-between;
  236. align-items: center;
  237. color: #15716E;
  238. margin: -80rpx auto 0;
  239. position: relative;
  240. z-index: 2;
  241. .left{
  242. width: 340rpx;
  243. .point-num{
  244. font-size: 48rpx;
  245. font-weight: bold;
  246. margin: 0 10rpx;
  247. }
  248. }
  249. .item{
  250. width: 100rpx;
  251. display: flex;
  252. justify-content: center;
  253. align-items: center;
  254. flex-direction: column;
  255. font-size: 24rpx;
  256. position: relative;
  257. &:nth-child(2n){
  258. margin-left: 40rpx;
  259. }
  260. .angle-mark{
  261. width: 30rpx;
  262. height: 30rpx;
  263. background-color: #FF9D9D;
  264. color: #FFFFFF;
  265. border-radius: 50%;
  266. position: absolute;
  267. right: 10rpx;
  268. top: 10rpx;
  269. font-size: 18rpx;
  270. text-align: center;
  271. line-height: 30rpx;
  272. }
  273. }
  274. }
  275. .page-item{
  276. width: 750rpx;
  277. height: max-content;
  278. .filter{
  279. width: 100%;
  280. height: 83rpx;
  281. border: 1rpx solid #e5e5e5;
  282. box-sizing: border-box;
  283. padding: 0 32rpx;
  284. display: flex;
  285. align-items: center;
  286. .filter-item{
  287. width: 123rpx;
  288. height: 43rpx;
  289. font-size: 24rpx;
  290. color: #777777;
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. border-radius: 26rpx;
  295. &:nth-child(n+2){
  296. margin-left: 28rpx;
  297. }
  298. &.filter-active{
  299. background-color: #15716E;
  300. color: #FFFFFF;
  301. }
  302. }
  303. }
  304. .goods{
  305. padding: 30rpx 32rpx;
  306. }
  307. }
  308. // tabs 样式修改
  309. /deep/.u-scroll-box {
  310. display: flex;
  311. justify-content: center;
  312. align-items: center;
  313. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  314. width: max-content;
  315. }
  316. /deep/.u-scroll-box .u-tab-bar {
  317. background-color: #15716E!important;
  318. width: 80rpx!important;
  319. position: absolute;
  320. left: 0;
  321. bottom: -12rpx;
  322. }
  323. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  324. background-color: #15716E!important;
  325. width: 56rpx!important;
  326. position: absolute;
  327. height: 5rpx!important;
  328. left: 8rpx;
  329. bottom: -4rpx;
  330. }
  331. /deep/ .u-tab-item {
  332. font-size: 28rpx!important;
  333. }
  334. </style>