home.vue 15 KB

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