index-bak.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <view id="home" :data-theme="theme">
  3. <home-index v-if="tabActive == 0 && merId" :merId="merId" :diyId="diyId" :isScrolled="isScrolled"></home-index>
  4. <coupon-and-classify v-if="tabActive >0 && merId" :tabActive="tabActive" :merId="merId"></coupon-and-classify>
  5. <view class="footer">
  6. <view v-for="(item, index) in tabs" :key="index" :class="{ active: tabActive === index }" class="item"
  7. @click="handleChangetab(index)">
  8. <view :class="['iconfont', item.icon]"></view>
  9. <view>{{ item.name }}</view>
  10. </view>
  11. <view class="item" @click="handleCustomer">
  12. <view class="iconfont icon-kefu_o"></view>
  13. <view>联系客服</view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. // +----------------------------------------------------------------------
  20. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  21. // +----------------------------------------------------------------------
  22. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  23. // +----------------------------------------------------------------------
  24. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  25. // +----------------------------------------------------------------------
  26. // | Author: CRMEB Team <admin@crmeb.com>
  27. // +----------------------------------------------------------------------
  28. import {
  29. chatConfig
  30. } from '@/utils/consumerType.js'
  31. import tuiSkeleton from '@/components/base/tui-skeleton.vue';
  32. import homeIndex from './components/homeIndex.vue';
  33. import couponAndClassify from '../components/couponAndClassify/index.vue';
  34. import {
  35. getMerIndexInfoApi,
  36. } from '@/api/merchant.js';
  37. import {
  38. getShare
  39. } from '@/api/public.js';
  40. import {
  41. mapGetters
  42. } from "vuex";
  43. import {
  44. silenceBindingSpread,
  45. } from '@/utils/index.js';
  46. const arrTemp = ["beforePay", "afterPay", "createBargain", "pink"];
  47. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  48. let app = getApp();
  49. export default {
  50. computed: mapGetters(['isLogin', 'uid', 'globalData', 'bottomNavigationIsCustom']),
  51. components: {
  52. tuiSkeleton,
  53. homeIndex,
  54. couponAndClassify
  55. },
  56. data() {
  57. return {
  58. urlDomain: this.$Cache.get("imgHost"),
  59. isNoCommodity: false,
  60. isScrolled: false, //是否开始滚动
  61. showSkeleton: true, //骨架屏显示隐藏
  62. isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
  63. statusBarHeight: statusBarHeight,
  64. navIndex: 0, //判断首页显示内容,1显示分类页和商品,0首页
  65. site_name: '', //首页title
  66. configApi: {}, //分享类容配置
  67. theme: app.globalData.theme,
  68. imgHost: '', //图片域名地址
  69. wxText: "点击添加到我的小程序,微信首页下拉即可访问商城。",
  70. // #ifdef APP-PLUS || MP
  71. isFixed: true,
  72. // #endif
  73. // #ifdef H5
  74. isFixed: false,
  75. // #endif
  76. domOffsetTop: 50,
  77. domHeight: 0,
  78. styleConfig: [], //DIY数据
  79. diyId: 0, //DIYID
  80. homeCombData: {}, //组合组件数据
  81. showHomeComb: false, //是否显示组合
  82. showHeaderSerch: false, //是否显示搜索框
  83. headerSerchCombData: {}, //搜索框对象
  84. bgPic: '', //背景图片
  85. bgTabVal: '', //背景图片样式
  86. windowHeight: 0,
  87. pageStyle: {},
  88. isDefault: 1, //是否首页,1是,0不是
  89. merchantInfo: {},
  90. merId: 0,
  91. // 底部菜单
  92. tabs: [{
  93. icon: 'icon-yizhan_o',
  94. name: '首页',
  95. },
  96. {
  97. icon: 'icon-yingyongAPP_o',
  98. name: '分类'
  99. },
  100. {
  101. icon: 'icon-huobiliu_o',
  102. name: '领券'
  103. }
  104. ],
  105. tabActive: 0, // 底部切换
  106. }
  107. },
  108. onLoad(options) {
  109. if (options.hasOwnProperty('merId') || options.scene) {
  110. if (options.scene) { // 仅仅小程序扫码进入
  111. this.merId = this.globalData.merId ? this.globalData.merId : 0;
  112. } else {
  113. this.merId = options.merId ? parseInt(options.merId) : 0;
  114. }
  115. }
  116. if (options.hasOwnProperty('id') || options.scene) {
  117. if (options.scene) { // 仅仅小程序扫码进入
  118. this.diyId = this.globalData.id ? this.globalData.id : 0;
  119. } else {
  120. this.diyId = options.id ? parseInt(options.id) : 0;
  121. }
  122. }
  123. //分销码
  124. if(options.sd) this.$store.commit('Change_Spread', options.sd);
  125. this.getMerIndexInfo()
  126. let that = this;
  127. this.$nextTick(function() {
  128. uni.getSystemInfo({
  129. success: function(res) {
  130. that.windowHeight = res.windowHeight;
  131. }
  132. });
  133. })
  134. },
  135. // #ifdef MP
  136. /**
  137. * 用户点击右上角分享到朋友圈
  138. */
  139. onShareTimeline() {
  140. return {
  141. title: this.merchantInfo.name,
  142. imageUrl: this.merchantInfo.avatar,
  143. query: `merId=${this.merId}&sd=${this.uid}`
  144. };
  145. },
  146. /**
  147. * 用户点击右上角分享
  148. */
  149. onShareAppMessage() {
  150. return {
  151. title: this.merchantInfo.name,
  152. imageUrl: this.merchantInfo.avatar,
  153. path: `/pages/merchant/home/index?merId=${this.merId}&sd=${this.uid}`
  154. };
  155. },
  156. // #endif
  157. // 滚动监听
  158. onPageScroll(e) {
  159. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  160. uni.$emit('scroll');
  161. if (e.scrollTop > this.domOffsetTop) {
  162. this.isScrolled = true;
  163. }
  164. if (e.scrollTop < this.domOffsetTop) {
  165. this.$nextTick(() => {
  166. this.isScrolled = false;
  167. });
  168. }
  169. },
  170. methods: {
  171. //客服跳转
  172. handleCustomer: function() {
  173. chatConfig(this.merchantInfo);
  174. },
  175. //商户信息
  176. getMerIndexInfo() {
  177. let that = this;
  178. getMerIndexInfoApi(this.merId).then(res => {
  179. this.merchantInfo = res.data
  180. uni.setNavigationBarTitle({
  181. title: res.data.name
  182. })
  183. this.$store.commit('MERCHANTJINFO', res.data);
  184. this.skeletonShow = false;
  185. }).catch(err => {
  186. that.loading = false;
  187. that.loadTitle = '加载更多';
  188. this.skeletonShow = false;
  189. });
  190. },
  191. //底部切换
  192. handleChangetab(param) {
  193. this.tabActive = param;
  194. },
  195. //清除骨架屏
  196. reloadData() {
  197. this.showSkeleton = false;
  198. },
  199. shareApi: function() {
  200. getShare().then(res => {
  201. this.$set(this, 'configApi', res.data);
  202. this.$set(this, "site_name", res.data.title);
  203. uni.setNavigationBarTitle({
  204. title: this.site_name
  205. })
  206. // #ifdef H5
  207. this.setOpenShare(res.data);
  208. // #endif
  209. })
  210. },
  211. // 微信分享;
  212. setOpenShare: function(data) {
  213. let that = this;
  214. if (that.$wechat.isWeixin()) {
  215. let configAppMessage = {
  216. desc: data.synopsis,
  217. title: data.title,
  218. link: location.href,
  219. imgUrl: data.img
  220. };
  221. that.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"],
  222. configAppMessage);
  223. }
  224. },
  225. stopTouchMove() {
  226. return true //禁止新闻swiper手动滑动
  227. },
  228. goDetail(item) {
  229. goProductDetail(item.id, 0, '')
  230. },
  231. },
  232. onShow() {
  233. //分销绑定
  234. silenceBindingSpread(this.isLogin, this.globalData.spread);
  235. },
  236. mounted() {
  237. let query = uni.createSelectorQuery().in(this);
  238. query.select("#home").boundingClientRect();
  239. query.exec(res => {
  240. this.domHeight = res[0].height;
  241. })
  242. },
  243. onReachBottom() {
  244. // this.$refs.recommendIndex.get_host_product();
  245. }
  246. }
  247. </script>
  248. <style>
  249. page {
  250. height: auto;
  251. display: flex;
  252. flex-direction: column;
  253. height: 100%;
  254. /* #ifdef H5 */
  255. background-color: #fff;
  256. /* #endif */
  257. }
  258. </style>
  259. <style lang="scss" scoped>
  260. .footer {
  261. position: fixed;
  262. bottom: 0;
  263. left: 0;
  264. z-index: 999;
  265. display: flex;
  266. width: 100%;
  267. padding-top: 12rpx;
  268. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  269. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  270. background-color: #FFFFFF;
  271. opacity: 0.96;
  272. .item {
  273. flex: 1;
  274. display: flex;
  275. flex-direction: column;
  276. justify-content: center;
  277. align-items: center;
  278. font-weight: 500;
  279. font-size: 20rpx;
  280. color: #282828;
  281. .iconfont {
  282. font-size: 43rpx !important;
  283. }
  284. }
  285. .active {
  286. @include main_color(theme);
  287. }
  288. }
  289. </style>