jf.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <view class="">
  3. <empty v-if="loaded && goodList.length == 0"></empty>
  4. <view class="hot-list">
  5. <jfgood v-for="fitem in goodList" :item="fitem" @goItem="goItem"></jfgood>
  6. </view>
  7. <uni-load-more :status="loadingType" v-if="!(loaded && goodList.length == 0)"></uni-load-more>
  8. </view>
  9. </template>
  10. <script>
  11. import jfgood from '@/components/good/jf.vue'
  12. // #ifdef H5
  13. import {
  14. weixindata,
  15. shareLoad
  16. } from '@/utils/wxAuthorized';
  17. // #endif
  18. import empty from '@/components/empty.vue'
  19. import {
  20. getBargainList,
  21. getProducts,
  22. goodsDetail,
  23. poster,
  24. getBd,
  25. getGp,
  26. groomList
  27. } from '@/api/product.js';
  28. export default {
  29. components: {
  30. empty,
  31. jfgood
  32. },
  33. data() {
  34. return {
  35. goodList: [], //商品列表
  36. loadingType: 'more',
  37. page: 1,
  38. limit: 10,
  39. type: 0,
  40. loaded: false,
  41. cid: 0,
  42. }
  43. },
  44. onLoad(opt) {
  45. if (opt.id) {
  46. this.cid = opt.id
  47. uni.setNavigationBarTitle({
  48. title: opt.tit
  49. })
  50. }
  51. this.getGoodList()
  52. // #ifdef H5
  53. this.shareDate()
  54. // #endif
  55. },
  56. onShow() {
  57. },
  58. onReachBottom() {
  59. this.getGoodList()
  60. },
  61. onPullDownRefresh() {
  62. this.getGoodList('down')
  63. },
  64. methods: {
  65. // #ifdef H5
  66. // 加载微信html5页面分享方法
  67. shareDate() {
  68. // let obj = this;
  69. // 保存分享人id链接
  70. // let url = window.location.href + '&spread=' + this.userInfo.uid;
  71. // 判断是否微信浏览器
  72. // let bool = uni.getStorageSync('weichatBrowser') || '';
  73. // if (bool) {
  74. // // 过滤微信强制添加的链接地址
  75. // url = url.replace(/[\?,&]from=singlemessage/g, '');
  76. // }
  77. shareLoad();
  78. },
  79. // #endif
  80. navto(url) {
  81. uni.navigateTo({
  82. url,
  83. fail() {
  84. uni.switchTab({
  85. url
  86. })
  87. }
  88. })
  89. },
  90. getGoodList(type) {
  91. let obj = this
  92. if (type == 'down') {
  93. obj.loadingType = 'more'
  94. obj.page = 1
  95. }
  96. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  97. return
  98. }
  99. obj.loadingType = 'loading'
  100. getProducts({
  101. page: obj.page,
  102. limit: obj.limit,
  103. cid: obj.cid
  104. }).then(res => {
  105. if (type == 'down') {
  106. obj.goodList = []
  107. uni.stopPullDownRefresh();
  108. }
  109. obj.goodList = obj.goodList.concat(res.data)
  110. if (obj.limit == res.data.length) {
  111. obj.loadingType = 'more'
  112. obj.page++
  113. } else {
  114. obj.loadingType = 'noMore'
  115. }
  116. obj.loaded = true
  117. }).catch(err => {
  118. obj.loadingType = 'more'
  119. uni.stopPullDownRefresh();
  120. })
  121. },
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .hot-list {
  127. // margin-top: 38rpx;
  128. width: 100%;
  129. display: flex;
  130. flex-wrap: wrap;
  131. padding: 20rpx 20rpx 30rpx;
  132. justify-content: space-between;
  133. .hotgoods-item {
  134. width: 345rpx;
  135. background-color: #ffffff;
  136. border-radius: 12rpx;
  137. box-shadow: 0 0 15rpx rgba(0, 0, 0, 0.2);
  138. margin-bottom: 15rpx;
  139. .image-wrapper {
  140. width: 345rpx;
  141. height: 345rpx;
  142. border-radius: 3px;
  143. overflow: hidden;
  144. position: relative;
  145. .image-bg {
  146. position: absolute;
  147. top: 0;
  148. left: 0;
  149. right: 0;
  150. bottom: 0;
  151. width: 100%;
  152. height: 100%;
  153. opacity: 1;
  154. border-radius: 12rpx 12rpx 0 0;
  155. z-index: 2;
  156. }
  157. .image {
  158. width: 100%;
  159. height: 100%;
  160. opacity: 1;
  161. border-radius: 12rpx 12rpx 0 0;
  162. }
  163. }
  164. .title {
  165. margin-top: 24rpx;
  166. padding: 0 20rpx;
  167. font-size: 32rpx;
  168. font-weight: 500;
  169. color: #333333;
  170. }
  171. .hot-price {
  172. display: flex;
  173. justify-content: flex-start;
  174. align-items: center;
  175. width: 100%;
  176. padding: 0 10rpx;
  177. // padding: 14rpx 0 30rpx;
  178. .hotPrice-box {
  179. padding: 2rpx 6rpx;
  180. background: linear-gradient(90deg, #c79a4c, #f9df7f);
  181. border-radius: 5rpx;
  182. text-align: center;
  183. line-height: 28rpx;
  184. font-size: 20rpx;
  185. font-family: Source Han Sans CN;
  186. font-weight: 400;
  187. color: #ffffff;
  188. }
  189. .price {
  190. margin-left: 10rpx;
  191. font-size: 36rpx;
  192. color: #ff0000;
  193. font-weight: 500;
  194. display: flex;
  195. width: 100%;
  196. justify-content: flex-start;
  197. align-items: center;
  198. .jf {
  199. font-size: 20rpx;
  200. }
  201. .give-jf {
  202. display: inline-block;
  203. padding: 8rpx;
  204. background: linear-gradient(90deg, #FF834D, #FF2600);
  205. border-radius: 12rpx 0px 12rpx 0px;
  206. font-size: 22rpx;
  207. font-weight: 500;
  208. color: #FFFFFF;
  209. margin-left: 22rpx;
  210. }
  211. .ot-pirce {
  212. margin-left: 7rpx;
  213. font-size: 26rpx;
  214. font-weight: 500;
  215. text-decoration: line-through;
  216. color: #999999;
  217. align-self: flex-end;
  218. }
  219. }
  220. .yuanPrice {
  221. margin-left: 10rpx;
  222. font-size: 20rpx;
  223. font-family: PingFang SC;
  224. font-weight: 500;
  225. text-decoration: line-through;
  226. color: #999999;
  227. }
  228. .cart-icon {
  229. image {
  230. width: 44rpx;
  231. height: 44rpx;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. .goodss {
  238. border-radius: 0rpx 0rpx 20rpx 20rpx;
  239. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  240. margin-bottom: 20rpx;
  241. padding-bottom: 20rpx;
  242. &:last-of-type {
  243. margin-bottom: 0;
  244. }
  245. .goods-img {
  246. position: relative;
  247. width: 702rpx;
  248. height: 303rpx;
  249. image {
  250. width: 702rpx;
  251. height: 303rpx;
  252. }
  253. .img-bg {
  254. position: absolute;
  255. top: 0;
  256. left: 0;
  257. }
  258. }
  259. .goods-tit {
  260. font-weight: 500;
  261. font-size: 32rpx;
  262. color: #333333;
  263. padding: 15rpx 20rpx;
  264. }
  265. .goods-price {
  266. display: flex;
  267. padding: 0 20rpx;
  268. .new-price {
  269. font-weight: bold;
  270. font-size: 32rpx;
  271. color: #FF4C4C;
  272. }
  273. .tc {
  274. flex-grow: 1;
  275. }
  276. .ot-pirce {
  277. font-weight: 500;
  278. font-size: 26rpx;
  279. color: #999999;
  280. text-decoration-line: line-through;
  281. }
  282. .gobuy {
  283. display: inline-block;
  284. width: 170rpx;
  285. line-height: 53rpx;
  286. background: linear-gradient(30deg, #FF4C4C, #FE6238);
  287. border-radius: 27rpx;
  288. text-align: center;
  289. font-weight: bold;
  290. font-size: 28rpx;
  291. color: #FFFFFF;
  292. }
  293. }
  294. }
  295. </style>