integralGoodsList.vue 11 KB

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