home.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view class="container home clearfix" :style="{paddingTop:CustomBar+'px'}">
  3. <customer ref="customer" :navbar-data='nvabarData'></customer>
  4. <!-- 主页内容 -->
  5. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="5"></tui-skeleton>
  6. <view class="container-home tui-skeleton">
  7. <!-- 轮播 -->
  8. <banner :list="bannerImageList" v-if="isRequest"></banner>
  9. <!-- 金刚区菜单 -->
  10. <navbars :list="navBarsList" v-if="isRequest"></navbars>
  11. </view>
  12. <view class="container-section tui-skeleton">
  13. <view v-for="(item,index) in flootData" :key="index">
  14. <template v-if="item.type === 1">
  15. <!-- 推荐专区 -->
  16. <hot-product :list="RecommendList" :userIdentity="userIdentity" v-if="isRequest"></hot-product>
  17. </template>
  18. <template v-if="item.type === 3">
  19. <!-- 供应商专题 -->
  20. <supplier-list :list="item.floorData" v-if="isRequest"></supplier-list>
  21. </template>
  22. <template v-if="item.type === 4">
  23. <!-- 商品专题 -->
  24. <special-product :list="item.floorData" v-if="isRequest"></special-product>
  25. </template>
  26. <template v-if="item.type === 5">
  27. <!-- 小专题 -->
  28. <small-product :list="item.floorData" v-if="isRequest"></small-product>
  29. </template>
  30. <template v-if="item.type === 6">
  31. <!-- 楼层 -->
  32. <pages-product :list="item.subFloors" v-if="isRequest"></pages-product>
  33. </template>
  34. </view>
  35. </view>
  36. <!-- 侧边 -->
  37. <scroll-top :isScrollTop="isScrollTop"></scroll-top>
  38. </view>
  39. </template>
  40. <script>
  41. import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
  42. import authorize from '@/common/config/authorize.js'
  43. import customer from '@/components/cm-module/homeIndex/customer.vue'
  44. import banner from '@/components/cm-module/homeIndex/banner.vue'
  45. import navbars from '@/components/cm-module/homeIndex/navbars.vue'
  46. import hotProduct from '@/components/cm-module/homeIndex/hotProduct.vue'
  47. import pagesProduct from '@/components/cm-module/homeIndex/pagesProduct.vue'
  48. import specialProduct from '@/components/cm-module/homeIndex/specialProduct.vue'
  49. import smallProduct from '@/components/cm-module/homeIndex/smallProduct.vue'
  50. import supplierList from '@/components/cm-module/homeIndex/supplierList.vue'
  51. import { userInfoLogin } from "@/api/use.js"
  52. import { mapState,mapMutations} from 'vuex';
  53. export default {
  54. components:{
  55. tuiSkeleton,
  56. customer,
  57. hotProduct,
  58. banner,
  59. navbars,
  60. pagesProduct,
  61. specialProduct,
  62. smallProduct,
  63. supplierList
  64. },
  65. data() {
  66. return {
  67. webviewStyles: {
  68. progress: {
  69. color: '#FF3333'
  70. }
  71. },
  72. nvabarData: {//顶部自定义导航
  73. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  74. showSearch: 0,
  75. title: '采美采购商城', // 导航栏 中间的标题
  76. haveBack:false,
  77. textLeft:this.$store.state.isIphone,
  78. textColor:'#FFFFFF'
  79. },
  80. CustomBar:this.CustomBar,// 顶部导航栏高度
  81. userID:0,
  82. clubStatus:'',
  83. current:0,
  84. mode:'round',
  85. modallayer:false,
  86. isLogin:false,
  87. skeletonShow: true,
  88. userIdentity:'',
  89. bannerImageList:[],//轮播
  90. navBarsList:[],//导航分类
  91. pagesList:[],//楼层
  92. RecommendList:[],//热门推荐
  93. isScrollTop:false,
  94. isRequest:false
  95. }
  96. },
  97. created() {
  98. this.$api.getStorage().then((resolve) =>{
  99. this.userID = resolve.userID ? resolve.userID : 0
  100. this.userIdentity = resolve.userIdentity
  101. this.getHomeInformation()
  102. })
  103. },
  104. filters: {
  105. NumFormat:function(text) {//处理金额
  106. return Number(text).toFixed(2);
  107. },
  108. },
  109. computed: {
  110. ...mapState(['hasLogin','userInfo','isActivity'])
  111. },
  112. methods: {
  113. ...mapMutations(['login','logout']),
  114. GetHomeInit(){//金刚区分类
  115. this.CommonService.GetHomeInit({}).then(response =>{
  116. let data = response.data
  117. this.navBarsList = data.topMenuList
  118. }).catch(error =>{
  119. this.$util.msg(error.msg,2000)
  120. })
  121. },
  122. GetHomeFloorInfo(){//初始化首页楼层数据
  123. this.CommonService.GetHomeFloorInfo({}).then(response =>{
  124. this.flootData = response.data
  125. }).catch(error =>{
  126. this.$util.msg(error.msg,2000)
  127. })
  128. },
  129. getHomeInformation(){//初始化首页数据
  130. this.CommonService.GetHomeModulesDataInfo({ userId:this.userID }).then(res =>{
  131. let data = res.data;
  132. this.bannerImageList = data.bannerImageList
  133. this.$store.commit('updateAllNum',data.shoppingCartCount)
  134. this.GetHomeInit();
  135. this.GetHomeFloorInfo()
  136. this.GetHomeRecommendInfo()
  137. }).catch(error =>{
  138. this.$util.msg(error.msg,2000)
  139. })
  140. },
  141. GetHomeRecommendInfo(){//首页热门推荐
  142. this.CommonService.GetHomeRecommendInfo().then(response =>{
  143. this.RecommendList = response.data
  144. this.GetProductPrice()
  145. })
  146. },
  147. GetProductPrice(){//获取商品或者活动价格
  148. let productIdArr = [];
  149. let productIds ='';
  150. this.RecommendList.map(item=>{// 0公开价格 1不公开价格 2仅对会员机构公开
  151. productIdArr.push(item.id)
  152. })
  153. productIds = productIdArr.join(",");
  154. this.ProductService.querySearchProductPrice({userId: this.userID,productIds:productIds}).then(response =>{
  155. this.RecommendList = this.ReturnNewProducts(this.RecommendList,response.data);
  156. this.skeletonShow = false;
  157. this.isRequest = true
  158. }).catch(error =>{
  159. this.$util.msg(error.msg,2000)
  160. })
  161. },
  162. ReturnNewProducts(Array,list){
  163. let NewArray = []
  164. Array.map(item=>{
  165. for (let i = 0; i < list.length; i++) {
  166. if( item.id == list[i].productId ){
  167. NewArray.push(Object.assign(item,list[i]))
  168. }
  169. }
  170. });
  171. return NewArray
  172. },
  173. PromotionsFormat(promo){//促销活动类型数据处理
  174. if(promo!=null){
  175. if(promo.type == 1 && promo.mode == 1){
  176. return true
  177. }else{
  178. return false
  179. }
  180. }
  181. return false
  182. },
  183. swiperChange(e) {//轮播图切换修改背景色
  184. const index = e.detail.current;
  185. this.current = index;
  186. },
  187. formatMoney(num){
  188. return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
  189. return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
  190. return $1 + ",";
  191. });
  192. });
  193. },
  194. handleBannerActivity(item,index){
  195. switch(index){
  196. case 0:
  197. this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
  198. break;
  199. }
  200. },
  201. handleClick(data){
  202. this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
  203. this.$store.commit('setActivity',data)
  204. },
  205. handleCancelClick(data){
  206. this.$store.commit('setActivity',data)
  207. },
  208. navToListPage(nav){//三个分类模块跳转
  209. let self = this;
  210. uni.setStorage({
  211. key: 'commodity_id',
  212. data: nav.id,
  213. success: function () {
  214. self.$api.navToListPage({type:'0',value:nav.classifyName,id:nav.id});
  215. }
  216. })
  217. },
  218. navigateToGoods(nav){//分类导航跳转
  219. let self = this;
  220. uni.setStorage({
  221. key: 'commodity_id',
  222. data: nav.id,
  223. success: function () {
  224. self.$api.navigateToGoods({type:'0',value:nav.classifyName,id:nav.id});
  225. }
  226. })
  227. },
  228. navToDetailPage(id) {//跳转商品详情页
  229. this.modallayer = true;
  230. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  231. },
  232. handleContact(e){
  233. console.log(e.detail.path)
  234. console.log(e.detail.query)
  235. },
  236. showTost(){
  237. this.$util.msg("功能开发中,敬请期待~",2000)
  238. // this.$api.navigateTo(`/seller/pages/login/login`)
  239. // uni.navigateToMiniProgram({
  240. // appId: 'wx5a5cda32926f55ac',
  241. // path: '/pages/tabBar/home/index',
  242. // extraData: {
  243. // 'data1': 'test'
  244. // },
  245. // envVersion: 'develop',
  246. // success(res) {
  247. // console.log(res)
  248. // // 打开成功
  249. // }
  250. // })
  251. },
  252. navto(url){
  253. this.$api.navigateTo(url)
  254. },
  255. swiperNavtopage(link){
  256. this.$api.navigateTo(`/h5/pages/activity/activity?productID=4204&path=${link}`)
  257. },
  258. telPhoneTo(){
  259. let self = this;
  260. this.$api.get('/home/afterSale',{organizeID:this.userOrganizeID},
  261. response => {
  262. console.log(response.data.contactNumber)
  263. uni.makePhoneCall({
  264. phoneNumber:response.data.contactNumber //仅为示例
  265. });
  266. }
  267. )
  268. }
  269. },
  270. onPageScroll(e){//实时获取到滚动的值
  271. if(e.scrollTop>50){
  272. this.inputActive = 'fixed'
  273. }else{
  274. this.inputActive = 'float'
  275. }
  276. if(e.scrollTop>400){
  277. this.isScrollTop = true
  278. }else{
  279. this.isScrollTop = false
  280. }
  281. },
  282. onPullDownRefresh() {//下拉刷新
  283. this.getHomeInformation()
  284. uni.stopPullDownRefresh()
  285. },
  286. onShareAppMessage(res){//分享转发
  287. if (res.from === 'button') {
  288. // 来自页面内转发按钮
  289. }
  290. return {
  291. title: '采美采购商城-生美/医美采购服务平台',
  292. path: 'pages/tabBar/home/home',
  293. imageUrl:'https://img.caimei365.com/group1/M00/03/8C/Cmis215XHXSAWWkhAAXDP4-6m_c397.png'
  294. }
  295. }
  296. }
  297. </script>
  298. <style lang="scss">
  299. page{
  300. background-color: #FFFFFF;
  301. }
  302. .container-section{
  303. width: 100%;
  304. height: auto;
  305. background-color: #F7F7F7;
  306. }
  307. </style>