index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. <template>
  2. <view class="home">
  3. <MyNav title="洲际酒店集团中国西区" bgColor="" :backIcon="true"></MyNav>
  4. <!-- swiper -->
  5. <view class="home-swiper">
  6. <uni-swiper-dot :info="infoList" :current="current1" :mode="mode" :dots-styles="dotsStyles">
  7. <swiper class="swiper-box" @change="change1" circular>
  8. <swiper-item v-for="(item ,index) in infoList" :key="index">
  9. <view class="swiper-item" v-if="item.resource_type == 1" @click="$utils.jump({
  10. jump_type: item.jump_type,
  11. jump_config: item.jump_config
  12. })">
  13. <image style="width: 100%;height:592rpx;" :src="item.img" mode="aspectFill"></image>
  14. </view>
  15. <view class="swiper-item" v-if="item.resource_type == 2">
  16. <video id="swiperVideo" ref="swiperVideo" style="width: 100%; height: 592rpx;"
  17. :src="item.video_url" controls :enable-progress-gesture="false">
  18. </video>
  19. </view>
  20. </swiper-item>
  21. </swiper>
  22. </uni-swiper-dot>
  23. </view>
  24. <!-- 金刚图 -->
  25. <view class="home-nav">
  26. <view class="home-nav-item" v-for="(item,index) in navList" :key="index" @click="$utils.jump({
  27. jump_type: item.jump_type,
  28. jump_config: item.jump_config
  29. })">
  30. <image style="width: 101.96rpx;height: 103.96rpx;" :src="item.img" mode=""></image>
  31. <text style="color: #333;font-size: 24rpx;margin-top: 18rpx; ">{{item.title}}</text>
  32. </view>
  33. </view>
  34. <!-- 活动专区 -->
  35. <view class="home-special-area">
  36. <view class="home-special-area-left">
  37. <text>非凡西区</text>
  38. <view class="text-shadow"></view>
  39. <image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
  40. </image>
  41. </view>
  42. <view @click="goSpecialList" class="home-special-area-right">
  43. <text>全部</text>
  44. <image style="width: 12rpx; height: 20rpx;margin-left: 8rpx;" src="/static/icon/right01.png" mode="">
  45. </image>
  46. </view>
  47. </view>
  48. <!-- 活动图片 -->
  49. <view class="home-special-img">
  50. <template v-for="(item,index) in specialList">
  51. <view class="ListItem" v-if="item.show_status" :key="index" @click="$utils.jump({
  52. jump_type: 3,
  53. jump_config: '/pages/index/active-detail/index',
  54. id: item.id,
  55. })">
  56. <image style="width: 312rpx;height: 200rpx; border-radius: 12rpx; "
  57. :src="item.banners?item.cover_img:'http://t9.9026.com/imgs/Kudosbg.png'" mode=""></image>
  58. <view class="kudosicon" @click.stop="kudosActive(item.id,index)">
  59. <image style="width:24rpx;height: 24rpx;" src="/static/icon/Kudos.png" v-if="item.is_like==0">
  60. </image>
  61. <image style="width:24rpx;height: 24rpx;" src="/static/icon/Kudos(1).png"
  62. v-if="item.is_like==1">
  63. </image>
  64. </view>
  65. <text style="color: #333;font-weight: bold;font-size: 28rpx;">{{item.title}}</text>
  66. </view>
  67. </template>
  68. </view>
  69. <!-- 广告图 -->
  70. <view class="home-banner" v-if="!isShowAdver">
  71. <view class="home-banner-img" v-if="in_page==1 && type == 1 ">
  72. <image style="width: 100%; height: 576rpx; border-radius: 12rpx;" :src="advData.img" mode="" @click="$utils.jump({
  73. jump_type: advData.jump_type,
  74. jump_config: advData.jump_config
  75. })"></image>
  76. <image @click="cleanCoverImg" class="img-clean" style="width: 20rpx; height: 20rpx; "
  77. src="/static/icon/clean.png" mode="">
  78. </image>
  79. </view>
  80. <view class="home-banner-img" v-if="in_page==1 && type == 2">
  81. <image class="banner-img" v-if="!isOpenVideo" @click="openVideoPlay"
  82. style="width: 100%; height: 576rpx; border-radius: 12rpx;" :src="videoCoverImg" mode=""></image>
  83. <image @click="cleanCoverImg" class="img-clean" style="width: 20rpx; height: 20rpx; "
  84. src="/static/icon/clean.png" mode="">
  85. </image>
  86. <video class="baner-video" id="myVideo" ref="myVideo"
  87. style="width: 100%; height: 576rpx;border-radius: 12rpx; " :src="videoSrc" controls
  88. :enable-progress-gesture="false">
  89. </video>
  90. </view>
  91. </view>
  92. <movable-area class="movableArea">
  93. <movable-view class="movableView" direction="all" x="630rpx" y="700rpx">
  94. <view class="img-IHg" @click="goJoin()">
  95. <image style="width: 64rpx; height: 58rpx; " src="/static/icon/vip.png" mode=""></image>
  96. </view>
  97. </movable-view>
  98. </movable-area>
  99. <!-- 广告的附图 -->
  100. <view class="home-attach" @click="$utils.jump({
  101. jump_type: advInsetImg.jump_type,
  102. jump_config: advInsetImg.jump_config
  103. })">
  104. <image style="width: 690rpx;height: 156rpx;border-radius: 79rpx;" :src="advInsetImg.img" mode=""></image>
  105. </view>
  106. <!-- 酒店推荐 -->
  107. <view class="home-hotel home-special-area">
  108. <view class="home-special-area-left">
  109. <text>西区优品</text>
  110. <view class="text-shadow"></view>
  111. <image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
  112. </image>
  113. </view>
  114. </view>
  115. <!-- 酒店推荐图片 -->
  116. <view class="home-hotel-img">
  117. <view class="home-hotel-img-content">
  118. <template v-for="(item,index) in goodsList">
  119. <view v-if="item.status==1" class="home-hotel-img-content-item" :key="index"
  120. :style="{marginTop:item.marginTop || 0 }" @click="goToProduct(item.id)">
  121. <image class="home-hotel-img-content-item-img"
  122. :class="item.short?'home-hotel-img-content-item-img': 'home-hotel-img-content-item-img-long' "
  123. :src="item.cover_img" mode=""></image>
  124. <view class="text">
  125. <text class="text-top">{{item.name}}</text>
  126. </view>
  127. </view>
  128. </template>
  129. </view>
  130. <view class="home-hotel-img-more" @click='geMore'>
  131. <text>查看更多商品</text>
  132. </view>
  133. </view>
  134. <!-- 酒店品牌 -->
  135. <view class="home-brand home-special-area">
  136. <view class="home-special-area-left">
  137. <text>洲际酒店集团品牌</text>
  138. <view class="text-shadow"></view>
  139. <image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
  140. </image>
  141. </view>
  142. </view>
  143. <!-- 酒店品牌图片 -->
  144. <view class="home-brand-img">
  145. <uni-swiper-dot :info="info" mode="default" :current="current2" :dots-styles="dotsStylesBand">
  146. <swiper class="swiper-box" circular @change="change2">
  147. <swiper-item v-for="(items ,index) in info" :key="index">
  148. <view v-for="(item ,j) in items" :key="j" class="swiper-item" @click="$utils.jump({
  149. jump_type: item.jump_type,
  150. jump_config: item.jump_config
  151. })">
  152. <image style="width:144rpx;height:142rpx;" :src="item.img" mode="aspectFill"></image>
  153. </view>
  154. </swiper-item>
  155. </swiper>
  156. </uni-swiper-dot>
  157. </view>
  158. <!-- 触底 -->
  159. <view class="home-bottom">
  160. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText" />
  161. </view>
  162. <!-- 弹窗广告 -->
  163. <uni-popup ref="popup" type="center">
  164. <view class="popup-banner">
  165. <image @click="$utils.jump({
  166. jump_type: popupData.jump_type,
  167. jump_config: popupData.jump_config
  168. })" style="width: 656rpx;height: 916rpx;border-radius: 12rpx;" :src="popupData.img">
  169. </image>
  170. <view class="popup-banner-clean" @click='closePopupBanner'>
  171. <image style="width: 20rpx; height: 20rpx; " src="/static/icon/clean.png" mode="">
  172. </view>
  173. </view>
  174. </uni-popup>
  175. <view style="height:168rpx; background-color: #f9f9f9; "></view>
  176. <tab-bar></tab-bar>
  177. </view>
  178. </template>
  179. <script>
  180. import TabBar from '../../components/TabBar/tabbar.vue'
  181. import MyNav from "@/components/my-nav/my-nav.vue"
  182. export default {
  183. components: {
  184. TabBar,
  185. MyNav
  186. },
  187. data() {
  188. return {
  189. //加入会员跳转
  190. adviseVip:'',
  191. jump_type_vip:'',
  192. jump_config_vip:{},
  193. //用户个人信息,判断是否登录
  194. admin: '',
  195. //获取token
  196. data: {},
  197. //录播图是展示视频1:图片2:视频
  198. resource_type: '',
  199. //广告弹框跳转
  200. jup_type: '',
  201. jump_config: '',
  202. //广告弹框图
  203. popupData: {},
  204. //弹窗的类型 1只弹一次首次 2就是每次都弹啊
  205. times_type: '',
  206. //弹窗的显示0不显示 1显示
  207. popupImgStatus: '',
  208. //视频封面图
  209. isOpenVideo: false,
  210. videoCoverImg: '',
  211. videoSrc: '',
  212. in_page: '',
  213. type: '',
  214. //隐藏广告图
  215. isShowAdver: false,
  216. //广告图
  217. advertis: '',
  218. advData: {},
  219. //广告附图展示图片
  220. advertisInsetImg: '',
  221. advInsetImg: {},
  222. //广告图展示图片:
  223. advertisImg: '',
  224. //广告图展示视频
  225. goodsList: [{
  226. cover_img: 'https://t9.9026.com/imgs/11.png',
  227. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  228. },
  229. {
  230. cover_img: 'https://t9.9026.com/imgs/22.png',
  231. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  232. },
  233. {
  234. cover_img: 'https://t9.9026.com/imgs/33.png',
  235. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  236. },
  237. {
  238. cover_img: 'https://t9.9026.com/imgs/44.png',
  239. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  240. },
  241. ],
  242. status: 'noMore',
  243. contentText: {
  244. contentdown: '查看更多',
  245. contentrefresh: '加载中',
  246. contentnomore: '—— 已经到底啦 ——'
  247. },
  248. infoList: [],
  249. //轮播图
  250. info: [],
  251. dotsStyles: {
  252. bottom: 24,
  253. backgroundColor: 'rgba(255, 255, 255, .3)',
  254. border: '1px rgba(255, 255, 255, .3) solid',
  255. color: '#fff',
  256. selectedBackgroundColor: 'rgba(255, 255, 255, 1)',
  257. selectedBorder: '1px rgba(255, 255, 255, 1) solid'
  258. },
  259. dotsStylesBand: {
  260. bottom: -24,
  261. backgroundColor: 'rgba(198, 198, 198, 1)',
  262. border: '1px rgba(0, 0, 0, .3) solid',
  263. color: '#fff',
  264. selectedBackgroundColor: 'rgba(151, 151, 151, 1)',
  265. selectedBorder: '1px rgba(0, 0, 0, .9) solid'
  266. },
  267. //指示点显示位置
  268. current1: 0,
  269. current2: 0,
  270. //指示点模式
  271. mode: 'dot',
  272. // 金刚图
  273. navList: [],
  274. //活动专区
  275. specialList: [],
  276. isDevelopment: false,
  277. }
  278. },
  279. onTabItemTap(e) {
  280. console.log(e)
  281. },
  282. // 下拉刷新
  283. onPullDownRefresh() {
  284. setTimeout(() => {
  285. uni.stopPullDownRefresh();
  286. this.$store.dispatch('user/allset', null)
  287. this.getAllSet()
  288. this.getList()
  289. }, 1000);
  290. },
  291. onReady: function(res) {
  292. this.videoContext = uni.createVideoContext('myVideo')
  293. },
  294. onShow() {
  295. //获取token
  296. this.getmsg()
  297. this.admin = this.$store.getters.userInfo
  298. },
  299. onLoad() {
  300. this.getGoodsList()
  301. this.getAllSet()
  302. // this.isDevelopment = process.env.NODE_ENV === 'development';
  303. this.isDevelopment = true;
  304. },
  305. methods: {
  306. // **************** Data ***************//
  307. //获取配置数据
  308. getAllSet() {
  309. this.$api.document.allSet().then(res => {
  310. this.$store.dispatch('user/allset', res.data)
  311. this.infoList = this.$store.getters.allset.banners
  312. this.navList = this.$store.getters.allset.nav_icon
  313. this.info = this.$store.getters.allset.partner
  314. //广告图
  315. this.advertis = this.$store.getters.allset.advertises.filter(item => {
  316. return item.in_page == 1
  317. })
  318. this.advData = this.advertis[0];
  319. if (this.advertis[0].type == 1) {
  320. this.in_page = 1
  321. this.type = 1
  322. this.advertisImg = this.advertis[0].img
  323. } else if (this.advertis[0].type == 2) {
  324. this.in_page = 1
  325. this.type = 2
  326. this.videoCoverImg = this.advertis[0].video_cover
  327. this.videoSrc = this.advertis[0].video
  328. }
  329. //胶囊图
  330. this.advertisInset = this.$store.getters.allset.advertises.filter(item => {
  331. return item.in_page == 2
  332. })
  333. this.advInsetImg = this.advertisInset[0]
  334. this.advertisInsetImg = this.advertisInset[0].img
  335. //广告弹框图
  336. this.popupData = this.$store.getters.allset.popup_ads[0]
  337. //弹窗是否展示
  338. this.popupImgStatus = this.popupData?.status
  339. this.times_type = this.popupData?.times_type
  340. //广告弹框跳转h5和小程序和内部
  341. this.jump_type = this.popupData?.jump_type,
  342. this.jump_config = this.popupData?.jump_config
  343. this.open()
  344. //加入vip跳转
  345. this.adviseVip = this.$store.getters.allset.add_member
  346. this.jump_type_vip = this.adviseVip.value.index_jump_type
  347. if( this.jump_type_vip == 1){
  348. this.jump_config_vip = this.adviseVip.value.index_h5_url
  349. }else if(this.jump_type_vip == 2){
  350. this.jump_config_vip.appid = this.adviseVip.value.index_appid
  351. this.jump_config_vip.path = this.adviseVip.value.index_path
  352. }else if(this.jump_type_vip == 3){
  353. this.jump_config_vip =this.adviseVip.value.index_other_path
  354. }
  355. })
  356. },
  357. // 获取活动列表
  358. getList() {
  359. this.$api.active.getActiveList({
  360. page: 0,
  361. keyword: '',
  362. category_id: ''
  363. }).then(res => {
  364. console.log(res, '活动列表')
  365. if (res.code == 0) {
  366. this.specialList = res.data.data
  367. }
  368. })
  369. },
  370. //产品列表type:1,第三方购买产品
  371. getGoodsList(category_id) {
  372. this.$api.product.getProducts({
  373. type: 1,
  374. page: 0,
  375. }).then(res => {
  376. this.goodsList = res.data.data.slice(0, 4)
  377. this.shortLong()
  378. console.log(this.goodsList, '------>产品图');
  379. })
  380. },
  381. //产品详情
  382. produceDetail(id) {
  383. uni.navigateTo({
  384. url: `/pages/goods/goods-detail/index?id=${id}&type=1`
  385. })
  386. },
  387. // **************** Dev ***************//
  388. shortLong() {
  389. this.goodsList.forEach((item, index, arr) => {
  390. if (index % 4 === 0) {
  391. item.short = true
  392. }
  393. if (index % 4 === 1) {
  394. item.long = true
  395. }
  396. if (index % 4 === 2) {
  397. item.long = true
  398. item.marginTop = -68 + "rpx"
  399. }
  400. if (index % 4 === 3) {
  401. item.short = true
  402. }
  403. })
  404. },
  405. //隐藏图片
  406. cleanCoverImg() {
  407. this.isShowAdver = !this.isShowAdver
  408. },
  409. //打开弹框
  410. open() {
  411. console.log(this.popupImgStatus, this.times_type);
  412. // 从本地缓存中同步获取指定 key 对应的内容,用于判断是否是第一次打开应用
  413. if (this.popupImgStatus == 1) {
  414. if (this.times_type == 1) {
  415. //首次进入弹窗
  416. const value = uni.getStorageSync('launchFlag');
  417. if (value) {
  418. console.log('首次弹窗')
  419. } else {
  420. // 没有值,跳到引导页,并存储,下次打开就不会进去引导页
  421. uni.setStorage({
  422. key: 'launchFlag',
  423. data: true
  424. });
  425. this.$refs.popup.open('center')
  426. }
  427. } else {
  428. this.$refs.popup.open('center') //每次都弹
  429. }
  430. } else {
  431. this.$refs.popup.close() //不显示广告弹框
  432. }
  433. },
  434. //关闭弹框
  435. closePopupBanner() {
  436. this.$refs.popup.close()
  437. },
  438. //点击视频封面图片,播放视频
  439. openVideoPlay() {
  440. this.isOpenVideo = !this.isOpenVideo
  441. this.videoContext.play()
  442. },
  443. // **************** 跳转 ***************//
  444. //合同伙伴跳转h5和小程序
  445. goGoodsDetail(id, urls) {
  446. console.log(urls, '----->url');
  447. if (id == 1) {
  448. const url = urls; // 跳转的外链
  449. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  450. uni.navigateTo({
  451. // 跳转到webview页面
  452. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  453. success: () => {
  454. console.log('成功')
  455. },
  456. fail: (e) => {
  457. console.log(e, "失败")
  458. }
  459. });
  460. } else if (id == 2) {
  461. let obj = JSON.parse(urls);
  462. wx.navigateToMiniProgram({
  463. appId: `${obj.appid}`, //appid
  464. path: `${obj.path}`, //path
  465. extraData: { //参数
  466. foo: 'bar'
  467. },
  468. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  469. success(res) {
  470. console.log('成功')
  471. // 打开成功
  472. },
  473. fail(e) {
  474. console.log(e, '失败')
  475. }
  476. })
  477. }
  478. },
  479. // 活动详情页
  480. activeDetail(id) {
  481. uni.navigateTo({
  482. url: '/pages/index/active-detail/index?id=' + id
  483. })
  484. },
  485. // 点赞活动
  486. kudosActive(id, index) {
  487. let beforeLike = this.specialList[index].is_like
  488. this.$api.active.kudos({
  489. activity_id: id
  490. }).then(res => {
  491. console.log(res, '点赞')
  492. if (res.code == 0) {
  493. if (beforeLike == 1) {
  494. this.specialList[index].is_like = 0
  495. uni.showToast({
  496. icon: 'none',
  497. title: '取消点赞'
  498. })
  499. } else {
  500. this.specialList[index].is_like = 1
  501. uni.showToast({
  502. icon: 'none',
  503. title: '点赞成功'
  504. })
  505. }
  506. }
  507. })
  508. },
  509. //获取当前页面路径
  510. getPageUrl() {
  511. const pages = getCurrentPages();
  512. console.log(pages, '--------->pages')
  513. if (pages.length == 1) {
  514. const currentPage = pages[0];
  515. let pageUrl = `/${currentPage.route}`;
  516. return pageUrl
  517. console.log('当前页面url:', pageUrl);
  518. } else {
  519. const currentPage = pages[pages.length - 1];
  520. let pageUrl = `/${currentPage.route}`;
  521. return pageUrl
  522. console.log('当前页面url:', pageUrl);
  523. }
  524. },
  525. // 跳转其他小程序
  526. goJoin() {
  527. let _this = this
  528. this.jumpHAppID(this.jump_type_vip, this.jump_config_vip)
  529. },
  530. // 跳转其他小程序
  531. jumpHAppID(id, urls) {
  532. if (id == 1) {
  533. const url = urls; // 跳转的外链
  534. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  535. uni.navigateTo({
  536. // 跳转到webview页面
  537. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  538. success: () => {
  539. console.log('成功')
  540. },
  541. fail: (e) => {
  542. console.log(e, "失败")
  543. }
  544. });
  545. } else if (id == 2) {
  546. let _this = this
  547. let obj = urls;
  548. console.log(obj, '----->obj');
  549. wx.navigateToMiniProgram({
  550. appId: `${obj.appid}`, //appid
  551. path: `${obj.path}`, //path
  552. extraData: { //参数
  553. foo: 'bar'
  554. },
  555. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  556. success(res) {
  557. let page = _this.getPageUrl()
  558. let user_id = ''
  559. if (_this.admin != null) {
  560. user_id = _this.admin.id
  561. } else {
  562. user_id = 0
  563. }
  564. _this.$api.my.userMemberAdd({
  565. user_id,
  566. page,
  567. }).then(res => {
  568. console.log(res.data);
  569. })
  570. // 打开成功
  571. },
  572. fail(e) {
  573. console.log(e, '失败')
  574. }
  575. })
  576. } else if (id == 3) {
  577. uni.redirectTo({
  578. url: urls,
  579. fail: (err) => {
  580. uni.reLaunch({
  581. url: urls
  582. })
  583. }
  584. })
  585. }
  586. },
  587. //用户访问
  588. getUserVisits() {
  589. this.$api.my.userVisits({
  590. page: '/pages/index/index'
  591. }).then(res => {
  592. console.log(res.data);
  593. })
  594. },
  595. //跳转方法
  596. // jumpHAppID(id, urls) {
  597. // if (id == 1) {
  598. // const url = urls; // 跳转的外链
  599. // const navtitle = 'H5'; // 这个标题是你自己可以设置的
  600. // uni.navigateTo({
  601. // // 跳转到webview页面
  602. // url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  603. // success: () => {
  604. // console.log('成功')
  605. // },
  606. // fail: (e) => {
  607. // console.log(e, "失败")
  608. // }
  609. // });
  610. // } else if (id == 2) {
  611. // let obj = JSON.parse(urls);
  612. // wx.navigateToMiniProgram({
  613. // appId: `${obj.appid}`, //appid
  614. // path: `${obj.path}`, //path
  615. // extraData: { //参数
  616. // foo: 'bar'
  617. // },
  618. // // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  619. // success(res) {
  620. // console.log('成功')
  621. // // 打开成功
  622. // },
  623. // fail(e) {
  624. // console.log(e, '失败')
  625. // }
  626. // })
  627. // } else if (id == 3) {
  628. // uni.redirectTo({
  629. // url: urls,
  630. // fail:(err)=>{
  631. // uni.reLaunch({
  632. // url: urls
  633. // })
  634. // }
  635. // })
  636. // }
  637. // },
  638. //查看更多商品
  639. geMore() {
  640. if (this.admin == undefined) {
  641. uni.navigateTo({
  642. url: '/pages/login/login'
  643. })
  644. } else {
  645. uni.navigateTo({
  646. url: '/pages/goods/goods'
  647. })
  648. }
  649. },
  650. //跳转产品详情
  651. goToProduct(id) {
  652. if (this.admin == undefined) {
  653. uni.navigateTo({
  654. url: '/pages/login/login'
  655. })
  656. } else {
  657. uni.navigateTo({
  658. url: `/pages/goods/goods-detail/index?id=${id}&type=1`
  659. })
  660. }
  661. },
  662. //产品列表
  663. goProduceList() {
  664. uni.navigateTo({
  665. url: '/pages/goods/goods'
  666. })
  667. },
  668. //活动列表
  669. goSpecialList() {
  670. uni.navigateTo({
  671. url: '/pages/index/active-list/index'
  672. })
  673. },
  674. // 切换轮播图指示点
  675. change1(e) {
  676. this.current1 = e.detail.current;
  677. },
  678. change2(e) {
  679. this.current2 = e.detail.current;
  680. },
  681. getCode() {
  682. return new Promise((resolve, reject) => {
  683. uni.getUserInfo({
  684. success: loginRes => {
  685. console.log(loginRes);
  686. this.data.encryptData = loginRes.encryptedData,
  687. this.data.iv = loginRes.iv
  688. resolve(this.data)
  689. }
  690. })
  691. })
  692. },
  693. //获取微信登录的code码
  694. getmsg() {
  695. uni.login({
  696. provider: uni.$u.platform,
  697. success: res => {
  698. console.log(res, '------->res');
  699. this.getCode().then((data) => {
  700. console.log(this.data, '------>data');
  701. const params = {
  702. code: res.code,
  703. iv: data.iv,
  704. encryptData: data.encryptData
  705. }
  706. console.log(params);
  707. this.$api.my.myLogin(params).then(res => {
  708. if(res.code == 0){
  709. let {
  710. token
  711. } = res.data
  712. this.$store.dispatch('user/token', token)
  713. // 获取活动列表
  714. this.getList()
  715. //用户访问
  716. this.getUserVisits()
  717. }else{
  718. uni.showToast({
  719. icon:'none',
  720. title:res.msg
  721. })
  722. }
  723. })
  724. })
  725. }
  726. })
  727. }
  728. },
  729. }
  730. </script>
  731. <style lang="scss" src="./index.scss" scoped></style>