index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <script>
  2. import {
  3. mapState,
  4. mapActions,
  5. mapGetters
  6. } from 'vuex'
  7. import api from '@/api'
  8. import notice from '@/pages/index/components/notice.vue'
  9. import listWaterfall from '@/pages/index/components/listWaterfall.vue'
  10. import businessCooperation from '@/pages/me/components/businessCooperation.vue'
  11. import VersionUp from '@/pages/index/components/versionUp.vue'
  12. export default {
  13. components: {
  14. VersionUp,
  15. notice,
  16. listWaterfall,
  17. businessCooperation
  18. },
  19. data() {
  20. return {
  21. banner: [],
  22. tasks: [{
  23. label: '关于福袋',
  24. icon: 'guanyufudai'
  25. },
  26. {
  27. label: '新手教程',
  28. icon: 'xinshou_jiaoc'
  29. },
  30. {
  31. label: '在线客服',
  32. icon: 'zaixian_kefu'
  33. },
  34. {
  35. label: '商务合作',
  36. icon: 'shangwu_hezuo'
  37. }
  38. ],
  39. services: [{
  40. label: '群聊',
  41. icon: 'qunliao'
  42. },
  43. {
  44. label: '手机充值',
  45. icon: 'shouji_chongzhi'
  46. },
  47. {
  48. label: '交电费',
  49. icon: 'jiaodianfei'
  50. },
  51. {
  52. label: '酒店/民宿',
  53. icon: 'jiudian'
  54. },
  55. {
  56. label: '美食/外卖',
  57. icon: 'meishi_waimai'
  58. },
  59. {
  60. label: '电影演出',
  61. icon: 'dianying'
  62. },
  63. {
  64. label: '飞机/火车',
  65. icon: 'feiji_hc'
  66. },
  67. {
  68. label: '加油站',
  69. icon: 'jiayouzhan'
  70. }
  71. ],
  72. goods: [],
  73. showToTop: false
  74. }
  75. },
  76. computed: {
  77. ...mapState({
  78. user: 'user',
  79. appConfig: 'appConfig',
  80. adultWarn: 'adultWarn'
  81. }),
  82. ...mapGetters({
  83. isAppVersionUp: 'isAppVersionUp'
  84. })
  85. },
  86. methods: {
  87. ...mapActions({
  88. refreshAppVersion: 'refreshAppVersion'
  89. }),
  90. async getList(page) {
  91. let res = await api.goodsList({
  92. ...page,
  93. goods_type: '1'
  94. })
  95. //如果是第一页需手动制空列表 追加新数据
  96. this.goods = page.page === 1 ? res : [...this.goods, ...res]
  97. return res.length
  98. },
  99. taskJump({
  100. label
  101. }) {
  102. switch (label) {
  103. case '关于福袋':
  104. this.$jump({
  105. url: '/pagesUser/webview/webview'
  106. }, {
  107. url: this.appConfig.aboutbox_url
  108. })
  109. break
  110. case '新手教程':
  111. this.$jump({
  112. url: '/pagesUser/webview/webview'
  113. }, {
  114. url: this.appConfig.newhand_url
  115. })
  116. break
  117. case '在线客服':
  118. this.$jump({
  119. url: '/pagesUser/webview/webview'
  120. }, {
  121. url: this.appConfig.chat_url
  122. })
  123. break
  124. case '商务合作':
  125. this.$refs.business.show = true
  126. break
  127. }
  128. },
  129. serviceJump({
  130. label
  131. }) {
  132. switch (label) {
  133. case '群聊':
  134. this.$jump({
  135. url: '/pagesUser/chat/chat'
  136. })
  137. break
  138. default:
  139. this.$common.toast('功能开发中')
  140. }
  141. },
  142. // 点击回到顶部的按钮回调
  143. toTopClick() {
  144. if (!this.showToTop) return
  145. uni.pageScrollTo({
  146. scrollTop: 0,
  147. duration: 300
  148. })
  149. }
  150. },
  151. async onLoad() {
  152. this.banner = await api.getBanner(1)
  153. },
  154. onShow() {
  155. this.refreshAppVersion()
  156. },
  157. provide() {
  158. return {
  159. getList: this.getList
  160. }
  161. },
  162. onPageScroll({
  163. scrollTop
  164. }) {
  165. this.showToTop = scrollTop > 400
  166. }
  167. }
  168. </script>
  169. <template>
  170. <view class="page">
  171. <view class="statusBarBg">
  172. <image src="/static/images/home/bg_home_top.png" mode="widthFix" class="bg_top"></image>
  173. <view class="placeholder"></view>
  174. </view>
  175. <view class="main">
  176. <notice v-if="adultWarn" />
  177. <scroll ref="mescrollItem" class="scroll" :up-opt="{ toTop: { src: null } }" :style="{
  178. transform: adultWarn ? 'translateY(107rpx)' : '',
  179. marginBottom: adultWarn ? '107rpx' : ''
  180. }">
  181. <view class="banner w-m">
  182. <u-swiper :list="banner" height="260rpx" circular :autoplay="true" radius="10px" key-name="img_pic"
  183. bgColor="transparent" indicator indicatorMode="dot"></u-swiper>
  184. </view>
  185. <view class="task w flex flex-around">
  186. <view class="item" v-for="(t, i) in tasks" :key="i" @click="taskJump(t)">
  187. <image :src="`/static/images/home/${t.icon}.png`" class="img" mode="widthFix"></image>
  188. <view class="title">{{ t.label }}</view>
  189. </view>
  190. </view>
  191. <view v-if="user.has_hiddencate === 0" class="service w-m bg-white radius">
  192. <view class="service_item flex flex-column align-center" v-for="(s, i) in services" :key="i"
  193. @click="serviceJump(s)">
  194. <image class="service_item_icon" :src="`/static/images/home/ic_${s.icon}@2x.png`"></image>
  195. <view class="service_item_label"><text>{{ s.label }}</text></view>
  196. <image v-if="s.label === '群聊'" class="tag" src="/static/images/home/ic_qunliao_biaoqian@2x.png">
  197. </image>
  198. </view>
  199. </view>
  200. <list-waterfall class="list" :list="goods" />
  201. </scroll>
  202. </view>
  203. <businessCooperation ref="business" />
  204. <version-up v-if="isAppVersionUp" />
  205. <!-- <mescroll-top :option="mescroll.optUp.toTop" @click="toTopClick"></mescroll-top>-->
  206. <view class="totop" :class="{ show: showToTop }" @click="toTopClick">
  207. <image class="totop_icon" src="/static/images/common/ic_hui_dingbu@2x.png"></image>
  208. </view>
  209. </view>
  210. </template>
  211. <style lang="scss" scoped>
  212. .page {
  213. //background-color: #f76883;
  214. .statusBarBg {
  215. .placeholder {
  216. height: 119rpx;
  217. }
  218. .bg_top {
  219. width: 100%;
  220. position: fixed;
  221. z-index: 999;
  222. top: 0;
  223. }
  224. }
  225. }
  226. .main {
  227. background-image: url('../../static/images/home/bg_home_bottom.png');
  228. background-repeat: no-repeat;
  229. background-size: 100% 332rpx;
  230. overflow: hidden;
  231. }
  232. .scroll {
  233. transition: transform 0.4s 0.1s ease;
  234. will-change: transform;
  235. }
  236. .task {
  237. margin-top: 46rpx;
  238. .item {
  239. text-align: center;
  240. .img {
  241. width: 86rpx;
  242. }
  243. .title {
  244. font-size: 24rpx;
  245. font-weight: 500;
  246. color: #232323;
  247. }
  248. }
  249. }
  250. .service {
  251. margin-top: 20rpx;
  252. padding: 18rpx 0 24rpx;
  253. display: grid;
  254. grid-template-columns: repeat(4, 1fr);
  255. grid-row-gap: 20rpx;
  256. &_item {
  257. text-align: center;
  258. position: relative;
  259. &_icon {
  260. width: 106rpx;
  261. height: 96rpx;
  262. }
  263. &_label {
  264. font-size: 24rpx;
  265. font-weight: 500;
  266. color: #232323;
  267. }
  268. .tag {
  269. position: absolute;
  270. left: calc(50% - 10rpx);
  271. top: -9rpx;
  272. width: 54rpx;
  273. height: 24rpx;
  274. }
  275. }
  276. }
  277. .list {
  278. margin: 0 25rpx 20rpx;
  279. }
  280. .totop {
  281. position: fixed;
  282. right: 20rpx;
  283. bottom: 200rpx;
  284. opacity: 0;
  285. // 不接受事件
  286. pointer-events: none;
  287. transition: all 0.3s;
  288. &_icon {
  289. width: 113rpx;
  290. height: 113rpx;
  291. }
  292. &.show {
  293. opacity: 1;
  294. pointer-events: auto;
  295. }
  296. }
  297. </style>