list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <view class="details">
  3. <!-- 详情页面 -->
  4. <navbar :config="config">
  5. <view slot="right"
  6. style="margin-right: 30rpx;
  7. "
  8. @click="ProvideData"
  9. >确认</view>
  10. </navbar>
  11. <view class="zdtopbox">
  12. <view class="top-input">
  13. <text class="iconfont position-ab u-mt15 u-ml30 u-D1D9D4">&#xe7a6;</text>
  14. <input type="text" style="font-size: 28rpx;flex: 1;" value="" @confirm='confirmSubmit' v-model="value" placeholder="请输入搜索关键字" placeholder-class="pc" />
  15. <text style="color: #FFFFFF;font-size: 36rpx; font-weight: 500;margin-left: 20rpx" @click="SearchContent">搜索</text>
  16. </view>
  17. <view class="details-top">
  18. <view class="item" @click="changecolor(1)" >
  19. <view class="content" :class="topIndex==1?'itemcolor':''">
  20. 综合
  21. </view>
  22. <view class="icontb">
  23. <!-- <view class="iconfont u-font24 linge top" :class="topIndex==1&&!price?'itemcolor':''" >&#xeb20;</view> -->
  24. <!-- <view class="iconfont u-font24 linge" :class="topIndex==1&&price?'itemcolor':''">&#xeb1f;</view> -->
  25. </view>
  26. </view>
  27. <view class="item" @click="changecolor(2)" >
  28. <view class="content" :class="topIndex==2?'itemcolor':''">
  29. 最新
  30. </view>
  31. <!-- <view class="icontb">
  32. <view class="iconfont u-font24 linge top" :class="topIndex==2&&!towPrice?'twoitemcolor':''">&#xeb20;</view>
  33. <view class="iconfont u-font24 linge" :class="topIndex==2&&towPrice?'twoitemcolor':''">&#xeb1f;</view>
  34. </view> -->
  35. </view>
  36. <view class="item" @click="changecolor(3)" >
  37. <view class="content" :class="topIndex==3?'itemcolor':''">
  38. 利润
  39. </view>
  40. <view class="icontb">
  41. <view class="iconfont arrow" :class="topIndex==3&&!threePrice?'twoitemcolor':''">&#xe648;</view>
  42. <view class="iconfont arrow" :class="topIndex==3&&threePrice?'twoitemcolor':''">&#xe645;</view>
  43. </view>
  44. </view>
  45. <view class="item" @click="changecolor(4)" >
  46. <view class="content" :class="topIndex==4?'itemcolor':''">
  47. 销量
  48. </view>
  49. <!-- <view class="icontb">
  50. <view class="iconfont u-font24 linge top" :class="topIndex==4&&!fourPrice?'twoitemcolor':''">&#xeb20;</view>
  51. <view class="iconfont u-font24 linge" :class="topIndex==4&&fourPrice?'twoitemcolor':''">&#xeb1f;</view>
  52. </view> -->
  53. </view>
  54. <!-- <view class="item" @click="changecolor(5)" >
  55. <view class="content" :class="topIndex==5?'itemcolor':''">
  56. 筛选
  57. </view>
  58. <view class="icontb">
  59. <view class="iconfont u-font24 linge top" :class="topIndex==5&&!fivePrice?'twoitemcolor':''">&#xe648;</view>
  60. <view class="iconfont u-font24 linge" :class="topIndex==5&&fivePrice?'twoitemcolor':''">&#xe645;</view>
  61. </view>
  62. </view> -->
  63. </view>
  64. </view>
  65. <!-- 中间的列表 -->
  66. <view class="middle-content">
  67. <view class="white-lump" v-for="(item,index) in goodsList" @click="onFlag(item,index)" :key="index">
  68. <view class="radio">
  69. <view class="addcommodity" v-if="item.flag" >
  70. <icon type="success" color="#ff0000" size="18"></icon>
  71. </view>
  72. <view class="addcommodity" v-else style="width: 16px; height: 16px; border-radius: 50%;border: 1px solid #333;box-sizing: border-box;">
  73. </view>
  74. </view>
  75. <image :src="item.cover" mode="" class="list-image"></image>
  76. <view class="name-and-num">
  77. <div>
  78. <view class="name">
  79. {{item.title}}
  80. </view>
  81. <view class="sell">
  82. 已售<text class="yello">{{item.result_sale_num}}</text>
  83. </view>
  84. </div>
  85. <view class="num u-FF0000">
  86. <!-- <view class="red">
  87. <text class="symbol">¥</text>
  88. <text class="one">1</text>
  89. <text class="large">25.</text>
  90. <text class="zero">00</text>
  91. </view> -->
  92. <rich-text :nodes="$mUtil.priceBigSmall(item.min_sale_price)"></rich-text>
  93. <view class="past">
  94. <!-- ¥{{item.max_market_price}} -->
  95. <rich-text :nodes="$mUtil.priceBigSmall(item.max_market_price)"></rich-text>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <loadMore v-if="goodsList.length>0" :status="status"></loadMore>
  102. <nodata v-else :config="{top:20,content:'暂无商品~'}"></nodata>
  103. <!-- 页面加载动画 -->
  104. <ldLoading isFullScreen :active="loading"></ldLoading>
  105. </view>
  106. </template>
  107. <script>
  108. var app = getApp()
  109. export default{
  110. data(){
  111. return{
  112. config: {
  113. back: true, //false是tolbar页面 是则不写
  114. title: '选择商品',
  115. color: '#fff',
  116. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  117. backgroundColor: [1, "#0B844A"],
  118. statusBarFontColor: '#ffffff',
  119. rightSlot:true,
  120. },
  121. comprehensivedata:[
  122. {
  123. id:1,
  124. name:"综合"
  125. },
  126. {
  127. id:2,
  128. name:"最新"
  129. },
  130. {
  131. id:3,
  132. name:"利润"
  133. },
  134. {
  135. id:4,
  136. name:"销量"
  137. },
  138. {
  139. id:5,
  140. name:"筛选"
  141. }
  142. ],
  143. topIndex:1,
  144. price:false,//综合的上下切换
  145. towPrice:false,//最新的上下切换
  146. threePrice:false,//利润的上下切换
  147. fourPrice:false,//销量的上下切换
  148. fivePrice:false,//筛选的上下切换
  149. newest:false,
  150. screeningIndex:1, //
  151. loading:true,
  152. value:"",
  153. status:'more', //more|loading|noMore
  154. noData:false,
  155. goodsList:[],
  156. tabTop:0,
  157. params:{
  158. limit:10,
  159. page:1,
  160. order_type:1,//1是综合(按发布时间),2是新品,3价格,4销量
  161. order_mode:''//asc 或 desc
  162. },
  163. currPage: 1,
  164. totalPage: 1,
  165. ischeckbox:[]
  166. }
  167. },
  168. // onShow() {
  169. // this.getShopList()
  170. // },
  171. //监听页面加载
  172. onLoad(options){
  173. this.tabTop = app.globalData.barHeight+44;
  174. if(options.keyword){
  175. this.params.title = options.keyword
  176. this.value = options.keyword
  177. this.getShopList()
  178. }else{
  179. this.getShopList()
  180. }
  181. },
  182. //页面滚动到底部的事件
  183. onReachBottom(e){
  184. if (this.totalPage <= this.currPage) {
  185. this.status = "noMore";
  186. } else {
  187. this.status='loading'
  188. this.params.page++
  189. this.getShopList()
  190. }
  191. },
  192. //下拉刷新
  193. onPullDownRefresh(){
  194. this.rest()
  195. this.getShopList()
  196. },
  197. methods:{
  198. //模糊搜索
  199. confirmSubmit(e){
  200. this.params.title = e.detail.value
  201. this.value = e.detail.value
  202. this.rest()
  203. this.getShopList()
  204. },
  205. SearchContent(){
  206. this.params.title = this.value
  207. this.rest();
  208. this.getShopList();
  209. },
  210. //每个选项
  211. onFlag(item,index){
  212. item.flag=!item.flag
  213. if(item.flag){
  214. this.ischeckbox.push(item)
  215. console.log(item)
  216. }else{
  217. this.ischeckbox.splice(index,1)
  218. // if(this.ischeckbox.some(val=>val.id==item.id)){
  219. // this.ischeckbox.shift(item)
  220. // }
  221. }
  222. console.log(this.ischeckbox)
  223. },
  224. //获取数据
  225. // getShopList(){
  226. // let shop= uni.getStorageSync("shop")
  227. // },
  228. // addList(){
  229. // uni.$emit("changeList",data)
  230. // },
  231. ProvideData(){
  232. if(this.ischeckbox.length==0||this.ischeckbox==null){
  233. this.$mUtil.toast("请选择需要添加的商品");
  234. return false
  235. }
  236. if(this.ischeckbox.length>6){
  237. this.$mUtil.toast("最多添加6件商品");
  238. return false
  239. }
  240. console.log(this.ischeckbox)
  241. uni.setStorageSync("ischeckbox",this.ischeckbox)
  242. // let checkList = uni.getStorageSync("ischeckbox")
  243. // ? uni.getStorageSync("ischeckbox")
  244. // : [];
  245. // this.ischeckbox.forEach(val=>{
  246. // checkList.unshift(val)
  247. // })
  248. // let arr = JSON.parse(JSON.stringify(checkList));
  249. // let hash = {};
  250. // arr = arr.reduce((preVal, curVal) => {
  251. // hash[curVal.id] ? '' : hash[curVal.id] = true && preVal.push(curVal);
  252. // return preVal
  253. // }, [])
  254. // if(arr.length>6){
  255. // this.$mUtil.toast("最多添加6件商品");
  256. // return false
  257. // }
  258. // uni.setStorageSync("ischeckbox",arr)
  259. var pages = getCurrentPages();
  260. var beforePage = pages[pages.length - 2];
  261. // console.log(beforePage.smallBox,1111111111)
  262. //返回上一层页面并保持上一层页面的数据
  263. uni.navigateBack()
  264. },
  265. //获取数据
  266. getShopList(){
  267. this.$http.get("/goods/all/pages",this.params)
  268. .then(res=>{
  269. uni.stopPullDownRefresh()
  270. this.loading = false;
  271. this.triggered=false
  272. if(res&&res.code==200){
  273. this.ischeckbox=uni.getStorageSync("ischeckbox")?uni.getStorageSync("ischeckbox"):[]
  274. if(this.ischeckbox){
  275. res.page.list.forEach((val,index)=>{
  276. if(this.ischeckbox.some(item=>item.id==val.id)){
  277. res.page.list[index].flag=true
  278. }else{
  279. res.page.list[index].flag=false
  280. }
  281. })
  282. }else{
  283. res.page.list.forEach(val=>{
  284. val.flag=false
  285. })
  286. }
  287. this.goodsList = this.goodsList.concat(res.page.list)
  288. if(this.goodsList.length==0){
  289. this.noData = true
  290. }else{
  291. this.noData=false
  292. }
  293. if(res.page.currPage >= res.page.totalPage){
  294. this.status="noMore"
  295. }else{
  296. this.status = "more"
  297. }
  298. this.currPage = res.page.currPage
  299. this.totalPage = res.page.totalPage
  300. }
  301. })
  302. },
  303. //点击切换排序条件
  304. changecolor(e){
  305. // this.loading=true;
  306. this.topIndex=e
  307. this.params.order_type = e
  308. // if(e==1){
  309. // this.price=!this.price
  310. // if(this.price){
  311. // this.params.order_mode='asc'
  312. // }else{
  313. // this.params.order_mode='desc'
  314. // }
  315. // }
  316. // if(e==2){
  317. // this.towPrice=!this.towPrice
  318. // if(this.params){
  319. // this.params.order_mode='asc'
  320. // }else{
  321. // this.params.order_mode='desc'
  322. // }
  323. // }
  324. if(e==3){
  325. this.threePrice=!this.threePrice
  326. if(this.threePrice){
  327. this.params.order_mode="asc"
  328. }else{
  329. this.params.order_mode="desc"
  330. }
  331. }
  332. if(e==4){
  333. this.fourPrice=!this.fourPrice
  334. this.params.order_mode='desc'
  335. }
  336. if(e==5){
  337. this.fivePrice=!this.fivePrice
  338. }
  339. this.rest()
  340. this.getShopList()
  341. },
  342. //初始化数据
  343. rest(){
  344. this.params.page =1
  345. this.goodsList=[]
  346. },
  347. }
  348. }
  349. </script>
  350. <style lang="scss" scoped>
  351. .arrow{
  352. font-size: 20rpx;
  353. }
  354. /deep/ .pc{
  355. font-size: 22rpx;
  356. color: #dbdbdb !important;
  357. }
  358. .position-ab{
  359. position: absolute;
  360. margin-top: 4rpx;
  361. margin-left: 30rpx;
  362. color: #D1D9D4;
  363. }
  364. .zdtopbox{
  365. background-color: #0B844A;
  366. padding: 8rpx 30rpx 0 30rpx;
  367. position: fixed;
  368. left: 0;
  369. width: 100%;
  370. z-index: 66;
  371. box-sizing: border-box;
  372. }
  373. .top-input{
  374. display: flex;
  375. background-color: #0B844A;
  376. align-items: center;
  377. input{
  378. width: 100%;
  379. height: 60rpx;
  380. line-height: 60rpx;
  381. border-radius: 50rpx;
  382. background-color: rgba($color: #ABC5B5, $alpha: .4);
  383. color: #fff;
  384. padding-left: 78rpx;
  385. box-sizing: border-box;
  386. }
  387. }
  388. .details{
  389. .middle-content{
  390. margin-top: 140rpx;
  391. background-color: #f5f5f5;
  392. overflow: hidden;
  393. .white-lump{
  394. display: flex;
  395. background-color: white;
  396. height: 227rpx;
  397. width: 690rpx;
  398. border-radius: 18rpx;
  399. margin: 32rpx 30rpx 25rpx 30rpx;
  400. .name-and-num{
  401. margin-left: 30rpx;
  402. width: 368rpx;
  403. margin-top: 20rpx;
  404. overflow: hidden;
  405. display: flex;
  406. flex-direction: column;
  407. justify-content: space-between;
  408. height: 187rpx;
  409. .name{
  410. font-size: 28rpx;
  411. font-weight: 400;
  412. color: #181818;
  413. opacity: 1;
  414. overflow: hidden;
  415. text-overflow: ellipsis;
  416. display: -webkit-box;
  417. -webkit-line-clamp: 2;
  418. -webkit-box-orient: vertical;
  419. word-wrap: break-word;
  420. word-break: break-all;
  421. white-space: normal !important
  422. }
  423. .sell{
  424. color: #999999;
  425. font-size: 28rpx;
  426. font-weight: 500;
  427. margin-top: 3rpx;
  428. .yello{
  429. color: rgba(254,144,0,1);
  430. }
  431. }
  432. .num{
  433. display: flex;
  434. margin-top: 30rpx;
  435. .red{
  436. color: #ff0000;
  437. .symbol{
  438. font-size: 20rpx;
  439. font-weight: 500;
  440. }
  441. .one{
  442. font-size: 32rpx;
  443. font-weight: 500;
  444. }
  445. .large{
  446. font-size: 32rpx;
  447. font-weight: Bold;
  448. }
  449. .zero{
  450. font-size: 20rpx;
  451. font-weight: Bold;
  452. }
  453. }
  454. .past{
  455. color: #cccccc;
  456. font-weight: 500;
  457. font-size: 22rpx;
  458. margin-left: 17rpx;
  459. margin-top: 8rpx;
  460. text-decoration: line-through;
  461. }
  462. }
  463. }
  464. .radio{
  465. display: flex;
  466. align-items: center;
  467. margin-left: 22rpx;
  468. width: 18px;
  469. .addcommodity{
  470. // margin-top: 80rpx;
  471. }
  472. }
  473. .list-image{
  474. width: 187rpx;
  475. height: 187rpx;
  476. margin-left: 15rpx;
  477. border-radius: 18rpx;
  478. margin-top: 20rpx;
  479. }
  480. }
  481. }
  482. }
  483. .twoitemcolor{
  484. color: rgba(220,205,164,1) ;
  485. }
  486. .details-top{
  487. margin-top: 30rpx;
  488. margin-bottom: 24rpx;
  489. display: flex;
  490. justify-content: space-around;
  491. color: #ffffff;
  492. font-weight: 500;
  493. font-size: 28rpx;
  494. align-items: center;
  495. background-color: #0B844A;
  496. .item{
  497. display: flex;
  498. .content{
  499. // line-height: 14rpx;
  500. }
  501. }
  502. //图标上下
  503. .icontb{
  504. margin-left: 8rpx;
  505. .top{
  506. padding-top:10rpx;
  507. }
  508. .linge{
  509. line-height: 12rpx;
  510. }
  511. }
  512. }
  513. .itemcolor{
  514. color: rgba(220,205,164,1);
  515. }
  516. </style>