index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <view class="center">
  3. <view class="top">
  4. <view class="status_bar"><!-- 这里是状态栏 --></view>
  5. <view class="top-bg"><image src="../../static/img/index-bg.png" mode=""></image></view>
  6. </view>
  7. <view class="carousel">
  8. <swiper autoplay="true" duration="400" interval="5000" @change="swiperChange" class="bor">
  9. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"><image :src="item.pic" /></swiper-item>
  10. </swiper>
  11. </view>
  12. <view class="swiper-dot">
  13. <template v-for="item in swiperLength">
  14. <view class="swiper-dots-item" :key="item" :class="{ action: swiperCurrent + 1 === item }"></view>
  15. </template>
  16. </view>
  17. <view class="main">
  18. <view class="main-item" v-for="(item, index) in main" :key="index" @click="nav(item.url)">
  19. <view class="pic"><image :src="item.pic" mode=""></image></view>
  20. <view class="main-name">{{ item.name }}</view>
  21. </view>
  22. </view>
  23. <!-- 商品栏 -->
  24. <view class="commodity">
  25. <view class="commodity-item" v-for="(item, index) in commodityList" @click="navToDetailPages(item)">
  26. <view class="commodity-prc">
  27. <image :src="item.image" mode=""></image>
  28. <view class="fanli" v-if="item.type == 1">
  29. <view class="fanli-bg"><image src="../../static/img/index-fanl.png" mode=""></image></view>
  30. <!-- <view class="fanli-font flex">
  31. <view class="font-left">购物最高可返消费金额的</view>
  32. <view class="font-right">10<text>%</text></view>
  33. </view> -->
  34. </view>
  35. </view>
  36. <view class="commodity-info">
  37. <view class="commodity-name clamp">{{ item.store_name }}</view>
  38. <view class="commodity-systom clamp">{{ item.systom }}</view>
  39. <view class="commodity-price">
  40. ¥{{ item.price }}
  41. <text>¥{{ item.ot_price }}</text>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import { getTime } from '@/utils/rocessor.js';
  50. import { loadIndexs } from '@/api/user.js';
  51. import { saveUrl,interceptor } from '@/utils/loginUtils.js';
  52. import { mapState,mapMutations } from 'vuex';
  53. export default {
  54. computed: {
  55. ...mapState('user',['userInfo', 'baseURL', 'hasLogin', 'urlFile'])
  56. },
  57. data() {
  58. return {
  59. carouselList: [],
  60. main: [
  61. {
  62. name: '自动拼团',
  63. pic: '../../static/icon/index1.png',
  64. url:'/pages/index/appointment'
  65. },
  66. {
  67. name: '11人团专区',
  68. pic: '../../static/icon/index2.png',
  69. url:'/pages/product/ping'
  70. },
  71. {
  72. name: '拼团合伙人',
  73. pic: '../../static/icon/index3.png',
  74. url:'/pages/index/node'
  75. },
  76. {
  77. name: '素材分享',
  78. pic: '../../static/icon/index4.png',
  79. url:''
  80. },
  81. {
  82. name: '邀请有礼',
  83. pic: '../../static/icon/index5.png',
  84. url:'/pages/user/shareQrCode'
  85. },
  86. {
  87. name: '拼购福利',
  88. pic: '../../static/icon/index6.png',
  89. url:'/pages/user/fulilist'
  90. },
  91. {
  92. name: '互助专区',
  93. pic: '../../static/icon/index7.png',
  94. url:'/pages/assets/logroll'
  95. },
  96. {
  97. name: '签到领钱',
  98. pic: '../../static/icon/index8.png',
  99. url:'/pages/index/sign'
  100. },
  101. {
  102. name: '服务器兑换',
  103. pic: '../../static/icon/index9.png',
  104. url:'/pages/market/market'
  105. },
  106. {
  107. name: '话费充值',
  108. pic: '../../static/icon/index10.png',
  109. url:'/pages/money/phone'
  110. }
  111. ],
  112. swiperLength: 0,
  113. swiperCurrent: 0,
  114. commodityList: []
  115. };
  116. },
  117. //页面加载即刻发生
  118. onShow() {
  119. this.loadDate();
  120. },
  121. methods: {
  122. async loadDate() {
  123. const obj = this;
  124. loadIndexs({}).then(({ data }) => {
  125. console.log(data);
  126. obj.carouselList = data.banner;
  127. obj.swiperLength = data.banner.length;
  128. obj.commodityList = data.likeInfo;
  129. });
  130. },
  131. //轮播图切换修改背景色
  132. swiperChange(e) {
  133. const index = e.detail.current;
  134. this.swiperCurrent = index;
  135. },
  136. navToDetailPages(e) {
  137. if (!this.hasLogin) {
  138. uni.showModal({
  139. title: '登录',
  140. content: '您未登录,是否马上登陆?',
  141. success: e => {
  142. if (e.confirm) {
  143. interceptor();
  144. }
  145. },
  146. fail: e => {
  147. console.log(e);
  148. }
  149. });
  150. return;
  151. }
  152. uni.navigateTo({
  153. url: '/pages/product/product?id=' + e.id
  154. });
  155. },
  156. nav(url){
  157. if (!this.hasLogin) {
  158. uni.showModal({
  159. title: '登录',
  160. content: '您未登录,是否马上登陆?',
  161. success: e => {
  162. if (e.confirm) {
  163. interceptor();
  164. }
  165. },
  166. fail: e => {
  167. console.log(e);
  168. }
  169. });
  170. return;
  171. }
  172. uni.navigateTo({
  173. url,
  174. fail (error) {
  175. uni.switchTab({
  176. url
  177. });
  178. }
  179. });
  180. }
  181. }
  182. };
  183. </script>
  184. <style lang="scss">
  185. .center {
  186. height: auto;
  187. min-height: 100%;
  188. background-color: #ffffff;
  189. }
  190. .status_bar {
  191. height: var(--status-bar-height);
  192. width: 100%;
  193. }
  194. .top {
  195. width: 100%;
  196. height: 368rpx ;
  197. position: relative;
  198. .top-bg {
  199. position: absolute;
  200. top: 0;
  201. left: 0;
  202. width: 100%;
  203. height: 368rpx;
  204. image {
  205. width: 100%;
  206. height: 100%;
  207. }
  208. }
  209. }
  210. .carousel {
  211. width: 700rpx;
  212. height: 300rpx;
  213. border-radius: 14rpx;
  214. margin: -180rpx auto 0;
  215. .bor {
  216. border-radius: 14rpx;
  217. .carousel-item {
  218. image {
  219. width: 100%;
  220. height: 100%;
  221. border-radius: 14rpx;
  222. }
  223. }
  224. }
  225. }
  226. .swiper-dot {
  227. position: relative;
  228. z-index: 10;
  229. margin-top: -40rpx;
  230. display: flex;
  231. justify-content: center;
  232. .swiper-dots-item {
  233. width: 14rpx;
  234. height: 14rpx;
  235. background: #aaaaaa;
  236. border-radius: 50%;
  237. margin: 0 16rpx;
  238. // z-index: 999;
  239. }
  240. .action {
  241. background-color: #ffffff;
  242. }
  243. }
  244. .main {
  245. margin-top: 80rpx;
  246. display: flex;
  247. width: 100%;
  248. align-items: center;
  249. flex-wrap: wrap;
  250. .main-item {
  251. margin: 20rpx 0;
  252. width: 20%;
  253. display: flex;
  254. flex-direction: column;
  255. align-items: center;
  256. .pic {
  257. width: 64rpx;
  258. height: 64rpx;
  259. image {
  260. width: 100%;
  261. height: 100%;
  262. }
  263. }
  264. .main-name {
  265. font-size: 24rpx;
  266. font-family: PingFang SC;
  267. font-weight: 500;
  268. color: #333333;
  269. margin-top: 10rpx;
  270. }
  271. }
  272. }
  273. .commodity {
  274. padding: 36rpx 14rpx;
  275. margin-top: 20rpx;
  276. display: flex;
  277. flex-wrap: wrap;
  278. .commodity-item {
  279. width: 348rpx;
  280. background: #ffffff;
  281. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  282. margin: 10rpx 6rpx 0;
  283. border-radius: 10rpx;
  284. .commodity-prc {
  285. width: 344rpx;
  286. height: 344rpx;
  287. border-radius: 10rpx;
  288. position: relative;
  289. image {
  290. width: 100%;
  291. height: 100%;
  292. }
  293. .fanli {
  294. position: absolute;
  295. bottom: 0;
  296. left: 0;
  297. width: 344rpx;
  298. height: 96rpx;
  299. .fanli-bg{
  300. position: absolute;
  301. bottom: 0;
  302. left: 0;
  303. width: 344rpx;
  304. height: 96rpx;
  305. }
  306. .fanli-font {
  307. position: relative;
  308. z-index: 10;
  309. color: #FFFFFF;
  310. height: 96rpx;
  311. align-items: flex-end;
  312. padding: 36rpx 10rpx 10rpx;
  313. .font-left {
  314. width: 226px;
  315. font-size: 20rpx;
  316. font-family: PingFang SC;
  317. font-weight: 500;
  318. color: #FFFFFF;
  319. }
  320. .font-right {
  321. font-size: 62rpx;
  322. font-family: Microsoft YaHei;
  323. font-weight: bold;
  324. color: #FFFFFF;
  325. text {
  326. font-size: 26rpx;
  327. }
  328. }
  329. }
  330. }
  331. }
  332. .commodity-info {
  333. padding: 28rpx 20rpx 35rpx 24rpx;
  334. .commodity-name {
  335. width: 100%;
  336. font-size: 30rpx;
  337. font-family: PingFang SC;
  338. font-weight: bold;
  339. color: #333333;
  340. }
  341. .commodity-systom {
  342. margin-top: 16rpx;
  343. font-size: 26rpx;
  344. font-family: PingFang SC;
  345. font-weight: 500;
  346. color: #666666;
  347. }
  348. .commodity-price {
  349. margin-top: 34rpx;
  350. font-size: 36rpx;
  351. font-family: PingFang SC;
  352. font-weight: bold;
  353. color: #e83f30;
  354. text {
  355. display: inline-block;
  356. padding-left: 6rpx;
  357. font-size: 26rpx;
  358. font-family: PingFang SC;
  359. font-weight: bold;
  360. text-decoration: line-through;
  361. color: #999999;
  362. }
  363. }
  364. }
  365. }
  366. }
  367. </style>