index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <template>
  2. <view class="container">
  3. <view style="background-color: #03803B;">
  4. <uni-search-bar bgColor="#fff" v-model="name" placeholder="请输入综合查询" @confirm="custom" @clear="custom"
  5. :radius="100" cancelButton="none">
  6. </uni-search-bar>
  7. </view>
  8. <view class="recentSearches" v-if="recentSearches.length != 0">
  9. <view class="recentSearches-head">
  10. <view class="recentSearches-headLeft">
  11. <u-icon name="clock" color="#C4C4C4"></u-icon>
  12. <view style="font-size: 26rpx;margin-left: 6rpx;">最近搜索</view>
  13. </view>
  14. <view class="recentSearches-headRight">
  15. <u-icon name="trash" size="20px" @click="searchDeleteShow = true" color="#C4C4C4"></u-icon>
  16. </view>
  17. </view>
  18. <view class="recentSearches-text">
  19. <u-tag v-for="(item,index) in recentSearches" :key="index" :text="item" bgColor="#EFEFEF"
  20. color="#414141" borderColor="#EFEFEF" size="medium" closable @close="tagClose(index)" shape="circle"
  21. @click="tagSearches(item)"></u-tag>
  22. </view>
  23. <u-modal :show="searchDeleteShow" content="确认删除搜索记录吗?" showCancelButton @confirm="searchDeletefun"
  24. @cancel="searchDeleteShow = false" ref="uModal" :asyncClose="true">
  25. </u-modal>
  26. </view>
  27. <view class="tagClass">
  28. <view v-for="(item, index) in radios" :key="index" style="margin:0 6rpx;">
  29. <u-tag :text="item.label" :bgColor="item.checked?'#03803B':'#fff'" borderColor='#03803B'
  30. :color="item.checked?'#fff':'#03803B'" @click="checkboxChange(item.label,index)" size="mini">
  31. </u-tag>
  32. </view>
  33. <view style="margin:0 6rpx;">
  34. <u-tag text="品牌" :bgColor="search.brandId?'#03803B':'#fff'" borderColor='#03803B'
  35. :color="search.brandId?'#fff':'#03803B'" @click="openBrand" size="mini">
  36. </u-tag>
  37. </view>
  38. <view style="margin:0 6rpx;width: 2rpx;height: 43rpx;background: #03803B;border-radius: 1rpx;"></view>
  39. <view style="margin:0 6rpx;">
  40. <u-tag text="重置" bgColor="#F8AA09" borderColor='#F8AA09' color="#fff" @click="emptyfun" size="mini">
  41. </u-tag>
  42. </view>
  43. </view>
  44. <z-paging ref="paging" v-model="dataList" @query="getList" :fixed="false" :auto-show-back-to-top="true"
  45. :empty-view-text="search.searchCriteria ? '未找到相关结果' : '暂无数据'" :hide-empty-view="false"
  46. :auto-show-system-loading="true">
  47. <view>
  48. <view v-for=" (item, index) in dataList" :key="index">
  49. <view class="card" @click="selectProduct(item)">
  50. <image :src="item.url" class="cardImg" mode="scaleToFill">
  51. </image>
  52. <view style="margin-left: 20rpx;">
  53. <view style="display: flex;align-items: center;">
  54. <view class="cardTitle">
  55. <text class="cardName">
  56. {{item.cname}}
  57. </text>
  58. </view>
  59. <image src="/static/images/goods/carIcon@2x.png" @click.stop="shoppingCartfun(item)"
  60. style="width: 54rpx;height: 54rpx;margin-left: 80rpx;" mode="scaleToFill">
  61. </image>
  62. </view>
  63. <view style="display: flex;justify-content: space-between;align-items: center;">
  64. <!-- <view class="cardTab">
  65. <image src="/static/images/goods/280@2x.png" style="width: 142rpx;height: 36rpx;"
  66. mode="scaleToFill">
  67. </image>
  68. <image src="/static/images/goods/6@2x.png"
  69. style="width: 78rpx;height: 20rpx;position: absolute;left:10rpx;top:10rpx"
  70. mode="scaleToFill">
  71. </image>
  72. <view class="cardKc">
  73. {{Number(item.balanceQuantity) > 10?'充足':Number(item.balanceQuantity)}}
  74. </view>
  75. </view>
  76. <view class="cardTab" style="margin-left: 10rpx;">
  77. <image src="/static/images/goods/2801@2x.png" style="width: 142rpx;height: 36rpx;"
  78. mode="scaleToFill">
  79. </image>
  80. <image src="/static/images/goods/7@2x.png"
  81. style="width: 78rpx;height: 20rpx;position: absolute;left:10rpx;top:10rpx"
  82. mode="scaleToFill">
  83. </image>
  84. <view class="cardKc">
  85. {{Number(item.total) > 10?'充足':Number(item.total)}}
  86. </view>
  87. </view> -->
  88. <view style="color:#797979;">
  89. 库存:{{Number(item.balanceQuantity) > 10?'充足':Number(item.balanceQuantity)}}
  90. </view>
  91. <view class="cardPrice">
  92. ¥{{checkStatus == '审核通过'?item.price:'***'}}
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </z-paging>
  100. <view>
  101. <uni-popup ref="popup" background-color="#fff" type="bottom">
  102. <view style="padding: 40rpx 0 120rpx 0;">
  103. <scroll-view scroll-y="true" style="max-height: 60vh;">
  104. <uni-row>
  105. <uni-col :span="6" v-for="(item,index) in tabbarTwo" :key="index">
  106. <view class="brandImg" @click="swichMenu(item,index)">
  107. <image :src="item.brandFilesList.length?item.brandFilesList[0].url:null"
  108. mode="aspectFit"
  109. style="width:110rpx;height: 110rpx;border-radius:6rpx;border: 2rpx solid #EBEBEB;" />
  110. <text class='text'>{{item.cname}}</text>
  111. </view>
  112. </uni-col>
  113. </uni-row>
  114. </scroll-view>
  115. </view>
  116. </uni-popup>
  117. <view class="suspensionBox" @click="opensalesman">
  118. <u-icon name="server-fill" color="#2979ff" size="30"></u-icon>
  119. </view>
  120. <u-modal :show="salesmanShow" title="业务员联系方式" showCancelButton confirmText="拨号" cancelText="关闭"
  121. @confirm="clickCall" @cancel="salesmanShow=false">
  122. <view class="slot-content">
  123. <view style="margin-bottom: 10rpx;">业务员:{{salesmanName?salesmanName:''}}</view>
  124. <view>电话:{{phoneNumber?phoneNumber:''}}</view>
  125. </view>
  126. </u-modal>
  127. </view>
  128. </view>
  129. </template>
  130. <script>
  131. import {
  132. listAll2,
  133. goodsList,
  134. cloudWarehouseList
  135. } from '@/api/goods/index.js'
  136. import {
  137. details,
  138. nameDetail
  139. } from '@/api/personalInformation/index.js'
  140. import {
  141. appDetail,
  142. addToCart,
  143. } from '@/api/home/index.js'
  144. import {
  145. isProcurement
  146. } from '@/api/goods/index.js'
  147. import {
  148. shoppingCartList
  149. } from '@/api/shoppingCart/index.js'
  150. export default {
  151. data() {
  152. return {
  153. scrollTop: 0,
  154. old: {
  155. scrollTop: 0
  156. },
  157. radios: [{
  158. label: '静音棉',
  159. checked: false,
  160. },
  161. {
  162. label: '自修补',
  163. checked: false,
  164. },
  165. {
  166. label: '防爆',
  167. checked: false,
  168. },
  169. ],
  170. current: 0, // 预设当前项的值
  171. tabbar: [],
  172. dataList: [],
  173. show: false,
  174. status: 'loadmore',
  175. filesList: [],
  176. tabbarTwo: [],
  177. name: '',
  178. page: {
  179. total: 0,
  180. size: 10,
  181. current: 1
  182. },
  183. search: {
  184. whether: '0',
  185. brandId: null,
  186. },
  187. checkStatus: null,
  188. recentSearches: [], // 搜索数据
  189. searchDeleteShow: false, // 搜索全部删除弹窗
  190. form: {}, // 详情数据
  191. checkboxValue: [], // 多选
  192. salesmanName: '', // 业务员姓名
  193. phoneNumber: '', // 业务员联系电话
  194. salesmanShow: false, // 联系业务员弹窗
  195. cloudWarehouse: 0,
  196. showIcon: true
  197. }
  198. },
  199. mounted() {},
  200. onLoad(data) {
  201. // uni.showToast({
  202. // title: "开发中",
  203. // icon: "none",
  204. // });
  205. listAll2({
  206. type: 'PP',
  207. enableOrNot: '1',
  208. whetherIntegral: '0'
  209. }).then(res => {
  210. let arr = []
  211. arr = res.data.sort(this.compare('sort'))
  212. this.tabbarTwo = arr
  213. })
  214. },
  215. onShow() {
  216. // 获取审核状态
  217. details().then(res => {
  218. this.checkStatus = res.data.checkStatus
  219. uni.setStorageSync('checkStatus', res.data.checkStatus);
  220. this.salesmanName = res.data.salesmanName
  221. // 查询业务员详情拿取手机号
  222. if (!this.phoneNumber) {
  223. nameDetail({
  224. id: res.data.salesmanId
  225. }).then(res => {
  226. this.phoneNumber = res.data.phone
  227. })
  228. }
  229. })
  230. this.getBadge()
  231. // 获取最近搜索数据
  232. if (uni.getStorageSync('recentSearches')) {
  233. this.recentSearches = uni.getStorageSync('recentSearches').slice(0, 8);
  234. }
  235. },
  236. methods: {
  237. getBadge() {
  238. shoppingCartList().then(res => {
  239. let num = res.data.length
  240. if (num) {
  241. uni.setTabBarBadge({
  242. index: 3, // tabIndex,tabBar的哪一项,从0开始
  243. text: num.toString() // 显示的文本,超过 99 显示成 “…”
  244. })
  245. } else {
  246. uni.removeTabBarBadge({
  247. index: 3, // tabIndex,tabBar的哪一项,从0开始
  248. })
  249. }
  250. })
  251. },
  252. opensalesman() {
  253. if (this.checkStatus != '审核通过') {
  254. uni.showToast({
  255. title: "当前用户未授权,请联系客服",
  256. icon: "none",
  257. mask: true
  258. });
  259. return
  260. }
  261. this.salesmanShow = true
  262. },
  263. openBrand() {
  264. if (this.checkStatus != '审核通过') {
  265. uni.showToast({
  266. title: "当前用户未授权,请联系客服",
  267. icon: "none",
  268. mask: true
  269. });
  270. return
  271. }
  272. this.$refs.popup.open('bottom')
  273. },
  274. goTop(e) {
  275. // 解决view层不同步的问题
  276. this.scrollTop = this.old.scrollTop
  277. this.$nextTick(() => {
  278. this.scrollTop = 0
  279. this.old.scrollTop = 0
  280. });
  281. },
  282. scroll(e) {
  283. this.old.scrollTop = e.detail.scrollTop
  284. },
  285. // 数组排序 property:根据什么属性排序
  286. compare(property) {
  287. return function(a, b) {
  288. var value1 = a[property]
  289. var value2 = b[property]
  290. return value1 - value2
  291. }
  292. },
  293. // 点击联系业务员
  294. clickCall() {
  295. uni.makePhoneCall({
  296. phoneNumber: this.phoneNumber,
  297. success: function() {
  298. console.log('拨打电话成功');
  299. },
  300. fail() {
  301. console.log('打电话失败了');
  302. }
  303. })
  304. },
  305. // 清空搜索条件
  306. emptyfun() {
  307. this.name = ''
  308. this.current = -1
  309. this.radios.map((item, index) => {
  310. item.checked = false
  311. });
  312. this.checkboxValue = []
  313. this.search = {
  314. whether: '0',
  315. brandId: null
  316. }
  317. this.$refs.paging.reload()
  318. },
  319. checkboxChange(value, index) {
  320. if (this.checkStatus != '审核通过') {
  321. uni.showToast({
  322. title: "当前用户未授权,请联系客服",
  323. icon: "none",
  324. mask: true
  325. });
  326. return
  327. }
  328. this.radios.map((item, index) => {
  329. item.checked = item.label === value ? true : false;
  330. });
  331. this.checkboxValue = value
  332. this.search.originalFactory = null
  333. this.search.selfRecovery = null
  334. this.search.explosionProof = null
  335. if (this.checkboxValue.indexOf('静音棉') != -1) {
  336. this.search.originalFactory = 1
  337. }
  338. if (this.checkboxValue.indexOf('自修补') != -1) {
  339. this.search.selfRecovery = 1
  340. }
  341. if (this.checkboxValue.indexOf('防爆') != -1) {
  342. this.search.explosionProof = 1
  343. }
  344. this.$refs.paging.reload()
  345. },
  346. // 加入购物车
  347. shoppingCartfun(row) {
  348. if (this.checkStatus != '审核通过') {
  349. uni.showToast({
  350. title: "当前用户未授权,请联系客服",
  351. icon: "none",
  352. mask: true
  353. });
  354. return
  355. }
  356. if (row.inventory == 0) {
  357. uni.showToast({
  358. title: "当前商品库存为零",
  359. icon: "none",
  360. mask: true,
  361. duration: 2500
  362. });
  363. return
  364. }
  365. uni.showLoading({
  366. title: '加载中',
  367. mask: true
  368. });
  369. appDetail({
  370. id: row.id
  371. }).then(res => {
  372. let obj = {
  373. ...res.data,
  374. goodsNum: 1
  375. }
  376. addToCart(obj).then(res => {
  377. uni.showToast({
  378. title: "加入购物车成功",
  379. icon: "none",
  380. });
  381. this.getBadge()
  382. uni.hideLoading();
  383. }).catch(err => {
  384. uni.hideLoading();
  385. })
  386. })
  387. },
  388. // 搜索全部删除
  389. searchDeletefun() {
  390. this.recentSearches = []
  391. uni.setStorageSync('recentSearches', this.recentSearches);
  392. this.searchDeleteShow = false
  393. },
  394. // 点击搜索
  395. tagSearches(name) {
  396. this.name = name
  397. this.search.searchCriteria = name
  398. this.$refs.paging.reload()
  399. },
  400. // 最近搜索点击关闭按钮
  401. tagClose(index) {
  402. this.recentSearches.splice(index, 1)
  403. uni.setStorageSync('recentSearches', this.recentSearches.slice(0, 8));
  404. },
  405. selectProduct(row) {
  406. if (this.checkStatus != '审核通过') {
  407. uni.showToast({
  408. title: "当前用户未授权,请联系客服",
  409. icon: "none",
  410. mask: true
  411. });
  412. return
  413. }
  414. uni.navigateTo({
  415. url: '/pages/goods/details?id=' + row.id,
  416. });
  417. },
  418. // 搜索
  419. custom() {
  420. if (this.checkStatus != '审核通过') {
  421. uni.showToast({
  422. title: "当前用户未授权,请联系客服",
  423. icon: "none",
  424. mask: true
  425. });
  426. return
  427. }
  428. if (this.name) {
  429. this.recentSearches.unshift(this.name)
  430. // 去重
  431. this.recentSearches = this.recentSearches.filter((item, index) => this.recentSearches.indexOf(item) ===
  432. index).slice(0, 8);
  433. uni.setStorageSync('recentSearches', this.recentSearches.slice(0, 8));
  434. }
  435. delete this.search.brandId
  436. this.search.searchCriteria = this.name
  437. this.$refs.paging.reload()
  438. },
  439. // 左侧选择
  440. swichMenu(row, index) {
  441. this.search.brandId = row.id
  442. this.search.searchCriteria = this.name ? this.name : null
  443. this.$refs.paging.reload()
  444. this.$refs.popup.close()
  445. },
  446. async getList(pageNo, pageSize) {
  447. try {
  448. const obj = {
  449. ...this.search,
  450. current: pageNo,
  451. size: pageSize
  452. }
  453. const res = await goodsList(obj)
  454. this.$refs.paging.complete(res.data.records)
  455. } catch (e) {
  456. this.$refs.paging.complete(false)
  457. uni.showToast({
  458. title: '加载失败',
  459. icon: 'none'
  460. })
  461. }
  462. }
  463. }
  464. }
  465. </script>
  466. <style lang="scss" scoped>
  467. // .scroll-view {
  468. // flex: 1;
  469. // height: 100%;
  470. // /* 关键样式:防止内容被裁剪 */
  471. // overflow-anchor: none;
  472. // }
  473. ::v-deep .uni-searchbar__cancel {
  474. color: #fff;
  475. }
  476. .container {
  477. // #ifdef H5
  478. height: calc(100vh - var(--nav-bar, 44px) - var(--tab-bar, 50px));
  479. // #endif
  480. // #ifdef APP-PLUS
  481. height: 100vh;
  482. // #endif
  483. display: flex;
  484. flex-direction: column;
  485. }
  486. .suspensionBox {
  487. width: 80rpx;
  488. height: 80rpx;
  489. background: #fff;
  490. border-radius: 50%;
  491. position: fixed;
  492. bottom: 200rpx;
  493. right: 40rpx;
  494. box-shadow: 4px 4px 8px 1px rgba(0, 0, 0, .5);
  495. display: flex;
  496. align-items: center;
  497. justify-content: center;
  498. }
  499. .brandImg {
  500. display: flex;
  501. flex-direction: column;
  502. align-items: center;
  503. justify-content: center;
  504. margin: 10rpx 0;
  505. .text {
  506. white-space: nowrap;
  507. overflow: hidden;
  508. text-overflow: ellipsis;
  509. width: 130rpx;
  510. text-align: center;
  511. font-size: 24rpx;
  512. color: #797979;
  513. }
  514. }
  515. .tagClass {
  516. display: flex;
  517. padding: 8rpx 63rpx 18rpx 63rpx;
  518. background-color: #fff;
  519. justify-content: space-around;
  520. ::v-deep .u-tag--mini {
  521. font-size: 28rpx;
  522. line-height: 22px;
  523. padding: 0rpx 24rpx;
  524. }
  525. }
  526. .card {
  527. display: flex;
  528. // align-items: center;
  529. background-color: #fff;
  530. width: 100%;
  531. margin-top: 28rpx;
  532. padding: 20rpx;
  533. .cardImg {
  534. width: 120rpx;
  535. height: 120rpx;
  536. border: 1rpx solid #E7E7E7;
  537. border-radius: 6rpx;
  538. }
  539. .cardName {
  540. font-weight: 400;
  541. font-size: 26rpx;
  542. line-height: 1.5;
  543. width: 400rpx;
  544. color: #797979;
  545. display: -webkit-box;
  546. -webkit-box-orient: vertical;
  547. -webkit-line-clamp: 2;
  548. overflow: hidden;
  549. text-overflow: ellipsis;
  550. }
  551. .cardTitle {
  552. font-weight: 400;
  553. font-size: 24rpx;
  554. width: 400rpx;
  555. height: 80rpx;
  556. .cardRetailPrice {
  557. display: flex;
  558. color: #909399;
  559. font-size: 22rpx;
  560. height: 28rpx;
  561. }
  562. }
  563. .cardTab {
  564. position: relative;
  565. top: 6rpx;
  566. height: 36rpx;
  567. .cardKc {
  568. text-align: center;
  569. position: absolute;
  570. right: 0rpx;
  571. top: 50%;
  572. transform: translateY(-50%);
  573. font-size: 22rpx;
  574. color: #FFFFFF;
  575. font-weight: 500;
  576. width: 50rpx;
  577. line-height: 36rpx;
  578. height: 36rpx;
  579. }
  580. }
  581. .cardPrice {
  582. margin-right: 60rpx;
  583. color: #03803B;
  584. font-size: 32rpx;
  585. font-weight: 500;
  586. }
  587. }
  588. .recentSearches {
  589. padding: 8rpx 12rpx;
  590. background-color: #fff;
  591. .recentSearches-head {
  592. display: flex;
  593. align-items: center;
  594. justify-content: space-between;
  595. color: #C4C4C4;
  596. .recentSearches-headLeft {
  597. display: flex;
  598. align-items: center;
  599. }
  600. .recentSearches-headRight {}
  601. }
  602. .recentSearches-text {
  603. display: flex;
  604. flex-wrap: wrap;
  605. align-items: baseline;
  606. ::v-deep .u-tag__close {
  607. z-index: 99 !important;
  608. }
  609. }
  610. }
  611. </style>