classification.vue 17 KB

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