home.vue 14 KB

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