mall.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view>
  3. <scroll-view scroll-x class="bg-white nav text-center solid-bottom echo-fixed-top">
  4. <view class="cu-item" :class="0==cateid && userid==0?'text-blue cur':''" @tap="tabSelect" data-id="0" data-userid="0"> 全部 </view>
  5. <view class="cu-item" v-if="userinfo!=false" :class="0==cateid && userid==userinfo.id?'text-green cur':''" @tap="tabSelect" data-id="0" :data-userid="userinfo.id"> 我可兑购的 </view>
  6. <view class="cu-item" :class="item.id==cateid && userid==0?'text-blue cur':''" v-for="(item, index) in allcate" :key="item.id" @tap="tabSelect" :data-id="item.id" data-userid="0">
  7. {{item.title}}
  8. </view>
  9. </scroll-view>
  10. <view class="echo-fixed-top-empty"></view>
  11. <view class="padding-sm bg-white">
  12. <view class="echo-img-card">
  13. <block v-for="(item,index) in plist" :key="index">
  14. <navigator class="item" :url="'/pages/mall/detail?goodsid='+item.id">
  15. <image :src="item.tilpic" mode="aspectFill"></image>
  16. <view class="title">{{item.title}}</view>
  17. <view class="price">{{item.integral}}积分 + ¥{{item.paymoney}}</view>
  18. </navigator>
  19. </block>
  20. </view>
  21. </view>
  22. <uni-load-more :status="pstatus"></uni-load-more>
  23. <button class="cu-btn bg-blue lg shadow echo-gomyorder" @tap="goMyOrder"> 我的订单 </button>
  24. </view>
  25. </template>
  26. <script>
  27. import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
  28. var _this;
  29. export default {
  30. components: {
  31. uniLoadMore
  32. },
  33. data() {
  34. return {
  35. userinfo: false,
  36. cateid: 0,
  37. userid: 0,
  38. allcate: [],
  39. pstatus: 'more',
  40. ppage: 1,
  41. psize: 20,
  42. plist: []
  43. };
  44. },
  45. onLoad: function(option) {
  46. _this = this;
  47. _this.cateid = option.cateid || 0;
  48. _this.userid = option.userid || 0;
  49. _this.userinfo = uni.getStorageSync('userinfo') || false;
  50. _this.$req.ajax({
  51. path: "mall/allcate",
  52. }).then((data) => {
  53. _this.allcate = data.allcate;
  54. _this.getMore();
  55. }).catch((err) => {
  56. uni.showModal({
  57. title: '信息提示',
  58. content: err,
  59. showCancel: false
  60. });
  61. });
  62. },
  63. onShareAppMessage: function(res) {
  64. return {
  65. title: "积分商城",
  66. path: "/pages/mall/mall"
  67. }
  68. },
  69. onPullDownRefresh: function() {
  70. _this.ppage = 1;
  71. _this.pstatus = 'more';
  72. _this.plist = [];
  73. _this.getMore();
  74. },
  75. onReachBottom: function() {
  76. if (_this.pstatus !== 'more') {
  77. return;
  78. }
  79. _this.getMore();
  80. },
  81. methods: {
  82. goMyOrder: function() {
  83. uni.navigateTo({
  84. url: "/pages/mall/myorder"
  85. });
  86. },
  87. tabSelect: function(e) {
  88. _this.cateid = e.currentTarget.dataset.id;
  89. _this.userid = e.currentTarget.dataset.userid;
  90. _this.pageRefresh();
  91. },
  92. pageRefresh: function() {
  93. _this.pstatus = 'more';
  94. _this.ppage = 1;
  95. _this.plist = [];
  96. _this.getMore();
  97. },
  98. getMore: function() {
  99. _this.$req.ajax({
  100. path: "mall/listgoods",
  101. data: {
  102. ppage: _this.ppage,
  103. psize: _this.psize,
  104. cateid: _this.cateid,
  105. userid: _this.userid
  106. }
  107. }).then((data) => {
  108. _this.pstatus = data.pstatus;
  109. _this.plist = _this.plist.concat(data.plist);
  110. _this.ppage += 1;
  111. uni.stopPullDownRefresh();
  112. }).catch((err) => {
  113. uni.showModal({
  114. title: '信息提示',
  115. content: err,
  116. showCancel: false
  117. });
  118. });
  119. },
  120. goDetail: function(goodsid) {
  121. uni.navigateTo({
  122. url: '/pages/mall/detail?goodsid=' + goodsid
  123. });
  124. }
  125. }
  126. }
  127. </script>
  128. <style>
  129. .echo-img-card {
  130. display: flex;
  131. flex-direction: row;
  132. flex-wrap: wrap;
  133. justify-content: space-between;
  134. }
  135. .echo-img-card>.item {
  136. width: 340rpx;
  137. margin: 15rpx 0rpx 30rpx 0rpx;
  138. overflow: hidden;
  139. font-size: 0;
  140. position: relative;
  141. }
  142. .echo-img-card>.item>image {
  143. width: 340rpx;
  144. height: 340rpx;
  145. }
  146. .echo-img-card>.item>.title {
  147. width: 100%;
  148. font-size: 28rpx;
  149. margin-top: 3px;
  150. height: 80rpx;
  151. line-height: 40rpx;
  152. overflow: hidden;
  153. color: #333333;
  154. }
  155. .echo-img-card>.item>.price {
  156. line-height: 46rpx;
  157. color: #FF0036;
  158. font-size: 32rpx;
  159. }
  160. </style>