mall.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class="indexBox">
  3. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  4. <swiper-item v-for="item in imagelist" class="carousel-item" @click="navTo(item.url)">
  5. <image class="imageitem" :src="item.img" />
  6. </swiper-item>
  7. </swiper>
  8. <view class="hot-list-box">
  9. <view class="list-box">
  10. <view class="list" v-for="(item,index) in navList.orderList" @click="navTo('/pages/user/model/model?mtype=' + item.id)">
  11. <view class="list-image-box">
  12. <image class="list-image" :src="item.img" mode="widthFix"></image>
  13. </view>
  14. <view class="list-content">
  15. <view class="list-title clamp">
  16. {{item.title}}
  17. </view>
  18. <view class="list-money flex flex-start">
  19. <view class="money">
  20. ¥{{item.price}}
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <uni-load-more :status="navList.loadingType"></uni-load-more>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. mapState,
  33. mapMutations
  34. } from 'vuex';
  35. import {
  36. loadIndexs
  37. } from '@/api/index.js';
  38. import {
  39. share
  40. } from '@/api/wx';
  41. export default {
  42. data() {
  43. return {
  44. //轮播图
  45. imagelist: [],
  46. // 推荐商品
  47. navList: {
  48. state: 1,
  49. text: '通知',
  50. loadingType: 'more',
  51. orderList: [],
  52. page: 1, //当前页数
  53. limit: 10, //每次信息条数
  54. count: 0, //总消息条数
  55. },
  56. // 热门商品
  57. rmList: []
  58. };
  59. },
  60. computed: {
  61. ...mapState('user', [ 'userInfo']),
  62. },
  63. onLoad: function(option) {
  64. // #ifndef MP
  65. if (option.spread) {
  66. // 存储其他邀请人
  67. uni.setStorageSync('spread', option.spread);
  68. }
  69. // #endif
  70. // #ifdef MP
  71. if (option.scene) {
  72. // 存储小程序邀请人
  73. uni.setStorage({
  74. key: 'spread_code',
  75. data: option.scene
  76. });
  77. }
  78. // #endif
  79. // 加载分享信息
  80. this.share()
  81. },
  82. onShow() {
  83. this.loadIndexs();
  84. },
  85. onReady() {},
  86. // 滚动到底部
  87. onReachBottom() {
  88. // this.getShowTemplateList();
  89. },
  90. // #ifdef MP
  91. onShareAppMessage(options) {
  92. // 获取缓存的用户id
  93. const user = uni.getStorageSync('userInfo')
  94. // 设置菜单中的转发按钮触发转发事件时的转发内容
  95. let shareObj = {
  96. title: this.shareData.title, // 默认是小程序的名称(可以写slogan等)
  97. path: '/pages/index/index?scene=' + user.uid, // 默认是当前页面,必须是以‘/’开头的完整路径
  98. };
  99. return shareObj;
  100. },
  101. // #endif
  102. methods: {
  103. share() {
  104. // console.log('加载分享');
  105. const that = this;
  106. // 请求获取默认数据
  107. share({}).then(({
  108. data
  109. }) => {
  110. // console.log('分享回调', data);
  111. that.shareData = data.data
  112. });
  113. },
  114. // 首页初始化
  115. loadIndexs() {
  116. const that = this;
  117. // 轮播图
  118. loadIndexs().then(
  119. (res) => {
  120. console.log(res,'index');
  121. }
  122. ).catch(
  123. (res) => {
  124. console.log(res);
  125. }
  126. )
  127. },
  128. // 获取模板列表
  129. navTo(url) {
  130. if (url) {
  131. if (url.indexOf('http') > -1) {
  132. // #ifdef H5
  133. window.location.href = url
  134. // #endif
  135. // #ifdef APP
  136. plus.runtime.openURL(url)
  137. // #endif
  138. } else {
  139. uni.navigateTo({
  140. url: url
  141. })
  142. }
  143. }
  144. }
  145. },
  146. };
  147. </script>
  148. <style lang="scss">
  149. page,
  150. .indexBox {
  151. height: auto;
  152. min-height: 100%;
  153. }
  154. .indexBox {
  155. padding-bottom: 50rpx;
  156. }
  157. .top-swiper {
  158. margin: auto;
  159. width: 750rpx;
  160. height: 273rpx;
  161. padding: 0 $page-row-spacing;
  162. background: linear-gradient(to bottom, #ff629f, rgba(255, 255, 255, 1) 80%, rgba(255, 255, 255, 1));
  163. .carousel-item {
  164. border-radius: 20rpx;
  165. .imageitem {
  166. // margin: auto;
  167. width: 690rpx;
  168. height: 273rpx;
  169. }
  170. }
  171. }
  172. .hot-list-box {
  173. padding: $page-row-spacing;
  174. background-color: #FFFFFF;
  175. padding-bottom: 0;
  176. .list-box {
  177. display: flex;
  178. flex-wrap: wrap;
  179. justify-content: space-between;
  180. align-items: flex-start;
  181. padding-top: 30rpx;
  182. padding-bottom: 20rpx;
  183. .list {
  184. box-shadow: 0px 0px 20rpx 0px rgba(50,50,52,0.06);
  185. border-radius: 15rpx;
  186. .list-image-box {
  187. width: 330rpx;
  188. height: 420rpx;
  189. overflow: hidden;
  190. .list-image {
  191. width: 100%;
  192. }
  193. }
  194. .list-content{
  195. padding: 20rpx;
  196. line-height: 1;
  197. .list-title {
  198. color: $font-color-dark;
  199. font-size: $font-base;
  200. margin-bottom: 20rpx;
  201. }
  202. .list-money {
  203. .money {
  204. font: $font-lg;
  205. color: #FF3342;
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. </style>