place-order.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="place-order">
  3. <custom-nav noback="noback" transparent="transparent" ref="ltm" title=" " />
  4. <AddCart ref="addCart" />
  5. <view class="content">
  6. <scroll-view scroll-y :style="{ height: scrollviewHeight + 'px' }">
  7. <view
  8. class="item"
  9. v-for="(item, index) in list" :key="index"
  10. @tap="tap(index)"
  11. >
  12. <view class="img">
  13. <image :src="item.main_img"></image>
  14. </view>
  15. <view class="info">
  16. <view class="top ellipsis">{{ item.name }}</view>
  17. <view class="mid">¥{{ item.money }}.00/{{ item.unit }}</view>
  18. <view class="bot">
  19. <text>{{ item.size.length }}个尺码可选</text>
  20. <view class="shopCar" @tap.stop="tapShopCar(item)">
  21. <view v-if="item.cart.reduce((t, e) => t + e, 0)" class="sizeNum">{{ item.cart.reduce((t, e) => t + e, 0) }}</view>
  22. <text class="cuIcon-cart"></text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view v-if="!goodsList.length" class="loading">加载中...</view>
  28. </scroll-view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import { deepClone } from '@/common/util/index.js'
  34. import { _API_GoodList } from '@/apis/good.js'
  35. import AddCart from '@/components/public/add-cart.vue'
  36. export default {
  37. components: { AddCart },
  38. data() {
  39. return {
  40. title: '订货下单',
  41. mode: 'square',
  42. goodsList: [],
  43. scrollviewHeight: 0
  44. }
  45. },
  46. computed: {
  47. list() {
  48. const temp = deepClone(this.goodsList)
  49. temp.forEach(goodItem => {
  50. goodItem.cart = Array(goodItem.size.length).fill(0)
  51. const itemInCart = this.$store.state.cart.list.find(e => e.id === goodItem.id)
  52. if (itemInCart) {
  53. Object.assign(goodItem, itemInCart)
  54. }
  55. })
  56. return temp
  57. }
  58. },
  59. mounted() { // 获取商品列表
  60. this.$offset('.content').then(res => this.scrollviewHeight = res.height) // 设置scrollview 高
  61. if (this.$store.state.userinfo.level !== '代理公司') {
  62. uni.navigateBack()
  63. setTimeout(() => uni.$emit('noopening'))
  64. return
  65. }
  66. this.request()
  67. },
  68. methods: {
  69. request() {
  70. uni.showLoading({ mask: true })
  71. _API_GoodList().then(res => {
  72. if (res.code === 200) {
  73. this.goodsList = res.data.list
  74. } else {
  75. uni.toast('网络好像出了点问题,下拉刷新试试')
  76. }
  77. }).catch(() => setTimeout(() => uni.toast('网络好像出了点问题,下拉刷新试试'), 123))
  78. },
  79. tap(index) { // 查看商品详情
  80. // if (this.$store.state.userinfo.level === '销售主管') {
  81. // uni.toast('销售主管不能通过App下单')
  82. // } else {
  83. uni.navigateTo({ url: `../good-detail1/good-detail1?data=${JSON.stringify(this.goodsList[index])}` })
  84. // }
  85. // console.log()
  86. },
  87. tapShopCar(item) {
  88. this.$refs.addCart.show(deepClone(item))
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. .place-order {
  95. @include page();
  96. .content {
  97. .loading {
  98. text-align: center;
  99. margin-top: 567rpx;
  100. }
  101. .item {
  102. @include flex();
  103. height: 300rpx;
  104. background: #FFFFFF;
  105. margin-bottom: 10rpx;
  106. padding: 30rpx;
  107. align-items: flex-end;
  108. box-sizing: border-box;
  109. .img {
  110. height: 240rpx;
  111. width: 300rpx;
  112. image {
  113. width: 100%;
  114. height: 100%;
  115. }
  116. }
  117. .info {
  118. @include flex(column);
  119. flex: 1;
  120. height: 100%;
  121. margin-left: 23rpx;
  122. align-items: flex-start;
  123. justify-content: space-between;
  124. > view {
  125. width: 100%;
  126. overflow: hidden;
  127. white-space: nowrap;
  128. text-overflow: ellipsis;
  129. &.top {
  130. font-size: 32rpx;
  131. line-height: 3;
  132. }
  133. &.mid {
  134. font-size: 26rpx;
  135. color: $app-base-color;
  136. }
  137. &.bot {
  138. width: 100%;
  139. display: flex;
  140. overflow: visible;
  141. justify-content: space-between;
  142. > text {
  143. font-size: 26rpx;
  144. line-height: 2;
  145. color: #666666;
  146. }
  147. > view {
  148. @include flex();
  149. color: #FFFFFF;
  150. height: 60rpx;
  151. width: 60rpx;
  152. font-size: 40rpx;
  153. border-radius: 50%;
  154. position: relative;
  155. overflow: visible;
  156. background: $app-base-color;
  157. view {
  158. position: absolute;
  159. font-size: 20rpx;
  160. right: 0;
  161. height: 32rpx;
  162. top: -24rpx;
  163. padding: 2rpx 8rpx;
  164. border-radius: 32rpx;
  165. background: #FF0000;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }
  174. </style>