index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view>
  3. <view class="container-home tui-skeleton">
  4. <view class="cate-section clearfix">
  5. <!-- 自定义分类导航栏 -->
  6. <view class="tabbar clearfix">
  7. <view class="cate-item" v-for="(nav,idx) in productsClassifyList" :key="idx" @click.stop="navigateToGoods(nav)">
  8. <image class="tui-skeleton-circular" :src="nav.classifyImage"></image>
  9. <text class="tui-skeleton-fillet">{{nav.classifyName}}</text>
  10. </view>
  11. </view>
  12. <!-- 优选分类 -->
  13. <view class="tabbar bot clearfix">
  14. <view class="cate-item-info" @click.stop="this.$api.navToListPage({type:'1',value:firstModulesName})">
  15. <image class="tui-skeleton-circular" :src="firstModulesImage"></image>
  16. <text class="tui-skeleton-fillet">{{firstModulesName}}</text>
  17. </view>
  18. <view class="cate-item-info" @click.stop="this.$api.navToListPage({type:'2',value:secondModulesName})">
  19. <image class="tui-skeleton-circular" :src="secondModulesImage"></image>
  20. <text class="tui-skeleton-fillet">{{secondModulesName}}</text>
  21. </view>
  22. <view class="cate-item-info" @click="showTost">
  23. <image class="tui-skeleton-circular" :src="navInforList[0].icon"></image>
  24. <text class="tui-skeleton-fillet">{{navInforList[0].text}}</text>
  25. </view>
  26. <view class="cate-item-info">
  27. <!-- #ifdef MP-WEIXIN -->
  28. <button class="contact-btn" open-type="contact" @bindcontact="handleContact">
  29. <image class="tui-skeleton-circular" :src="navInforList[1].icon"></image>
  30. </button>
  31. <!-- #endif -->
  32. <text class="tui-skeleton-fillet">{{navInforList[1].text}}</text>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 热销商品 -->
  37. <view class="hotgoods-section">
  38. <view class="s-header" @click="this.$api.navToListPage({type:'3',value:thirdModulesName})">
  39. <text class="tip tui-skeleton-fillet">{{thirdModulesName}}</text>
  40. <text class="tit tui-skeleton-fillet">更多</text>
  41. <text class="iconfont icon-xiayibu"></text>
  42. </view>
  43. <view class="hotgoods-swiper">
  44. <view class="scoll-wrapper clearfix">
  45. <view class="floor-item" v-for="(item, index) in organizeProducts" :key="index" @click.stop="navToDetailPage(item.productID)">
  46. <image class="tui-skeleton-fillet" :src="item.mainImage" mode="aspectFill"></image>
  47. <view class="floor-item-content">
  48. <view class="title tui-skeleton-rect">
  49. <text class="mclap">{{item.name}}</text>
  50. </view>
  51. <view class="floor-item-act">
  52. <template v-if="item.actStatus==1">
  53. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  54. {{item.promotions.name}}<text v-if="hasLogin && item.price1TextFlag != '1'">:¥{{item.price | NumFormat}}</text>
  55. </view>
  56. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  57. </template>
  58. <template v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
  59. <view class="floor-tags">阶梯价格</view>
  60. </template>
  61. </view>
  62. <view class="" v-if="hasLogin">
  63. <view v-if="userIdentity == 4">
  64. <view class="title-none" v-show="item.price1TextFlag == '1'">
  65. <text class="p big">¥未公开价格</text>
  66. </view>
  67. <view class="title-none" v-show="item.price1TextFlag == '2'">
  68. <text class="p big">¥价格仅会员可见</text>
  69. </view>
  70. <view class="price tui-skeleton-rect" v-show="item.price1TextFlag == '0'" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  71. <text class="p sm">¥</text>
  72. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  73. </view>
  74. </view>
  75. <view v-else>
  76. <view class="title-none" v-if="item.price1TextFlag == '1'">
  77. <text class="p big">未公开价格</text>
  78. </view>
  79. <view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  80. <text class="p sm">¥</text>
  81. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  82. </view>
  83. </view>
  84. </view>
  85. <view v-else class="no-price">
  86. <view class="p-stars">
  87. <text class="p-no">¥</text>
  88. <uni-stars :stars="parseInt(item.price1Grade)" :fontSize="36" :widthInfo="180"></uni-stars>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 底部 -->
  97. <view class="footer-section ">
  98. <view class="s-header member tui-skeleton-fillet">
  99. <text class="tip">医美机构正品联盟</text>
  100. </view>
  101. <view class="f-content tui-skeleton-fillet" @click="navto('/pages/service/member')">
  102. <image class="tui-banner" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AEwQlAAjGFdpI2LM357.png" mode="scaleToFill"></image>
  103. </view>
  104. <view class="f-tab-section">
  105. <!-- 优选分类 -->
  106. <view class="tabbar clearfix">
  107. <view class="cate-item" @click="showTost">
  108. <image class="tui-skeleton-circular" :src="navServerList[0].icon"></image>
  109. <text class="tui-skeleton-fillet">{{navServerList[0].text}}</text>
  110. </view>
  111. <view class="cate-item" @click="navto(navServerList[1].path)">
  112. <image class="tui-skeleton-circular" :src="navServerList[1].icon"></image>
  113. <text class="tui-skeleton-fillet">{{navServerList[1].text}}</text>
  114. </view>
  115. <view class="cate-item" @click="navto(navServerList[2].path)">
  116. <image class="tui-skeleton-circular" :src="navServerList[2].icon"></image>
  117. <text class="tui-skeleton-fillet">{{navServerList[2].text}}</text>
  118. </view>
  119. <view class="cate-item" @click="telPhoneTo">
  120. <image class="tui-skeleton-circular" :src="navServerList[3].icon"></image>
  121. <text class="tui-skeleton-fillet">{{navServerList[3].text}}</text>
  122. </view>
  123. </view>
  124. </view>
  125. <view class="f-text tui-skeleton-fillet">
  126. <view class="">
  127. <image class="logo" src="http://static-b.caimei365.com/app/img/icon/logo-c@2x.png" mode=""></image>
  128. <text class="">采美365网</text>
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. <!-- 透明模态层 -->
  134. <modal-layer v-if='modallayer'></modal-layer>
  135. </view>
  136. </template>
  137. <script>
  138. import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
  139. import authorize from '@/common/config/authorize.js'
  140. import modalLayer from "@/components/modal-layer"
  141. import cmCustom from '@/components/cm-module/homeIndex/customer.vue'
  142. import activityAlert from '@/components/cm-module/activity/activity_on_1.vue'
  143. import uniStars from '@/components/uni-stars/uni-stars.vue'
  144. import { userInfoLogin } from "@/api/use.js"
  145. import { mapState,mapMutations} from 'vuex';
  146. export default {
  147. components:{
  148. tuiSkeleton,
  149. modalLayer,
  150. cmCustom,
  151. uniStars,
  152. activityAlert,
  153. },
  154. data() {
  155. return {
  156. webviewStyles: {
  157. progress: {
  158. color: '#FF3333'
  159. }
  160. },
  161. nvabarData: {//顶部自定义导航
  162. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  163. showSearch: 0,
  164. title: '采美采购商城', // 导航栏 中间的标题
  165. haveBack:false,
  166. textLeft:this.$store.state.isIphone,
  167. textColor:'#FFFFFF'
  168. },
  169. CustomBar:this.CustomBar,// 顶部导航栏高度
  170. userID:0,
  171. clubStatus:'',
  172. current:0,
  173. mode:'round',
  174. modallayer:false,
  175. isLogin:false,
  176. bannerImageList:[],
  177. skeletonShow: true,
  178. userIdentity:'',
  179. organizeProducts:[],//常用商品
  180. productsClassifyList:[
  181. {classifyImage:'https://admin-b.caimei365.com/userfiles/1/images/photo/2020/04/%E7%BB%84%201238.png',classifyName:'采美'},
  182. {classifyImage:'https://admin-b.caimei365.com/userfiles/1/images/photo/2020/04/%E7%BB%84%201238.png',classifyName:'采美'},
  183. {classifyImage:'https://admin-b.caimei365.com/userfiles/1/images/photo/2020/04/%E7%BB%84%201238.png',classifyName:'采美'},
  184. {classifyImage:'https://admin-b.caimei365.com/userfiles/1/images/photo/2020/04/%E7%BB%84%201238.png',classifyName:'采美'},
  185. {classifyImage:'https://admin-b.caimei365.com/userfiles/1/images/photo/2020/04/%E7%BB%84%201238.png',classifyName:'采美'}
  186. ],//分类导航
  187. firstModulesName:'https://img.caimei365.com/group1/M00/03/8C/Cmis215XHXSAAZU0AACaPrfbB8I435.png', //优惠模块1
  188. secondModulesName:'', //优惠模块2
  189. firstModulesImage:'https://img.caimei365.com/group1/M00/03/8C/Cmis215XHXSAAZU0AACaPrfbB8I435.png',//优惠模块icon1
  190. secondModulesImage:'',//优惠模块icon2
  191. thirdModulesName:'', //优惠模块3
  192. navInforList:[
  193. {text:'会员中心',icon:'https://img.caimei365.com/group1/M00/03/B0/Cmis217Z9LCABdf_AAAfdMmM_xY655.png'},
  194. {text:'在线客服',icon:'https://img.caimei365.com/group1/M00/03/B0/Cmis217Z9BSAXPobAAApo6I0Tlo684.png'}
  195. ],
  196. navServerList:[
  197. {text:'会员优惠',icon:'../../../static/temp/server1@2x.png',path:'/pages/service/member'},
  198. {text:'售后无忧',icon:'../../../static/temp/server2@2x.png',path:'/pages/service/aftersale'},
  199. {text:'购物须知',icon:'../../../static/temp/server3@2x.png',path:'/pages/service/shoppingnotice'},
  200. {text:'联系我们',icon:'../../../static/temp/server4@2x.png',path:''},
  201. ],
  202. isScrollTop:false
  203. }
  204. },
  205. created() {
  206. this.modallayer = false;
  207. authorize.getSetting().then(res =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  208. if(res == 1){
  209. this.getWxAuthorize()
  210. }else{
  211. this.$api.getComStorage('userInfo').then((resolve) =>{
  212. this.userID = resolve.userID ? resolve.userID :0;
  213. this.getHomeInformation()
  214. this.getOrganizeProducts()
  215. }).catch(error =>{
  216. this.getHomeInformation()
  217. this.getOrganizeProducts()
  218. })
  219. }
  220. })
  221. },
  222. filters: {
  223. NumFormat:function(text) {//处理金额
  224. return Number(text).toFixed(2);
  225. },
  226. },
  227. computed: {
  228. ...mapState(['hasLogin','userInfo','isActivity'])
  229. },
  230. methods: {
  231. ...mapMutations(['login','logout']),
  232. getWxAuthorize(){
  233. authorize.getCode('weixin').then(wechatcode =>{// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
  234. authorize.getUserInfo('weixin').then(wxResponse =>{
  235. userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
  236. this.isLogin = true;
  237. this.userID = response.data.userID;
  238. this.userIdentity = response.data.userIdentity;
  239. this.clubStatus = response.data.clubStatus;
  240. this.$store.commit('updateStatus',response.data)
  241. this.login(response.data);
  242. uni.setStorageSync('token',response.data.token)
  243. uni.removeStorageSync('sessionid')
  244. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  245. if(response.data.userIdentity ==1){
  246. this.$api.navigateTo('/seller/pages/index/index')
  247. }
  248. this.getHomeInformation()
  249. this.getOrganizeProducts()
  250. }).catch(error =>{
  251. this.isLogin = false;
  252. this.logout()
  253. uni.removeStorageSync('sessionid')
  254. uni.setStorageSync('sessionid','JSESSIONID='+error.data)
  255. this.$store.commit('updateStatus',error.data)
  256. this.getHomeInformation()
  257. this.getOrganizeProducts()
  258. })
  259. })
  260. })
  261. },
  262. getHomeInformation(){//初始化首页数据
  263. this.CommonService.GetHomeModulesDataInfo({ userId:this.userID }).then(res =>{
  264. let data = res.data;
  265. this.bannerImageList = data.bannerImageList
  266. this.mallPageModules = data.mallPageModules
  267. this.firstModulesName= data.firstModulesName
  268. this.secondModulesName= data.secondModulesName
  269. this.firstModulesImage= data.firstModulesImage
  270. this.secondModulesImage= data.secondModulesImage
  271. this.thirdModulesName= data.thirdModulesName
  272. this.productsClassifyList = data.productsClassifyList
  273. this.$store.commit('updateAllNum',data.shoppingCartCount)
  274. }).catch(error =>{
  275. this.$util.msg(error.msg,2000)
  276. })
  277. },
  278. getOrganizeProducts(){//获取模块三商品
  279. this.ProductService.queryProductPreferred({userId:this.userID,preferredFlag:100,pageNum:1,pageSize:6}).then(res =>{
  280. this.organizeProducts = res.data.results
  281. this.getProductPrice()
  282. }).catch(error =>{
  283. this.$util.msg(error.msg,2000)
  284. })
  285. },
  286. getProductPrice(){//获取商品或者活动价格
  287. let productIdArr = [];
  288. let productIds ='';
  289. this.organizeProducts.map(item=>{// 0公开价格 1不公开价格 2仅对会员机构公开
  290. productIdArr.push(item.productID)
  291. })
  292. productIds = productIdArr.join(",");
  293. this.ProductService.querySearchProductPrice({userId: this.userID,productIds:productIds}).then(response =>{
  294. this.organizeProducts = this.ReturnNewProducts(this.organizeProducts,response.data);
  295. this.skeletonShow = false;
  296. }).catch(error =>{
  297. this.$util.msg(error.msg,2000)
  298. })
  299. },
  300. ReturnNewProducts(Array,list){
  301. let NewArray = []
  302. Array.map(item=>{
  303. for (let i = 0; i < list.length; i++) {
  304. if( item.productID == list[i].productId ){
  305. NewArray.push(Object.assign(item,list[i]))
  306. }
  307. }
  308. });
  309. return NewArray
  310. },
  311. PromotionsFormat(promo){//促销活动类型数据处理
  312. if(promo!=null){
  313. if(promo.type == 1 && promo.mode == 1){
  314. return true
  315. }else{
  316. return false
  317. }
  318. }
  319. return false
  320. },
  321. //轮播图切换修改背景色
  322. swiperChange(e) {
  323. const index = e.detail.current;
  324. this.current = index;
  325. },
  326. formatMoney(num){
  327. return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
  328. return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
  329. return $1 + ",";
  330. });
  331. });
  332. },
  333. handleBannerActivity(item,index){
  334. switch(index){
  335. case 0:
  336. this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
  337. break;
  338. }
  339. },
  340. handleClick(data){
  341. this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
  342. this.$store.commit('setActivity',data)
  343. },
  344. handleCancelClick(data){
  345. this.$store.commit('setActivity',data)
  346. },
  347. navToListPage(nav){//三个分类模块跳转
  348. let self = this;
  349. uni.setStorage({
  350. key: 'commodity_id',
  351. data: nav.id,
  352. success: function () {
  353. self.$api.navToListPage({type:'0',value:nav.classifyName,id:nav.id});
  354. }
  355. })
  356. },
  357. navigateToGoods(nav){//分类导航跳转
  358. let self = this;
  359. uni.setStorage({
  360. key: 'commodity_id',
  361. data: nav.id,
  362. success: function () {
  363. self.$api.navigateToGoods({type:'0',value:nav.classifyName,id:nav.id});
  364. }
  365. })
  366. },
  367. navToDetailPage(id) {//跳转商品详情页
  368. this.modallayer = true;
  369. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  370. },
  371. handleContact(e){
  372. console.log(e.detail.path)
  373. console.log(e.detail.query)
  374. },
  375. showTost(){
  376. this.$util.msg("功能开发中,敬请期待~",2000)
  377. // this.$api.navigateTo(`/seller/pages/login/login`)
  378. // uni.navigateToMiniProgram({
  379. // appId: 'wx5a5cda32926f55ac',
  380. // path: '/pages/tabBar/home/index',
  381. // extraData: {
  382. // 'data1': 'test'
  383. // },
  384. // envVersion: 'develop',
  385. // success(res) {
  386. // console.log(res)
  387. // // 打开成功
  388. // }
  389. // })
  390. },
  391. navto(url){
  392. this.$api.navigateTo(url)
  393. },
  394. swiperNavtopage(link){
  395. this.$api.navigateTo(`/h5/pages/activity/activity?productID=4204&path=${link}`)
  396. },
  397. telPhoneTo(){
  398. let self = this;
  399. this.$api.get('/home/afterSale',{organizeID:this.userOrganizeID},
  400. response => {
  401. console.log(response.data.contactNumber)
  402. uni.makePhoneCall({
  403. phoneNumber:response.data.contactNumber //仅为示例
  404. });
  405. }
  406. )
  407. }
  408. },
  409. onPageScroll(e){//实时获取到滚动的值
  410. if(e.scrollTop>50){
  411. this.inputActive = 'fixed'
  412. }else{
  413. this.inputActive = 'float'
  414. }
  415. if(e.scrollTop>600){
  416. this.isScrollTop = true
  417. }else{
  418. this.isScrollTop = false
  419. }
  420. },
  421. onPullDownRefresh() {//下拉刷新
  422. this.getHomeInformation()
  423. this.getOrganizeProducts()
  424. uni.stopPullDownRefresh()
  425. },
  426. onShareAppMessage(res){//分享转发
  427. if (res.from === 'button') {
  428. // 来自页面内转发按钮
  429. }
  430. return {
  431. title: '采美采购商城-生美/医美采购服务平台',
  432. path: 'pages/tabBar/home/home',
  433. imageUrl:'https://img.caimei365.com/group1/M00/03/8C/Cmis215XHXSAWWkhAAXDP4-6m_c397.png'
  434. }
  435. }
  436. }
  437. </script>
  438. <style>
  439. </style>