gift.vue 6.5 KB

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