place-order.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="place-order">
  3. <custom-nav ref="ltm" :title="title" @rTap="navRight">
  4. <text :class="mode === 'list' ? 'cuIcon-apps' : 'cuIcon-list'" style="margin-right: 16px;"></text>
  5. </custom-nav>
  6. <view class="content">
  7. <scroll-view scroll-y :style="{ height: scrollviewHeight + 'px' }">
  8. <view
  9. :class="mode === 'list' ? 'list' : 'square'"
  10. v-for="item in goodsList" :key="item.id"
  11. @tap="tap(item.id, item.storage)"
  12. >
  13. <view class="img">
  14. <image :src="item.img"></image>
  15. </view>
  16. <view class="info">
  17. <view class="top">{{ item.name }}</view>
  18. <view class="mid">进货价:¥{{ item.price }}</view>
  19. <view class="bot">我的库存:{{ item.storage }}套</view>
  20. </view>
  21. <view class="buy">立即购买</view>
  22. </view>
  23. <view v-if="!goodsList.length" class="loading">加载中...</view>
  24. </scroll-view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { _API_GoodList } from '@/apis/good.js'
  30. export default {
  31. data() {
  32. return {
  33. title: '订货下单',
  34. mode: 'square',
  35. goodsList: [],
  36. scrollviewHeight: 0
  37. }
  38. },
  39. mounted() { // 获取商品列表
  40. this.$offset('.content').then(res => this.scrollviewHeight = res.height) // 设置scrollview 高
  41. uni.startPullDownRefresh()
  42. },
  43. onPullDownRefresh() {
  44. this.request()
  45. },
  46. methods: {
  47. request() {
  48. this.$refs.ltm.loading()
  49. _API_GoodList().then(res => {
  50. if (res.code === 200) {
  51. this.goodsList = res.data.list
  52. } else {
  53. this.$refs.ltm.toast('网络好像出了点问题,下拉刷新试试')
  54. }
  55. }).catch(() => setTimeout(() => this.$refs.ltm.toast('网络好像出了点问题,下拉刷新试试'), 123))
  56. },
  57. navRight() { // 切换显示模式
  58. this.mode = this.mode === 'list' ? 'square' : 'list'
  59. },
  60. tap(id, storage) { // 查看商品详情
  61. if (this.$store.state.userinfo.level === '特级代理') {
  62. this.$refs.ltm.toast('特级代理不能通过App下单')
  63. } else {
  64. uni.navigateTo({ url: `../good-detail/good-detail?id=${id}&storage=${storage}` })
  65. }
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss">
  71. .place-order {
  72. @include page();
  73. .content {
  74. .loading {
  75. text-align: center;
  76. margin-top: 567rpx;
  77. }
  78. .list {
  79. @include flex();
  80. height: 180rpx;
  81. background: #FFFFFF;
  82. margin-bottom: 10rpx;
  83. padding: 20rpx 30rpx;
  84. align-items: flex-end;
  85. box-sizing: border-box;
  86. .img {
  87. height: 100%;
  88. width: 140rpx;
  89. image {
  90. width: 100%;
  91. height: 100%;
  92. }
  93. }
  94. .info {
  95. @include flex(column);
  96. flex: 1;
  97. height: 100%;
  98. margin: 0 30rpx;
  99. justify-content: space-between;
  100. align-items: flex-start;
  101. view {
  102. width: 100%;
  103. overflow: hidden;
  104. white-space: nowrap;
  105. text-overflow: ellipsis;
  106. &.top {
  107. font-size: 32rpx;
  108. }
  109. &.mid {
  110. font-size: 26rpx;
  111. color: $app-base-color;
  112. }
  113. &.bot {
  114. font-size: 26rpx;
  115. color: $app-sec-text-color;
  116. }
  117. }
  118. }
  119. .buy {
  120. @include flex();
  121. width: 130rpx;
  122. height: 48rpx;
  123. font-size: 26rpx;
  124. color: $app-base-color;
  125. border: 2rpx solid $app-base-color;
  126. }
  127. }
  128. .square {
  129. @include flex(column);
  130. float: left;
  131. width: 335rpx;
  132. height: 500rpx;
  133. overflow: hidden;
  134. margin-top: 30rpx;
  135. margin-left: 30rpx;
  136. position: relative;
  137. background: #FFFFFF;
  138. border-radius: 10rpx;
  139. box-shadow: 0rpx 10rpx 14rpx 2rpx rgba(168, 168, 168, 0.56);
  140. &:nth-child(even) {
  141. margin-left: 20rpx;
  142. }
  143. .img {
  144. width: 100%;
  145. height: 335rpx;
  146. image {
  147. width: 100%;
  148. height: 100%;
  149. }
  150. }
  151. .info {
  152. @include flex(column);
  153. flex: 1;
  154. width: 100%;
  155. padding: 20rpx;
  156. box-sizing: border-box;
  157. align-items: flex-start;
  158. justify-content: space-between;
  159. view {
  160. width: 100%;
  161. overflow: hidden;
  162. white-space: nowrap;
  163. text-overflow: ellipsis;
  164. &.top {
  165. font-size: 32rpx;
  166. }
  167. &.mid {
  168. font-size: 28rpx;
  169. color: $app-base-color;
  170. }
  171. &.bot {
  172. font-size: 22rpx;
  173. color: $app-sec-text-color;
  174. }
  175. }
  176. }
  177. .buy {
  178. @include flex();
  179. right: 10rpx;
  180. bottom: 10rpx;
  181. width: 120rpx;
  182. height: 48rpx;
  183. color: #FFFFFF;
  184. font-size: 26rpx;
  185. position: absolute;
  186. border-radius: 10rpx;
  187. background: $app-base-color;
  188. }
  189. }
  190. }
  191. }
  192. </style>