classification.vue 17 KB

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