51store.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view>
  3. <ujp-navbar title="51商城"></ujp-navbar>
  4. <!-- 广告-->
  5. <!-- <view class="banner">
  6. </view> -->
  7. <view class="banner">
  8. <u-swiper bg-color="#fff" v-if="bannerList.length"
  9. :img-mode="'scaleToFill'" :list="bannerList" @click="clickBanner"
  10. :name="'picUrl'">
  11. </u-swiper>
  12. <img src="../../assets/img/storeBanner1.png" alt="" v-else >
  13. </view>
  14. <!-- 标签 -->
  15. <!-- <view class="banner2">
  16. <img src="../../assets/img/storeBanner1.png" alt="">
  17. <u-tabs :list="list" :is-scroll="false" :current="current" @change="change" >
  18. </u-tabs>
  19. </view> -->
  20. <!-- 商品 -->
  21. <view class="commodity">
  22. <view class="item" v-for="(item,i) in mallList"
  23. @click="gotoUrl('pages/store/commodityDetails?id='+item.id)"
  24. :key="i">
  25. <!--图片 -->
  26. <view class="picture">
  27. <u-image v-if="item.pic"
  28. width="308"
  29. height="308"
  30. :src="item.pic" mode="scaleToFill" ></u-image>
  31. <u-image v-else
  32. width="308"
  33. height="308"
  34. src="@/assets/img/chargesite_default.png" ></u-image>
  35. </view>
  36. <!-- 商品名 -->
  37. <view class="title">
  38. <view class="tag" v-if="item.own">
  39. <img src="@/assets/img/commodityTag.png" alt="">
  40. </view>{{item.name}}
  41. </view>
  42. <view class="price">
  43. <view class="number">
  44. <text>¥</text>{{item.price}}
  45. </view>
  46. <view class="buy">
  47. <img src="@/assets/img/antOutline-shopping-cart@3x.png" alt="">
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import * as API from '@/apis/mall.js'
  56. import * as newsApi from '@/apis/news.js'
  57. export default {
  58. data() {
  59. return {
  60. mallList:[],
  61. bannerList: [],
  62. pageIndex: 1,
  63. recordsTotal: 0,
  64. }
  65. },
  66. onReady() {
  67. this.getList()
  68. this.getBannerInfo("store");
  69. },
  70. onReachBottom() {
  71. if (this.mallList.length < this.recordsTotal) {
  72. this.myLoadmore();
  73. }
  74. },
  75. methods: {
  76. clickBanner(index, bl, modout) {
  77. var uurl = "";
  78. var mod = this.bannerList[index]
  79. if (modout) {
  80. mod = modout;
  81. }
  82. mod.clickUrl = mod.linkUrl
  83. if (mod.linkPicUrl && !bl) {
  84. this.showOss = true;
  85. this.showOssImg = mod.linkPicUrl;
  86. this.showOssIndex = index;
  87. } else if (mod.clickUrl == null) {
  88. } else if (mod.clickUrl.indexOf('http') == 0) {
  89. window.location = mod.clickUrl + uurl;
  90. } else if (mod.clickUrl.slice(-5) == 'login' && this.userId) {
  91. } else if (mod.clickUrl.indexOf('#/') == 0) {
  92. if (mod.clickUrl.indexOf("?") == -1) {
  93. mod.clickUrl += '?';
  94. }
  95. var url = mod.clickUrl.split("#")[1]
  96. //window.location = mod.clickUrl;
  97. uni.navigateTo({
  98. url: url + uurl
  99. })
  100. } else if (mod.clickUrl == '#' || mod.clickUrl == '') {
  101. } else {
  102. uni.navigateTo({
  103. url: mod.clickUrl + uurl
  104. })
  105. }
  106. },
  107. getBannerInfo(code, list) {
  108. newsApi.getBannerInfo(code).then((res) => {
  109. if (list) {
  110. this[list] = res.data;
  111. } else {
  112. this.bannerList = res.data;
  113. }
  114. //uni.hideLoading()
  115. //document.getElementsByClassName("uni-swiper-wrapper")[0].parentNode.style="background-color: rgb(255, 255, 255); height: 120px;"
  116. }).catch(error => {
  117. uni.showToast({
  118. title: error,
  119. icon: "none"
  120. })
  121. })
  122. },
  123. myLoadmore(){
  124. this.pageIndex += 1;
  125. this.getList()
  126. },
  127. getList(){
  128. uni.showLoading({
  129. title: "加载中",
  130. mask: true,
  131. })
  132. API.mallList({
  133. pageIndex: this.pageIndex,
  134. pageSize: 20,
  135. }).then((res) => {
  136. if(this.pageIndex==1){
  137. this.mallList = res.data.data;
  138. }else{
  139. this.mallList = [
  140. ...this.mallList,
  141. ...res.data.data
  142. ];
  143. }
  144. uni.hideLoading();
  145. this.recordsTotal = res.data.recordsTotal;
  146. }).catch(error => {
  147. uni.showToast({
  148. title: error,
  149. icon: "none"
  150. })
  151. })
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="scss" scoped>
  157. page{
  158. padding-bottom: 50px;
  159. }
  160. // 广告
  161. .banner{
  162. margin: 24rpx 32rpx;
  163. border-radius: 16rpx;
  164. img{
  165. width: 100%;
  166. height: 100%;
  167. }
  168. }
  169. .banner2{
  170. padding: 24rpx 32rpx 0 32rpx;
  171. border-radius: 16rpx;
  172. background-color: #fff;
  173. img{
  174. width: 100%;
  175. height: 100%;
  176. }
  177. }
  178. // 商品
  179. .commodity{
  180. background-color: #fff;
  181. margin: 24rpx 32rpx;
  182. padding: 24rpx;
  183. display: flex;
  184. justify-content: space-between;
  185. flex-wrap: wrap;
  186. .item{
  187. width: 48%;
  188. margin-bottom: 32rpx;
  189. // 图片
  190. .picture{
  191. width: 308rpx;
  192. height: 308rpx;
  193. img{
  194. width: 100%;
  195. height: 100%;
  196. }
  197. }
  198. // 商品名
  199. .title{
  200. color: rgba(16, 16, 16, 1);
  201. line-height: 40rpx;
  202. height: 60rpx;
  203. margin-top: 16rpx;
  204. .tag{
  205. display: inline-block;
  206. margin-right: 8rpx;
  207. vertical-align: middle;
  208. img{
  209. width: 104rpx;
  210. height: 32rpx;
  211. }
  212. }
  213. }
  214. // 价格
  215. .price{
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. margin-top: 12rpx;
  220. .number{
  221. color: rgba(255, 40, 0, 1);
  222. font-size: 40rpx;
  223. text{
  224. font-size: 24rpx
  225. }
  226. }
  227. .buy{
  228. width: 64rpx;
  229. height: 64rpx;
  230. border-radius: 999px;
  231. display: flex;
  232. justify-content: center;
  233. align-items: center;
  234. background: linear-gradient(180deg, rgba(255,98,0,1) 0%,rgba(255,40,0,1) 100%);
  235. img{
  236. width: 40rpx;
  237. height: 40rpx;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. </style>