home.vue 10 KB

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