goodList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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. } else {
  140. this.goodsList = []
  141. }
  142. this.isOver = res.data.list.length != 10
  143. this.goodsList = this.goodsList.concat(res.data.list)
  144. }).catch(error => {
  145. this.$refs.uTips.show({
  146. title: '获取今日特惠商品列表失败',
  147. type: 'warning',
  148. })
  149. })
  150. } else {
  151. NET.request(API.getGoodsByType, {
  152. name: this.goodName,
  153. productType: this.goodType,
  154. pageIndex: this.pageIndex,
  155. pageSize: 10,
  156. }, 'POST').then(res => {
  157. if (type == 'refresh') {
  158. uni.stopPullDownRefresh();
  159. } else {
  160. this.goodsList = []
  161. }
  162. this.isOver = res.data.list.length != 10
  163. this.goodsList = this.goodsList.concat(res.data.list)
  164. }).catch(error => {
  165. this.$refs.uTips.show({
  166. title: '获取商品列表失败',
  167. type: 'warning',
  168. })
  169. })
  170. }
  171. },
  172. // 添加购物车
  173. addCart(item) {
  174. this.goodItem = {
  175. productId: this.goodType == 5 ? item.productId : item.id,
  176. productName: item.productName,
  177. imgUrl: item.imgPath,
  178. bizPrice: item.bizPrice,
  179. originalPrice: item.originalPrice,
  180. productType: item.productType,
  181. tenantCode: item.tenantCode,
  182. buyNum: 1
  183. }
  184. this.modalShow = true
  185. },
  186. // 提交购物车
  187. submitAddCart() {
  188. NET.request(API.addCart, this.goodItem, 'POST').then(res => {
  189. this.$refs.uTips.show({
  190. title: '加入购物车成功',
  191. type: 'success',
  192. })
  193. this.modalShow = false
  194. }).catch(res => {
  195. this.modalShow = false
  196. this.$refs.uTips.show({
  197. title: '加入购物车失败',
  198. type: 'warning',
  199. })
  200. })
  201. },
  202. // 跳转商品详情
  203. goToGoodDetails(item) {
  204. if (this.goodType == 5) {
  205. item.id = item.productId
  206. }
  207. uni.navigateTo({
  208. url: '/pagesGood/goodDetails?goodId=' + item.id
  209. });
  210. }
  211. },
  212. }
  213. </script>
  214. <style>
  215. page {
  216. width: 100%;
  217. height: 100%;
  218. background-color: #f7f7f7;
  219. }
  220. </style>
  221. <style lang="less" scoped>
  222. page {
  223. width: 100%;
  224. height: 100%;
  225. }
  226. .container {
  227. width: 100%;
  228. height: 100%;
  229. background-color: #f7f7f7;
  230. .auction-main {
  231. // background: #52A63A;
  232. }
  233. .auction-title {
  234. height: 35px;
  235. background:#52A63A;
  236. color: #FFFFFF;
  237. text-align: center;
  238. padding: 5px;
  239. }
  240. .auction-explain {
  241. background:#52A63A;
  242. color: #FFFFFF;
  243. border-radius: 0 0 8px 8px;
  244. // text-align: center;
  245. padding: 10px;
  246. p {
  247. margin-bottom: 5px;
  248. text-indent:25px;
  249. }
  250. }
  251. .search-box {
  252. width: 100%;
  253. height: 58px;
  254. box-sizing: border-box;
  255. padding: 2px 3px 1px 3px;
  256. /deep/.uni-searchbar {
  257. background-color: #f7f7f7;
  258. }
  259. }
  260. .goods-box {
  261. width: 100%;
  262. height: calc(100% - 58px) !important;
  263. padding: 6px 0 10px 0;
  264. box-sizing: border-box;
  265. overflow-y: auto;
  266. .goods-row {
  267. width: calc(100% - 24px);
  268. height: 104px;
  269. float: left;
  270. padding: 11px 11px 11px 7px;
  271. box-sizing: border-box;
  272. margin: 4px 0 12px 12px;
  273. background: #FFFFFF;
  274. box-shadow: 0px 1px 5px 0px rgba(102, 102, 102, 0.43);
  275. border-radius: 15px;
  276. .goods-img {
  277. width: 84px;
  278. height: 84px;
  279. float: left;
  280. border-radius: 5px;
  281. }
  282. .goods-info {
  283. width: calc(100% - 108px);
  284. height: 84px;
  285. box-sizing: border-box;
  286. padding-left: 6px;
  287. float: left;
  288. .goods-name {
  289. width: calc(100% + 24px);
  290. height: 18px;
  291. font-size: 15px;
  292. font-family: PingFang SC;
  293. color: #333333;
  294. line-height: 18px;
  295. white-space: nowrap;
  296. text-overflow: ellipsis;
  297. overflow: hidden;
  298. }
  299. .goods-details {
  300. height: 28px;
  301. font-size: 12px;
  302. font-family: PingFang SC;
  303. color: #999999;
  304. line-height: 14px;
  305. overflow: hidden;
  306. text-overflow: ellipsis;
  307. display: -webkit-box;
  308. -webkit-line-clamp: 2;
  309. -webkit-box-orient: vertical;
  310. word-wrap: break-word;
  311. // margin: 4px 0 10px 0;
  312. margin-top: 4px
  313. }
  314. .goods-area {
  315. height: 28px;
  316. margin: 8px 0;
  317. line-height: 28px;
  318. font-size: 13px;
  319. font-family: PingFang SC;
  320. color: #666666;
  321. }
  322. .goods-endTime {
  323. margin-bottom: 10px;
  324. font-size: 12px;
  325. }
  326. .goods-number {
  327. height: 16px;
  328. font-family: PingFang SC;
  329. line-height: 16px;
  330. .goods-icon {
  331. font-size: 12px;
  332. color: #52A63A;
  333. }
  334. .goods-spec {
  335. font-size: 16px;
  336. color: #52A63A;
  337. margin-right: 5px;
  338. }
  339. .goods-original {
  340. font-size: 12px;
  341. color: #a67954;
  342. margin-right: 10px;
  343. text-decoration:line-through
  344. }
  345. .goods-sales {
  346. font-size: 12px;
  347. color: #999999;
  348. }
  349. }
  350. }
  351. .goods-cart {
  352. width: 24px;
  353. height: 84px;
  354. float: left;
  355. .cart-button {
  356. width: 24px;
  357. height: 24px;
  358. margin-top: 30px;
  359. background-color: #52A63A;
  360. border-radius: 50%;
  361. text-align: center;
  362. .iconfont {
  363. color: #FFFFFF;
  364. font-size: 18px;
  365. line-height: 24px;
  366. }
  367. }
  368. .more-button {
  369. width: 24px;
  370. height: 20px;
  371. margin-top: 64px;
  372. .iconfont {
  373. color: #999999;
  374. font-size: 32px;
  375. line-height: 20px;
  376. }
  377. }
  378. }
  379. }
  380. }
  381. }
  382. </style>