classification.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <template>
  2. <view>
  3. <view style="background-color: #E75F37;padding: 20rpx;">
  4. <u-search placeholder="请输入商品名称" bgColor="#fff" :showAction="false" searchIconColor='#E75F37'
  5. :searchIconSize='24' v-model="name" @click="inSearch" disabled></u-search>
  6. </view>
  7. <scroll-view @scrolltolower="lowerBottom" scroll-y="true" style="max-height: 82vh;" @scroll="scroll"
  8. :scroll-top="scrollTop">
  9. <view class="tag-calss">
  10. <view style="margin:0 12rpx;">
  11. <u-tag text="品牌" bgColor="#fff" borderColor='#E75F37' color="#E75F37" @click="openBrand"
  12. size="mini">
  13. </u-tag>
  14. </view>
  15. <view style="margin:0 12rpx;width: 2rpx;height: 43rpx;background: #E75F37;border-radius: 1rpx;"></view>
  16. <view style="margin:0 12rpx;">
  17. <u-tag text="清空" bgColor="#F8AA09" borderColor='#F8AA09' color="#fff" @click="emptyfun" size="mini">
  18. </u-tag>
  19. </view>
  20. </view>
  21. <view v-for="(item, index) in dataList" :key="index">
  22. <view class="card" @click="selectProduct(item)">
  23. <image :src="item.filesList[0].url" class="cardImg" mode="scaleToFill">
  24. </image>
  25. <view class="">
  26. <view style="display: flex;align-items: center;">
  27. <view class="cardName">
  28. {{item.cname}}
  29. </view>
  30. <image src="/static/images/tabBar/carIcon@2x.png" @click.stop="shoppingCartfun(item)"
  31. style="width: 54rpx;height: 54rpx;margin-left: 32rpx;" mode="scaleToFill">
  32. </image>
  33. </view>
  34. <view style="display: flex;align-items: center;">
  35. <view class="cardTab">
  36. <image src="/static/images/tabBar/280@2x.png" style="width: 142rpx;height: 36rpx;"
  37. mode="scaleToFill">
  38. </image>
  39. <image src="/static/images/tabBar/6@2x.png"
  40. style="width: 78rpx;height: 20rpx;position: absolute;left:10rpx;top:8rpx"
  41. mode="scaleToFill">
  42. </image>
  43. <view class="cardKc">
  44. {{Number(item.inventoryLocal) > 10?'充足':Number(item.inventoryLocal)}}
  45. </view>
  46. </view>
  47. <view>
  48. <view class="cardTab" style="margin-left: 10rpx;">
  49. <image src="/static/images/tabBar/2801@2x.png" style="width: 142rpx;height: 36rpx;"
  50. mode="scaleToFill">
  51. </image>
  52. <image src="/static/images/tabBar/7@2x.png"
  53. style="width: 78rpx;height: 20rpx;position: absolute;left:10rpx;top:8rpx"
  54. mode="scaleToFill">
  55. </image>
  56. <view class="cardKc">
  57. {{Number(item.inventoryShare) > 10?'充足':Number(item.inventoryShare)}}
  58. </view>
  59. </view>
  60. </view>
  61. <view class="cardPrice">
  62. ¥{{item.mallPrice}}
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <u-loadmore v-if="page.total !== 0" :status="status" />
  69. </scroll-view>
  70. <u-back-top :scroll-top="old.scrollTop" @tap="goTop" bottom="300rpx"></u-back-top>
  71. <uni-popup ref="popup" background-color="#fff" type="bottom">
  72. <view>
  73. <uni-row>
  74. <uni-col :span="6" v-for="(item,index) in tabbarTwo" :key="index">
  75. <view class="brandImg" @click="swichMenu(item,index)">
  76. <image :src="item.brandFilesList[0].url" mode="aspectFit"
  77. style="width:110rpx;height: 110rpx;border-radius:6rpx;border: 2rpx solid #EBEBEB;" />
  78. <text class='text'>{{item.cname}}</text>
  79. </view>
  80. </uni-col>
  81. </uni-row>
  82. </view>
  83. </uni-popup>
  84. </view>
  85. </template>
  86. <script>
  87. import {
  88. listAll2,
  89. goodsList
  90. } from '@/api/tabBar/classification.js'
  91. import {
  92. details,
  93. nameDetail
  94. } from '@/api/views/personalInformation/index.js'
  95. import {
  96. appDetail,
  97. addToCart
  98. } from '@/api/tabBar/home.js'
  99. export default {
  100. data() {
  101. return {
  102. scrollTop: 0,
  103. old: {
  104. scrollTop: 0
  105. },
  106. radios: [{
  107. label: '静音棉',
  108. checked: false,
  109. },
  110. {
  111. label: '自修补',
  112. checked: false,
  113. },
  114. {
  115. label: '防爆',
  116. checked: false,
  117. },
  118. ],
  119. current: 0, // 预设当前项的值
  120. tabbar: [],
  121. dataList: [],
  122. show: false,
  123. status: 'loadmore',
  124. filesList: [],
  125. tabbarTwo: [],
  126. name: '',
  127. page: {
  128. total: 0,
  129. size: 10,
  130. current: 1
  131. },
  132. search: {
  133. whether: '0'
  134. },
  135. checkStatus: null,
  136. recentSearches: [], // 搜索数据
  137. searchDeleteShow: false, // 搜索全部删除弹窗
  138. form: {}, // 详情数据
  139. checkboxValue: [], // 多选
  140. salesmanName: '', // 业务员姓名
  141. phoneNumber: '', // 业务员联系电话
  142. salesmanShow: false, // 联系业务员弹窗
  143. }
  144. },
  145. options: {
  146. styleIsolation: 'shared', // 解除样式隔离
  147. },
  148. props: {
  149. keyword: {
  150. type: String
  151. }
  152. },
  153. created() {
  154. // 获取最近搜索数据
  155. if (uni.getStorageSync('recentSearches')) {
  156. this.recentSearches = uni.getStorageSync('recentSearches');
  157. }
  158. // 获取审核状态
  159. details().then(res => {
  160. this.checkStatus = res.data.checkStatus
  161. uni.setStorageSync('checkStatus', res.data.checkStatus);
  162. if (this.checkStatus != '通过') {
  163. // uni.showToast({
  164. // title: "当前用户未授权,请联系客服",
  165. // icon: "none",
  166. // mask:true
  167. // });
  168. uni.switchTab({
  169. url: '/pages/tabBar/home'
  170. })
  171. return
  172. }
  173. this.salesmanName = res.data.salesmanName
  174. // 查询业务员详情拿取手机号
  175. if (!this.phoneNumber) {
  176. nameDetail({
  177. id: res.data.salesmanId
  178. }).then(res => {
  179. this.phoneNumber = res.data.phone
  180. })
  181. }
  182. })
  183. listAll2({
  184. type: 'PP',
  185. enableOrNot: '1',
  186. whetherIntegral: '1'
  187. }).then(res => {
  188. console.log(res.data.sort(this.compare('sort')), 111111)
  189. let arr = []
  190. arr = res.data.sort(this.compare('sort'))
  191. this.tabbarTwo = arr
  192. this.page = {
  193. total: 0,
  194. size: 10,
  195. current: 1
  196. }
  197. this.dataList = []
  198. let searchCache = JSON.parse(JSON.stringify(uni.getStorageSync('homeSearch')))
  199. uni.removeStorageSync('homeSearch')
  200. if (searchCache.cname) {
  201. this.name = searchCache.cname
  202. this.custom()
  203. } else {
  204. this.name = null
  205. if (this.current == -1) {
  206. this.current = 0
  207. }
  208. this.search = {
  209. // brandId: this.tabbarTwo[this.current].id,
  210. whether: '0',
  211. }
  212. this.onSearch()
  213. }
  214. })
  215. },
  216. methods: {
  217. searchData(data) {
  218. console.log(data)
  219. this.name = data
  220. this.custom()
  221. },
  222. openBrand() {
  223. this.$refs.popup.open('bottom')
  224. },
  225. goTop(e) {
  226. // 解决view层不同步的问题
  227. this.scrollTop = this.old.scrollTop
  228. this.$nextTick(() => {
  229. this.scrollTop = 0
  230. this.old.scrollTop = 0
  231. });
  232. },
  233. scroll(e) {
  234. this.old.scrollTop = e.detail.scrollTop
  235. },
  236. // 数组排序 property:根据什么属性排序
  237. compare(property) {
  238. return function(a, b) {
  239. var value1 = a[property]
  240. var value2 = b[property]
  241. return value1 - value2
  242. }
  243. },
  244. // 点击联系业务员
  245. clickCall() {
  246. uni.makePhoneCall({
  247. phoneNumber: this.phoneNumber,
  248. success: function() {
  249. console.log('拨打电话成功');
  250. },
  251. fail() {
  252. console.log('打电话失败了');
  253. }
  254. })
  255. },
  256. // 清空搜索条件
  257. emptyfun() {
  258. this.name = ''
  259. this.current = -1
  260. this.checkboxValue = []
  261. this.search = {
  262. whether: '0'
  263. }
  264. this.page = {
  265. total: 0,
  266. size: 10,
  267. current: 1
  268. }
  269. this.dataList = []
  270. this.onSearch()
  271. },
  272. checkboxChange(value) {
  273. this.checkboxValue = value
  274. this.search.originalFactory = null
  275. this.search.selfRecovery = null
  276. this.search.explosionProof = null
  277. if (this.checkboxValue.indexOf('静音棉') != -1) {
  278. this.search.originalFactory = 1
  279. }
  280. if (this.checkboxValue.indexOf('自修补') != -1) {
  281. this.search.selfRecovery = 1
  282. }
  283. if (this.checkboxValue.indexOf('防爆') != -1) {
  284. this.search.explosionProof = 1
  285. }
  286. this.page = {
  287. total: 0,
  288. size: 10,
  289. current: 1
  290. }
  291. this.dataList = []
  292. this.onSearch()
  293. },
  294. // 加入购物车
  295. shoppingCartfun(row) {
  296. console.log(row, 166);
  297. if (row.inventory == 0) {
  298. uni.showToast({
  299. title: "当前商品库存为零",
  300. icon: "none",
  301. mask: true,
  302. duration: 2500
  303. });
  304. return
  305. }
  306. // 获取详情数据
  307. appDetail({
  308. id: row.id
  309. }).then(res => {
  310. if (res.data.type == 0) {
  311. this.form = res.data.thisLocality
  312. } else {
  313. this.form = res.data.offsite
  314. }
  315. addToCart({
  316. ...this.form,
  317. whetherIntegral: '1',
  318. detailsText: ''
  319. }).then(res => {
  320. uni.showToast({
  321. title: "加入购物车成功",
  322. icon: "none",
  323. mask: true,
  324. duration: 2500
  325. });
  326. this.$emit('goTab', 2)
  327. })
  328. })
  329. },
  330. // 搜索全部删除
  331. searchDeletefun() {
  332. this.recentSearches = []
  333. uni.setStorageSync('recentSearches', this.recentSearches);
  334. this.searchDeleteShow = false
  335. },
  336. // 点击搜索
  337. tagSearches(name) {
  338. this.name = name
  339. this.search.cname = name
  340. this.custom()
  341. },
  342. // 最近搜索点击关闭按钮
  343. tagClose(index) {
  344. this.recentSearches.splice(index, 1)
  345. uni.setStorageSync('recentSearches', this.recentSearches);
  346. },
  347. selectProduct(item) {
  348. uni.$u.route('/pages/integralMall/buyGoods/commodityDetails', {
  349. id: item.id
  350. });
  351. },
  352. // 搜索全部删除
  353. searchDeletefun() {
  354. this.recentSearches = []
  355. uni.setStorageSync('recentSearches', this.recentSearches);
  356. this.searchDeleteShow = false
  357. },
  358. // 点击搜索
  359. inSearch() {
  360. uni.navigateTo({
  361. url: `/pages/integralMall/searchPage?searchData=${this.name?this.name:''}`
  362. })
  363. },
  364. lowerBottom() {
  365. this.status = 'loading'
  366. if (this.dataList.length < this.page.total) {
  367. this.page.current++
  368. this.onSearch()
  369. } else {
  370. this.status = 'nomore'
  371. }
  372. },
  373. // 搜索
  374. custom() {
  375. this.current = -1
  376. this.page = {
  377. total: 0,
  378. size: 10,
  379. current: 1
  380. }
  381. if (this.name) {
  382. this.recentSearches.unshift(this.name)
  383. // 去重
  384. this.recentSearches = this.recentSearches.filter((item, index) => this.recentSearches.indexOf(item) ===
  385. index);
  386. uni.setStorageSync('recentSearches', this.recentSearches);
  387. }
  388. delete this.search.brandId
  389. this.search.cname = this.name
  390. this.dataList = []
  391. this.onSearch()
  392. },
  393. // 左侧选择
  394. swichMenu(row, index) {
  395. // this.current = index;
  396. this.page = {
  397. total: 0,
  398. size: 10,
  399. current: 1
  400. }
  401. this.search.brandId = row.id
  402. this.search.cname = this.name ? this.name : null
  403. this.dataList = []
  404. this.onSearch()
  405. this.$refs.popup.close()
  406. },
  407. // 列表数据获取
  408. onSearch() {
  409. uni.showLoading({
  410. title: '加载中',
  411. mask: true
  412. });
  413. goodsList({
  414. size: this.page.size,
  415. current: this.page.current,
  416. ...this.search,
  417. whetherIntegral: "1"
  418. }).then(res => {
  419. this.dataList = this.dataList.concat(res.data.records)
  420. this.page.total = res.data.total
  421. if (this.dataList.length == res.data.total) {
  422. this.status = 'nomore'
  423. }
  424. uni.hideLoading();
  425. }).catch(err => {
  426. uni.hideLoading();
  427. })
  428. },
  429. }
  430. }
  431. </script>
  432. <style lang="scss" scoped>
  433. .brandImg {
  434. display: flex;
  435. flex-direction: column;
  436. align-items: center;
  437. justify-content: center;
  438. margin: 10rpx 0;
  439. .text {
  440. white-space: nowrap;
  441. overflow: hidden;
  442. text-overflow: ellipsis;
  443. width: 130rpx;
  444. text-align: center;
  445. font-size: 24rpx;
  446. color: #797979;
  447. }
  448. }
  449. .tag-calss {
  450. display: flex;
  451. padding: 41rpx 63rpx;
  452. background-color: #fff;
  453. justify-content: flex-end;
  454. ::v-deep .u-tag--mini {
  455. font-size: 28rpx;
  456. line-height: 22px;
  457. padding: 0rpx 24rpx !important;
  458. }
  459. }
  460. .card {
  461. display: flex;
  462. align-items: center;
  463. background-color: #fff;
  464. width: 100%;
  465. margin-top: 28rpx;
  466. .cardImg {
  467. margin: 31rpx;
  468. width: 180rpx;
  469. height: 180rpx;
  470. border: 2rpx solid #E7E7E7;
  471. }
  472. .cardName {
  473. font-weight: 400;
  474. font-size: 24rpx;
  475. height: 64rpx;
  476. width: 400rpx;
  477. color: #797979;
  478. display: -webkit-box;
  479. -webkit-box-orient: vertical;
  480. -webkit-line-clamp: 2;
  481. overflow: hidden;
  482. text-overflow: ellipsis;
  483. margin-bottom: 28rpx;
  484. }
  485. .cardTab {
  486. position: relative;
  487. top: 4rpx;
  488. .cardKc {
  489. text-align: center;
  490. position: absolute;
  491. right: 4rpx;
  492. top: 3rpx;
  493. font-size: 22rpx;
  494. color: #FFFFFF;
  495. font-weight: 500;
  496. width: 43rpx;
  497. height: 28rpx;
  498. }
  499. }
  500. .cardPrice {
  501. margin-left: 10rpx;
  502. color: #E75F37;
  503. font-size: 32rpx;
  504. font-weight: 500;
  505. }
  506. }
  507. </style>