gift.vue 6.1 KB

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