classification.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <template>
  2. <view class="containerMall">
  3. <view class="u-wrap">
  4. <view class="u-search-box">
  5. <u-tabs :list="tabbar" @click="click" lineColor="#fff" :activeStyle="{ color: '#fff' }"
  6. :inactiveStyle="{ color: '#ffffff80' }">></u-tabs>
  7. <view style="padding: 10rpx; font-size: 40rpx;">
  8. <u-search placeholder="请输入商品名称" :actionStyle="{ color: '#fff' }" v-model="name" @search="custom"
  9. @custom="custom" :animation="false"></u-search>
  10. </view>
  11. </view>
  12. <view class="recentSearches" v-if="recentSearches.length != 0">
  13. <view class="recentSearches-head">
  14. <view class="recentSearches-headLeft">
  15. <u-icon name="clock"></u-icon>
  16. <view style="font-size: 26rpx;margin-left: 6rpx;">最近搜索</view>
  17. </view>
  18. <view class="recentSearches-headRight">
  19. <u-icon name="trash" size="20px" @click="searchDeleteShow = true"></u-icon>
  20. </view>
  21. </view>
  22. <view class="recentSearches-text">
  23. <u-tag ref="myElement" v-for="(item,index) in recentSearches" :key="index" :text="item"
  24. bgColor="#e7e7e7" color="#000" borderColor="#e7e7e7" size="medium" closable :show="item"
  25. @close="tagClose(index)" @click.stop="tagSearches(item)"></u-tag>
  26. </view>
  27. </view>
  28. <view style="margin: 20rpx 10rpx;display: flex;align-items: center;justify-content: flex-end;">
  29. <view style="margin-left: 20rpx;"><u-button type="warning" size="small" text="清空"
  30. @click="emptyfun"></u-button></view>
  31. </view>
  32. <view class="u-menu-wrap">
  33. <view class="u-tab-view">
  34. <view v-for="(item,index) in tabbarTwo" :key="index" class="u-tab-item"
  35. :class="[current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
  36. <text class="u-line-1" style="text-align: center;">{{item.cname}}</text>
  37. </view>
  38. </view>
  39. <scroll-view @scrolltolower="lowerBottom" scroll-y="true" class="scrollHeight">
  40. <view class="right-box">
  41. <view class="page-view">
  42. <view class="class-item">
  43. <!-- <view class="item-title">
  44. <text>{{item.type}}</text>
  45. </view> -->
  46. <view class="item-container">
  47. <view class="thumb" style="display: flex;justify-content: space-between;"
  48. v-for="(itemTwo, indexTwo) in dataList" :key="indexTwo"
  49. @click="selectProduct(itemTwo)">
  50. <view>
  51. <image v-for="(itemThree,indexThree) in itemTwo.filesList" :key="indexThree"
  52. v-if="itemThree.version === '0'" class="item-menu-image"
  53. :src="itemThree.url">
  54. </image>
  55. </view>
  56. <view v-if='Number(itemTwo.inventory)>0'
  57. style="margin-left: 10rpx;width: 368rpx;">
  58. <view class="thumb-text">
  59. {{itemTwo.cname}}
  60. </view>
  61. <view
  62. style="display: flex;justify-content: space-between;align-items: center;">
  63. <view>
  64. <view style="color: #707070;font-size: 24rpx;">{{Number(itemTwo.mallPrice)}}
  65. </view>
  66. <view style="color: #FD4B09;font-size: 24rpx;">
  67. 库存:{{Number(itemTwo.inventory) > 10?'充足':Number(itemTwo.inventory)}}
  68. </view>
  69. </view>
  70. <view
  71. style="padding: 8rpx;border-radius: 50%;background: #edeef2;display: flex;align-items: center;justify-content: center;"
  72. @click.stop="shoppingCartfun(itemTwo)">
  73. <u-icon name="shopping-cart" color="#dd4919" size="28"></u-icon>
  74. </view>
  75. </view>
  76. </view>
  77. <view v-if='Number(itemTwo.inventory)==0'
  78. style="margin-left: 10rpx;width: 368rpx;color: #909399;">
  79. <view class="thumb-text">
  80. {{itemTwo.cname}}
  81. </view>
  82. <view
  83. style="display: flex;justify-content: space-between;align-items: center;">
  84. <view>
  85. <view style="color: #909399;font-size: 24rpx;">{{Number(itemTwo.mallPrice)}}
  86. </view>
  87. <view style="color: #909399;font-size: 24rpx;">
  88. 库存:{{Number(itemTwo.inventory) > 10?'充足':Number(itemTwo.inventory)}}
  89. </view>
  90. </view>
  91. <view
  92. style="padding: 8rpx;border-radius: 50%;background: #edeef2;display: flex;align-items: center;justify-content: center;"
  93. @click.stop="shoppingCartfun(itemTwo)">
  94. <u-icon name="shopping-cart" color="#909399" size="28"></u-icon>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <u-loadmore v-if="page.total !== 0" :status="status" />
  103. </view>
  104. </scroll-view>
  105. </view>
  106. </view>
  107. <u-modal :show="searchDeleteShow" content="确认删除搜索记录吗?" showCancelButton @confirm="searchDeletefun"
  108. @cancel="searchDeleteShow = false" ref="uModal" :asyncClose="true">
  109. </u-modal>
  110. </view>
  111. </template>
  112. <script>
  113. import {
  114. listAll2,
  115. goodsList
  116. } from '@/api/tabBar/classification.js'
  117. import {
  118. details,
  119. nameDetail
  120. } from '@/api/views/personalInformation/index.js'
  121. import {
  122. appDetail,
  123. addToCart
  124. } from '@/api/tabBar/home.js'
  125. export default {
  126. data() {
  127. return {
  128. current: 0, // 预设当前项的值
  129. tabbar: [],
  130. dataList: [],
  131. show: false,
  132. status: 'loadmore',
  133. filesList: [],
  134. tabbarTwo: [],
  135. name: '',
  136. page: {
  137. total: 0,
  138. size: 10,
  139. current: 1
  140. },
  141. search: {
  142. whether: '0'
  143. },
  144. checkStatus: null,
  145. recentSearches: [], // 搜索数据
  146. searchDeleteShow: false, // 搜索全部删除弹窗
  147. form: {}, // 详情数据
  148. checkboxValue: [], // 多选
  149. salesmanName: '', // 业务员姓名
  150. phoneNumber: '', // 业务员联系电话
  151. salesmanShow: false, // 联系业务员弹窗
  152. }
  153. },
  154. created() {
  155. // 获取最近搜索数据
  156. if (uni.getStorageSync('recentSearches')) {
  157. this.recentSearches = uni.getStorageSync('recentSearches');
  158. }
  159. // 获取审核状态
  160. details().then(res => {
  161. this.checkStatus = res.data.checkStatus
  162. uni.setStorageSync('checkStatus', res.data.checkStatus);
  163. if (this.checkStatus != '通过') {
  164. // uni.showToast({
  165. // title: "当前用户未授权,请联系客服",
  166. // icon: "none",
  167. // mask:true
  168. // });
  169. uni.switchTab({
  170. url: '/pages/tabBar/home'
  171. })
  172. return
  173. }
  174. this.salesmanName = res.data.salesmanName
  175. // 查询业务员详情拿取手机号
  176. if (!this.phoneNumber) {
  177. nameDetail({
  178. id: res.data.salesmanId
  179. }).then(res => {
  180. this.phoneNumber = res.data.phone
  181. })
  182. }
  183. })
  184. uni.showLoading({
  185. title: '加载中',
  186. mask: true
  187. });
  188. listAll2({
  189. type: 'PP',
  190. enableOrNot: '1',
  191. whetherIntegral: '1'
  192. }).then(res => {
  193. console.log(res.data.sort(this.compare('sort')), 111111)
  194. let arr = []
  195. arr = res.data.sort(this.compare('sort'))
  196. this.tabbarTwo = arr
  197. this.page = {
  198. total: 0,
  199. size: 10,
  200. current: 1
  201. }
  202. this.dataList = []
  203. let searchCache = JSON.parse(JSON.stringify(uni.getStorageSync('homeSearch')))
  204. uni.removeStorageSync('homeSearch')
  205. if (searchCache.cname) {
  206. this.name = searchCache.cname
  207. this.custom()
  208. } else {
  209. this.name = null
  210. if (this.current == -1) {
  211. this.current = 0
  212. }
  213. this.search = {
  214. brandId: this.tabbarTwo[this.current].id,
  215. whether: '0',
  216. }
  217. this.onSearch()
  218. }
  219. uni.hideLoading();
  220. }).catch(err => {
  221. uni.hideLoading();
  222. })
  223. },
  224. mounted() {
  225. },
  226. methods: {
  227. // 数组排序 property:根据什么属性排序
  228. compare(property) {
  229. return function(a, b) {
  230. var value1 = a[property]
  231. var value2 = b[property]
  232. return value1 - value2
  233. }
  234. },
  235. // 点击联系业务员
  236. clickCall() {
  237. uni.makePhoneCall({
  238. phoneNumber: this.phoneNumber,
  239. success: function() {
  240. console.log('拨打电话成功');
  241. },
  242. fail() {
  243. console.log('打电话失败了');
  244. }
  245. })
  246. },
  247. // 清空搜索条件
  248. emptyfun() {
  249. this.name = ''
  250. this.current = -1
  251. this.checkboxValue = []
  252. this.search = {
  253. whether: '0'
  254. }
  255. this.page = {
  256. total: 0,
  257. size: 10,
  258. current: 1
  259. }
  260. this.dataList = []
  261. this.onSearch()
  262. },
  263. checkboxChange(value) {
  264. this.checkboxValue = value
  265. this.search.originalFactory = null
  266. this.search.selfRecovery = null
  267. this.search.explosionProof = null
  268. if (this.checkboxValue.indexOf('静音棉') != -1) {
  269. this.search.originalFactory = 1
  270. }
  271. if (this.checkboxValue.indexOf('自修补') != -1) {
  272. this.search.selfRecovery = 1
  273. }
  274. if (this.checkboxValue.indexOf('防爆') != -1) {
  275. this.search.explosionProof = 1
  276. }
  277. this.page = {
  278. total: 0,
  279. size: 10,
  280. current: 1
  281. }
  282. this.dataList = []
  283. this.onSearch()
  284. },
  285. // 加入购物车
  286. shoppingCartfun(row) {
  287. console.log(row, 166);
  288. if (row.inventory == 0) {
  289. uni.showToast({
  290. title: "当前商品库存为零",
  291. icon: "none",
  292. mask: true,
  293. duration: 2500
  294. });
  295. return
  296. }
  297. // 获取详情数据
  298. appDetail({
  299. id: row.id
  300. }).then(res => {
  301. if (res.data.type == 0) {
  302. this.form = res.data.thisLocality
  303. } else {
  304. this.form = res.data.offsite
  305. }
  306. addToCart({
  307. ...this.form,
  308. whetherIntegral:'1',
  309. detailsText: ''
  310. }).then(res => {
  311. uni.showToast({
  312. title: "加入购物车成功",
  313. icon: "none",
  314. mask: true,
  315. duration: 2500
  316. });
  317. this.$emit('goTab', 2)
  318. })
  319. })
  320. },
  321. // 搜索全部删除
  322. searchDeletefun() {
  323. this.recentSearches = []
  324. uni.setStorageSync('recentSearches', this.recentSearches);
  325. this.searchDeleteShow = false
  326. },
  327. // 点击搜索
  328. tagSearches(name) {
  329. this.name = name
  330. this.search.cname = name
  331. this.custom()
  332. },
  333. // 最近搜索点击关闭按钮
  334. tagClose(index) {
  335. this.recentSearches.splice(index, 1)
  336. uni.setStorageSync('recentSearches', this.recentSearches);
  337. },
  338. selectProduct(item) {
  339. uni.$u.route('/pages/integralMall/buyGoods/commodityDetails', {
  340. id: item.id
  341. });
  342. },
  343. lowerBottom() {
  344. this.status = 'loading'
  345. if (this.dataList.length < this.page.total) {
  346. this.page.current++
  347. this.onSearch()
  348. } else {
  349. this.status = 'nomore'
  350. }
  351. },
  352. // 搜索
  353. custom() {
  354. this.current = -1
  355. this.page = {
  356. total: 0,
  357. size: 10,
  358. current: 1
  359. }
  360. if (this.name) {
  361. this.recentSearches.unshift(this.name)
  362. // 去重
  363. this.recentSearches = this.recentSearches.filter((item, index) => this.recentSearches.indexOf(item) ===
  364. index);
  365. uni.setStorageSync('recentSearches', this.recentSearches);
  366. }
  367. delete this.search.brandId
  368. this.search.cname = this.name
  369. this.dataList = []
  370. this.onSearch()
  371. },
  372. // 左侧选择
  373. swichMenu(index) {
  374. this.current = index;
  375. this.page = {
  376. total: 0,
  377. size: 10,
  378. current: 1
  379. }
  380. this.search.brandId = this.tabbarTwo[this.current].id
  381. this.search.cname = this.name ? this.name : null
  382. this.dataList = []
  383. this.onSearch()
  384. },
  385. // 列表数据获取
  386. onSearch() {
  387. uni.showLoading({
  388. title: '加载中',
  389. mask: true
  390. });
  391. goodsList({
  392. size: this.page.size,
  393. current: this.page.current,
  394. ...this.search,
  395. whetherIntegral: "1"
  396. }).then(res => {
  397. this.dataList = this.dataList.concat(res.data.records)
  398. this.page.total = res.data.total
  399. if (this.dataList.length == res.data.total) {
  400. this.status = 'nomore'
  401. }
  402. uni.hideLoading();
  403. }).catch(err => {
  404. uni.hideLoading();
  405. })
  406. },
  407. }
  408. }
  409. </script>
  410. <style lang="scss" scoped>
  411. .suspensionBox {
  412. width: 80rpx;
  413. height: 80rpx;
  414. background: #fff;
  415. border-radius: 50%;
  416. position: fixed;
  417. top: 92%;
  418. right: 2%;
  419. box-shadow: 2px 2px 8px 1px rgba(0, 0, 0, .5);
  420. display: flex;
  421. align-items: center;
  422. justify-content: center;
  423. }
  424. .searchBox {
  425. background-color: antiquewhite;
  426. display: flex;
  427. width: 400px;
  428. flex-wrap: wrap;
  429. .searchItem {
  430. background-color: aliceblue;
  431. height: 20px;
  432. margin: 5px 10px;
  433. padding: 5px;
  434. max-width: 200px;
  435. overflow: hidden;
  436. text-overflow: ellipsis; //溢出用省略号显示
  437. white-space: nowrap; //溢出不换行
  438. }
  439. .searchBtn {
  440. height: 20px;
  441. width: 40px;
  442. text-align: center;
  443. margin: 10px;
  444. border-radius: 50%;
  445. background-color: #fff;
  446. line-height: 20px;
  447. cursor: pointer;
  448. }
  449. }
  450. .recentSearches {
  451. padding: 10rpx 20rpx;
  452. .recentSearches-head {
  453. display: flex;
  454. align-items: center;
  455. justify-content: space-between;
  456. .recentSearches-headLeft {
  457. display: flex;
  458. align-items: center;
  459. }
  460. .recentSearches-headRight {}
  461. }
  462. .recentSearches-text {
  463. display: flex;
  464. flex-wrap: wrap;
  465. align-items: baseline;
  466. .recentSearches-textWidth {
  467. // width: 140rpx;
  468. }
  469. }
  470. }
  471. .submitBar {
  472. width: 100%;
  473. font-size: 32rpx;
  474. color: #000;
  475. text-align: center;
  476. // border-top: 1rpx solid #f2f2f6;
  477. }
  478. .u-wrap {
  479. height: calc(100vh - 85px);
  480. /* #ifdef H5 */
  481. height: calc(100vh - var(--window-top));
  482. /* #endif */
  483. display: flex;
  484. flex-direction: column;
  485. }
  486. .u-search-box {
  487. padding: 10rpx;
  488. padding-top: 0;
  489. background-color: #FD4B09;
  490. }
  491. .u-menu-wrap {
  492. flex: 1;
  493. display: flex;
  494. overflow: hidden;
  495. }
  496. .u-search-inner {
  497. background-color: rgb(234, 234, 234);
  498. border-radius: 100rpx;
  499. display: flex;
  500. align-items: center;
  501. padding: 10rpx 16rpx;
  502. }
  503. .u-search-text {
  504. font-size: 26rpx;
  505. color: $u-tips-color;
  506. margin-left: 10rpx;
  507. }
  508. .data-v-1a326067 {
  509. font-size: 40rpx;
  510. }
  511. .u-tab-view {
  512. width: 200rpx;
  513. overflow-x: scroll;
  514. white-space: nowrap;
  515. }
  516. .u-tab-item {
  517. height: 110rpx;
  518. background: #f6f6f6;
  519. box-sizing: border-box;
  520. display: flex;
  521. align-items: center;
  522. justify-content: center;
  523. font-size: 26rpx;
  524. color: #444;
  525. font-weight: 400;
  526. line-height: 1;
  527. white-space: normal;
  528. word-break: break-all;
  529. word-wrap: break-word;
  530. overflow: hidden;
  531. text-overflow: ellipsis;
  532. // display: -webkit-box;
  533. -webkit-line-clamp: 2;
  534. -webkit-box-orient: vertical;
  535. }
  536. .u-tab-item-active {
  537. position: relative;
  538. color: #000;
  539. font-size: 30rpx;
  540. font-weight: 600;
  541. background: #fff;
  542. }
  543. .u-tab-item-active::before {
  544. content: "";
  545. position: absolute;
  546. border-left: 4px solid #FD4B09;
  547. height: 32rpx;
  548. left: 0;
  549. top: 39rpx;
  550. }
  551. .u-tab-view {
  552. height: 100%;
  553. }
  554. .right-box {
  555. width: 100%;
  556. background-color: rgb(250, 250, 250);
  557. padding-bottom: 20rpx;
  558. }
  559. .page-view {
  560. padding: 16rpx;
  561. }
  562. .class-item {
  563. // margin-bottom: 30rpx;
  564. background-color: #fff;
  565. padding: 16rpx;
  566. border-radius: 8rpx;
  567. }
  568. // .class-item:last-child {
  569. // min-height: 100vh;
  570. // }
  571. .item-title {
  572. font-size: 26rpx;
  573. color: $u-main-color;
  574. font-weight: bold;
  575. }
  576. .item-menu-name {
  577. font-weight: normal;
  578. font-size: 24rpx;
  579. color: $u-main-color;
  580. }
  581. .item-container {
  582. display: flex;
  583. flex-wrap: wrap;
  584. }
  585. .thumb-box {
  586. width: 33.33333%;
  587. display: flex;
  588. align-items: center;
  589. justify-content: center;
  590. flex-direction: column;
  591. margin-top: 20rpx;
  592. }
  593. .thumb {
  594. width: 100%;
  595. align-items: center;
  596. margin: 10rpx auto;
  597. }
  598. .thumb-text {
  599. font-size: 26rpx;
  600. white-space: normal;
  601. word-break: break-all;
  602. word-wrap: break-word;
  603. overflow: hidden;
  604. text-overflow: ellipsis;
  605. display: -webkit-box;
  606. -webkit-line-clamp: 2;
  607. -webkit-box-orient: vertical;
  608. }
  609. .thumb ::v-deep .u-cell__body {
  610. padding: 20rpx 0;
  611. }
  612. .item-menu-image {
  613. width: 150rpx;
  614. height: 150rpx;
  615. border-radius: 20rpx;
  616. }
  617. ::v-deep .u-popup {
  618. flex: 0;
  619. }
  620. .containerMall {
  621. height: calc(100vh - calc(50px + env(safe-area-inset-bottom)));
  622. }
  623. </style>