home.vue 9.7 KB

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