goodList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <view class="container">
  3. <view v-if="goodType == 2" class="auction-main">
  4. <view class="auction-title" @click="isOpen = !isOpen">拍卖规则
  5. <u-icon :name="isOpen?'arrow-up-fill':'arrow-down-fill'" color="#ffffff" style="margin-left:5px"></u-icon>
  6. </view>
  7. <view v-if="isOpen" class="auction-explain">
  8. <span>特别注意:</span>
  9. <p>本商城拍卖采用竞拍即付款的拍卖方式,每名会员每次拍卖仅能购买一件拍卖商品,同时根据拍卖商品的数量也可能会有多个会员竞拍成功。</p>
  10. <span>关于退款:</span>
  11. <p>会员出价如果已经不具有竞拍成功资质(也就是出价已经不是最高出价的几名会员之一时),则会立刻退还费用。同一会员多次出价会立刻退还上次出价的费用。</p>
  12. <span>关于竞拍结果:</span>
  13. <p>拍卖结束时,出价最高的几名会员竞拍成功,至多有"拍卖商品数量"个竞拍成功的会员。</p>
  14. </view>
  15. </view>
  16. <!-- <u-collapse v-if="goodType == 2" :head-style="auctiontitle">
  17. <u-collapse-item>
  18. <view slot="title-all" class="auction-title" @click="isOpen = !isOpen">拍卖规则
  19. <u-icon :name="isOpen?'arrow-up-fill':'arrow-down-fill'" color="#ffffff" style="margin-left:5px"></u-icon>
  20. </view>
  21. <view class="auction-main">
  22. <view class="auction-explain">
  23. <span>特别注意:</span>
  24. <p>本商城拍卖采用竞拍即付款的拍卖方式,每名会员每次拍卖仅能购买一件拍卖商品,同时根据拍卖商品的数量也可能会有多个会员竞拍成功。</p>
  25. <span>关于退款:</span>
  26. <p>会员出价如果已经不具有竞拍成功资质(也就是出价已经不是最高出价的几名会员之一时),则会立刻退还费用。同一会员多次出价会立刻退还上次出价的费用。</p>
  27. <span>关于竞拍结果:</span>
  28. <p>拍卖结束时,出价最高的几名会员竞拍成功,至多有"拍卖商品数量"个竞拍成功的会员。</p>
  29. </view>
  30. </view>
  31. </u-collapse-item>
  32. </u-collapse> -->
  33. <view class="search-box" v-if="goodsList.length">
  34. <uni-search-bar ref="searchBar" radius="5" placeholder="搜索" :defaultText="goodName" clearButton="auto" cancelButton="none"
  35. bgColor="#ffffff" @confirm="search" class="search-bar" />
  36. </view>
  37. <scroll-view class="goods-box" scroll-y="true" @scrolltolower="handleLoadMore()">
  38. <view class="goods-row" :style="{height: (item.productType == 2 ? '124px' : '104px')}" v-for="(item, index) in goodsList" :key="index" @click="goToGoodDetails(item)">
  39. <image class="goods-img" :src="item.imgPath" mode="aspectFill"></image>
  40. <view class="goods-info">
  41. <view class="goods-name">{{item.productName}}</view>
  42. <view class="goods-details" v-if="item.productType != 4">{{item.productDescribe}}</view>
  43. <view class="goods-area" v-if="item.productType == 4">面积:{{item.areaSize}}㎡&nbsp;&nbsp;&nbsp;&nbsp;时长:{{item.term}}天</view>
  44. <view class="goods-endTime" v-if="item.productType == 2">结束时间: {{item.auctionEndTime}}</view>
  45. <view class="goods-number">
  46. <text class="goods-icon">¥</text>
  47. <text class="goods-spec">{{item.bizPrice}}{{item.productType != 4 ? '/' + item.unit : ''}}</text>
  48. <text class="goods-original">原价:{{item.originalPrice}}</text>
  49. <!-- <text class="goods-sales" v-if="item.productType != 4">{{item.sellCount}}人付款</text> -->
  50. </view>
  51. </view>
  52. <view class="goods-cart">
  53. <view class="cart-button" v-if="goodType == 1 || goodType == 3 || goodType == 5" @click.stop="addCart(item)">
  54. <view class="iconfont icongouwuche"></view>
  55. </view>
  56. <view class="more-button" v-else>
  57. <view class="iconfont icongengduo"></view>
  58. </view>
  59. </view>
  60. </view>
  61. <view style="padding-top: 20px;background-color: transparent;" v-if="isOver">
  62. <u-divider color="#909399" border-color="#909399" bg-color="transparent">没有更多了</u-divider>
  63. </view>
  64. </scroll-view>
  65. <u-modal v-model="modalShow" content="是否将该商品添加至购物车" @confirm="submitAddCart()" :async-close="true"
  66. :show-cancel-button="true"></u-modal>
  67. <u-top-tips ref="uTips"></u-top-tips>
  68. </view>
  69. </template>
  70. <script>
  71. const NET = require('@/utils/request')
  72. const API = require('@/config/api')
  73. export default {
  74. data() {
  75. return {
  76. goodType: '',
  77. pageIndex: 1,
  78. isOver: false,
  79. goodName: '',
  80. goodsList: [],
  81. modalShow: false,
  82. goodItem: {},
  83. isOpen: false,
  84. auctiontitle: {
  85. height: '35px',
  86. background:'#52A63A',
  87. color: '#FFFFFF',
  88. 'text-align': 'center',
  89. padding: '5px',
  90. }
  91. }
  92. },
  93. onLoad(options) {
  94. this.goodName = options.goodName ? options.goodName : ''
  95. this.goodType = options.goodType
  96. uni.setNavigationBarTitle({
  97. title: this.goodType == 1 ? '商品列表' : (this.goodType == 3 ? '自助采摘' : (this.goodType == 4 ? '共享种植' : this.goodType == 5 ? '今日特惠' : '拍卖'))
  98. });
  99. this.getGoodsList()
  100. },
  101. onShow() {
  102. this.getGoodsList()
  103. },
  104. onReady() {
  105. if (this.goodName) {
  106. this.$refs.searchBar.show = true
  107. this.$refs.searchBar.showSync = true
  108. this.$refs.searchBar.searchVal = this.goodName
  109. }
  110. },
  111. onPullDownRefresh() {
  112. this.goodsList = []
  113. this.pageIndex = 1
  114. this.getGoodsList('refresh')
  115. },
  116. methods: {
  117. // 搜索商品
  118. search(data) {
  119. this.goodName = data.value
  120. this.goodsList = []
  121. this.pageIndex = 1
  122. this.getGoodsList()
  123. },
  124. // 懒加载
  125. handleLoadMore() {
  126. if (!this.isOver) {
  127. this.pageIndex++
  128. this.getGoodsList()
  129. }
  130. },
  131. // 获取商品
  132. getGoodsList(type) {
  133. if (this.goodType == 5) {
  134. NET.request(API.getPreferentialGoods+'/' + this.pageIndex+'/10', {
  135. name: this.goodName
  136. }, 'GET').then(res => {
  137. if (type == 'refresh') {
  138. uni.stopPullDownRefresh();
  139. }
  140. this.isOver = res.data.list.length != 10
  141. this.goodsList = this.goodsList.concat(res.data.list)
  142. }).catch(error => {
  143. this.$refs.uTips.show({
  144. title: '获取今日特惠商品列表失败',
  145. type: 'warning',
  146. })
  147. })
  148. } else {
  149. NET.request(API.getGoodsByType, {
  150. name: this.goodName,
  151. productType: this.goodType,
  152. pageIndex: this.pageIndex,
  153. pageSize: 10,
  154. }, 'POST').then(res => {
  155. if (type == 'refresh') {
  156. uni.stopPullDownRefresh();
  157. }
  158. this.isOver = res.data.list.length != 10
  159. this.goodsList = this.goodsList.concat(res.data.list)
  160. }).catch(error => {
  161. this.$refs.uTips.show({
  162. title: '获取商品列表失败',
  163. type: 'warning',
  164. })
  165. })
  166. }
  167. },
  168. // 添加购物车
  169. addCart(item) {
  170. debugger
  171. this.goodItem = {
  172. productId: this.goodType == 5 ? item.productId : item.id,
  173. productName: item.productName,
  174. imgUrl: item.imgPath,
  175. bizPrice: item.bizPrice,
  176. originalPrice: item.originalPrice,
  177. productType: item.productType,
  178. tenantCode: item.tenantCode,
  179. buyNum: 1
  180. }
  181. this.modalShow = true
  182. },
  183. // 提交购物车
  184. submitAddCart() {
  185. NET.request(API.addCart, this.goodItem, 'POST').then(res => {
  186. this.$refs.uTips.show({
  187. title: '加入购物车成功',
  188. type: 'success',
  189. })
  190. this.modalShow = false
  191. }).catch(res => {
  192. this.modalShow = false
  193. this.$refs.uTips.show({
  194. title: '加入购物车失败',
  195. type: 'warning',
  196. })
  197. })
  198. },
  199. // 跳转商品详情
  200. goToGoodDetails(item) {
  201. if (this.goodType == 5) {
  202. item.id = item.productId
  203. }
  204. uni.navigateTo({
  205. url: '/pagesGood/goodDetails?goodId=' + item.id
  206. });
  207. }
  208. },
  209. }
  210. </script>
  211. <style>
  212. page {
  213. width: 100%;
  214. height: 100%;
  215. background-color: #f7f7f7;
  216. }
  217. </style>
  218. <style lang="less" scoped>
  219. page {
  220. width: 100%;
  221. height: 100%;
  222. }
  223. .container {
  224. width: 100%;
  225. height: 100%;
  226. background-color: #f7f7f7;
  227. .auction-main {
  228. // background: #52A63A;
  229. }
  230. .auction-title {
  231. height: 35px;
  232. background:#52A63A;
  233. color: #FFFFFF;
  234. text-align: center;
  235. padding: 5px;
  236. }
  237. .auction-explain {
  238. background:#52A63A;
  239. color: #FFFFFF;
  240. border-radius: 0 0 8px 8px;
  241. // text-align: center;
  242. padding: 10px;
  243. p {
  244. margin-bottom: 5px;
  245. text-indent:25px;
  246. }
  247. }
  248. .search-box {
  249. width: 100%;
  250. height: 58px;
  251. box-sizing: border-box;
  252. padding: 2px 12px 1px 12px;
  253. /deep/.uni-searchbar {
  254. background-color: #f7f7f7;
  255. }
  256. }
  257. .goods-box {
  258. width: 100%;
  259. height: calc(100% - 58px) !important;
  260. padding: 6px 0 10px 0;
  261. box-sizing: border-box;
  262. overflow-y: auto;
  263. .goods-row {
  264. width: calc(100% - 24px);
  265. height: 104px;
  266. float: left;
  267. padding: 11px 11px 11px 7px;
  268. box-sizing: border-box;
  269. margin: 4px 0 12px 12px;
  270. background: #FFFFFF;
  271. box-shadow: 0px 1px 5px 0px rgba(102, 102, 102, 0.43);
  272. border-radius: 15px;
  273. .goods-img {
  274. width: 84px;
  275. height: 84px;
  276. float: left;
  277. border-radius: 5px;
  278. }
  279. .goods-info {
  280. width: calc(100% - 108px);
  281. height: 84px;
  282. box-sizing: border-box;
  283. padding-left: 6px;
  284. float: left;
  285. .goods-name {
  286. width: calc(100% + 24px);
  287. height: 18px;
  288. font-size: 15px;
  289. font-family: PingFang SC;
  290. color: #333333;
  291. line-height: 18px;
  292. white-space: nowrap;
  293. text-overflow: ellipsis;
  294. overflow: hidden;
  295. }
  296. .goods-details {
  297. height: 28px;
  298. font-size: 12px;
  299. font-family: PingFang SC;
  300. color: #999999;
  301. line-height: 14px;
  302. overflow: hidden;
  303. text-overflow: ellipsis;
  304. display: -webkit-box;
  305. -webkit-line-clamp: 2;
  306. -webkit-box-orient: vertical;
  307. word-wrap: break-word;
  308. margin: 4px 0 10px 0;
  309. }
  310. .goods-area {
  311. height: 28px;
  312. margin: 8px 0;
  313. line-height: 28px;
  314. font-size: 13px;
  315. font-family: PingFang SC;
  316. color: #666666;
  317. }
  318. .goods-endTime {
  319. margin-bottom: 10px;
  320. font-size: 12px;
  321. }
  322. .goods-number {
  323. height: 16px;
  324. font-family: PingFang SC;
  325. line-height: 16px;
  326. .goods-icon {
  327. font-size: 12px;
  328. color: #52A63A;
  329. }
  330. .goods-spec {
  331. font-size: 16px;
  332. color: #52A63A;
  333. margin-right: 5px;
  334. }
  335. .goods-original {
  336. font-size: 12px;
  337. color: #a67954;
  338. margin-right: 10px;
  339. text-decoration:line-through
  340. }
  341. .goods-sales {
  342. font-size: 12px;
  343. color: #999999;
  344. }
  345. }
  346. }
  347. .goods-cart {
  348. width: 24px;
  349. height: 84px;
  350. float: left;
  351. .cart-button {
  352. width: 24px;
  353. height: 24px;
  354. margin-top: 30px;
  355. background-color: #52A63A;
  356. border-radius: 50%;
  357. text-align: center;
  358. .iconfont {
  359. color: #FFFFFF;
  360. font-size: 18px;
  361. line-height: 24px;
  362. }
  363. }
  364. .more-button {
  365. width: 24px;
  366. height: 20px;
  367. margin-top: 64px;
  368. .iconfont {
  369. color: #999999;
  370. font-size: 32px;
  371. line-height: 20px;
  372. }
  373. }
  374. }
  375. }
  376. }
  377. }
  378. </style>