index.vue 15 KB

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