金诚优选前端代码
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.

378 lines
8.7 KiB

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