place-order.vue 4.4 KB

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