home.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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 v-if="false" 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
  10. :show="false" @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?'108rpx':'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 class="cardBox classification">
  24. <view class="classificationBox" v-for="(item,index) in brandList" :key="item.id"
  25. @click="click(index)">
  26. <view class="classificationBox_img">
  27. <image :src="item.brandFilesList[0].url" mode=""></image>
  28. </view>
  29. <view class="classificationBox_text" :style="PPindex == index?'color:#3c9cff':''">{{item.cname}}</view>
  30. </view>
  31. <view class="classificationBox" @click="Moreprojectsfun"
  32. v-if="brandList.length >= 7 && gengduofalse">
  33. <view class="classificationBox_img">
  34. <image src="../../static/images/view/buyGoods/gengduo.png"
  35. style="width: 60rpx;height: 60rpx;" mode=""></image>
  36. </view>
  37. <view class="classificationBox_text">更多项目</view>
  38. </view>
  39. <view class="classificationBox" @click="shohuifun"
  40. v-if="brandList.length >= zsbrandList.length && zsbrandList.length > 8">
  41. <view class="classificationBox_img">
  42. <image src="../../static/images/view/buyGoods/fanhui.png"
  43. style="width: 60rpx;height: 60rpx;" mode=""></image>
  44. </view>
  45. <view class="classificationBox_text">收回项目</view>
  46. </view>
  47. <!-- <u-grid :border="false" @click="click" col="4">
  48. <u-grid-item v-for="(item,index) in brandList" :key="index">
  49. <view v-if="item.brandFilesList.length>0" style="text-align: center;">
  50. <view v-for="(li,i) in item.brandFilesList" :key="i" :src="li.url">
  51. <image :src="li.url" style="width: 80rpx;height: 80rpx;"></image>
  52. <view style="font-size: 28rpx;" :style="PPindex == index?'color:#3c9cff':''" >{{item.cname}}</view>
  53. </view>
  54. </view>
  55. <view v-else style="text-align: center;">
  56. <u-icon :customStyle="{paddingBottom:8+'rpx'}" labelPos="bottom" name="error-circle"
  57. :size="40"></u-icon>
  58. <view style="font-size: 28rpx;">{{item.cname}}</view>
  59. </view>
  60. </u-grid-item>
  61. </u-grid> -->
  62. </view>
  63. <view style="margin-top: 10rpx;display: flex;">
  64. <u-tabs :list="dianjiqielist" v-model="groupModel" @click="groupChange"></u-tabs>
  65. </view>
  66. <view style="padding: 20rpx 20rpx;">
  67. <u-divider text="爆品推荐"></u-divider>
  68. </view>
  69. </view>
  70. <view style="margin-top: 0rpx;" class="content">
  71. <view class="left">
  72. <block v-for="(item,index) in dataList" :key="index" v-if="index%2==0">
  73. <view class="item" @click="choice(item,index)">
  74. <image v-for="(ite,ind) in item.filesList" :key="ind" v-if="ite.version === '0'" :src="ite.url"
  75. style="width: 100%;height: 340rpx;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;">
  76. </image>
  77. <view style="width: calc(100% - 20rpx);margin: 0 auto;">
  78. <u--text :text="item.cname" size="12"></u--text>
  79. <view style="display: flex;justify-content: space-between;margin: 5rpx auto;">
  80. <view style="padding-top: 12rpx;">
  81. <view v-if="item.billType == 0"
  82. style="font-size: 16rpx;background-color: #FD4B09;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  83. 今日达</view>
  84. <view v-else
  85. style="font-size: 16rpx;background-color: #5ac725;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  86. 次日达</view>
  87. </view>
  88. <view style="color: #FD4B09;font-size: 40rpx;">¥{{item.mallPrice}}</view>
  89. </view>
  90. </view>
  91. </view>
  92. </block>
  93. </view>
  94. <view class="right">
  95. <block v-for="(item,index) in dataList" :key="index" v-if="index%2==1">
  96. <view class="item" @click="choice(item,index)">
  97. <image v-for="(ite,ind) in item.filesList" :key="ind" v-if="ite.version === '0'" :src="ite.url"
  98. style="width: 100%;height: 340rpx;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;">
  99. </image>
  100. <view style="width: calc(100% - 20rpx);margin: 0 auto;">
  101. <u--text :text="item.cname" size="12"></u--text>
  102. <view style="display: flex;justify-content: space-between;margin: 5rpx auto;">
  103. <view style="padding-top: 12rpx;">
  104. <view v-if="item.billType == 0"
  105. style="font-size: 16rpx;background-color: #FD4B09;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  106. 今日达</view>
  107. <view v-else
  108. style="font-size: 16rpx;background-color: #5ac725;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  109. 次日达</view>
  110. </view>
  111. <view style="color: #FD4B09;font-size: 40rpx;">¥{{item.mallPrice}}</view>
  112. </view>
  113. </view>
  114. </view>
  115. </block>
  116. </view>
  117. </view>
  118. <u-empty v-if="dataList.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
  119. <u-loadmore v-if="page.total !== 0 && dataList.length != 0" :status="status" />
  120. </view>
  121. </template>
  122. <script>
  123. import {
  124. appList,
  125. userDept,
  126. validationCorpEmpty,
  127. brandDescList,
  128. brandDescDetail
  129. } from '@/api/tabBar/home.js'
  130. import {
  131. listAll
  132. } from '@/api/tabBar/classification.js'
  133. export default {
  134. data() {
  135. return {
  136. show:false,
  137. search: {},
  138. page: {
  139. total: 0,
  140. size: 10,
  141. current: 1
  142. },
  143. status: 'loadmore',
  144. dataList: [],
  145. list3: [],
  146. brandList: [],
  147. // 静音棉
  148. originalFactory:0,
  149. // 自修补
  150. selfRecovery:0,
  151. // 防爆
  152. explosionProof:0,
  153. dianjiqielist:[
  154. {
  155. name: '全部',
  156. },
  157. {
  158. name: '静音棉',
  159. },
  160. {
  161. name: '自修补',
  162. },
  163. {
  164. name: '防爆',
  165. }
  166. ],
  167. groupModel:null,
  168. PPindex:null,
  169. // 品牌
  170. zsbrandList:[],
  171. brandDescfor:7,
  172. gengduofalse:true,
  173. }
  174. },
  175. onReachBottom() {
  176. this.status = 'loading'
  177. if (this.dataList.length < this.page.total) {
  178. this.page.current++
  179. this.onSearch()
  180. } else {
  181. this.status = 'nomore'
  182. }
  183. },
  184. onShow() {
  185. // 轮播图
  186. brandDescList({type:'LBT'}).then(res=>{
  187. brandDescDetail({id:res.data.records[0].id}).then(res=>{
  188. console.log(res,193);
  189. // this.list3 = res.data.brandFilesList
  190. this.list3 = res.data.brandFilesList.map(item=>{
  191. return item.url
  192. })
  193. })
  194. })
  195. uni.showLoading({
  196. title: '加载中',
  197. mask: true
  198. });
  199. validationCorpEmpty().then(res => {
  200. uni.hideLoading();
  201. //获取公司名称
  202. userDept().then(res => {
  203. uni.setNavigationBarTitle({
  204. title: res.data.fullName
  205. })
  206. })
  207. //获取所有品牌
  208. listAll({type:'PP', enableOrNot:'1'}).then(res => {
  209. this.zsbrandList = res.data
  210. if (this.zsbrandList.length <= 8) {
  211. this.gengduofalse = false
  212. this.brandList = this.zsbrandList
  213. }else {
  214. for(let i in res.data) {
  215. if (i < this.brandDescfor) {
  216. this.brandList.push(res.data[i])
  217. }
  218. }
  219. }
  220. })
  221. this.page = {
  222. total: 0,
  223. size: 10,
  224. current: 1
  225. }
  226. this.dataList = []
  227. this.onSearch()
  228. }).catch(err => {
  229. uni.hideLoading();
  230. uni.$u.route('/pages/views/personalInformation/index');
  231. })
  232. },
  233. methods: {
  234. // 更多项目盒子
  235. Moreprojectsfun(){
  236. this.brandDescfor += 4
  237. this.brandList = []
  238. console.log(123);
  239. for(let i in this.zsbrandList) {
  240. if (i < this.brandDescfor) {
  241. this.brandList.push(this.zsbrandList[i])
  242. }
  243. }
  244. if (this.brandDescfor >= this.zsbrandList.length) {
  245. this.gengduofalse = false
  246. }
  247. },
  248. // 收回项目
  249. shohuifun(){
  250. this.brandDescfor = 7
  251. this.brandList = []
  252. for(let i in this.zsbrandList) {
  253. if (i < this.brandDescfor) {
  254. this.brandList.push(this.zsbrandList[i])
  255. }
  256. }
  257. this.gengduofalse = true
  258. // if (this.brandDescfor >= this.zsbrandList.length) {
  259. // this.gengduofalse = false
  260. // }
  261. },
  262. groupChange(e){
  263. console.log(e,228);
  264. if (e.name == '静音棉') {
  265. this.originalFactory = 1
  266. this.selfRecovery = 0
  267. this.explosionProof = 0
  268. }else if (e.name == '自修补') {
  269. this.originalFactory = 0
  270. this.selfRecovery = 1
  271. this.explosionProof = 0
  272. }else if (e.name == '防爆') {
  273. this.originalFactory = 0
  274. this.selfRecovery = 0
  275. this.explosionProof = 1
  276. }else {
  277. this.originalFactory = 0
  278. this.selfRecovery = 0
  279. this.explosionProof = 0
  280. }
  281. this.page.current = 1
  282. this.dataList = []
  283. this.onSearch()
  284. },
  285. // 点击筛选条件
  286. dianjiqiehuan(name){
  287. if (this[name] == 0) {
  288. this[name] = 1
  289. }else {
  290. this[name] = 0
  291. }
  292. this.click()
  293. },
  294. // 获取列表数据
  295. onSearch() {
  296. uni.showLoading({
  297. title: '加载中',
  298. mask: true
  299. });
  300. let obj = {}
  301. if(this.originalFactory){
  302. obj.originalFactory = 1
  303. }
  304. if (this.selfRecovery){
  305. obj.selfRecovery = 1
  306. }
  307. if (this.explosionProof) {
  308. obj.explosionProof = 1
  309. }
  310. appList({
  311. size: this.page.size,
  312. current: this.page.current,
  313. ...obj,
  314. ...this.search
  315. }).then(res => {
  316. this.dataList = this.dataList.concat(res.data.records)
  317. this.page.total = res.data.total
  318. if (this.dataList.length == res.data.total) {
  319. this.status = 'nomore'
  320. }
  321. uni.hideLoading();
  322. }).catch(err => {
  323. uni.hideLoading();
  324. })
  325. },
  326. close(){
  327. this.show = false
  328. this.search.brandId = ''
  329. this.search.brandName = ''
  330. },
  331. // 原厂点击差号
  332. yuanchangclose(type){
  333. if (type == 'originalFactory') {
  334. this.originalFactory = false
  335. }else if (type == 'selfRecovery') {
  336. this.selfRecovery = false
  337. }else {
  338. this.explosionProof = false
  339. }
  340. this.click()
  341. },
  342. click(name) {
  343. if (name != undefined) {
  344. this.page = {
  345. total: 0,
  346. size: 10,
  347. current: 1,
  348. }
  349. this.dataList = []
  350. if (this.PPindex == name) {
  351. this.PPindex = null
  352. delete this.search.brandId
  353. delete this.search.brandNmae
  354. }else {
  355. this.PPindex = name
  356. this.search = {
  357. ...this.search,
  358. brandId: this.brandList[this.PPindex].id,
  359. brandNmae: this.brandList[this.PPindex].cname,
  360. }
  361. }
  362. }
  363. this.show = true
  364. this.onSearch()
  365. },
  366. searchButton(value) {
  367. this.dataList = []
  368. this.page = {
  369. total: 0,
  370. size: 10,
  371. current: 1
  372. }
  373. this.search = {
  374. ...this.search,
  375. cname: value,
  376. }
  377. this.onSearch()
  378. },
  379. //打开明细
  380. choice(item, index) {
  381. uni.$u.route('/pages/views/buyGoods/commodityDetails', {
  382. id: item.id
  383. });
  384. },
  385. }
  386. }
  387. </script>
  388. <style lang="scss" scoped>
  389. ::v-deep .u-divider {
  390. margin: 0 !important;
  391. }
  392. .content {
  393. text-align: justify;
  394. }
  395. .left,
  396. .right {
  397. display: inline-block;
  398. vertical-align: top;
  399. width: 50%;
  400. }
  401. .item {
  402. width: calc(100% - 20rpx);
  403. margin: 0 auto;
  404. background-color: #FFFFFF;
  405. border-radius: 10rpx;
  406. break-inside: avoid;
  407. margin-bottom: 20rpx;
  408. }
  409. .search {
  410. width: 100%;
  411. position: fixed;
  412. top: 0;
  413. z-index: 8;
  414. background-color: #f2f2f2;
  415. }
  416. .cardBox {
  417. margin-top: 20rpx;
  418. background: #fff;
  419. border-radius: 12rpx;
  420. width: 100%;
  421. padding: 40rpx;
  422. box-sizing: border-box;
  423. .classificationBox {
  424. width: 25%;
  425. display: flex;
  426. flex-direction: column;
  427. align-items: center;
  428. margin: 10rpx 0;
  429. .classificationBox_img {
  430. width: 70rpx;
  431. height: 70rpx;
  432. // filter: grayscale(100%) hue-rotate(180deg) brightness(0.5) contrast(200%);
  433. // mix-blend-mode: screen;
  434. // background-color: #FF00FF;
  435. }
  436. .classificationBox_text {
  437. margin-top: 10rpx;
  438. font-size: 28rpx;
  439. color: #101010;
  440. }
  441. .brandDescColor {
  442. color: #92c3fd;
  443. // border: 2rpx solid;
  444. }
  445. }
  446. }
  447. .classification {
  448. display: flex;
  449. flex-wrap: wrap;
  450. min-height: 180rpx;
  451. }
  452. image {
  453. width: 100%;
  454. height: 100%;
  455. }
  456. </style>