home.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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 v-if="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. flootData:[],//楼层
  90. bannerImageList:[],//轮播
  91. navBarsList:[],//导航分类
  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. //轮播图切换修改背景色
  184. swiperChange(e) {
  185. const index = e.detail.current;
  186. this.current = index;
  187. },
  188. formatMoney(num){
  189. return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
  190. return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
  191. return $1 + ",";
  192. });
  193. });
  194. },
  195. handleBannerActivity(item,index){
  196. switch(index){
  197. case 0:
  198. this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
  199. break;
  200. }
  201. },
  202. handleClick(data){
  203. this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
  204. this.$store.commit('setActivity',data)
  205. },
  206. handleCancelClick(data){
  207. this.$store.commit('setActivity',data)
  208. },
  209. navToListPage(nav){//三个分类模块跳转
  210. let self = this;
  211. uni.setStorage({
  212. key: 'commodity_id',
  213. data: nav.id,
  214. success: function () {
  215. self.$api.navToListPage({type:'0',value:nav.classifyName,id:nav.id});
  216. }
  217. })
  218. },
  219. navigateToGoods(nav){//分类导航跳转
  220. let self = this;
  221. uni.setStorage({
  222. key: 'commodity_id',
  223. data: nav.id,
  224. success: function () {
  225. self.$api.navigateToGoods({type:'0',value:nav.classifyName,id:nav.id});
  226. }
  227. })
  228. },
  229. navToDetailPage(id) {//跳转商品详情页
  230. this.modallayer = true;
  231. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  232. },
  233. handleContact(e){
  234. console.log(e.detail.path)
  235. console.log(e.detail.query)
  236. },
  237. showTost(){
  238. this.$util.msg("功能开发中,敬请期待~",2000)
  239. // this.$api.navigateTo(`/seller/pages/login/login`)
  240. // uni.navigateToMiniProgram({
  241. // appId: 'wx5a5cda32926f55ac',
  242. // path: '/pages/tabBar/home/index',
  243. // extraData: {
  244. // 'data1': 'test'
  245. // },
  246. // envVersion: 'develop',
  247. // success(res) {
  248. // console.log(res)
  249. // // 打开成功
  250. // }
  251. // })
  252. },
  253. navto(url){
  254. this.$api.navigateTo(url)
  255. },
  256. swiperNavtopage(link){
  257. this.$api.navigateTo(`/h5/pages/activity/activity?productID=4204&path=${link}`)
  258. },
  259. telPhoneTo(){
  260. let self = this;
  261. this.$api.get('/home/afterSale',{organizeID:this.userOrganizeID},
  262. response => {
  263. console.log(response.data.contactNumber)
  264. uni.makePhoneCall({
  265. phoneNumber:response.data.contactNumber //仅为示例
  266. });
  267. }
  268. )
  269. }
  270. },
  271. onPageScroll(e){//实时获取到滚动的值
  272. if(e.scrollTop>50){
  273. this.inputActive = 'fixed'
  274. }else{
  275. this.inputActive = 'float'
  276. }
  277. if(e.scrollTop>400){
  278. this.isScrollTop = true
  279. }else{
  280. this.isScrollTop = false
  281. }
  282. },
  283. onPullDownRefresh() {//下拉刷新
  284. this.getHomeInformation()
  285. uni.stopPullDownRefresh()
  286. },
  287. onShareAppMessage(res){//分享转发
  288. if (res.from === 'button') {
  289. // 来自页面内转发按钮
  290. }
  291. return {
  292. title: '采美采购商城-生美/医美采购服务平台',
  293. path: 'pages/tabBar/home/home',
  294. imageUrl:'https://img.caimei365.com/group1/M00/03/8C/Cmis215XHXSAWWkhAAXDP4-6m_c397.png'
  295. }
  296. }
  297. }
  298. </script>
  299. <style lang="scss">
  300. page{
  301. background-color: #FFFFFF;
  302. }
  303. .container-section{
  304. width: 100%;
  305. height: auto;
  306. background-color: #F7F7F7;
  307. }
  308. </style>