home.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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" @click="searchButton"
  7. :animation="false" :disabled="true" :showAction="false" >
  8. </u-search>
  9. </view>
  10. <view v-if="false" style="margin: -15rpx auto 10rpx auto;display: flex;padding: 0 20rpx;z-index: 999;" >
  11. <u-tag :text="search.brandNmae" borderColor="#FD4B09" color="#FD4B09" plain size="medium" closable
  12. :show="false" @close="close" @click="close"></u-tag>
  13. <!-- <u-tag text="原厂" borderColor="#FD4B09" color="#FD4B09" plain size="medium" closable v-if="originalFactory"
  14. :show="originalFactory" @close="yuanchangclose('originalFactory')" @click="yuanchangclose('originalFactory')"></u-tag>
  15. <u-tag text="自修补" borderColor="#FD4B09" color="#FD4B09" plain size="medium" closable v-if="selfRecovery"
  16. :show="selfRecovery" @close="yuanchangclose('selfRecovery')" @click="yuanchangclose('selfRecovery')"></u-tag>
  17. <u-tag text="防爆" borderColor="#FD4B09" color="#FD4B09" plain size="medium" closable v-if="explosionProof"
  18. :show="explosionProof" @close="yuanchangclose('explosionProof')" @click="yuanchangclose('explosionProof')"></u-tag> -->
  19. </view>
  20. </view>
  21. <view :style="{marginTop:show == true?'108rpx':'108rpx'}">
  22. <u-swiper :list="list3" indicator indicatorMode="dot" circular></u-swiper>
  23. </view>
  24. <view style="background-color: #fff;margin-bottom: 20rpx;">
  25. <view class="cardBox classification">
  26. <view class="classificationBox" v-for="(item,index) in brandList" :key="item.id"
  27. @click="click(index)">
  28. <view class="classificationBox_img">
  29. <image :src="item.brandFilesList[0].url" mode=""></image>
  30. </view>
  31. <view class="classificationBox_text" :style="PPindex == index?'color:#3c9cff':''">{{item.cname}}</view>
  32. </view>
  33. <view class="classificationBox" @click="Moreprojectsfun"
  34. v-if="brandList.length >= 7 && gengduofalse">
  35. <view class="classificationBox_img">
  36. <image src="../../static/images/view/buyGoods/gengduo.png"
  37. style="width: 60rpx;height: 60rpx;" mode=""></image>
  38. </view>
  39. <view class="classificationBox_text">更多项目</view>
  40. </view>
  41. <view class="classificationBox" @click="shohuifun"
  42. v-if="brandList.length >= zsbrandList.length && zsbrandList.length > 8">
  43. <view class="classificationBox_img">
  44. <image src="../../static/images/view/buyGoods/fanhui.png"
  45. style="width: 60rpx;height: 60rpx;" mode=""></image>
  46. </view>
  47. <view class="classificationBox_text">收回项目</view>
  48. </view>
  49. <!-- <u-grid :border="false" @click="click" col="4">
  50. <u-grid-item v-for="(item,index) in brandList" :key="index">
  51. <view v-if="item.brandFilesList.length>0" style="text-align: center;">
  52. <view v-for="(li,i) in item.brandFilesList" :key="i" :src="li.url">
  53. <image :src="li.url" style="width: 80rpx;height: 80rpx;"></image>
  54. <view style="font-size: 28rpx;" :style="PPindex == index?'color:#3c9cff':''" >{{item.cname}}</view>
  55. </view>
  56. </view>
  57. <view v-else style="text-align: center;">
  58. <u-icon :customStyle="{paddingBottom:8+'rpx'}" labelPos="bottom" name="error-circle"
  59. :size="40"></u-icon>
  60. <view style="font-size: 28rpx;">{{item.cname}}</view>
  61. </view>
  62. </u-grid-item>
  63. </u-grid> -->
  64. </view>
  65. <view style="margin-top: 10rpx;display: flex;">
  66. <u-tabs :list="dianjiqielist" v-model="groupModel" @click="groupChange"></u-tabs>
  67. </view>
  68. <view style="padding: 20rpx 20rpx;">
  69. <u-divider text="爆品推荐"></u-divider>
  70. </view>
  71. </view>
  72. <view style="margin-top: 0rpx;" class="content">
  73. <view class="left">
  74. <block v-for="(item,index) in dataList" :key="index" v-if="index%2==0">
  75. <view class="item" @click="choice(item,index)">
  76. <image v-for="(ite,ind) in item.filesList" :key="ind" v-if="ite.version === '0'" :src="ite.url"
  77. style="width: 100%;height: 340rpx;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;">
  78. </image>
  79. <view style="width: calc(100% - 20rpx);margin: 0 auto;">
  80. <u--text :text="item.cname" size="12"></u--text>
  81. <view style="display: flex;justify-content: space-between;margin: 5rpx auto;">
  82. <view style="padding-top: 12rpx;">
  83. <view v-if="item.billType == 0"
  84. style="font-size: 16rpx;background-color: #FD4B09;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  85. 今日达</view>
  86. <view v-else
  87. style="font-size: 16rpx;background-color: #5ac725;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  88. 次日达</view>
  89. </view>
  90. <view style="color: #FD4B09;font-size: 40rpx;">¥{{checkStatus == '通过'?item.mallPrice:'***'}}</view>
  91. </view>
  92. </view>
  93. </view>
  94. </block>
  95. </view>
  96. <view class="right">
  97. <block v-for="(item,index) in dataList" :key="index" v-if="index%2==1">
  98. <view class="item" @click="choice(item,index)">
  99. <image v-for="(ite,ind) in item.filesList" :key="ind" v-if="ite.version === '0'" :src="ite.url"
  100. style="width: 100%;height: 340rpx;border-top-left-radius: 20rpx;
  101. border-top-right-radius: 20rpx;">
  102. </image>
  103. <view style="width: calc(100% - 20rpx);margin: 0 auto;">
  104. <u--text :text="item.cname" size="12"></u--text>
  105. <view style="display: flex;justify-content: space-between;margin: 5rpx auto;">
  106. <view style="padding-top: 12rpx;">
  107. <view v-if="item.billType == 0"
  108. style="font-size: 16rpx;background-color: #FD4B09;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  109. 今日达</view>
  110. <view v-else
  111. style="font-size: 16rpx;background-color: #5ac725;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  112. 次日达</view>
  113. </view>
  114. <view style="color: #FD4B09;font-size: 40rpx;">¥{{checkStatus == '通过'?item.mallPrice:'***'}}</view>
  115. </view>
  116. </view>
  117. </view>
  118. </block>
  119. </view>
  120. </view>
  121. <u-empty v-if="dataList.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
  122. <u-loadmore v-if="page.total !== 0 && dataList.length != 0" :status="status" />
  123. <view v-if="userInfo.tenant_id != '000000'" class="suspensionBox"
  124. @click="salesmanShow=true">
  125. <u-icon name="server-fill" color="#2979ff" size="40"></u-icon>
  126. </view>
  127. <u-modal :show="salesmanShow" title="业务员联系方式" showCancelButton
  128. confirmText="拨号" cancelText="关闭"
  129. @confirm="clickCall" @cancel="salesmanShow=false">
  130. <view class="slot-content">
  131. <view style="margin-bottom: 10rpx;">业务员:{{salesmanName?salesmanName:''}}</view>
  132. <view>电话:{{phoneNumber?phoneNumber:''}}</view>
  133. </view>
  134. </u-modal>
  135. </view>
  136. </template>
  137. <script>
  138. import {
  139. appList,
  140. userDept,
  141. validationCorpEmpty,
  142. brandDescList,
  143. brandDescDetail
  144. } from '@/api/tabBar/home.js'
  145. import {
  146. listAll
  147. } from '@/api/tabBar/classification.js'
  148. import {
  149. details,
  150. nameDetail
  151. } from '@/api/views/personalInformation/index.js'
  152. export default {
  153. data() {
  154. return {
  155. show:false,
  156. search: {},
  157. page: {
  158. total: 0,
  159. size: 10,
  160. current: 1
  161. },
  162. status: 'loadmore',
  163. dataList: [],
  164. list3: [],
  165. brandList: [],
  166. // 静音棉
  167. originalFactory:0,
  168. // 自修补
  169. selfRecovery:0,
  170. // 防爆
  171. explosionProof:0,
  172. dianjiqielist:[
  173. {
  174. name: '全部',
  175. },
  176. {
  177. name: '静音棉',
  178. },
  179. {
  180. name: '自修补',
  181. },
  182. {
  183. name: '防爆',
  184. }
  185. ],
  186. groupModel:null,
  187. PPindex:null,
  188. // 品牌
  189. zsbrandList:[],
  190. brandDescfor:7,
  191. gengduofalse:true,
  192. // 审核状态
  193. checkStatus:'',
  194. enableOrNot:'',
  195. salesmanName:'', // 业务员姓名
  196. phoneNumber:'', // 业务员联系电话
  197. salesmanShow:false, // 联系业务员弹窗
  198. userInfo:{}, // 当前用户数据
  199. }
  200. },
  201. onReachBottom() {
  202. this.status = 'loading'
  203. if (this.dataList.length < this.page.total) {
  204. this.page.current++
  205. this.onSearch()
  206. } else {
  207. this.status = 'nomore'
  208. }
  209. },
  210. onLoad(e) {
  211. console.log(e,200);
  212. },
  213. onShow() {
  214. this.userInfo = uni.getStorageSync('userInfo')
  215. if (uni.getStorageSync('cname')) {
  216. this.$set(this.search,'cname',JSON.parse(JSON.stringify(uni.getStorageSync('cname'))))
  217. uni.removeStorageSync('cname')
  218. }
  219. // 获取审核状态
  220. details().then(res => {
  221. this.checkStatus = res.data.checkStatus
  222. this.enableOrNot = res.data.enableOrNot
  223. uni.setStorageSync('checkStatus', res.data.checkStatus);
  224. uni.setStorageSync('enableOrNot', res.data.enableOrNot);
  225. // 查询业务员详情拿取手机号
  226. this.salesmanName = res.data.salesmanName
  227. if (!this.phoneNumber) {
  228. nameDetail({id:res.data.salesmanId}).then(res=>{
  229. this.phoneNumber = res.data.phone
  230. })
  231. }
  232. })
  233. // 轮播图
  234. brandDescList({type:'LBT'}).then(res=>{
  235. brandDescDetail({id:res.data.records[0].id}).then(res=>{
  236. console.log(res,193);
  237. // this.list3 = res.data.brandFilesList
  238. this.list3 = res.data.brandFilesList.map(item=>{
  239. return item.url
  240. })
  241. })
  242. })
  243. uni.showLoading({
  244. title: '加载中',
  245. mask: true
  246. });
  247. // 判断是怎么登录的
  248. if (JSON.parse(JSON.stringify(uni.getStorageSync('userInfo'))).tenant_id != '000000') {
  249. // 查看是否有客户信息
  250. validationCorpEmpty().then(res => {
  251. uni.hideLoading();
  252. //获取公司名称
  253. userDept().then(res => {
  254. uni.setNavigationBarTitle({
  255. title: res.data.fullName
  256. })
  257. })
  258. //获取所有品牌
  259. listAll({type:'PP', enableOrNot:'1'}).then(res => {
  260. this.zsbrandList = []
  261. this.brandList = []
  262. // this.zsbrandList = res.data
  263. this.zsbrandList = res.data.sort(this.compare('sort'))
  264. if (this.zsbrandList.length <= 8) {
  265. this.gengduofalse = false
  266. this.brandList = this.zsbrandList
  267. }else {
  268. for(let i in res.data) {
  269. if (i < this.brandDescfor) {
  270. this.brandList.push(res.data[i])
  271. }
  272. }
  273. }
  274. })
  275. this.page = {
  276. total: 0,
  277. size: 10,
  278. current: 1
  279. }
  280. this.dataList = []
  281. this.onSearch()
  282. }).catch(err => {
  283. uni.hideLoading();
  284. uni.$u.route('/pages/views/personalInformation/index');
  285. })
  286. }else {
  287. uni.setNavigationBarTitle({
  288. title: '青岛途宝'
  289. })
  290. //获取所有品牌
  291. listAll({type:'PP', enableOrNot:'1'}).then(res => {
  292. this.zsbrandList = []
  293. this.brandList = []
  294. // this.zsbrandList = res.data
  295. this.zsbrandList = res.data.sort(this.compare('sort'))
  296. if (this.zsbrandList.length <= 8) {
  297. this.gengduofalse = false
  298. this.brandList = this.zsbrandList
  299. }else {
  300. for(let i in res.data) {
  301. if (i < this.brandDescfor) {
  302. this.brandList.push(res.data[i])
  303. }
  304. }
  305. }
  306. })
  307. this.page = {
  308. total: 0,
  309. size: 10,
  310. current: 1
  311. }
  312. this.dataList = []
  313. this.onSearch()
  314. }
  315. uni.hideLoading();
  316. },
  317. methods: {
  318. // 点击联系业务员
  319. clickCall() {
  320. uni.makePhoneCall({
  321. phoneNumber: this.phoneNumber,
  322. success: function() {
  323. console.log('拨打电话成功');
  324. this.salesmanShow = false
  325. },
  326. fail() {
  327. console.log('打电话失败了');
  328. this.salesmanShow = false
  329. }
  330. })
  331. },
  332. // 数组排序 property:根据什么属性排序
  333. compare(property){
  334. return function(a,b) {
  335. var value1 = a[property]
  336. var value2 = b[property]
  337. return value1 - value2
  338. }
  339. },
  340. // 更多项目盒子
  341. Moreprojectsfun(){
  342. this.brandDescfor += 4
  343. this.brandList = []
  344. console.log(123);
  345. for(let i in this.zsbrandList) {
  346. if (i < this.brandDescfor) {
  347. this.brandList.push(this.zsbrandList[i])
  348. }
  349. }
  350. if (this.brandDescfor >= this.zsbrandList.length) {
  351. this.gengduofalse = false
  352. }
  353. },
  354. // 收回项目
  355. shohuifun(){
  356. this.brandDescfor = 7
  357. this.brandList = []
  358. for(let i in this.zsbrandList) {
  359. if (i < this.brandDescfor) {
  360. this.brandList.push(this.zsbrandList[i])
  361. }
  362. }
  363. this.gengduofalse = true
  364. // if (this.brandDescfor >= this.zsbrandList.length) {
  365. // this.gengduofalse = false
  366. // }
  367. },
  368. groupChange(e){
  369. console.log(e,228);
  370. if (e.name == '静音棉') {
  371. this.originalFactory = 1
  372. this.selfRecovery = 0
  373. this.explosionProof = 0
  374. }else if (e.name == '自修补') {
  375. this.originalFactory = 0
  376. this.selfRecovery = 1
  377. this.explosionProof = 0
  378. }else if (e.name == '防爆') {
  379. this.originalFactory = 0
  380. this.selfRecovery = 0
  381. this.explosionProof = 1
  382. }else {
  383. this.originalFactory = 0
  384. this.selfRecovery = 0
  385. this.explosionProof = 0
  386. }
  387. this.page.current = 1
  388. this.dataList = []
  389. this.onSearch()
  390. },
  391. // 点击筛选条件
  392. dianjiqiehuan(name){
  393. if (this[name] == 0) {
  394. this[name] = 1
  395. }else {
  396. this[name] = 0
  397. }
  398. this.click()
  399. },
  400. // 获取列表数据
  401. onSearch() {
  402. uni.showLoading({
  403. title: '加载中',
  404. mask: true
  405. });
  406. let obj = {}
  407. if(this.originalFactory){
  408. obj.originalFactory = 1
  409. }
  410. if (this.selfRecovery){
  411. obj.selfRecovery = 1
  412. }
  413. if (this.explosionProof) {
  414. obj.explosionProof = 1
  415. }
  416. appList({
  417. size: this.page.size,
  418. current: this.page.current,
  419. ...obj,
  420. ...this.search
  421. }).then(res => {
  422. this.dataList = this.dataList.concat(res.data.records)
  423. this.page.total = res.data.total
  424. if (this.dataList.length == res.data.total) {
  425. this.status = 'nomore'
  426. }
  427. uni.hideLoading();
  428. }).catch(err => {
  429. uni.hideLoading();
  430. })
  431. },
  432. close(){
  433. this.show = false
  434. this.search.brandId = ''
  435. this.search.brandName = ''
  436. },
  437. // 原厂点击差号
  438. yuanchangclose(type){
  439. if (type == 'originalFactory') {
  440. this.originalFactory = false
  441. }else if (type == 'selfRecovery') {
  442. this.selfRecovery = false
  443. }else {
  444. this.explosionProof = false
  445. }
  446. this.click()
  447. },
  448. click(name) {
  449. if (name != undefined) {
  450. this.page = {
  451. total: 0,
  452. size: 10,
  453. current: 1,
  454. }
  455. this.dataList = []
  456. if (this.PPindex == name) {
  457. this.PPindex = null
  458. delete this.search.brandId
  459. delete this.search.brandNmae
  460. }else {
  461. this.PPindex = name
  462. this.search = {
  463. ...this.search,
  464. brandId: this.brandList[this.PPindex].id,
  465. brandNmae: this.brandList[this.PPindex].cname,
  466. }
  467. }
  468. }
  469. this.show = true
  470. this.onSearch()
  471. },
  472. searchButton(value) {
  473. this.dataList = []
  474. this.page = {
  475. total: 0,
  476. size: 10,
  477. current: 1
  478. }
  479. this.search = {
  480. ...this.search,
  481. cname: value,
  482. }
  483. // this.onSearch()
  484. uni.setStorageSync('homeSearch', this.search);
  485. this.search.cname = null
  486. uni.switchTab({
  487. url: '/pages/tabBar/classification',
  488. })
  489. },
  490. //打开明细
  491. choice(item, index) {
  492. if (this.checkStatus != '通过') {
  493. uni.showToast({
  494. title: "当前用户未授权,请联系客服",
  495. icon: "none",
  496. mask:true
  497. });
  498. return
  499. }
  500. uni.$u.route('/pages/views/buyGoods/commodityDetails', {
  501. id: item.id
  502. });
  503. },
  504. }
  505. }
  506. </script>
  507. <style lang="scss" scoped>
  508. .suspensionBox {
  509. width: 100rpx;
  510. height: 100rpx;
  511. background: #fff;
  512. border-radius: 50%;
  513. position: fixed;
  514. top: 60%;
  515. right: 2%;
  516. box-shadow: 2px 2px 8px 1px rgba(0, 0, 0, .5);
  517. display: flex;
  518. align-items: center;
  519. justify-content: center;
  520. }
  521. ::v-deep .u-divider {
  522. margin: 0 !important;
  523. }
  524. .content {
  525. text-align: justify;
  526. }
  527. .left,
  528. .right {
  529. display: inline-block;
  530. vertical-align: top;
  531. width: 50%;
  532. }
  533. .item {
  534. width: calc(100% - 20rpx);
  535. margin: 0 auto;
  536. background-color: #FFFFFF;
  537. border-radius: 10rpx;
  538. break-inside: avoid;
  539. margin-bottom: 20rpx;
  540. }
  541. .search {
  542. width: 100%;
  543. position: fixed;
  544. top: 0;
  545. z-index: 8;
  546. background-color: #f2f2f2;
  547. }
  548. .cardBox {
  549. margin-top: 20rpx;
  550. background: #fff;
  551. border-radius: 12rpx;
  552. width: 100%;
  553. padding: 40rpx;
  554. box-sizing: border-box;
  555. .classificationBox {
  556. width: 25%;
  557. display: flex;
  558. flex-direction: column;
  559. align-items: center;
  560. margin: 10rpx 0;
  561. .classificationBox_img {
  562. width: 70rpx;
  563. height: 70rpx;
  564. // filter: grayscale(100%) hue-rotate(180deg) brightness(0.5) contrast(200%);
  565. // mix-blend-mode: screen;
  566. // background-color: #FF00FF;
  567. }
  568. .classificationBox_text {
  569. margin-top: 10rpx;
  570. font-size: 28rpx;
  571. color: #101010;
  572. }
  573. .brandDescColor {
  574. color: #92c3fd;
  575. // border: 2rpx solid;
  576. }
  577. }
  578. }
  579. .classification {
  580. display: flex;
  581. flex-wrap: wrap;
  582. min-height: 180rpx;
  583. }
  584. image {
  585. width: 100%;
  586. height: 100%;
  587. }
  588. </style>