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

376 lines
8.6 KiB

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