home.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view>
  3. <view class="search">
  4. <view style="margin: 10rpx 20rpx;margin-top: 20rpx;">
  5. <u-search placeholder="请输入商品名称" inputAlign="center" bgColor="#fff" shape="square" v-model="search.cname"
  6. @search="searchButton" @custom="searchButton" :animation="true"></u-search>
  7. </view>
  8. <view style="margin: -15rpx auto 10rpx auto;display: flex;padding: 0 20rpx;z-index: 999;" v-if="show == true">
  9. <u-tag :text="search.brandNmae" borderColor="#FD4B09" color="#FD4B09" plain size="medium" closable
  10. :show="show" @close="close" @click="close"></u-tag>
  11. </view>
  12. </view>
  13. <view :style="{marginTop:show == true?'164rpx':'108rpx'}">
  14. <u-swiper :list="list3" indicator indicatorMode="dot" circular></u-swiper>
  15. </view>
  16. <view style="background-color: #fff;margin-bottom: 20rpx;">
  17. <view style="padding: 20rpx 0 0 0;">
  18. <u-grid :border="false" @click="click" col="5">
  19. <u-grid-item v-for="(item,index) in brandList" :key="index">
  20. <view v-if="item.brandFilesList.length>0" style="text-align: center;">
  21. <view v-for="(li,i) in item.brandFilesList" :key="i" :src="li.url">
  22. <image :src="li.url" style="width: 80rpx;height: 80rpx;"></image>
  23. <view style="font-size: 28rpx;">{{item.cname}}</view>
  24. </view>
  25. </view>
  26. <view v-else style="text-align: center;">
  27. <u-icon :customStyle="{paddingBottom:8+'rpx'}" labelPos="bottom" name="error-circle"
  28. :size="40"></u-icon>
  29. <view style="font-size: 28rpx;">{{item.cname}}</view>
  30. </view>
  31. </u-grid-item>
  32. </u-grid>
  33. </view>
  34. <view style="padding: 20rpx 20rpx;">
  35. <u-divider text="爆品推荐"></u-divider>
  36. </view>
  37. </view>
  38. <view style="margin-top: 0rpx;" class="content">
  39. <view class="left">
  40. <block v-for="(item,index) in dataList" :key="index" v-if="index%2==0">
  41. <view class="item" @click="choice(item,index)">
  42. <image v-for="(ite,ind) in item.filesList" :key="ind" v-if="ite.version === '0'" :src="ite.url"
  43. style="width: 100%;height: 340rpx;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;">
  44. </image>
  45. <view style="width: calc(100% - 20rpx);margin: 0 auto;">
  46. <u--text :text="item.cname" size="12"></u--text>
  47. <view style="display: flex;justify-content: space-between;margin: 5rpx auto;">
  48. <view style="padding-top: 12rpx;">
  49. <view v-if="item.billType == 0"
  50. style="font-size: 16rpx;background-color: #FD4B09;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  51. 今日达</view>
  52. <view v-else
  53. style="font-size: 16rpx;background-color: #5ac725;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  54. 次日达</view>
  55. </view>
  56. <view style="color: #FD4B09;font-size: 40rpx;">¥{{item.mallPrice}}</view>
  57. </view>
  58. </view>
  59. </view>
  60. </block>
  61. </view>
  62. <view class="right">
  63. <block v-for="(item,index) in dataList" :key="index" v-if="index%2==1">
  64. <view class="item" @click="choice(item,index)">
  65. <image v-for="(ite,ind) in item.filesList" :key="ind" v-if="ite.version === '0'" :src="ite.url"
  66. style="width: 100%;height: 340rpx;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;">
  67. </image>
  68. <view style="width: calc(100% - 20rpx);margin: 0 auto;">
  69. <u--text :text="item.cname" size="12"></u--text>
  70. <view style="display: flex;justify-content: space-between;margin: 5rpx auto;">
  71. <view style="padding-top: 12rpx;">
  72. <view v-if="item.billType == 0"
  73. style="font-size: 16rpx;background-color: #FD4B09;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  74. 今日达</view>
  75. <view v-else
  76. style="font-size: 16rpx;background-color: #5ac725;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  77. 次日达</view>
  78. </view>
  79. <view style="color: #FD4B09;font-size: 40rpx;">¥{{item.mallPrice}}</view>
  80. </view>
  81. </view>
  82. </view>
  83. </block>
  84. </view>
  85. </view>
  86. <u-empty v-if="dataList.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
  87. <u-loadmore v-if="page.total !== 0 && dataList.length != 0" :status="status" />
  88. </view>
  89. </template>
  90. <script>
  91. import {
  92. appList,
  93. userDept,
  94. validationCorpEmpty
  95. } from '@/api/tabBar/home.js'
  96. import {
  97. listAll
  98. } from '@/api/tabBar/classification.js'
  99. export default {
  100. data() {
  101. return {
  102. show:false,
  103. search: {},
  104. page: {
  105. total: 0,
  106. size: 10,
  107. current: 1
  108. },
  109. status: 'loadmore',
  110. dataList: [],
  111. list3: [
  112. 'https://td.echepei.com/file/applets/temporary/images/swiper1.jpg',
  113. 'https://td.echepei.com/file/applets/temporary/images/swiper2.jpg',
  114. 'https://td.echepei.com/file/applets/temporary/images/swiper3.jpg'
  115. ],
  116. brandList: []
  117. }
  118. },
  119. onReachBottom() {
  120. this.status = 'loading'
  121. if (this.dataList.length < this.page.total) {
  122. this.page.current++
  123. this.onSearch()
  124. } else {
  125. this.status = 'nomore'
  126. }
  127. },
  128. onShow() {
  129. uni.showLoading({
  130. title: '加载中',
  131. mask: true
  132. });
  133. validationCorpEmpty().then(res => {
  134. uni.hideLoading();
  135. //获取公司名称
  136. userDept().then(res => {
  137. uni.setNavigationBarTitle({
  138. title: res.data.fullName
  139. })
  140. })
  141. //获取所有品牌
  142. listAll().then(res => {
  143. this.brandList = res.data
  144. })
  145. this.page = {
  146. total: 0,
  147. size: 10,
  148. current: 1
  149. }
  150. this.dataList = []
  151. this.onSearch()
  152. }).catch(err => {
  153. uni.hideLoading();
  154. uni.$u.route('/pages/views/personalInformation/index');
  155. })
  156. },
  157. methods: {
  158. onSearch() {
  159. uni.showLoading({
  160. title: '加载中',
  161. mask: true
  162. });
  163. appList({
  164. size: this.page.size,
  165. current: this.page.current,
  166. ...this.search
  167. }).then(res => {
  168. this.dataList = this.dataList.concat(res.data.records)
  169. this.page.total = res.data.total
  170. if (this.dataList.length == res.data.total) {
  171. this.status = 'nomore'
  172. }
  173. uni.hideLoading();
  174. }).catch(err => {
  175. uni.hideLoading();
  176. })
  177. },
  178. close(){
  179. this.show = false
  180. this.search.brandId = ''
  181. this.search.brandName = ''
  182. },
  183. click(name) {
  184. this.page = {
  185. total: 0,
  186. size: 10,
  187. current: 1
  188. }
  189. this.dataList = []
  190. this.search = {
  191. ...this.search,
  192. brandId: this.brandList[name].id,
  193. brandNmae: this.brandList[name].cname,
  194. }
  195. this.show = true
  196. this.onSearch()
  197. },
  198. searchButton(value) {
  199. this.dataList = []
  200. this.page = {
  201. total: 0,
  202. size: 10,
  203. current: 1
  204. }
  205. this.search = {
  206. ...this.search,
  207. cname: value,
  208. }
  209. this.onSearch()
  210. },
  211. //打开明细
  212. choice(item, index) {
  213. uni.$u.route('/pages/views/buyGoods/commodityDetails', {
  214. id: item.id
  215. });
  216. },
  217. }
  218. }
  219. </script>
  220. <style lang="scss" scoped>
  221. ::v-deep .u-divider {
  222. margin: 0 !important;
  223. }
  224. .content {
  225. text-align: justify;
  226. }
  227. .left,
  228. .right {
  229. display: inline-block;
  230. vertical-align: top;
  231. width: 50%;
  232. }
  233. .item {
  234. width: calc(100% - 20rpx);
  235. margin: 0 auto;
  236. background-color: #FFFFFF;
  237. border-radius: 10rpx;
  238. break-inside: avoid;
  239. margin-bottom: 20rpx;
  240. }
  241. .search {
  242. width: 100%;
  243. position: fixed;
  244. top: 0;
  245. z-index: 8;
  246. background-color: #f2f2f2;
  247. }
  248. </style>