goods.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view :style="viewColor">
  3. <view class="top-top">
  4. <view class="sys-bar" :style="{height:sysHeight}"></view>
  5. <!-- #ifdef MP -->
  6. <view class="title-bar" style="height: 43px;">
  7. <view class="icon" @click="home">
  8. <text class="iconfont icon-fanhui"></text>
  9. </view>
  10. 购买消费券
  11. </view>
  12. <!-- #endif -->
  13. <view class="xf-num">
  14. {{userInfo.cash_price || 0}}
  15. </view>
  16. <view class="xf-tit">
  17. 我的消费券
  18. </view>
  19. </view>
  20. <view class="xf-jl">
  21. <view class="jl-item" @click="navto('/pages/users/user_cash_price/index')">
  22. <image src="https://shushijia.qiniu1314.com/static/i2.png" mode=""></image>
  23. 消费券明细
  24. </view>
  25. <view class="jl-item" @click="navto('/pages/users/user_cash_price/index?cu=1')">
  26. <image src="https://shushijia.qiniu1314.com/static/i1.png" mode=""></image>
  27. 购买记录
  28. </view>
  29. </view>
  30. <view class="goods-list">
  31. <view class="goods" v-for="(item,index) in productList" :key="index" @click="navto('/pages/goods_details/index?id=' + item.product_id)">
  32. <image :src="item.image" mode=""></image>
  33. <view class="title">
  34. {{item.store_name}}
  35. </view>
  36. <view class="price">
  37. {{item.price}}
  38. </view>
  39. <view class="btn">
  40. 立即购买
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import { getMenuList, getUserInfo, setVisit } from '@/api/user.js';
  48. import { getProductslist } from '@/api/store.js'
  49. let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  50. export default {
  51. data() {
  52. return {
  53. productList: [],
  54. sysHeight,
  55. isHome: false,
  56. page: 1,
  57. limit: 10,
  58. where: {
  59. page:1,
  60. limit:30,
  61. use_cash: 1
  62. },
  63. loadTitle: '',
  64. loadend: false,
  65. loading: false,
  66. userInfo: {}
  67. }
  68. },
  69. onLoad() {
  70. this.getList();
  71. this.getUserInfo();
  72. },
  73. onShow() {
  74. },
  75. methods: {
  76. /**
  77. * 获取个人用户信息
  78. */
  79. getUserInfo: function() {
  80. let that = this;
  81. getUserInfo().then(res => {
  82. that.userInfo = res.data;
  83. });
  84. },
  85. navto(url) {
  86. uni.navigateTo({
  87. url
  88. })
  89. },
  90. back() {
  91. uni.navigateBack();
  92. },
  93. home() {
  94. uni.switchTab({
  95. url:'/pages/index/index'
  96. })
  97. },
  98. getList(isPage) {
  99. let that = this;
  100. if (that.loadend) return;
  101. if (that.loading) return;
  102. if (isPage === true) that.$set(that, 'productList', []);
  103. that.loading = true;
  104. that.loadTitle = '';
  105. getProductslist(that.where).then(res => {
  106. let list = res.data.list;
  107. let productList = that.$util.SplitArray(list, that.productList);
  108. console.log('productList',productList);
  109. let loadend = list.length < that.where.limit;
  110. that.loadend = loadend;
  111. that.loading = false;
  112. that.loadTitle = loadend ? '已全部加载' : '加载更多';
  113. that.$set(that, 'productList', productList);
  114. that.$set(that.where, 'page', that.where.page + 1);
  115. }).catch(err => {
  116. that.loading = false;
  117. that.loadTitle = '加载更多';
  118. });
  119. },
  120. }
  121. }
  122. </script>
  123. <style lang="scss">
  124. .noCommodity {
  125. background-color: #fff;
  126. padding-bottom: 30rpx;
  127. }
  128. .top-top {
  129. width: 750rpx;
  130. height: 480rpx;
  131. background-image: url('https://shushijia.qiniu1314.com/static/xf_bg.png');
  132. background-size: 100% 100%;
  133. color: #FFFFFF;
  134. .xf-num {
  135. text-align: center;
  136. font-weight: bold;
  137. font-size: 83rpx;
  138. padding-top: 30rpx;
  139. }
  140. .xf-tit {
  141. text-align: center;
  142. font-weight: 500;
  143. font-size: 33rpx;
  144. padding-top: 20rpx;
  145. }
  146. }
  147. .title-bar {
  148. position: relative;
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. font-size: 34rpx;
  153. font-weight: 500;
  154. color: #fff;
  155. line-height: 48rpx;
  156. }
  157. .icon {
  158. position: absolute;
  159. left: 30rpx;
  160. top: 0;
  161. display: flex;
  162. align-items: center;
  163. justify-content: center;
  164. width: 80rpx;
  165. height: 80rpx;
  166. image {
  167. width: 50rpx;
  168. height: 50rpx;
  169. }
  170. }
  171. .xf-jl {
  172. width: 702rpx;
  173. height: 106rpx;
  174. background: #FFFFFF;
  175. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50,50,52,0);
  176. border-radius: 15rpx;
  177. margin: -50rpx auto 0;
  178. display: flex;
  179. align-items: center;
  180. .line {
  181. width: 2rpx;
  182. height: 54rpx;
  183. background: #EEEEEE;
  184. }
  185. .jl-item {
  186. display: flex;
  187. flex-grow: 1;
  188. justify-content: center;
  189. align-items: center;
  190. font-weight: 500;
  191. font-size: 28rpx;
  192. color: #111111;
  193. image {
  194. width: 40rpx;
  195. height: 40rpx;
  196. margin-right: 15rpx;
  197. }
  198. }
  199. }
  200. .goods-list {
  201. display: flex;
  202. justify-content: space-between;
  203. padding: 20rpx 24rpx;
  204. .goods {
  205. position: relative;
  206. width: 335rpx;
  207. height: 484rpx;
  208. background: #FFFFFF;
  209. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50,50,52,0);
  210. border-radius: 20rpx;
  211. image {
  212. width: 335rpx;
  213. height: 335rpx;
  214. border-radius:20rpx 20rpx 0 0;
  215. }
  216. .btn {
  217. width: 147rpx;
  218. height: 46rpx;
  219. background: #ff6b2e;
  220. border-radius: 23rpx;
  221. text-align: center;
  222. font-weight: 500;
  223. font-size: 25rpx;
  224. color: #FFFFFF;
  225. line-height: 46rpx;
  226. position: absolute;
  227. right: 16rpx;
  228. bottom: 30rpx;
  229. }
  230. .title {
  231. width: 335rpx;
  232. padding:5rpx 20rpx;
  233. font-weight: bold;
  234. font-size: 29rpx;
  235. color: #333333;
  236. white-space: nowrap; /* 确保文本在一行内显示 */
  237. overflow: hidden; /* 超出容器部分的文本隐藏 */
  238. text-overflow: ellipsis; /* 超出部分显示省略号 */
  239. }
  240. .price {
  241. padding: 20rpx 0 0 20rpx;
  242. font-weight: bold;
  243. font-size: 32rpx;
  244. color: #FF6B2E;
  245. }
  246. }
  247. }
  248. </style>