home.vue 14 KB

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