home.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. <template>
  2. <view class="container">
  3. <image class="background-image" src="/static/images/tabBar/527@2x.png" style="width: 100%;height: 320rpx;"
  4. mode="scaleToFill"></image>
  5. <view>
  6. <view style="display: flex;align-items: center;">
  7. <view style="width: 75%;">
  8. <!-- <uni-search-bar radius="100" placeholder="请输入商品名称" readonly bgColor="#fff"/> -->
  9. <u-search placeholder="请输入商品名称" bgColor="#fff" readonly :showAction="false"
  10. searchIconColor='#E75F37' :searchIconSize='24' margin='20rpx' disabled
  11. @click="insearchPage"></u-search>
  12. </view>
  13. <view style="height: 64rpx;width: 25%;" @click="clickVehicle">
  14. <image class="background-image" src="/static/images/tabBar/car@2x.png"
  15. style="width:164rpx;height: 64rpx;" mode="scaleToFill"></image>
  16. </view>
  17. </view>
  18. </view>
  19. <view style="padding: 0 20rpx 20rpx 20rpx;">
  20. <view style="border-radius: 10rpx;overflow: hidden;" v-if="list3.length>0">
  21. <uni-swiper-dot :info="list3" :current="dotCurrent" mode="round" :dots-styles="dotsStyles">
  22. <swiper circular :autoplay="true" :interval="2000" :duration="500" @change="swiperChange">
  23. <swiper-item v-for="(item,index) in list3" :key="index">
  24. <image mode="scaleToFill" :src="item" @error="imageError" style="width: 100%;height: 100%;">
  25. </image>
  26. </swiper-item>
  27. </swiper>
  28. </uni-swiper-dot>
  29. </view>
  30. <view class="card" v-if="brandList.length >0" style="padding: 20rpx;">
  31. <uni-grid :column="5" :show-border="false" :square="false" :highlight="false">
  32. <uni-grid-item v-for="(item ,index) in brandList" :key="index">
  33. <view class="brandImg" @click="click(index)">
  34. <image :src="item.brandFilesList[0].url" mode="aspectFit"
  35. style="width:88rpx;height: 88rpx;border-radius: 100%;" />
  36. <text class="text">{{item.cname}}</text>
  37. </view>
  38. </uni-grid-item>
  39. <uni-grid-item v-if="brandList.length >= 9 && gengduofalse">
  40. <view class="brandImg" @click="Moreprojectsfun">
  41. <image src="/static/images/view/buyGoods/2842x.png" mode="aspectFit"
  42. style="width:88rpx;height: 88rpx;border-radius: 100%;" />
  43. <text class="text">更多品牌</text>
  44. </view>
  45. </uni-grid-item>
  46. <uni-grid-item v-if="brandList.length >= zsbrandList.length && zsbrandList.length > 8">
  47. <view class="brandImg" @click="shohuifun">
  48. <image src="../../static/images/view/buyGoods/fanhui.png" mode="aspectFit"
  49. style="width:88rpx;height: 88rpx;border-radius: 100%;" />
  50. <text class="text">回收品牌</text>
  51. </view>
  52. </uni-grid-item>
  53. </uni-grid>
  54. </view>
  55. <view @click="inIntegralMall">
  56. <image src="/static/images/tabBar/JF.png" style="width: 100%;height: 251rpx;" mode="scaleToFill">
  57. </image>
  58. </view>
  59. <view class="card">
  60. <u-tabs :list="dianjiqielist" v-model="groupModel" @click="groupChange" :lineHeight='0'
  61. :activeStyle="activeStyle" :inactiveStyle="inactiveStyle"></u-tabs>
  62. <view style="padding: 16rpx;border-top: 2px #F1F1F1 solid;;">
  63. <uni-grid :column="2" :show-border="false" :square="false" :highlight="false"
  64. v-if="dataList.length > 0">
  65. <uni-grid-item v-for="(item ,index) in dataList" :key="index">
  66. <view class="goodsImg" @click="choice(item,index)">
  67. <image v-if="item.inventoryLocal > 0" src="/static/images/tabBar/xsd2x.png"
  68. mode="aspectFit" class='imgIcon' />
  69. <image v-if="item.inventoryLocal == 0&&item.inventoryShare > 0"
  70. src="/static/images/tabBar/crd2x.png" mode="aspectFit" class='imgIcon' />
  71. <image :src="item.url" mode="aspectFit"
  72. style="width:300rpx;height:300rpx;border-radius:20rpx;border: 2rpx #E7E7E7 solid;" />
  73. <text class="text">{{item.cname}}</text>
  74. <text
  75. style="color:#E75F37;width: 300rpx;font-weight: bold;font-size: 32rpx;">¥{{checkStatus == '通过'?item.mallPrice:'***'}}</text>
  76. </view>
  77. </uni-grid-item>
  78. </uni-grid>
  79. <u-empty v-if="dataList.length == 0" mode="list" icon="/static/images/tabBar/emptylist.jpg"
  80. text='暂无数据' />
  81. </view>
  82. </view>
  83. <u-loadmore v-if="page.total !== 0 && dataList.length != 0" :status="status" />
  84. <u-back-top :scroll-top="scrollTop"></u-back-top>
  85. <view v-if="userInfo.tenant_id != '000000'" class="suspensionBox" @click="salesmanShow=true">
  86. <u-icon name="server-fill" color="#2979ff" size="30"></u-icon>
  87. </view>
  88. <u-modal :show="salesmanShow" title="业务员联系方式" showCancelButton confirmText="拨号" cancelText="关闭"
  89. @confirm="clickCall" @cancel="salesmanShow=false">
  90. <view class="slot-content">
  91. <view style="margin-bottom: 10rpx;">业务员:{{salesmanName?salesmanName:''}}</view>
  92. <view>电话:{{phoneNumber?phoneNumber:''}}</view>
  93. </view>
  94. </u-modal>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. import {
  100. appList,
  101. appListNew,
  102. userDept,
  103. validationCorpEmpty,
  104. isProcurement,
  105. brandDescList,
  106. brandDescDetail
  107. } from '@/api/tabBar/homeNew.js'
  108. import {
  109. shoppingCartList
  110. } from '@/api/tabBar/shoppingCart.js'
  111. import {
  112. listAll
  113. } from '@/api/tabBar/classification.js'
  114. import {
  115. details,
  116. nameDetail
  117. } from '@/api/views/personalInformation/index.js'
  118. import {
  119. activityList
  120. } from '@/api/tabBar/activity.js'
  121. export default {
  122. data() {
  123. return {
  124. scrollTop: 0,
  125. activeStyle: {
  126. color: '#E75F37',
  127. fontWeight: 'bold',
  128. fontSize: '28rpx'
  129. },
  130. inactiveStyle: {
  131. color: '#797979',
  132. fontSize: '28rpx'
  133. },
  134. dotsStyles: {
  135. backgroundColor: 'rgba(0, 0, 0, .1)',
  136. border: '1px #fff solid',
  137. color: '#fff',
  138. selectedBackgroundColor: '#fff',
  139. selectedBorder: '1px #fff solid'
  140. },
  141. dotCurrent: 0,
  142. show: false,
  143. search: {},
  144. page: {
  145. total: 0,
  146. size: 10,
  147. current: 1
  148. },
  149. status: 'loadmore',
  150. dataList: [],
  151. list3: [],
  152. brandList: [],
  153. // 静音棉
  154. originalFactory: 0,
  155. // 自修补
  156. selfRecovery: 0,
  157. // 防爆
  158. explosionProof: 0,
  159. dianjiqielist: [{
  160. name: '全部',
  161. },
  162. {
  163. name: '静音棉',
  164. },
  165. {
  166. name: '自修补',
  167. },
  168. {
  169. name: '防爆',
  170. }
  171. ],
  172. groupModel: null,
  173. PPindex: null,
  174. // 品牌
  175. zsbrandList: [],
  176. brandDescfor: 9,
  177. gengduofalse: true,
  178. // 审核状态
  179. checkStatus: '',
  180. enableOrNot: '',
  181. salesmanName: '', // 业务员姓名
  182. phoneNumber: '', // 业务员联系电话
  183. salesmanShow: false, // 联系业务员弹窗
  184. userInfo: {}, // 当前用户数据
  185. }
  186. },
  187. onPageScroll(e) {
  188. this.scrollTop = e.scrollTop;
  189. },
  190. onPullDownRefresh() {
  191. // 调用数据刷新方法
  192. this.refreshData();
  193. setTimeout(() => {
  194. uni.stopPullDownRefresh(); // 停止下拉刷新动画
  195. }, 1000);
  196. },
  197. onReachBottom() {
  198. this.status = 'loading'
  199. if (this.dataList.length < this.page.total) {
  200. this.page.current++
  201. this.onSearch()
  202. } else {
  203. this.status = 'nomore'
  204. }
  205. },
  206. onLoad(e) {
  207. isProcurement({
  208. "param": "whether.open.share"
  209. }).then(res => {
  210. uni.setStorageSync('whether_openShare', res.data);
  211. })
  212. this.userInfo = uni.getStorageSync('userInfo')
  213. // 轮播图
  214. brandDescList({
  215. type: 'LBT',
  216. whetherIntegral: "0"
  217. }).then(res => {
  218. brandDescDetail({
  219. id: res.data.records[0].id
  220. }).then(res => {
  221. this.list3 = res.data.brandFilesList.map(item => {
  222. return item.url
  223. })
  224. })
  225. })
  226. uni.showLoading({
  227. title: '加载中',
  228. mask: true
  229. });
  230. // 判断是怎么登录的
  231. if (JSON.parse(JSON.stringify(uni.getStorageSync('userInfo'))).tenant_id != '000000') {
  232. // 查看是否有客户信息
  233. validationCorpEmpty().then(res => {
  234. uni.hideLoading();
  235. //获取公司名称
  236. userDept().then(res => {
  237. uni.setNavigationBarTitle({
  238. title: res.data.fullName
  239. })
  240. })
  241. //获取所有品牌
  242. listAll({
  243. type: 'PP',
  244. enableOrNot: '1',
  245. whetherIntegral: '0'
  246. }).then(res => {
  247. this.zsbrandList = []
  248. this.brandList = []
  249. // this.zsbrandList = res.data
  250. this.zsbrandList = res.data.sort(this.compare('sort'))
  251. if (this.zsbrandList.length <= 10) {
  252. this.gengduofalse = false
  253. this.brandList = this.zsbrandList
  254. } else {
  255. for (let i in res.data) {
  256. if (i < this.brandDescfor) {
  257. this.brandList.push(res.data[i])
  258. }
  259. }
  260. }
  261. })
  262. this.page = {
  263. total: 0,
  264. size: 10,
  265. current: 1
  266. }
  267. this.dataList = []
  268. this.onSearch()
  269. }).catch(err => {
  270. uni.hideLoading();
  271. uni.$u.route('/pages/views/personalInformation/index');
  272. })
  273. } else {
  274. uni.setNavigationBarTitle({
  275. title: '青岛途宝'
  276. })
  277. //获取所有品牌
  278. listAll({
  279. type: 'PP',
  280. enableOrNot: '1',
  281. whetherIntegral: '0'
  282. }).then(res => {
  283. this.zsbrandList = []
  284. this.brandList = []
  285. // this.zsbrandList = res.data
  286. this.zsbrandList = res.data.sort(this.compare('sort'))
  287. if (this.zsbrandList.length <= 10) {
  288. this.gengduofalse = false
  289. this.brandList = this.zsbrandList
  290. } else {
  291. for (let i in res.data) {
  292. if (i < this.brandDescfor) {
  293. this.brandList.push(res.data[i])
  294. }
  295. }
  296. }
  297. })
  298. this.page = {
  299. total: 0,
  300. size: 10,
  301. current: 1
  302. }
  303. this.dataList = []
  304. this.onSearch()
  305. }
  306. uni.hideLoading();
  307. },
  308. onShow() {
  309. activityList({
  310. current: 1,
  311. size: 10,
  312. status: 1
  313. }).then(res => {
  314. uni.setTabBarBadge({
  315. index: 1, // tabIndex,tabBar的哪一项,从0开始
  316. text: res.data.total.toString() // 显示的文本,超过 99 显示成 “…”
  317. })
  318. })
  319. shoppingCartList({
  320. whetherIntegral: '0'
  321. }).then(res => {
  322. let num = 0
  323. res.data.forEach(e => {
  324. num = num + e.list.length
  325. })
  326. uni.setTabBarBadge({
  327. index: 3, // tabIndex,tabBar的哪一项,从0开始
  328. text: num.toString() // 显示的文本,超过 99 显示成 “…”
  329. })
  330. })
  331. // 获取审核状态
  332. details().then(res => {
  333. this.checkStatus = res.data.checkStatus
  334. this.enableOrNot = res.data.enableOrNot
  335. uni.setStorageSync('checkStatus', res.data.checkStatus);
  336. uni.setStorageSync('enableOrNot', res.data.enableOrNot);
  337. // 查询业务员详情拿取手机号
  338. this.salesmanName = res.data.salesmanName
  339. if (!this.phoneNumber) {
  340. nameDetail({
  341. id: res.data.salesmanId
  342. }).then(res => {
  343. this.phoneNumber = res.data.phone
  344. })
  345. }
  346. })
  347. },
  348. methods: {
  349. refreshData() {
  350. listAll({
  351. type: 'PP',
  352. enableOrNot: '1',
  353. whetherIntegral: '0'
  354. }).then(res => {
  355. this.zsbrandList = []
  356. this.brandList = []
  357. // this.zsbrandList = res.data
  358. this.zsbrandList = res.data.sort(this.compare('sort'))
  359. if (this.zsbrandList.length <= 10) {
  360. this.gengduofalse = false
  361. this.brandList = this.zsbrandList
  362. } else {
  363. for (let i in res.data) {
  364. if (i < this.brandDescfor) {
  365. this.brandList.push(res.data[i])
  366. }
  367. }
  368. }
  369. })
  370. this.page = {
  371. total: 0,
  372. size: 10,
  373. current: 1
  374. }
  375. this.search = {}
  376. this.dataList = []
  377. this.onSearch()
  378. },
  379. insearchPage() {
  380. uni.$emit('homeSearch', true)
  381. uni.navigateTo({
  382. url: '/pages/tabBar/homeSearch'
  383. })
  384. },
  385. // 车型
  386. clickVehicle() {
  387. this.$u.route('/pages/tabBar/vehicleModel');
  388. },
  389. swiperChange(e) {
  390. this.dotCurrent = e.detail.current;
  391. },
  392. // 点击联系业务员
  393. clickCall() {
  394. uni.makePhoneCall({
  395. phoneNumber: this.phoneNumber,
  396. success: function() {
  397. console.log('拨打电话成功');
  398. this.salesmanShow = false
  399. },
  400. fail() {
  401. console.log('打电话失败了');
  402. this.salesmanShow = false
  403. }
  404. })
  405. },
  406. // 数组排序 property:根据什么属性排序
  407. compare(property) {
  408. return function(a, b) {
  409. var value1 = a[property]
  410. var value2 = b[property]
  411. return value1 - value2
  412. }
  413. },
  414. // 更多项目盒子
  415. Moreprojectsfun() {
  416. this.brandDescfor += 5
  417. this.brandList = []
  418. console.log(123);
  419. for (let i in this.zsbrandList) {
  420. if (i < this.brandDescfor) {
  421. this.brandList.push(this.zsbrandList[i])
  422. }
  423. }
  424. if (this.brandDescfor >= this.zsbrandList.length) {
  425. this.gengduofalse = false
  426. }
  427. },
  428. // 收回项目
  429. shohuifun() {
  430. this.brandDescfor = 9
  431. this.brandList = []
  432. for (let i in this.zsbrandList) {
  433. if (i < this.brandDescfor) {
  434. this.brandList.push(this.zsbrandList[i])
  435. }
  436. }
  437. this.gengduofalse = true
  438. // if (this.brandDescfor >= this.zsbrandList.length) {
  439. // this.gengduofalse = false
  440. // }
  441. },
  442. groupChange(e) {
  443. console.log(e, 228);
  444. if (e.name == '静音棉') {
  445. this.originalFactory = 1
  446. this.selfRecovery = 0
  447. this.explosionProof = 0
  448. } else if (e.name == '自修补') {
  449. this.originalFactory = 0
  450. this.selfRecovery = 1
  451. this.explosionProof = 0
  452. } else if (e.name == '防爆') {
  453. this.originalFactory = 0
  454. this.selfRecovery = 0
  455. this.explosionProof = 1
  456. } else {
  457. this.originalFactory = 0
  458. this.selfRecovery = 0
  459. this.explosionProof = 0
  460. }
  461. this.page.current = 1
  462. this.dataList = []
  463. this.onSearch()
  464. },
  465. // 点击筛选条件
  466. dianjiqiehuan(name) {
  467. if (this[name] == 0) {
  468. this[name] = 1
  469. } else {
  470. this[name] = 0
  471. }
  472. this.click()
  473. },
  474. // 获取列表数据
  475. onSearch() {
  476. uni.showLoading({
  477. title: '加载中',
  478. mask: true
  479. });
  480. let obj = {}
  481. if (this.originalFactory) {
  482. obj.originalFactory = 1
  483. }
  484. if (this.selfRecovery) {
  485. obj.selfRecovery = 1
  486. }
  487. if (this.explosionProof) {
  488. obj.explosionProof = 1
  489. }
  490. if (uni.getStorageSync('whether_openShare') == 1) {
  491. appListNew({
  492. size: this.page.size,
  493. current: this.page.current,
  494. ...obj,
  495. ...this.search,
  496. whetherIntegral: 0
  497. }).then(res => {
  498. this.dataList = this.dataList.concat(res.data.records)
  499. this.page.total = res.data.total
  500. if (this.dataList.length == res.data.total) {
  501. this.status = 'nomore'
  502. }
  503. uni.hideLoading();
  504. }).catch(err => {
  505. uni.hideLoading();
  506. })
  507. } else {
  508. appList({
  509. size: this.page.size,
  510. current: this.page.current,
  511. ...obj,
  512. ...this.search,
  513. whetherIntegral: 0
  514. }).then(res => {
  515. this.dataList = this.dataList.concat(res.data.records)
  516. this.page.total = res.data.total
  517. if (this.dataList.length == res.data.total) {
  518. this.status = 'nomore'
  519. }
  520. uni.hideLoading();
  521. }).catch(err => {
  522. uni.hideLoading();
  523. })
  524. }
  525. },
  526. close() {
  527. this.show = false
  528. this.search.brandId = ''
  529. this.search.brandName = ''
  530. },
  531. // 原厂点击差号
  532. yuanchangclose(type) {
  533. if (type == 'originalFactory') {
  534. this.originalFactory = false
  535. } else if (type == 'selfRecovery') {
  536. this.selfRecovery = false
  537. } else {
  538. this.explosionProof = false
  539. }
  540. this.click()
  541. },
  542. click(name) {
  543. if (name != undefined) {
  544. this.page = {
  545. total: 0,
  546. size: 10,
  547. current: 1,
  548. }
  549. this.dataList = []
  550. if (this.PPindex == name) {
  551. this.PPindex = null
  552. delete this.search.brandId
  553. delete this.search.brandNmae
  554. } else {
  555. this.PPindex = name
  556. this.search = {
  557. ...this.search,
  558. brandId: this.brandList[this.PPindex].id,
  559. brandNmae: this.brandList[this.PPindex].cname,
  560. }
  561. }
  562. }
  563. this.show = true
  564. this.onSearch()
  565. },
  566. //打开明细
  567. choice(item, index) {
  568. if (this.checkStatus != '通过') {
  569. uni.showToast({
  570. title: "当前用户未授权,请联系客服",
  571. icon: "none",
  572. mask: true
  573. });
  574. return
  575. }
  576. uni.$u.route('/pages/views/buyGoods/commodityDetails', {
  577. id: item.id
  578. });
  579. },
  580. inIntegralMall() {
  581. uni.$u.route('/pages/integralMall/index');
  582. }
  583. }
  584. }
  585. </script>
  586. <style lang="scss" scoped>
  587. .suspensionBox {
  588. width: 80rpx;
  589. height: 80rpx;
  590. background: #fff;
  591. border-radius: 50%;
  592. position: fixed;
  593. top: 92%;
  594. right: 40rpx;
  595. box-shadow: 4px 4px 8px 1px rgba(0, 0, 0, .5);
  596. display: flex;
  597. align-items: center;
  598. justify-content: center;
  599. }
  600. .card {
  601. background-color: #fff;
  602. border-radius: 10rpx;
  603. overflow: hidden;
  604. margin: 12rpx 0;
  605. }
  606. .carBtn {
  607. display: flex;
  608. align-items: center;
  609. justify-content: center;
  610. color: #E75F37;
  611. font-weight: bold;
  612. width: 25%;
  613. text-align: center;
  614. background-color: #fff;
  615. height: 64rpx;
  616. border-radius: 36rpx;
  617. margin-right: 20rpx;
  618. }
  619. .brandImg {
  620. display: flex;
  621. flex-direction: column;
  622. align-items: center;
  623. justify-content: center;
  624. margin: 16rpx 0;
  625. .text {
  626. white-space: nowrap;
  627. overflow: hidden;
  628. text-overflow: ellipsis;
  629. width: 140rpx;
  630. text-align: center;
  631. font-size: 24rpx;
  632. color: #797979;
  633. }
  634. }
  635. .goodsImg {
  636. display: flex;
  637. flex-direction: column;
  638. align-items: center;
  639. justify-content: center;
  640. margin: 16rpx 0;
  641. .text {
  642. white-space: nowrap;
  643. overflow: hidden;
  644. text-overflow: ellipsis;
  645. width: 300rpx;
  646. text-align: center;
  647. font-size: 24rpx;
  648. color: #797979;
  649. }
  650. }
  651. .container {
  652. position: relative;
  653. }
  654. .background-image {
  655. position: absolute;
  656. z-index: -1;
  657. /* 将图片置于组件后面 */
  658. }
  659. .imgIcon {
  660. position: absolute;
  661. width: 100rpx;
  662. height: 35rpx;
  663. top: 16rpx;
  664. right: 36rpx;
  665. }
  666. </style>