integralGoodsList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. <template>
  2. <view class="content">
  3. <image class="bg" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/backbg.png"></image>
  4. <view class="header-nav"
  5. :style="{ height: `calc(88rpx + ${statusBarHeight}px)`, paddingTop: statusBarHeight + 'px' }">
  6. <view class="arrow-left-warning" @click="goBack()">
  7. <u-icon name="arrow-left" size='22' color="#222" bold></u-icon>
  8. </view>
  9. <view class="header-title">积分商城</view>
  10. </view>
  11. <view class="cont-box">
  12. <view class="top-box" :style="{ paddingTop: statusBarHeight + 44 + 'px' }">
  13. <view class="my-integral">
  14. <view class="left">
  15. <view class="label">我的积分</view>
  16. <view class="integral">{{ integral }}</view>
  17. </view>
  18. <view class="btn-box">
  19. <view class="btn" @click="loginNavTo('/pages_points/integralLogsList')">
  20. <image
  21. src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/integralLogs.png">
  22. </image>
  23. 获得记录
  24. </view>
  25. <view style="height: 40rpx;border: 1rpx solid #D8D8D8;"></view>
  26. <view class="btn" style="margin-bottom: 0;"
  27. @click="loginNavTo('/pages_points/integralOrderList')">
  28. <image
  29. src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/exchange.png">
  30. </image>
  31. 兑换订单
  32. </view>
  33. </view>
  34. <view class="search-cont">
  35. <view class="inner">
  36. <image class="icon-search" src="@/static/images/icon-search.png" mode=""></image>
  37. <input type="text" @confirm="goSearch" :value="keyWord" placeholder="搜索商品"
  38. placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  39. </view>
  40. </view>
  41. </view>
  42. <!-- <view class="navbox">
  43. <view class="navbox-item" @click="goCart()">
  44. <view class="box">
  45. <u-badge type="error" max="99" :value="cartNum" bgColor="#FF233C"></u-badge>
  46. </view>
  47. <image src="/static/images/cart_sel.png" mode="aspectFill"></image>
  48. <text>购物车</text>
  49. </view>
  50. <view class="navbox-item" @click="handleOrder(0)">
  51. <image src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/payment.png" mode="aspectFill"></image>
  52. <text>全部订单</text>
  53. </view>
  54. <view class="navbox-item" @click="handleOrder(1)">
  55. <image src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/send_goods.png" mode="aspectFill"></image>
  56. <text>待发货</text>
  57. </view>
  58. <view class="navbox-item" @click="handleOrder(3)">
  59. <image src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/sou_goods.png" mode="aspectFill"></image>
  60. <text>已完成</text>
  61. </view>
  62. <view class="navbox-item" @click="handleOrder(4)">
  63. <image src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/after_sales.png" mode="aspectFill"></image>
  64. <text>已取消</text>
  65. </view>
  66. </view> -->
  67. <view class="tabs" v-if="tabs.length > 0">
  68. <u-tabs :current="tabIndex" :scrollable="true" :list="tabs" lineColor="#F4F6F7"
  69. inactiveStyle="font-size: 40rpx;color: #222"
  70. activeStyle="font-size: 40rpx;font-weight:bold;color: #FF233C;" @change="tabChange">
  71. </u-tabs>
  72. </view>
  73. </view>
  74. <mescroll-body top="690rpx" bottom="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback"
  75. @up="upCallback" :down="downOption" :up="upOption">
  76. <view class="integral-box">
  77. <view class="item" @click="navTo('/pages_points/integralGoodsDetails?goodsId=' + item.goodsId)"
  78. v-for="(item, index) in dataList">
  79. <view class="top">
  80. <image :src="item.imgUrl"></image>
  81. </view>
  82. <view class="bottom">
  83. <view class="title ellipsis2">
  84. {{ item.goodsName }}
  85. </view>
  86. <view class="price-box">
  87. <view class="price">{{ item.integral }}积分</view>
  88. <view class="price-val" v-if="item.cash > 0">+{{ item.cash.toFixed(2) }}<text
  89. style="font-size: 20rpx;font-weight: normal;">元</text></view>
  90. <!-- <view class="count">价值:{{item.otPrice.toFixed(2)}}元</view> -->
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </mescroll-body>
  96. </view>
  97. </view>
  98. </template>
  99. <script>
  100. import { getStoreDictByKey } from '@/api/common.js'
  101. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  102. // import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  103. import { getIntegralGoodsList, getCartCount } from '@/api/integral.js'
  104. import { getUserInfo } from '@/api/user'
  105. export default {
  106. mixins: [MescrollMixin],
  107. data() {
  108. return {
  109. integral: 0,
  110. type: null,
  111. typeOptions: [],
  112. tabIndex: 0,
  113. tabs: [],
  114. mescroll: null,
  115. downOption: { //下拉刷新
  116. use: true,
  117. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  118. },
  119. keyWord: '',
  120. upOption: {
  121. onScroll: false,
  122. use: true, // 是否启用上拉加载; 默认true
  123. page: {
  124. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  125. size: 10 // 每页数据的数量,默认10
  126. },
  127. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  128. textNoMore: "已经到底了",
  129. empty: {
  130. icon: 'https://hdtobs.obs.cn-north-4.myhuaweicloud.com/hdt/empty_icon.png',
  131. tip: '暂无数据'
  132. }
  133. },
  134. dataList: [],
  135. top: 0,
  136. cartNum: 0,
  137. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  138. }
  139. },
  140. onLoad() {
  141. this.getDictByKey("sys_integral_goods_type");
  142. if (this.$isLogin()) {
  143. this.getUserInfo();
  144. }
  145. },
  146. onReady() {
  147. this.getTop()
  148. },
  149. onShow() {
  150. if (this.$isLogin()) {
  151. this.getcartNum()
  152. }
  153. },
  154. methods: {
  155. goBack() {
  156. uni.navigateBack();
  157. },
  158. goSearch(e) {
  159. this.keyWord = e.detail.value;
  160. this.mescroll.resetUpScroll();
  161. },
  162. goCart() {
  163. if (this.$isLogin()) {
  164. const url = './cart'
  165. uni.navigateTo({
  166. url: url
  167. })
  168. } else {
  169. uni.navigateTo({
  170. url: '/pages/auth/login'
  171. })
  172. }
  173. },
  174. getcartNum() {
  175. getCartCount().then(res => {
  176. if (res.code == 200) {
  177. this.cartNum = res.data || 0
  178. }
  179. })
  180. },
  181. getTop() {
  182. const query = uni.createSelectorQuery().in(this);
  183. query
  184. .select(".top-box")
  185. .boundingClientRect((data) => {
  186. if (data) {
  187. this.top = data.height + uni.upx2px(88)
  188. }
  189. })
  190. .exec();
  191. },
  192. handleOrder(current) {
  193. if (this.$isLogin()) {
  194. uni.navigateTo({
  195. url: '/pages_points/integralOrderList?current=' + current
  196. })
  197. } else {
  198. uni.navigateTo({
  199. url: '/pages/auth/login'
  200. })
  201. }
  202. },
  203. getUserInfo() {
  204. getUserInfo().then(
  205. res => {
  206. if (res.code == 200) {
  207. if (res.user != null) {
  208. this.integral = res.user.integral;
  209. }
  210. } else {
  211. uni.showToast({
  212. icon: 'none',
  213. title: "请求失败",
  214. });
  215. }
  216. },
  217. rej => { }
  218. );
  219. },
  220. loginNavTo(url) {
  221. if (this.$isLogin()) {
  222. uni.navigateTo({
  223. url: url
  224. })
  225. } else {
  226. uni.navigateTo({
  227. url: '/pages/auth/login'
  228. })
  229. }
  230. },
  231. navTo(url) {
  232. uni.navigateTo({
  233. url: url
  234. })
  235. },
  236. getDictByKey(key) {
  237. var data = { key: key }
  238. var that = this;
  239. getStoreDictByKey(data).then(
  240. res => {
  241. if (res.code == 200) {
  242. this.typeOptions = res.data;
  243. this.typeOptions.forEach(function (item, index) {
  244. var data = { name: item.dictLabel };
  245. that.tabs.push(data);
  246. })
  247. this.tabs.unshift({ name: '全部' })
  248. if (this.tabs.length > 0) {
  249. this.tabIndex = 0
  250. }
  251. }
  252. },
  253. err => {
  254. }
  255. );
  256. },
  257. tabChange(item) {
  258. this.tabIndex = item.index
  259. this.type = item.index == 0 ? null : this.typeOptions[item.index - 1].dictValue;
  260. this.mescroll.resetUpScroll()
  261. },
  262. mescrollInit(mescroll) {
  263. this.mescroll = mescroll;
  264. },
  265. /*下拉刷新的回调 */
  266. downCallback(mescroll) {
  267. mescroll.resetUpScroll()
  268. },
  269. upCallback(page) {
  270. //联网加载数据
  271. var that = this;
  272. var data = {
  273. pageNum: page.num,
  274. pageSize: page.size,
  275. keyword: this.keyWord
  276. };
  277. if (this.typeOptions && this.typeOptions.length > 0) {
  278. this.type = this.tabIndex == 0 ? null : this.typeOptions[this.tabIndex - 1].dictValue;
  279. }
  280. if (this.type != null) {
  281. data.goodsType = this.type
  282. }
  283. getIntegralGoodsList(data).then(res => {
  284. if (res.code == 200) {
  285. //设置列表数据
  286. if (page.num == 1) {
  287. that.dataList = res.data.list;
  288. } else {
  289. that.dataList = that.dataList.concat(res.data.list);
  290. }
  291. that.mescroll.endBySize(res.data.list.length, res.data.total);
  292. } else {
  293. uni.showToast({
  294. icon: 'none',
  295. title: "请求失败",
  296. });
  297. that.dataList = null;
  298. that.mescroll.endErr();
  299. }
  300. });
  301. }
  302. }
  303. }
  304. </script>
  305. <style>
  306. page {
  307. height: 100%;
  308. background: #F4F6F7;
  309. }
  310. </style>
  311. <style scoped lang="scss">
  312. @mixin u-flex($flexD, $alignI, $justifyC) {
  313. display: flex;
  314. flex-direction: $flexD;
  315. align-items: $alignI;
  316. justify-content: $justifyC;
  317. }
  318. .bg {
  319. width: 100%;
  320. height: 460rpx;
  321. position: fixed;
  322. top: 0;
  323. left: 0;
  324. z-index: 9;
  325. }
  326. .header-nav {
  327. height: 88rpx;
  328. display: flex;
  329. flex-direction: row;
  330. align-items: center;
  331. justify-content: center;
  332. overflow: hidden;
  333. //background-color: #fff;
  334. box-sizing: border-box;
  335. position: fixed;
  336. width: 100%;
  337. z-index: 9999;
  338. .header-title {
  339. text-align: center;
  340. margin-right: 0;
  341. //padding: 0 10rpx 0 100rpx;
  342. font-family: PingFang SC, PingFang SC;
  343. font-weight: 500;
  344. font-size: 32rpx;
  345. color: #000;
  346. box-sizing: border-box;
  347. }
  348. }
  349. .arrow-left-warning {
  350. position: absolute;
  351. left: 24rpx;
  352. height: 88rpx;
  353. overflow: hidden;
  354. color: #888;
  355. font-size: 24rpx;
  356. z-index: 999;
  357. @include u-flex(column, center, center);
  358. image {
  359. flex-shrink: 0;
  360. height: 36rpx;
  361. width: 36rpx;
  362. }
  363. }
  364. .navbox {
  365. @include u-flex(row, center, space-between);
  366. padding: 26rpx;
  367. background: #FFFFFF;
  368. border-radius: 16rpx 16rpx 16rpx 16rpx;
  369. font-size: 24rpx;
  370. &:last-child {
  371. margin-right: 0;
  372. }
  373. &-item {
  374. flex: 1;
  375. margin-right: 18rpx;
  376. @include u-flex(column, center, center);
  377. position: relative;
  378. }
  379. &-iteminfo {
  380. // width: 162rpx;
  381. // height: 162rpx;
  382. width: 100%;
  383. padding: 24rpx;
  384. box-sizing: border-box;
  385. background: rgba(255, 255, 255, 0.7);
  386. border-radius: 24rpx 24rpx 24rpx 24rpx;
  387. @include u-flex(row, center, center);
  388. font-size: 26rpx;
  389. color: #222222;
  390. }
  391. image {
  392. width: 48rpx;
  393. height: 48rpx;
  394. margin-bottom: 10rpx;
  395. }
  396. .box {
  397. position: absolute;
  398. top: -10rpx;
  399. right: 0;
  400. z-index: 99;
  401. }
  402. }
  403. .search-cont {
  404. padding: 24rpx;
  405. width: 100%;
  406. background-color: #F4F6F7;
  407. display: flex;
  408. align-items: center;
  409. justify-content: space-between;
  410. .inner {
  411. box-sizing: border-box;
  412. width: 100%;
  413. height: 76rpx;
  414. background: #FFFFFF;
  415. border-radius: 38rpx;
  416. display: flex;
  417. align-items: center;
  418. //padding: 0 20rpx;
  419. .icon-search {
  420. width: 44rpx;
  421. height: 44rpx;
  422. margin-right: 12rpx;
  423. }
  424. input {
  425. height: 76rpx;
  426. line-height: 76rpx;
  427. font-size: 32rpx;
  428. flex: 1;
  429. }
  430. }
  431. .icon-search {
  432. margin-left: 20rpx;
  433. width: 44rpx;
  434. height: 44rpx;
  435. image {
  436. width: 44rpx;
  437. height: 44rpx;
  438. }
  439. }
  440. }
  441. .content {
  442. height: 100%;
  443. .cont-box {
  444. .top-box {
  445. z-index: 999;
  446. // padding: 24rpx 24rpx 0 24rpx;
  447. width: 100%;
  448. position: fixed;
  449. left: 0rpx;
  450. //background-color: #f5f5f5;
  451. .my-integral {
  452. //box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  453. //background: linear-gradient(#2BC7B9, #a0f6ff);
  454. //border-radius: 30rpx;
  455. display: flex;
  456. align-items: flex-start;
  457. // justify-content: space-between;
  458. flex-direction: column;
  459. // padding: 30rpx;
  460. //margin-bottom: 24rpx;
  461. .left {
  462. padding: 20rpx 40rpx;
  463. .label {
  464. font-family: PingFangSC, PingFang SC;
  465. font-weight: 400;
  466. font-size: 40rpx;
  467. color: #FFFFFF;
  468. line-height: 56rpx;
  469. }
  470. .integral {
  471. margin-top: 20rpx;
  472. font-family: PingFangSC, PingFang SC;
  473. font-weight: 500;
  474. font-size: 64rpx;
  475. color: #FFFFFF;
  476. line-height: 90rpx;
  477. }
  478. }
  479. .btn-box {
  480. margin-top: 30rpx;
  481. display: flex;
  482. flex-direction: row;
  483. align-items: center;
  484. justify-content: space-between;
  485. background-color: #fff;
  486. border-radius: 24rpx;
  487. width: calc(100vw - 48rpx);
  488. margin-left: 24rpx;
  489. padding: 30rpx 50rpx;
  490. .btn {
  491. //margin-bottom: 30rpx;
  492. //background-color: #fff;
  493. //border-radius: 30rpx;
  494. display: flex;
  495. align-items: center;
  496. justify-content: center;
  497. //padding: 30rpx 50rpx;
  498. font-family: PingFangSC, PingFang SC;
  499. font-weight: 500;
  500. font-size: 32rpx;
  501. color: #000000;
  502. line-height: 44rpx;
  503. image {
  504. width: 100rpx;
  505. height: 100rpx;
  506. margin-right: 20rpx;
  507. }
  508. }
  509. }
  510. }
  511. .tabs {
  512. height: 88rpx;
  513. background: #F4F6F7;
  514. }
  515. }
  516. .integral-box {
  517. margin-top: 40rpx;
  518. padding: 30rpx;
  519. display: flex;
  520. align-items: flex-start;
  521. justify-content: flex-start;
  522. flex-wrap: wrap;
  523. .item {
  524. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  525. background-color: #fff;
  526. width: calc(50% - 20rpx);
  527. border-radius: 15rpx;
  528. margin: 10rpx;
  529. display: flex;
  530. flex-direction: column;
  531. align-items: flex-start;
  532. justify-content: flex-start;
  533. &:last-child {}
  534. .top {
  535. width: 100%;
  536. height: 300rpx;
  537. image {
  538. border-radius: 15rpx 15rpx 0rpx 0rpx;
  539. width: 100%;
  540. height: 300rpx;
  541. }
  542. }
  543. .bottom {
  544. width: 100%;
  545. padding: 15rpx;
  546. .title {
  547. font-weight: bold;
  548. font-size: 28upx;
  549. font-family: PingFang SC;
  550. color: #111111;
  551. }
  552. .price-box {
  553. margin-top: 10rpx;
  554. display: flex;
  555. align-items: center;
  556. // justify-content: space-between;
  557. width: 100%;
  558. .price {
  559. padding: 5rpx 10rpx;
  560. background-color: #FF233C;
  561. border-radius: 30rpx;
  562. font-size: 20upx;
  563. font-family: PingFang SC;
  564. color: #ffffff;
  565. }
  566. .price-val {
  567. font-size: 28rpx;
  568. font-weight: bold;
  569. font-family: PingFang SC;
  570. color: #FF233C;
  571. }
  572. .count {
  573. font-size: 24upx;
  574. font-family: PingFang SC;
  575. color: #333333;
  576. }
  577. }
  578. }
  579. }
  580. }
  581. }
  582. }
  583. </style>