51store.vue 5.7 KB

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