classification.vue 16 KB

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