productRetail.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="container">
  3. <!-- 商品列表 -->
  4. <view class="goods_con flex_r flex_ac flex_wrap">
  5. <view class="goods" v-for="(item,index) in goods" :key="index" @tap="NavToGoodsDetail(item.id)">
  6. <image class="goods_img" :src="item.original_img" mode=""></image>
  7. <view class="goods_info">
  8. <view class="info_title ellipsis2">{{item.goods_name}}</view>
  9. <view class="info_option flex_r flex_ac flex_jb">
  10. <view class="info_price"><text>¥</text>{{item.price}}</view>
  11. </view>
  12. <view class="info_hint">赠送{{item.give_integral ? item.give_integral + '批发积分' : item.give_cha_bao + '茶宝'}}</view>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 商品列表-end -->
  17. </view>
  18. </template>
  19. <script>
  20. let page = 1;
  21. let app = getApp();
  22. var appEv = app.$vm.$options;
  23. import { get, post, u_post } from "@/request/api.js";
  24. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  25. export default {
  26. components: { uniPopup },
  27. data() {
  28. return {
  29. goods: [], // 商品列表
  30. type: '',
  31. title: '',
  32. };
  33. },
  34. onLoad(e) {
  35. this.type = e.type;
  36. this.title = e.type == 1 ? "零售专区" : e.type == 3 ? "精品优选" : "今日值得买";
  37. uni.setNavigationBarTitle({
  38. title: this.title
  39. })
  40. },
  41. onShow() {
  42. page = 1;
  43. this.goods = [];
  44. this.loadData()
  45. },
  46. methods: {
  47. loadData() {
  48. let that = this;
  49. let data = {
  50. page: page,
  51. type: this.type
  52. }
  53. post("goods/goodsList", data).then(res => {
  54. if (res.code === 0) {
  55. let obj = res.data.data
  56. if(page == 1) that.goods = []
  57. if (obj.length > 0) {
  58. obj.forEach(e => {
  59. that.goods.push(e)
  60. });
  61. } else {
  62. page = -1;
  63. appEv.errTips('暂无更多')
  64. }
  65. } else {
  66. page = -1;
  67. appEv.errTips('暂无更多')
  68. }
  69. })
  70. },
  71. // 跳转到商品详情页
  72. NavToGoodsDetail(id, type) {
  73. uni.navigateTo({
  74. url: '/pages/product/p_details?id=' + id + '&type=' + this.type
  75. })
  76. },
  77. // 点击关闭弹窗
  78. closeBtn: function() {
  79. this.$refs.shopping.close()
  80. },
  81. },
  82. onShareAppMessage: function() {
  83. let userinfo = uni.getStorageSync('userinfo');
  84. var path = '/pages/product/productRetail?agentId=1';
  85. if (userinfo.user_id) {
  86. path = '/pages/product/productRetail?agentId=' + userinfo.user_id;
  87. }
  88. var title = `让数字经济赋能美好生活!`;
  89. return {
  90. title: title,
  91. path: path
  92. }
  93. },
  94. /**
  95. * 页面上拉触底事件的处理函数
  96. */
  97. onReachBottom: function() {
  98. if (page != -1) {
  99. var that = this;
  100. setTimeout(function() {
  101. ++page;
  102. that.loadData();
  103. }, 800);
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss">
  109. // 页面配置
  110. page {
  111. background: #F4F4F4;
  112. }
  113. .container {
  114. padding: 22rpx 30rpx;
  115. box-sizing: border-box;
  116. }
  117. // 页面配置-end
  118. // 商品列表
  119. .goods:nth-child(2n) {
  120. margin-right: 0;
  121. }
  122. .info_cart {
  123. width: 46rpx;
  124. height: 45rpx;
  125. }
  126. .goods_con {
  127. width: 100%;
  128. overflow: hidden;
  129. }
  130. .info_hint {
  131. font-size: 22rpx;
  132. color: #787878;
  133. }
  134. .info_option {
  135. width: 100%;
  136. overflow: hidden;
  137. }
  138. .goods_img {
  139. width: 100%;
  140. height: 232rpx;
  141. display: block;
  142. }
  143. .info_msg {
  144. font-size: 24rpx;
  145. color: #787878;
  146. margin-top: 8rpx;
  147. }
  148. .goods_info {
  149. padding: 20rpx 16rpx;
  150. width: 100%;
  151. box-sizing: border-box;
  152. }
  153. .info_price {
  154. font-size: 32rpx;
  155. color: #18BB87;
  156. font-family: "SourceHanSansCN-Bold";
  157. }
  158. .info_title {
  159. font-size: 28rpx;
  160. color: #1B1A1A;
  161. font-family: "SourceHanSansCN-Bold";
  162. font-weight: bold;
  163. }
  164. .info_price text {
  165. font-size: 22rpx;
  166. color: #18BB87;
  167. font-family: "SourceHanSansCN-Bold";
  168. font-weight: bold;
  169. }
  170. .goods {
  171. width: calc((100% - 22rpx) / 2);
  172. overflow: hidden;
  173. margin-right: 22rpx;
  174. margin-bottom: 22rpx;
  175. background: #fff;
  176. border-radius: 12rpx;
  177. }
  178. // 商品列表-end
  179. // 购买或加入购物车弹窗
  180. .option_box text {
  181. color: #2DB389;
  182. }
  183. .goods_raido {
  184. margin-right: 180rpx;
  185. }
  186. .close_img {
  187. width: 36rpx;
  188. height: 36rpx;
  189. }
  190. .option_box {
  191. font-size: 26rpx;
  192. margin-top: 80rpx;
  193. }
  194. .goods_raido:nth-last-child(1) {
  195. margin-right: 0;
  196. }
  197. .num_con {
  198. width: 100%;
  199. overflow: hidden;
  200. padding-bottom: 3rpx;
  201. }
  202. .goods_option {
  203. width: 100%;
  204. overflow: hidden;
  205. padding-top: 50rpx;
  206. }
  207. .close_con {
  208. width: 100%;
  209. overflow: hidden;
  210. margin-bottom: 35rpx;
  211. }
  212. .raido_text {
  213. font-size: 26rpx;
  214. color: #545454;
  215. margin-left: 30rpx;
  216. }
  217. .goods_cons {
  218. width: calc(100% - 202rpx - 30rpx);
  219. overflow: hidden;
  220. }
  221. .goods_imgs {
  222. width: 202rpx;
  223. height: 183rpx;
  224. margin-right: 30rpx;
  225. border-radius: 12rpx;
  226. }
  227. .confim {
  228. width: 100%;
  229. height: 60rpx;
  230. border-radius: 30rpx;
  231. background: #2DB389;
  232. color: #fff;
  233. font-size: 26rpx;
  234. margin-top: 44rpx;
  235. }
  236. .shopping {
  237. width: 100%;
  238. overflow: hidden;
  239. padding: 20rpx;
  240. box-sizing: border-box;
  241. border-radius: 30rpx 30rpx 0 0;
  242. background: #fff;
  243. }
  244. .goods_infos {
  245. width: 100%;
  246. overflow: hidden;
  247. align-items: inherit;
  248. padding-bottom: 48rpx;
  249. border-bottom: 3rpx solid rgba(0, 0, 0, .12);
  250. }
  251. .shop_names {
  252. width: 100%;
  253. overflow: hidden;
  254. font-family: "SourceHanSansCN-Bold";
  255. font-weight: bold;
  256. color: #1B1B1B;
  257. font-size: 32rpx;
  258. }
  259. .goods_msg {
  260. width: 100%;
  261. overflow: hidden;
  262. font-size: 28rpx;
  263. color: #18BB88;
  264. font-family: "SourceHanSansCN-Medium";
  265. font-weight: 500;
  266. }
  267. .raido_img {
  268. width: 39rpx;
  269. height: 35rpx;
  270. background: url(~@/static/img/weixuanzhong.png);
  271. background-repeat: no-repeat;
  272. background-size: 35rpx 35rpx;
  273. background-position: center center;
  274. }
  275. .raido_box {
  276. background: url(~@/static/img/consent.png);
  277. background-repeat: no-repeat;
  278. background-size: 39rpx 35rpx;
  279. background-position: center center;
  280. }
  281. // 购买或加入购物车弹窗-end
  282. </style>