home.vue 19 KB

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