home.vue 18 KB

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